Date: Mon, 22 Apr 1996 09:21:17 +0200 (MET DST) From: "Christoph P. Kukulies" <kuku@gilberto.physik.rwth-aachen.de> To: zgabor@CoDe.hu (Gabor Zahemszky) Cc: kuku@gilberto.physik.rwth-aachen.de, freebsd-questions@freebsd.org Subject: Re: How can I read/write from/to an I/O-port? Message-ID: <199604220721.JAA24177@gilberto.physik.rwth-aachen.de> In-Reply-To: <199604191211.MAA03635@CoDe.CoDe.hu>
next in thread | previous in thread | raw e-mail | index | archive | help
> > > > > > > > > Hi, > > > > > > I have a little problem. So I hope someone can help > > > me: > > > > > > Under Linux a /dev/port exits to write/read to/from an I/O-port. > > > Does a similar /dev/??? exits under FreeBSD or must I write > > > a little device driver for this? > > > > Under FreeBSD there is /dev/io. > > > > Do an open("/dev/io",flags,mode) on it and you can access i/o > > ports using in/out instructions. > > OK. How? What does flags mean? How can I use the fd, I get from open? > (A little example please....) /usr/include/fcntl.h: #define O_RDONLY 0x0000 /* open for reading only */ #define O_WRONLY 0x0001 /* open for writing only */ #define O_RDWR 0x0002 /* open for reading and writing */ #define O_ACCMODE 0x0003 /* mask for above modes */ If you want to read & write to a specific port, use O_RDWR. Once you have opened the io space (device), you can read/write (be cautious!) to any location in the io space. That can be done by in/out (inline assembler - gcc) or by functions, doing that. Look at the driver code in /sys/i386/isa. It's full of example code. > > -- > Gabor Zahemszky <zgabor@CoDe.hu> > > -:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:- > Earth is the cradle of human sense, but you can't stay in the cradle forever. > Tsiolkovsky > --Chris Christoph P. U. Kukulies kuku@gil.physik.rwth-aachen.de
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604220721.JAA24177>