[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Direct I/O port access (x86)



Hello,

I have a quick question regarding direct I/O port access
under OpenBSD 2.8-GENERIC that I was hoping someone here
might be able to answer.

Recently, I've been trying to get some code running that
sends data to the Yamaha OPL3 ("Adlib") sound-chip found
on many Sound Blaster-compatible sound cards. 

More specifically, the code uses the 'inb' / 'outb' macros
found in <machine/pio.h> (IIRC)  to send the data directly
to the chip,  which is most often found at ports 0x388 and 
0x389.

Unfortunately, the program segfault's on the first 'outb' 
call, leaving few clues as to where the problem may lie.

>From what I've been able to find in other sources, the 'pro-
per' way of doing direct I/O port access under *BSD seems to
be something like this:

  1. Open "/dev/io" in order to gain permissions needed to use 
     the 'inb' / 'outb' macros.

  2. Send data to the device using 'inb' / 'outb'.

  3. Close "/dev/io" (obviously ;-)


Would anyone care to take a guess as to where the problem may 
be?  Lack of permissions to access the sound device?

Thanks,


--
Chris Cox
cox.family@sk.sympatico.ca