Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Apr 1997 07:53:37 -0700
From:      John-Mark Gurney <jmg@hydrogen.nike.efn.org>
To:        Luiz de Barros <luiz@nlink.com.br>
Cc:        freebsd-hardware@FreeBSD.ORG
Subject:   Re: talk to I/O Devices.
Message-ID:  <19970416075337.16693@hydrogen.nike.efn.org>
In-Reply-To: <Pine.BSF.3.91.970416101425.14514I-100000@mirage.nlink.com.br>; from Luiz de Barros on Wed, Apr 16, 1997 at 10:18:14AM -0300
References:  <Pine.BSF.3.91.970416101425.14514I-100000@mirage.nlink.com.br>

next in thread | previous in thread | raw e-mail | index | archive | help
Luiz de Barros scribbled this message on Apr 16:
> Dear FreeBSD Experts,
> 
> I would like to know how i can talk to an input/output device attached to 
> some I/O ports in C. I want something equivalent to outportb and inportb 
> from DOS. The board we want to develop is a remote power controller to 
> reset our computers in case of a crash. The board will be controlled by 
> I/O ports.

this is relativily easy...  all you need to do is open the /dev/io file...
this will give you access to the io ports... then you use the out[wb] and
in[wb] macros/functions in machine/cpufunc.h to perform the operations..

something like this works:
#include <machine/cpufunc.h>
#include <fcntl.h>
#include <unistd.h>
#include <err.h>

void main()
{
        int i;

        if(open("/dev/io", O_RDWR, 0) == -1)
                err(1, "open of /dev/io failed");

        outb(0x3c8, 0);
        outb(0x3c9, 0);
        outb(0x3c9, 0);
        outb(0x3c9, 0);
}

hope this helps... ttyl...

-- 
  John-Mark
  Cu Networking                             Modem/FAX: +1 541 683 6954

  Live in Peace, destroy Micro$oft, support free software, run FreeBSD



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970416075337.16693>