Looking for help with Simple Device Driver for SCO Unix

Looking for help with Simple Device Driver for SCO Unix

Post by Rudy Wi » Mon, 12 Sep 1994 13:42:47



I need help writing a device driver for SCO Unix.  All it needs to do
is write a character to and IO port address and read a character from
another address.   Is this difficult to do on UNIX?  On DOS using Borland C++
i would simply use the INP and OUTP functions.

Any assistance would be greatly appreciated.

Thanks!

 
 
 

Looking for help with Simple Device Driver for SCO Unix

Post by Frank Pilhof » Tue, 13 Sep 1994 03:25:34



Quote:>I need help writing a device driver for SCO Unix.  All it needs to do
>is write a character to and IO port address and read a character from
>another address.   Is this difficult to do on UNIX?  On DOS using Borland C++
>i would simply use the INP and OUTP functions.

 Writing device drivers is not a matter you can learn today. There are
functions for byte I/O to ports in Unix, inb(addr) and outb(addr,c).
I don't know if they are compatible throughout the Unix world, but they
do exist in SCO unix.
 However, a device driver is much more than just these two functions.
They have to deal with multitasking, multiple I/O requests etc. If you
want a book on writing device drivers, I recommend 'Writing Unix de-
vice drivers' by George Pajari. It is well written and contains lots
of examples (not only) for SCO Unix.

        Frank

--

 | Darmstaedter Str. 22                                                      |
 | D-63225 Langen, Germany                                                   |
 +---------------------------------------------------------------------------+

 
 
 

Looking for help with Simple Device Driver for SCO Unix

Post by steve wallace x31 » Wed, 14 Sep 1994 09:14:26




> >I need help writing a device driver for SCO Unix.  All it needs to do
> >is write a character to and IO port address and read a character from  
> >another address.   Is this difficult to do on UNIX?  On DOS using Borland C++
> >i would simply use the INP and OUTP functions.
> Writing device drivers is not a matter you can learn today. There are  
>functions for byte I/O to ports in Unix, inb(addr) and outb(addr,c).
>I don't know if they are compatible throughout the Unix world, but they
>do exist in SCO unix.
> However, a device driver is much more than just these two functions.
>They have to deal with multitasking, multiple I/O requests etc. If you
>want a book on writing device drivers, I recommend 'Writing Unix de-
>vice drivers' by George Pajari. It is well written and contains lots
>of examples (not only) for SCO Unix.

>        Frank

>--  

> | Darmstaedter Str. 22                                                      |
> | D-63225 Langen, Germany                                                   |
> +---------------------------------------------------------------------------+

Gosh, Frank, I couldn't have said it better!  

Rudy, I make my living writing device drivers for different flavors of Unix,
and IMHO what Frank is trying to tell you is that the direct answer to your
question is inb(addr) and outb(addr,c) (and no, these functions are *not*
compatible in the Unix world, because some flavors of Unix [editorialize button
on] run on *real* computers, not the IBM Piece of trash that SCO runs on
[editorialize button off].  Many machines do not have different address space
for devices versus good old memory, so a function in the realm of inb() is not
needed, and not present.

The meat of Frank's answer is that the inb() part is simple, nothing to it,
piece o'cake.  However, the difference between a device driver and application
code is night and day.  In a driver, even one as simple as the one that you
are speaking of, there are several levels of things that you need to be aware
of that you needn't even address in app code.

If you choose to proceed with your driver, I agree with Frank's recommendation
of Pajari's book. It's well written, but extremely basic.  It's written at the
college undergrad level, and so there isn't and good reference in it, but it's
a good text book to teach you the basics.  In order to RTFM, you will need to
BTFM (Buy the F***ing Manual).  Buy or borrow a copy of the Writing Device
Drivers manual from SCO.  It's expensive (probably about $500), but you really
can't write a SCO device driver without it, because some of the generically
named functions that appear in other device driver dork books are SCO specific,
and only appear in this book, and possibly Pajari.  For example, the malloc()
like function that nearly everywhere else is spelled kmem_alloc() is spelled
spt_alloc() in SCO-land.  I never would have figured that out without the SCO
book.  Memory mapping functions are funny, too, as they want to deal with pages,
not bytes.

Another *excellent* text is "Writing a Unix Device Driver" by Egan and Teixeira
published by Wiley & Sons, ISBN 0-471-53575-3 now in second edition.  This is
more advanced and a good companion to Pajari.

Good Luck,
Steve
*************************************************************************
Approximate value:      $0.02
Standard Disclaimers Apply
*************************************************************************
I could tell that my lawyer was lying.  His lips were moving.