Specifications

Loadable Modules
13-
7
NOTE
A DLM can contain only one wrapper macro definition.
Note that only MOD_DRV_WRAPPER and MOD_HDRV_WRAPPER module types have the
halt argument; all other wrappers have only the remaining four arguments, prefix, load,
unload, and description. For non-driver modules, the keyword halt is omitted from the
wrapper macro coding.
The keyword prefix specifies the driver's prefix, as defined in the driver's Master(4) file,
and described on the prefix(D1) manual page. The keywords load, unload and halt
specify the names of the driver's _load routine, _unload routine, and (if the driver has
one) its halt routine.
The keyword description supplies a character string used to identify the driver.
Sample Wrapper Code 13
The following coding examples show some typical wrappers for the different loadable
module types. Note that all loadable modules must include <sys/moddefs.h> in their
wrapper definitions.
Screen 13-1 shows a sample wrapper for a device driver.
Screen 13-1. Device Driver Wrapper Coding Example
#include <sys/moddefs.h>
#define DRVNAME “hps - High Performance Serial Driver”
STATIC int hps_load(), hps_unload();
MOD_DRV_WRAPPER(hps, hps_load, hps_unload, NULL, DRVNAME);
STATIC int
hps_load()
{
int status;
hpsinit();
status = mod_drvattach(&hps_attach_info);
if (status == -1)
return (EBUSY);
hpsstart();
return(0);
}
STATIC int
hps_unload()
{
mod_drvdetach(&hps_attach_info);
.
.
.
return(0);
}