Managing and Developing Dynamically Loadable Kernel Modules

Managing and Developing Dynamically Loadable Kernel Modules
Developing Dynamically Loadable Kernel Modules
Chapter 12530
The source code for a DLKM module contains two additional sections
of code, one for the module’s wrapper and one for the module’s
_load() and _unload() functions (routines).
Module Wrapper The source code for a DLKM module must contain a
wrapper, defined by the modwrapper structure, specifying the _load()
and _unload() function entry points and other data structures used by
the module. The name of the modwrapper structure for a DLKM module
must be
module_name
_wrapper.
The wrapper data structures are partially initialized by the DLKM
infrastructure using values taken from the module’s configuration files.
These structures provide information needed during loading and
unloading, such as the values needed to populate a loadable driver’s
device switch table entries for the major device number it supports.
The code definition of the modwrapper structure is defined in header file
moddefs.h and shown below. The data structures and #define
statement preceding the modwrapper structure are also defined in
moddefs.h. The modwrapper structure contains a pointer to the modlink
structure, and the modlink structure contains pointers to the
mod_operations and mod_type data structures. The #define
statement indicates the revision (version) number of the modwrapper
structure, which is 1.0 for HP-UX 11.0.
NOTE The modwrapper revision numbers will be used to maintain backward/
forward compatibility of DLKM modules within the DLKM
infrastructure.
Example 12-1 An Extract from moddefs.h File Showing modwrapper Structure
#define MODREV 10
struct modlink {
struct mod_operations *ml_ops;
void *ml_type_data;
};
/*
* Module type specific linkage structure.
*/