For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > February 2005 > Perl interface to direct port I/O functions (inb(), outb() and friends)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

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

2005-02-20, 3:56 am

Hello,

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:

port_open($portnum);
write_byte($portnum, $value);
$value = read_byte($portnum);
port_close($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 w or so, I'll probably just go ahead with packaging up and
submitting the code I've got working. Thanks!

Humbly,

Andrew

-----------------------------------------------------------------------
'Twas brillig, and the slithy toves Andrew Ho
Did gyre and gimble in the wabe. andrew@zeuscat.com
All mimsy were the borogoves,
And the mome raths outgrabe. http://www.zeuscat.com/andrew/
-----------------------------------------------------------------------

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com