[comp.sys.mac.programmer] Opening Drivers

mikeoro@hubcap.clemson.edu (Michael K O'Rourke) (12/14/89)

I have a couple questions about drivers:

First, I know that there are a certain number of "slots" for use by
drivers and da's.  Does my driver have to be numbered as one of those
slots?  For instance, I am opening the driver from an INIT and the driver
will continue to run in the background while the machine is running.  Am
i going to have to look thru the system file at boot time to see if there
is an empty slot, renumber my driver and then open it?  I read the device
manager stuff but am still confused on this point.  My guess is that the
refNum passed by OpenDriver() will give me the slot i am in.  Is this correct?

Thanx,
Michael

tim@hoptoad.uucp (Tim Maroney) (12/17/89)

In article <7421@hubcap.clemson.edu> mikeoro@hubcap.clemson.edu (Michael
K O'Rourke) writes:
>First, I know that there are a certain number of "slots" for use by
>drivers and da's.  Does my driver have to be numbered as one of those
>slots?  For instance, I am opening the driver from an INIT and the driver
>will continue to run in the background while the machine is running.  Am
>i going to have to look thru the system file at boot time to see if there
>is an empty slot, renumber my driver and then open it?

Close.  Check the unit table, not the system file.  Walk over the unit
table in a way similar to that of Tech Note #71.  Look for an empty
DCE entry.  You may then install yourself as the driver with the
reference number corresponding to the empty slot.  Use the _DrvrInstall
trap documented in Tech Note #108.

>I read the device
>manager stuff but am still confused on this point.  My guess is that the
>refNum passed by OpenDriver() will give me the slot i am in.  Is this correct?

It doesn't give you the slot number, but it gives you a reference number
from which the slot number can readily be derived; the slot number is
-1 * (refNum + 1).
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"Those who restrain desire, do so because theirs is weak enough to be
 restrained..." - Blake, "The Marriage of Heaven and Hell"

urlichs@smurf.ira.uka.de (12/19/89)

In comp.sys.mac.programmer tim@hoptoad.UUCP (Tim Maroney) writes:
< In article <7421@hubcap.clemson.edu> mikeoro@hubcap.clemson.edu (Michael
< K O'Rourke) writes:
< Close.  Check the unit table, not the system file.  Walk over the unit
< table in a way similar to that of Tech Note #71.  Look for an empty
< DCE entry.  You may then install yourself as the driver with the
< reference number corresponding to the empty slot.  Use the _DrvrInstall
< trap documented in Tech Note #108.
< 
You'll have to check the System file also. Some drivers may not be opened yet,
and won't appear in the table.

There may not be any more free space in the unit table for your driver, so
you might have to make it bigger. The technique is straightforward (make new
pointer in system heap, copy old unit table there, enter pointer and size in
low mem globals). Don't forget to lock out interrupts while doing that, use
NewPtrSysClear and not NewPtr, and do not free the old table because you don't
know where it came from.

Disclaimer: I saw the above in Apple's ADSP Init, so to the best of my
knowledge it works.

-- 
Matthias Urlichs