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

_load(D2)


_load -- initialize a loadable driver

Synopsis

   #include <sys/ddi.h>
   

int _load(void);

Description

The driver's _load( ) entry point routine is called to perform any driver-specific setup and initialization needed to dynamically load the driver into a running system.


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

Arguments

None

Return values

The _load( ) routine should return 0 for success, or the appropriate error number from those listed in errnos(D5).

Usage

This entry point is required for all drivers. It is called before any other entry point when the driver is dynamically loaded into the kernel.

The _load( ) routine must call the drv_attach(D3) function to register the driver and its entry point routines with the kernel. It may also perform activities such as allocating memory for private data and initializing driver data structures that are required for the driver itself throughout its execution. Any resources that are allocated per device rather than per driver should not be allocated in the _load( ) routine, but should instead be allocated in the CFG_ADD subfunction to the config(D2) entry point routine, which is called by the drv_attach(D3) function.

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.

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 _load( ) entry point routine is optional and, even when provided, is called only if the driver is dynamically loaded. The init(D2) and/or start(D2) entry point routines are called if the driver is statically configured into the kernel.

The drv_attach(D3) function and config(D2) entry point routine are not available to drivers written for DDI versions prior to version 8. Consequently, _load( ) must perform any global driver-specific and device-specific initialization.

sys/moddefs.h provides a set of macros that are used to generate wrappers for loadable modules. The macros are of the form:

   type(prefix, load, unload, halt, verify, desc);
where

type
is the type of wrapper macro. Valid types are:

MOD_DRV_WRAPPER
Generates wrappers for device drivers.

MOD_ACDRV_WRAPPER
Generates wrappers for autoconfigurable device drivers.

MOD_HDRV_WRAPPER
Generates wrappers for Host Bus Adapter drivers.

MOD_ACHDRV_WRAPPER
Generates wrappers for autoconfigurable drivers that do not require switch table entries but do need to attach and detach interrupts, such as the Host Bus Adapter (HBA) drivers.

MOD_STR_WRAPPER
Generates wrappers for STREAMS modules.

MOD_MISC_WRAPPER
Generates wrappers for miscellaneous modules.


NOTE:


prefix
Specifies the module's prefix as defined in the driver's Master(DSP/4dsp) file and described on the prefix(D1) manual page.

load
Specifies the name of the module's _load(D2) routine.

unload
Specifies the name of the module's _unload(D2) routine.

halt
This optional keyword specifies the name of the module's halt(D2) routine, if any.

desc
Supplies a character string that identifies the module.
See ``WRAPPER macros for pre-DDI 8 drivers'' in Developing DDI kernel drivers for examples of module wrappers.

The drv_attach(D3) function and config(D2) entry point routine are not used in DDI versions prior to version 8, so _load( ) must contain all per-device initialization for these earlier driver versions.

References

config(D2), drv_attach(D3) _unload(D2),

halt(D2), init(D2), start(D2), mod_drvattach(D3)

_load(D2mdi), _load(D2sdi), _load(D2str)

``Dynamically-loadable kernel modules (DLKM)'' in HDK Technical Reference
``Driver structure'' in Developing device drivers

Examples

See ``DDI: 8 sample driver'' in HDK code samples for a sample DDI 8 _load( ) routine.
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005