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 / Opening and Closing Device Drivers


PBClose

You can use the PBClose function to close an open device driver.

pascal OSErr PBClose(ParmBlkPtr paramBlock, Boolean async); 
paramBlock
A pointer to an IOParam structure of the Device Manager parameter block.
async
A Boolean value that indicates whether the request is asynchronous. You must set this field to false because device drivers cannot be closed asynchronously.
<--ioResultOSErrThe device driver's result code.
-->ioRefNumshortThe driver reference number.

DESCRIPTION
The PBClose function closes the device driver specified by the ioRefNum field. The Device Manager waits until the driver is inactive before calling the driver's close routine. When the driver indicates it has processed the close request, the Device Manager unlocks the driver resource if the dRAMBased flag is set, and unlocks the device control entry if the dNeedLock flag is not set. The Device Manager does not dispose of the device control entry or remove it from the unit table.

If the driver returns a negative result in register D0, the Device Manager returns this result code in the ioResult field of the parameter block and does not close the driver.

WARNING
You should not close drivers that other applications may be using, such as a disk driver, the AppleTalk drivers, and so on.
SPECIAL CONSIDERATIONS
The Device Manager does not queue close requests.

WARNING
Do not call the PBClose function at interrupt time because if the driver was processing a request when the interrupt occurred the Device Manager may loop indefinitely, waiting for the driver to complete the request.
ASSEMBLY-LANGUAGE INFORMATION
The trap macro for the PBClose function is _Close (0xA001).

You must set up register A0 with the address of the parameter block. When _Close returns, register D0 contains the result code. Register D0 is the only register affected by this function.
Registers on entry
A0Address of the parameter block
Registers on exit
D0Result code

RESULT CODES
noErr0No error
badUnitErr-21Driver reference number does not match unit table
unitEmptyErr-22Driver reference number specifies a nil handle in unit table
closErr-24Driver unable to complete close request
dRemovErr-25Attempt to remove an open driver
SEE ALSO
For information about the high-level function for closing device drivers, see the description of the CloseDriver function on page 1-65. For an example of how to close a device driver using the PBClose function, see Listing 1-2 on page 1-20.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996