Writing device drivers that reach over a bus..

Roger Gonzalez rg at msel.unh.edu
Mon Apr 8 23:44:57 AEST 1991


I recently wrote a SCSI device driver that controls a WORM optical drive.
It actually isn't a Unix device driver, since the WORM schema wouldn't
allow a Unixish file system on it without having all dynamic tables on
a separate hard drive or something.  But I digress.  Although this isn't
a strictly Unix question, I have a feeling that people who have written
Unix drivers should be able to help me.

A frequent occurence in the driver is that I want to set some register bit
high, but I'm not allowed to do it until some other bits go to a certain
state.  My first cut driver used plain 'ol polling with a timeout.  This
worked ok, but beat the piss out of the VME bus.  I then changed it so
that my polling went more like this:

	while ((reg != val) && (counter < timeout))
	   usleep(N);  /* yeah, yeah.  non-portable SunOSism. BFHD. */

Now my driver is slightly kinder to the bus, but runs like molasses.

Is there a generally socially acceptable way to handle this?

(Note - this whole thing is further complicated by the fact that not only
do I go out over the VME bus, but from there I go out over a Bit3 VME adaptor
boardset to a remote VME bus.)

Thanks!

-Roger
       



-- 
"The question of whether a computer can think is no more interesting
 than the question of whether a submarine can swim" - Edsgar W. Dijkstra 
rg@[msel|unhd].unh.edu        |  UNH Marine Systems Engineering Laboratory
r_gonzalez at unhh.bitnet        |  Durham, NH  03824-3525



More information about the Comp.unix.wizards mailing list