to write a device driver or not to write (i/o, opl3, stupidity)
Bruce M Simpson
bms at spc.org
Thu Oct 16 03:01:09 PDT 2003
> > I mean, what services do drivers offer? What services they _need_ to offer? Do they just create appropriate device nodes and let the applications to worry about using them or do they do some data manipulation or do they offer routines and interfaces for applications or what? What should this particular driver do as I just want to read/write data.
I think for your application running in userland is fine, if kernel
programming is likely to be a steep learning curve. You can use nanosleep()
to get the timing you need.
On Wed, Oct 15, 2003 at 05:13:29PM -0400, Mathew Kanner wrote:
> I'm not positive about this but I think that you can do it
> from usermode by opening /dev/io (as root) and the use inb, outb
> macros defined in cpufunc.h.
You can also use i386_get_ioperm() and i386_set_ioperm(). These change
the I/O port permission bitmap in the process's Task State Segment (TSS)
accordingly, so that you can issue IN/OUT instructions without segfaulting
in a similar way to opening /dev/io. The only trouble with /dev/io is that
it's an all-or-nothing approach (processes literally can write anywhere in
I/O space); better to ask for what you need than ask for everything, IMHO.
More information about the freebsd-hackers