Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Devices /
Chapter 1 - Device Manager / Device Manager Reference
Device Manager Functions / Writing and Installing Device Drivers


DriverInstallReserveMem

You can use the DriverInstallReserveMem function to create a device control entry and install it in the unit table.

pascal OSErr DriverInstallReserveMem(Ptr drvrPtr, short refNum);
drvrPtr
A pointer to the device driver.
refNum
The driver reference number.
DESCRIPTION
The DriverInstallReserveMem function is equivalent to the DriverInstall function, except that it calls the Memory Manager ReserveMem function to compact the heap before allocating memory for the device control entry (DCE).

After calling the ReserveMem function, the DriverInstallReserveMem function allocates a DCE in the system heap and installs a handle to this DCE in the unit table location specified by the refNum parameter. You pass a pointer to the device driver in the drvrPtr parameter.

In addition, this function copies the refNum parameter to the dCtlRefNum field of the DCE, sets the dRAMBased flag in the dCtlFlags field, and clears all the other fields.

SPECIAL CONSIDERATIONS
The DriverInstallReserveMem function does not load the driver resource into memory, copy the flags from the driver header to the dCtlFlags field, or open the driver. You can write code to perform these tasks, or use the OpenDriver, OpenSlot, or PBOpen functions instead.

The DriverInstallReserveMem function allocates memory; you should not call it at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro for the DriverInstallReserveMem function is _DrvrInstall (0xA03D). You must set bit 10 of the trap word to signal the Device Manager to call the ReserveMem function before allocating memory for the DCE.

You place a pointer to the device driver in register A0, and the driver reference number in register D0. When _DrvrInstall returns, register D0 contains the result code.
Registers on entry
A0A pointer to the device driver
D0The driver reference number
Registers on exit
D0Result code

RESULT CODES
noErr0No error
badUnitErr-21Driver reference number does not match unit table

Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996