Subject: Re: netbsd i386 1.6.1 question: (user mode hw io)
To: Peter L. Peres <plp@actcom.co.il>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: port-i386
Date: 12/23/2004 08:44:01
"Peter L. Peres" <plp@actcom.co.il> writes:

> > You'll need to write a driver (though for memory-mapped stuff, you can
> > in principle use /dev/mem - depending on your device's interface, this
> > may be good enough).

He can't use bus_space stuff from userland, but i386 does make it
possible for user applications, running as root, to access I/O ports
directly, for purposes just like this.

> The program in cause was written specifically for poking and peeking
> simple devices that do not yet have a driver. No dma or interrupts are
> involved. /dev/io will do fine except:
> 
> man io:
> "NAME
>       io - I/O privilege file
> 
> DESCRIPTION
>       This device is obsolete and is provided for compatibility purposes only;
>       use i386_iopl(2) instead.

> hmm? This is implemented in libi386. Could I define my own
> bus_space_map using i386_iopl and i386_ioperm and link against libi386
> ?

Forget about bus_space in userland. Use i386_iopl() to enable I/O port
access for your program and use inb/inw/outb/outw directly. You can
use the wrapper functions in the <x86/pio.h> header to have C function
versions of those instructions.

        - Nathan