Perl interface to direct port I/O functions (inb(), outb() and friends)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


On Linux or BSD systems, you can do direct port I/O from C/C++ using
the inb() and outb() functions. In addition, on Linux and glibc based
systems you may have to use ioperm() to get access to a port, and the
BSDs have equivalents (I've been using /dev/io on FreeBSD and sysarch()
and iopl on OpenBSD).

Typically, you want to do this to do some sort of ad hoc hardware
interfacing: for example, using your joystick port or parallel port for
random hackery.

I've written some XS glue--it's pretty simple--to provide Perl access
to these functions; it's four simple exported functions:

    write_byte($portnum, $value);
    $value = read_byte($portnum);

I have a few questions. First, is there already a module that does this
for me? I note at least one port-specific module, Device::ParallelPort,
but no general interface to inb() and outb() and equivalents (it could
almost be, though, the API is pretty much the same, so perhaps it just
bears renaming!).

If there is not such a module, I'd like to contribute one. I'm thinking
the Sys:: namespace is the right place for it, so I'd suggest something
like Sys::PortIO. I'm quite open to alternate suggestions.

I'm already registered with PAUSE, so if I don't hear back from anybody
in a week or so, I'll probably just go ahead with packaging up and
submitting the code I've got working. Thanks!



'Twas brillig, and the slithy toves                          Andrew Ho
 Did gyre and gimble in the wabe.         
 All mimsy were the borogoves,
 And the mome raths outgrabe.  /

Site Timeline