Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Device Drivers in perl?

by deprecated (Priest)
on Mar 05, 2001 at 17:45 UTC ( #62227=perlquestion: print w/replies, xml ) Need Help??

deprecated has asked for the wisdom of the Perl Monks concerning the following question:

Well, after a brief but mostly thorough search of the monastery, I have found one other attempt at writing a device driver in perl.

Before I can ask for help with this, I need to give a brief explanation and perhaps some background.

Im using SunOS 5.8 ("Solaris 8") on a Sony VAIO subnote. It has a USB floppy drive which isnt quite supported by solaris, and a PCMCIA CD-ROM drive which is also not quite supported by solaris. Its onboard networking is fried, as the previous owner plugged a digital (high current) line into it and literally zapped the circuit traces on the board. So, while this is a great little critter for developing, it is 100% impossible to get data off of it (and I'm trying to use it to write a server in perl).

So the start of the solution here is a 3Com 'Megahertz' 10/100 network card, which is PCMCIA. Sun has excellent manpages and stuff, so writing the driver will be a bitch, but its not going to be fun because its C. I got to thinking last night that it might be possible to write a driver in perl, but it would have to call the C functions somewhere. Would this process be similar to the process people use to write C code for perl modules? It would be possible to extrapolate simple driver modules for perl using the manpages and whatnot. Has anyone done anything like this?

brother dep.

transcending "coolness" is what makes us cool.

Replies are listed 'Best First'.
Re: Device Drivers in perl?
by Jouke (Curate) on Mar 05, 2001 at 18:11 UTC
    I guess everything is possible, for example by using Inline::C. But the first thing that comes to mind is use the right tools for the job you have to do.

    Jouke Visser, Perl 'Adept'
Re: Device Drivers in perl?
by Malkavian (Friar) on Mar 05, 2001 at 18:17 UTC
    The previous example you have seems to deal in a more 'high level' driver. In that you're dealing with an abstraction layer already (talking through other low level devices and using a protocol).
    Writing a device driver requires some pretty hefty usage of registers, IO addresses and interrupt control. Easy in C (well, sorta), but (as far as I know, and I'm far from a guru), a bit of a nightmare in Perl.
    Also, a low level device driver is a real time system, and with all the best will in the world, I'd really break a heavy sweat if anyone asked me to code true real time systems in Perl. It's just not designed for the task.

    Just my tuppence worth,

Re (tilly) 1: Device Drivers in perl?
by tilly (Archbishop) on Mar 05, 2001 at 20:04 UTC
    It is likely that your device driver will need to operate in a hard limit of a few hundred K or so of memory. In which case Perl would be simply undoable.

    OTOH it might be possible to call out to user space. In that case amusing things are possible. But don't count on it.

Re: Device Drivers in perl?
by deprecated (Priest) on Mar 05, 2001 at 21:29 UTC
    Actually, now that I think about it, writing a device driver library for perl would be exceptionally useful for people actually having to do this horrid task in C. Imagine, being able to whip up one-liner solutions so that you could use Sun's poke, peek,andprobe functions without having to write a whole damn C program.

    for example:

    root@brak# perl -MSun::DDI -e 'probe /dev/pcmcia/*' # is muuuuuuch easier than: #include <stdio.h> #include <sunddi.h> #include <thatotherannoyingsunheaderfile.h> int main (void) { int i_will_save_you_the_agony_of_reading_c_code = 0; // ... }
    I'll let everyone know what I come up with after I read Sun's Writing Device Drivers today. This could be exceptionally useful.

    party on,
    brother dep.

    transcending "coolness" is what makes us cool.

Re: Device Drivers in perl?
by strredwolf (Chaplain) on Mar 06, 2001 at 03:25 UTC
    Definetly possible. Heck, they have the Perl File System modules for Linux, so you can program up your own filesystem.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://62227]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2020-12-04 05:35 GMT
Find Nodes?
    Voting Booth?
    How often do you use taint mode?

    Results (58 votes). Check out past polls.