Subject: Re: /dev/io - what, why and how? :)
To: None <oper@mikrobitti.fi>
From: Mike Long <mike.long@analog.com>
List: port-i386
Date: 05/22/1996 10:00:08
>From: Operator <oper@mikrobitti.fi>
>Date: Wed, 22 May 1996 11:33:16 +0300 (EET DST)
>A friend of mine is trying to get a DigiBoard serial card working on
>NetBSD. He would like to peek the UART registers to see what is going
>on with them.
>
>Is it possible to use /dev/io to read (and write?) i386 IO space
>registers? If so, how?
First: AFAIK, use of /dev/io is discouraged; you should use the
functions (e.g. ioperm()) in libi386.a instead.
/dev/io is similar to /dev/mem, except that it accesses the x86 I/O
space instead of memory. To use /dev/io, use something like:
#include <unistd.h>
int inb(addr)
unsigned addr;
{
int fd;
char data;
fd = open("/dev/io", O_RDONLY);
lseek(fd, (off_t)addr, SEEK_SET);
read(fd, &data, 1);
close(fd);
return (int)data;
}
...preferably something that checks syscall return values. :-)
--
Mike Long <mike.long@analog.com> <URL:http://www.shore.net/~mikel>
VLSI Design Engineer finger mikel@shore.net for PGP public key
Analog Devices, CPD Division CCBF225E7D3F7ECB2C8F7ABB15D9BE7B
Norwood, MA 02062 USA (eq (opinion 'ADI) (opinion 'mike)) -> nil