Subject: inb, outb, i386_set_ioperm and such
To: None <tech-userlevel@netbsd.org>
From: Bruce J.A. Nourish <bjan@bjan.freeshell.org>
List: tech-userlevel
Date: 03/28/2004 08:25:06
Hey everyone,
I'm porting TiLP to NetBSD. I have a couple of slightly tricky
questions:
* Given "from" and "num", two integers that describe a range of ports
to open up for inb/outb access, does the following code set up the
iomap correctly?
for (i = 0; i < num; ++i)
iomap[(from + num) / 32] |= 1 << (from + num) % 32;
return (i386_set_ioperm(iomap) ? ERR_ROOT : 0);
* How come we don't have inb() and outb() in machine/cpufunc.h?
* Are the following definitions of inb() and outb() from FreeBSD 5.2
appropriate?
static __inline u_char
inb(u_int port)
{
u_char data;
__asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port));
return (data);
}
static __inline void
outb(u_int port, u_char data)
{
u_char al;
al = data;
__asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port));
}
--
Bruce J.A. Nourish <bjan@bjan.freeshell.org> http://bjan.freeshell.org
SDF Public Access UNIX System - http://sdf.lonestar.org