Managing and Developing Dynamically Loadable Kernel Modules
Managing and Developing Dynamically Loadable Kernel Modules
Developing Dynamically Loadable Kernel Modules
Chapter 12540
Therefore, the module's _load() function should perform both the
installation tasks (those normally done during install for static modules)
and the driver initialization tasks, and the dev_init chain should be
ignored.
Additionally, the _load() function is passed a pointer to an updated
version of the drv_info_t structure; the driver must use this version of
the drv_info structure when it registers itself with WSIO. A sample
_load() function for a WSIO class driver is as follows:
Example 12-3 WSIO Class Driver _load Function
static wsio_drv_info_t
module_name
_wsio_info = { ... };
/*
* LOAD
*/
static int
module_name
_load(void *arg)
{
if (
module_name
_debug)
printf(ā
module_name
> Loading\nā);
/* Use drv_info passed to us instead of static version */
module_name
_wsio_info.drv_info = (drv_info_t *) arg;
/* Register with WSIO */
if (!wsio_install_driver(&
module_name
_wsio_info))
{
printf(ā
module_name
> wsio_install_driver failed!!\nā);
return (ENXIO);
}
/* Perform driver-specific initialization, but do not call
* next function in the dev_init list.
*/
(void)
module_name
_init();
return (0);
}