*BSD News Article 85111


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.Hawaii.Edu!news.uoregon.edu!arclight.uoregon.edu!news-feed.inet.tele.dk!news.nacamar.de!howland.erols.net!news.bbnplanet.com!cam-news-hub1.bbnplanet.com!uunet!in2.uu.net!171.69.2.138!usenet.cisco.com!usenet
From: deborah@cisco.com (Deborah Gronke Bennett)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: How to write a device driver in FreeBSD
Date: 13 Dec 1996 15:23:40 -0800
Organization: Cisco Systems, IOS Technology
Lines: 65
Sender: deborah@deborah-ss20.cisco.com
Message-ID: <nzs3exaxc3n.fsf@deborah-ss20.cisco.com>
References: <sehari.850425787@eng3.iastate.edu>
NNTP-Posting-Host: deborah-ss20.cisco.com
In-reply-to: sehari@iastate.edu's message of 12 Dec 96 21:23:07 GMT
X-Newsreader: Gnus v5.1
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:32583

In article <sehari.850425787@eng3.iastate.edu> sehari@iastate.edu (Babak $ehari) writes:


   I am very familiar with DOS programming, and have done some Assembly on x86
   under dos computers.  I would like to learn how to write device drivers
   under freebsd or in general unix.  

   Say I have this Single speed CD ROM and the RS422 driver card that
   runs it.  How can I write a FreeBSD driver for it? (philips CDD 462
   and CM 250 card)  Oh, by the way there is a linux driver for this CD
   ROM, which should help writing a Free BSD version for it.

   How to tell the c compiler or any assambly compiler to look up the
   content of an address which is a device.

I don't understand this question. Maybe you are asking how
to get the instructions which read and write to I/O space rather
than memory space? If so, there are some inline macros in the
FreeBSD sources already which do this for you (inb, outb, inw, outw, etc).
Take a look at the sources for some of the existing device drivers
to see how they are using it.

   Does the assembly program that runs under the dos run under FreeBSD unix
   assuming no INT 21H is used?!

I don't understand this either. I have written a device driver
for an ISA card under FreeBSD and this question doesn't ring
any bells with me . . .

   Let say I design this card for a PC and now want to write a program for
   it, are there any examples out there so I can compare FreeBSD programs
   and Dos program?

Well, I'm not sure how helpful comparing a DOS device driver and
a FreeBSD device driver will be. The only commonality will be
that the register layout of the device will be the same.
Beyond that they are very different.

   Any good book for advanced unix programing?

You should get a book on writing UNIX device drivers. FreeBSD drivers
look very much like standard BSD device drivers, so any reference
which uses BSD (of any kind) as a reference will help you.
I've done most of my learning about device drivers on a particular
platform (including FreeBSD) by looking at the sources to existing
drivers that are similar. When you're learning, stay away (mostly)
from the SCSI and networking interface drivers, which are more
complex. Pick a simple device like the parallel port, or one of
the special devices that are only in the LINT kernel.
These give you most of the basic driver bones without a lot
of complication with buffer management and such.

You probably also want to get one of the BSD reference books so
that you understand how device drivers and the I/O system live
inside the kernel. Either of the books with the little devil on
them are probably a good start (the titles are something like
"The Design and Implementation of the BSD 4.X Operating System",
where X is either 3 or 4). Take a look on the FreeBSD web page,
there is a list of reference manuals that has the full
reference for this one.
-- 
Deborah Gronke Bennett		System Software Engineer, IOS Technology
deborah@cisco.com		(408)-526-4000
Cisco Systems
170 West Tasman Dr., San Jose, CA 95134-1706