Subject: Re: netbsd i386 1.6.1 question: (user mode hw io)
To: Peter L. Peres <plp@actcom.co.il>
From: Michael <macallan18@earthlink.net>
List: port-i386
Date: 12/23/2004 07:15:10
Hello,

> I have a small question. I am trying to port an old usermode hw io 
> testing program that I wrote a long time ago from linux to netbsd. My 
> question is, how does one do user mode hw io using bus_space_... 
> functions when the handle for the bus space cannot be obtained in user 
> mode. In particular i386_memio_map and unmap are not implemented 
> anywhere in the header files supplied with netbsd-1.6.1 (I presume that 
> they are implemented in the kernel sources since they exist in /netbsd). 
> The other bus_space_... functions mostly *are* implemented in the 
> headers.
As far as I know you can't use any of the bus_space stuff from userland.

> So, am I trying to do something impossible, or not ? i.e. can I compile 
> a user mode program, to be run as root, which uses bus_space_peek and 
> _poke, or do I have to write a proper driver ? I know that this is 
> 'dangerous' etc but it is needed to debug and test certain hardware.
Either make a kernel module using bus_space_* or use the good(?) old mmap(/dev/mem) way if you don't need interrupts. You can access PCI config registers from userland with pcibus_conf_read() and friends ( man 3 pci ). It won't be as portable as a kernel module but it would be userland :)

have fun
Michael