(Answer) (Category) SCO comp.unix.sco.programmer FAQ. : (Category) Hardware related programming :
How can I access to I/O ports or card memory from my program?
UNIX is about sharing. While it may seem militant that it won't let you (a mere user program) go out and reset the disk controller and reprogram the interrupt controller at will, it's good for you. Honest. There is more information on doing this in this section of the FAQ.

However, if you're well disciplined, have only one instance of a program talking to the device, you don't need interrupts, and are willing to accept some responsibility, it is possible to do it from user space. The classic example of this is the X server.

On 5.0.0d and later it is possible to mmap() /dev/kmem into user space to talk to memory addressable hardware.

To talk to I/O space is a little trickier. You can call V86_IOPL to open up permissions for inb and outb from user space. This can be a little hazardous, as it allows all I/O accesses. Alternately, you can either create your own device driver to do the ins and outs for you or you can use minor numbers 3,4,5 of the major number of the mm driver (the driver for /dev/null, mem, and kmem) to access memory as bytes, halfwords, and words, respectively. Remember that you must re-seek the I/O address each time. If you are going to do this, it is wise to encapsulate this into functions with the usual in/out[bwl] names. This is utterly undocumented and unsupported.
robertlipe@usa.net

[Append to This Answer]
Previous: (Answer) How can I directly read or write the parallel port to use it for input or to control my non-printer devices?
Next: (Answer) How can I write directly to the console like I do in DOS?
This document is: http://www.zenez.com/cgi-bin/scoprogfaq/faq?file=30
[Search] [Appearance]
This is a Faq-O-Matic 2.721.