DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
DDI: 8 sample driver

_unload entry point routine

The _unload(D2) entry point routine is called, along with the CFG_REMOVE subfunction to the config(D2) entry point routine and the close(D2) entry point routine when the driver is unloaded from the system or when the system is shutdown. It basically is coded to undo anything that is done in the _load( ) entry point routine.

samp_unload( ) calls the drv_detach(D3) function to deregister the driver that is identified by the samp_drvinfo structure and that was registered with the drv_attach( ) function in the _load( ) entry point routine. Calling drv_detach( ) has the side effect of sending the CFG_REMOVE and possibly the CFG_SUSPEND subfunctions to the driver so it is important that global resources are freed afer returning from drv_detach( ).

The driver then calls the samp_free_globals( ) subordinate driver routine that frees the bcb(D4) and physreq(D4) structures that were allocated in the _load( ) entry point routine. Per-instance and per-channel data have been freed by the samp_close( ) entry point routine and the CFG_REMOVE subfunction to the config( ) entry point routine.

Note that this entry point routine is coded to return 0 for success. It does not do any error checking, but it could verify that the resources were freed and, if not, issue an error code from those listed on the errnos(D5) manual page to indicate that the module was not unloaded.


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