Initialization, configuration, and removal routines
The process for coding driver initialization and configuration
in a DDI 8 driver can be summarized as follows.
The
_load(D2)
entry point calls the
drv_attach(D3)
function.
The kernel then calls the
config(D2)
entry point with the CFG_ADD subfunction
once for each board,
passing it the key for that board.
The driver's
config( )
entry point can then call the
cm_intr_attach(D3)
function or any other
cm_xxx( )
or
devmem_xxx( )
functions that need a key.
The CFG_ADD subfunction
must also allocate a private instance data structure
that contains or references state information for the board
(possibly including the key,
and likely including the interrupt cookie).
This is then passed to the kernel as an opaque handle
by writing it to (*(void **)idata).
All subsequent entry points have
this idata value passed back
in to the driver so it can get at its per-board state.
The following sections summarize the entry point modifications
required for initialization, configuration, and removal
when porting drivers from
earlier DDI versions or SCO OpenServer 5
to run on DDI 8:
-
Remove the
init(D2)
and
start(D2)
routines, if present, and code driver initialization in the
_load(D2)
entry point routine
and per-instance initialization for hardware drivers in the
CFG_ADD subfunction of the
config(D2)
routine.
-
The
_load(D2)
entry point routine is required for all DDI 8 drivers.
It is called when the driver
is dynamically loaded into the kernel
or, for statically-configured drivers,
during system initialization.
_load( )
does general driver initialization.
If your pre-DDI 8 driver included an optional
_load( )
routine, modify it as follows:
-
Remove the prefix from the
_load( )
call. For DDI 8 drivers, the
_load( )
entry point routine must be unprefixed.
-
Remove any ``wrapper'' macro coding from the routine.
The wrapper macros are not required for DDI 8 drivers
because all DDI 8 drivers are loadable
and their entry points are defined through structures
rather than switch tables.
-
Move any hardware-specific configuration information
to the CFG_ADD subfunction of the
config(D2)
entry point routine.
Code the following in the
_load( )
routine whether porting from an earlier DDI version:
or SCO OpenServer 5:
-
Populate a
drvinfo(D4)
structure with information about the driver,
including a pointer to the
drvops(D4)
structure that points to the driver's entry point routine.
Any entry point routines that are not used in the driver
but have entries in the drvops structure
just be set to NULL.
STREAMS drivers, including MDI drivers,
will also need to populate a
streamtab(D4str)
structure.
SDI HBA drivers
need to identify additional entry point routines
through the
hba_info(D4sdi)
structure.
See the manual pages and sample driver code
for more details.
-
Add a call to the
drv_attach(D3)
function to attach the drvinfo structure.
-
Include any driver-specific initialization
that was previously coded in the driver's
init(D2)
or
start(D2)
routine.
-
Loadable drivers should also include a
_unload(D2)
entry point routine that calls the
drv_detach(D3)
function to deregister the driver
and frees any general driver resources
that were allocated in the
_load( )
routine
such as any kernel memory and lock structures
that were allocated for the driver
rather than device instances.
-
The
config(D2)
entry point routine is required for all hardware drivers.
config( )
does per-instance initialization and deinitialization.
All drivers must include
cases for the CFG_ADD subfunction.
Hotplug-ready devices
(the D_HOT flag is set in the
drvinfo(D4)
structure),
must support additional subfunctions,
including CFG_SUSPEND and CFG_REMOVE;
see the
config(D2)
manual page for details.
-
The CFG_ADD subfunction
must attach interrupts for hardware drivers
by calling the
cm_intr_attach(D3)
function.
-
The CFG_SUSPEND and CFG_REMOVE subfunctions
should call the
untimeout(D3)
function to cancel any
itimeout(D3)
or
bufcall(D3str)
requests and call the
cm_intr_detach(D3)
function to free up interrupt resources.
It should also free all resources
that were allocated per device in the
CFG_ADD subfunction.
The CFG_REMOVE subfunction should
free resources only if the CFG_SUSPEND subfunction
has not already freed them.
-
ISA drivers must implement
the CFG_VERIFY subfunction of the
config(D2)
entry point routine
to check that the configuration parameters
are correct for this board.
This code replaces the
_verify(D2)
entry point routine used in DDI drivers
prior to version 8.
-
Replace calls to the
halt(D2)
entry point routine with calls to
the CFG_SUSPEND subfunction of the
config(D2)
entry point routine.
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005