Managing and Developing Dynamically Loadable Kernel Modules

Managing and Developing Dynamically Loadable Kernel Modules
Developing Dynamically Loadable Kernel Modules
Chapter 12 543
if ( wsio_uninstall_driver(&
module_name
_wsio_info) ) {
/* Uninstall failed! Return to a loaded, functional
* state. */
printf(ā€œ
module_name
> wsio_uninstall_driver
failed!!\nā€);
return (ENXIO);
}
/* Cancel pending timeouts, free allocated memory and
* resources, etc.
*/
if (
module_name
_debug)
printf(ā€œ
module_name
> Unloaded\nā€);
return (0);
}
NOTE The wsio_uninstall_driver() function call returns 0 on success.
However (and inconsistently), the wsio_install_driver() function
call returns 1 on success.
WSIO Interface Drivers
A WSIO interface driver requires an _attach() function for any
interface card it intends to claim. It will also require a _probe()
function if it intends to install device probes. When installing a WSIO
interface driver, the driver must register itself with WSIO and set up the
_attach() function and any device probes.
Because the timing of initialization differs between loadable and
statically linked modules, some of the steps that are handled
automatically during boot for static drivers must be explicitly performed
by the _load() function.
The primary difference in making a WSIO interface driver loadable
concerns the handling of the attach list. Historically, drivers have added
their _attach() functions to a global list, and the _attach() function
was responsible for calling the next driver's _attach() function in the
list. However, this method does not allow the driver to remove its
_attach() function from the list; thus, this approach cannot support
unloading.