DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SVR5

_unload(D2)


_unload -- prepare to unload a driver

Synopsis

   #include <sys/ddi.h>
   

int _unload(void);

Description

The driver's _unload( ) entry point routine is called to handle any cleanup a loadable driver must perform before it can be dynamically unloaded from a running system. Typically, the _unload( ) routine undoes whatever was done in the driver's _load(D2) routine.


NOTE: Beginning with DDI version 8, this entry point routine must be defined as a global symbol named _unload with no prefix.

Return values

The _unload routine should return 0 for success, or the appropriate error number from those listed on the errnos(D5) manual page. If _unload( ) returns an error, the module is not unloaded.

Usage

This entry point is required for all drivers. It is called only when none of the devices controlled by the driver are open.

The _unload( ) routine can perform activities such as:

For DDI 8 drivers, the _unload( ) routine calls the CFG_REMOVE subfunction of the config(D2) entry point routine. The driver should be deregistered and interrupt handlers and global resources for the supported device(s) should be freed in the CFG_REMOVE subfunction rather than in the _unload( ) routine.

Context and synchronization

Blockable context. The driver can block but cannot do operations such as copyout(D3) that require access to the requesting process's address space.

Examples

See _load(D2) for an example of _unload.

``DDI: 8 sample driver'' in HDK code samples also includes a sample _load( ) entry point routine.

Hardware applicability

All

Version applicability

ddi: 4, 5, 5mp, 6, 6mp, 7, 7mp, 7.1, 7.1mp, 8, 8mp

Differences between versions

Prior to DDI version 8, the _unload( ) entry point routine is optional, even if the driver is dynamically loaded. If this entry point is not provided, the driver is never unloaded after it loads successfully.

References

cm_intr_detach(D3), drv_detach(D3), _load(D2), mod_drvdetach(D3)

_unload(D2mdi), _unload(D2sdi), _unload(D2str)

``Dynamically-loadable kernel modules (DLKM)'' in HDK Technical Reference


19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005