From: kem@cis.ufl.edu (Kelly Murray) Subject: Re: [Q] How to use "outp" Date: 19 Mar 1993 19:53:25 GMT
Device IO ports are a ``protected'' resource, generally limited to kernel access.
The 386 traps access to unprivledged ports, giving you the segmentation violation
when using the IN and OUT instructions.
I believe the supported mechanism is to open /dev/ports,
and then do seeks and reads on the fd, since the in's and out's will then
be done in the kernel.
(roughly: fd = open("/dev/ports"); seek(fd, 0x280); read(fd, buf, 1); )
I fixed the problem for myself by adding new ioctl system calls to the /dev/ports
device controller, allowing one to turn on and off access to specific ports.
This will allow user-programs to use in's and out's directly (much faster).
I actually ended up creating a kernel that disabled all port protection,
but I wouldn't recommend that generally. It is simpler than the ioctl approach,
since it only required editing one line in init/main.c? that initializes the
flags register for a new user process.
-Kelly
In article <9307816.24010@mulga.cs.mu.OZ.AU>, camerond@ee.mu.OZ.AU (cameron donaldson) writes:
|> G'day,
|>
|> I was wondering how to use "outp", the assembler command
|> defined as a C function in <asm/io.h>. When I have <asm/io.h>
|> as a header, ld naturally enough complains about "undefined
|> symbol _outb". When I actually define the function "outp"
|> as found in <asm/io.h> the program will compile, but not
|> surprisingly will die with a segmentation fault.
|>
|> Can I use "outp" in a user program, or will the kernel "not allow"
|> (for want of a better phrase) users to write directly to a port.
|> In which case is there a better solution ? (I'm attempting to develop
|> a hardware card, and need i/o. And of course would much rather use
|> Linux.)
|>
|> Thanks in advance,
|>
|> Cameron
|>
|>