Subject: Re: inb, outb, i386_set_ioperm and such
To: Bruce J.A. Nourish <netbsd@bjan.freeshell.org>
From: Dave Huang <khym@azeotrope.org>
List: tech-userlevel
Date: 03/28/2004 16:25:19
On Sun, Mar 28, 2004 at 04:20:54PM -0600, Dave Huang wrote:
> On Sun, Mar 28, 2004 at 08:25:06AM -0700, Bruce J.A. Nourish wrote:
> > * 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;
> 
> Shouldn't "i" be in that loop somewhere? s/from + num/from + i/g

Oh, and permission is granted if the bit is clear, not set. So you
should call i386_get_ioperm() first to get the current permission map,
then:

  for (i = 0; i < num; ++i)
       iomap[(from + i) / 32] &= ~(1 << (from + i) % 32);

Then call i386_set_ioperm().