DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Device driver overview

Initialization, configuration, and closing

The following entry point routines are used to initialize, configure, close, and analyze driver configuration in DDI 8 drivers: .


_load(D2)
This routine is called when a driver is dynamically loaded into the kernel or, for statically-configured drivers, in the final stages of system initialization. It should allocate resources (such as memory and lock structures) required for the driver throughout its execution and do other driver initialization except for hardware configuration. load( ) calls the drv_attach(D3) function to register the driver and its entry point routines with the kernel.

All DDI 8 drivers must include a _load(D2) entry point routine that is called to initialize the driver. MDI and SDI HBA drivers that use DDI 7 must also have a _load( ) entry point routine.

Drivers written for DDI versions prior to version 8 that are not dynamically loaded use the init(D2) and start(D2) entry point routines instead of _load(D2). Loadable drivers for DDI versions prior to DDI 8 do hardware configuration as well as driver initialization in their _load( ) routines. See ``Dynamically-loadable kernel modules (DLKM)''.

All SCO OpenServer 5 drivers use the init(D2oddi) and start(D2oddi) entry points for driver initialization and configuration. SCO OpenServer 5 does not support loadable drivers.


config(D2)
Configure hardware supported by the driver. The config( ) routine contains several subfunctions. The CFG_ADD subfunction is required for all drivers to create the driver instance that is used for subsequent reference to the hardware. The CFG_ADD subfunction is called once for each board, passing it the resource manager key for that board. The CFG_ADD subfunction calls the cm_intr_attach(D3) function and any other of the configuration manager or memory mapping functions (such as devmem_mapin(D3)) that require a resource manager key.

The driver's CFG_ADD subfunction must also allocate a private data structure for each supported board that contains (or references) state information for the board such as the resource manager key and the interrupt cookie. It then passes this structure back to the kernel by writing it to (*(void **)idata). All subsequent entry points have this idata value passed back into the driver so it can get at its per-board state.

PCI hotplug devices (identified by the D_HOT flag set in the drvinfo(D4) structure) must support additional subfunctions to the config( ) routine, including CFG_SUSPEND and CFG_REMOVE. See ``Hotplug devices''.

CFG_SUSPEND is called during system shutdown, and CFG_REMOVE is called when a hotplug device is removed from the system. These functions must, among other things, call the cm_intr_detach(D3) function to detach the device's interrupt vectors. CFG_REMOVE must detach interrupts conditionally (only if they have not already been detached), and then deallocate the idata.

DDI 8 ISA devices must support the CFG_VERIFY subfunction to compensate for the reduced autoconfiguration facilities for ISA devices relative to the smart-bus architectures such as PCI MCA, and EISA. See ``ISA bus autoconfiguration''.


devinfo(D2)
Used to get information about a configured device. This entry point is required for all DDI 8 drivers although it may have no functionality other than a return call.

mmap(D2)
Provides direct user access to memory for memory-mapped I/O devices.

open(D2)
Called in response to an open or mount system call, this routine prepares the device for further access. Note that, for DDI versions prior to version 8 and ODDI drivers for SCO OpenServer 5, the open(D2) and close(D2) entry point routines have a different syntax for STREAMS and non-STREAMS devices.


close(D2)
Relinquish access to a device.

_unload(D2)
Called when a driver is dynamically unloaded from a running system. Typically, the _unload( ) routine frees all resources allocated in the driver's _load( ) routine.

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