Subject: Re: netbsd i386 1.6.1 question: (user mode hw io)
To: None <port-i386@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: port-i386
Date: 12/23/2004 07:07:31
> 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_...

One doesn't.  The bus-space functions - and perhaps more importantly,
the support behind them - are kernel-only.  Indeed, one of the kernel's
jobs is to keep userland away from direct access to the hardware.

> 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 ?

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).

Unless your device has requirements such as DMA or tight timing, you
may well be able to get away with a very basic driver that just gives
userland a more or less direct interface to the appropriate bus-space
calls.  (It would be an immense security hole for normal use, or
distribution, but it may nevertheless be suitable on an
experimental-hackery system.)

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B