Port Access

Tom Neff tneff at bfmny0.UU.NET
Wed Jan 3 10:18:05 AEST 1990


In article <12720 at cbnews.ATT.COM> knt at cbnews.ATT.COM (kirk.n.trost,59473,cb,1k238,614 860 4225) writes:
>Is there an easy way to access 386 ports using C 
>under UNIX.
>
>For example:
>
>     x = input (portno)
>         output (portno, value)

[ This is not a C question, therefore I have crossposted this to
comp.lang.i386 and directed followups there.  Read the stuff in
news.announce.newusers, folks. ]

User written programs under UNIX 386 cannot typically access I/O ports
in the way described above.  That's a privilege granted only to the
kernel.  It takes a bit of getting used to the idea that when a real
OS like UNIX is running, as opposed to a baby monitor like DOS, one
cannot tweak the hardware at will from user programs.

There are two workarounds: write a *device driver* for the hardware in
question, which will be linked into the kernel and so have its
priveleges, and which will then be available as a 'device' to user
programs, or (if you have VP/ix aka Simul-Task) there is a special set
of routines to map certain registers into your space.

No specific example is given of what the user wants to do, so the best
solution isn't clear.  If it's just something like toggling 43/25 lines
or making sound, check to see if there isn't already something in the
library that will do what you want.  If it's something truly nonstandard
and site specific like operating an A/D converter card for a lab, then
write a device driver.

-- 
"DO NOT, repeat, DO NOT blow the hatch!"  /)\   Tom Neff
"Roger....hatch blown!"                   \(/   tneff at bfmny0.UU.NET



More information about the Comp.unix.i386 mailing list