Improvements to wording, grammar, and markup.
This commit is contained in:
parent
fffcd29dff
commit
da5cba2978
|
@ -1,4 +1,4 @@
|
||||||
.\" $NetBSD: module.9,v 1.5 2010/07/31 13:27:29 pgoyette Exp $
|
.\" $NetBSD: module.9,v 1.6 2010/08/04 05:51:20 jruoho Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
|
.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd August 1, 2010
|
.Dd August 4, 2010
|
||||||
.Dt MODULE 9
|
.Dt MODULE 9
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -56,20 +56,25 @@
|
||||||
.Ft void
|
.Ft void
|
||||||
.Fn module_rele "const char *"
|
.Fn module_rele "const char *"
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
Modules are sections of code that can be independantly linked and selectively
|
Modules are sections of code that can be independently linked and selectively
|
||||||
loaded into or unloaded from a running kernel.
|
loaded into or unloaded from a running kernel.
|
||||||
This provides a mechanism to update the module without having to relink
|
This provides a mechanism to update the module without having to relink
|
||||||
the kernel and reboot.
|
the kernel and reboot.
|
||||||
Modules can be loaded from within the kernel image, provided by the boot
|
Modules can be loaded from within the kernel image, provided by the boot
|
||||||
loader, or loaded from the file system.
|
loader, or loaded from the file system.
|
||||||
.Pp
|
.Pp
|
||||||
|
Two data types are relevant for
|
||||||
|
.Nm :
|
||||||
|
.Bl -enum -offset indent
|
||||||
|
.It
|
||||||
The
|
The
|
||||||
.Vt module_t
|
.Vt module_t
|
||||||
type provides storage to describe a module.
|
type provides storage to describe a module.
|
||||||
.Pp
|
.It
|
||||||
The
|
The
|
||||||
.Vt modinfo_t
|
.Vt modinfo_t
|
||||||
type resides within the module itself, and contains module header info.
|
type resides within the module itself, and contains module header info.
|
||||||
|
.El
|
||||||
.Sh FUNCTIONS
|
.Sh FUNCTIONS
|
||||||
.Bl -tag -width abcd
|
.Bl -tag -width abcd
|
||||||
.It Fn MODULE "class" "name" "required"
|
.It Fn MODULE "class" "name" "required"
|
||||||
|
@ -83,8 +88,8 @@ In addition to the explicit arguments, the
|
||||||
macro creates a reference to the module's
|
macro creates a reference to the module's
|
||||||
.Fn modcmd
|
.Fn modcmd
|
||||||
function.
|
function.
|
||||||
This function is defined as
|
This function is defined as:
|
||||||
.Bl -tag -width abcd
|
.Bl -tag -width modcmd -offset indent
|
||||||
.It Ft int
|
.It Ft int
|
||||||
.Fn modcmd "modcmd_t cmd" "void *data"
|
.Fn modcmd "modcmd_t cmd" "void *data"
|
||||||
.El
|
.El
|
||||||
|
@ -92,15 +97,15 @@ This function is defined as
|
||||||
The
|
The
|
||||||
.Fa cmd
|
.Fa cmd
|
||||||
argument requests one of the following operations:
|
argument requests one of the following operations:
|
||||||
.Bl -tag -width abcd
|
.Bl -tag -width MODULE_CMD_AUTOUNLOAD -offset indent
|
||||||
.It MODULE_CMD_INIT perform module-specific initialization when the \
|
.It Dv MODULE_CMD_INIT
|
||||||
module is loaded
|
Perform module-specific initialization when the module is loaded.
|
||||||
.It MODULE_CMD_FINI perform module-specific clean-up before the module \
|
.It Dv MODULE_CMD_FINI
|
||||||
is unloaded
|
Perform module-specific clean-up before the module is unloaded.
|
||||||
.It MODULE_CMD_AUTOUNLOAD notify the module that it is about to be \
|
.It Dv MODULE_CMD_AUTOUNLOAD
|
||||||
unloaded
|
Notify the module that it is about to be unloaded.
|
||||||
.It MODULE_CMD_STAT request the module to provide status information \
|
.It Dv MODULE_CMD_STAT
|
||||||
(not currently implemented)
|
Request the module to provide status information (not currently implemented).
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
All modules'
|
All modules'
|
||||||
|
@ -109,18 +114,23 @@ functions must implement the
|
||||||
.Dv MODULE_CMD_INIT
|
.Dv MODULE_CMD_INIT
|
||||||
and
|
and
|
||||||
.Dv MODULE_CMD_FINI
|
.Dv MODULE_CMD_FINI
|
||||||
commands; the other commands are optional, and should return ENOTTY if
|
commands.
|
||||||
not implemented.
|
The other commands are optional,
|
||||||
The
|
and should return
|
||||||
|
.Er ENOTTY
|
||||||
|
if not implemented.
|
||||||
|
The return values from
|
||||||
.Fn modcmd
|
.Fn modcmd
|
||||||
function's return value is ignored for
|
are ignored for
|
||||||
.Dv MODULE_CMD_FINI .
|
.Dv MODULE_CMD_FINI .
|
||||||
.Pp
|
.Pp
|
||||||
For the
|
For the
|
||||||
.Dv MODULE_CMD_INIT
|
.Dv MODULE_CMD_INIT
|
||||||
command, the
|
command, the
|
||||||
.Fa data
|
.Fa data
|
||||||
argument is used to pass the module's props dictionary; for the
|
argument is used to pass the module's
|
||||||
|
.Xr prop_dictionary 3 .
|
||||||
|
For the
|
||||||
.Dv MODULE_CMD_STAT
|
.Dv MODULE_CMD_STAT
|
||||||
command, the
|
command, the
|
||||||
.Fa data
|
.Fa data
|
||||||
|
@ -130,9 +140,8 @@ The __link_set mechanism is used to enable the
|
||||||
.Nm
|
.Nm
|
||||||
subsystem to locate the structure.
|
subsystem to locate the structure.
|
||||||
.It Fn module_load "name" "flags" "props" "class"
|
.It Fn module_load "name" "flags" "props" "class"
|
||||||
.Pp
|
|
||||||
Load a module, link it into the running kernel, and call the module's
|
Load a module, link it into the running kernel, and call the module's
|
||||||
.Fn modcmd
|
.Fn modcmd
|
||||||
routine with a
|
routine with a
|
||||||
.Fa cmd
|
.Fa cmd
|
||||||
argument of
|
argument of
|
||||||
|
@ -158,10 +167,14 @@ module within the file system.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fa flags
|
.Fa flags
|
||||||
argument can include
|
argument can include:
|
||||||
.Bl -tag -width abcd
|
.Bl -tag -width MODCTL_LOAD_FORCE -offset indent
|
||||||
.It MODCTL_NO_PROP
|
.It Dv MODCTL_NO_PROP
|
||||||
.It MODCTL_LOAD_FORCE force loading of disabled built-in modules
|
.\"
|
||||||
|
.\" XXX: Document this.
|
||||||
|
.\"
|
||||||
|
.It Dv MODCTL_LOAD_FORCE
|
||||||
|
Force loading of disabled built-in modules.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
|
@ -173,18 +186,25 @@ routine.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fa class
|
.Fa class
|
||||||
argument can be any of
|
argument can be any of:
|
||||||
.Dv MODULE_CLASS_ANY ,
|
.Pp
|
||||||
.Dv MODULE_CLASS_MISC ,
|
.\"
|
||||||
.Dv MODULE_CLASS_VFS ,
|
.\" XXX: Document these.
|
||||||
.Dv MODULE_CLASS_DRIVER ,
|
.\"
|
||||||
.Dv MODULE_CLASS_EXEC ,
|
.Bl -tag -width MODCTL_LOAD_FORCE -offset indent -compact
|
||||||
or
|
.It Dv MODULE_CLASS_ANY
|
||||||
.Dv MODULE_CLASS_SECMODEL .
|
.It Dv MODULE_CLASS_MISC
|
||||||
|
.It Dv MODULE_CLASS_VFS
|
||||||
|
.It Dv MODULE_CLASS_DRIVER
|
||||||
|
.It Dv MODULE_CLASS_EXEC
|
||||||
|
.It Dv MODULE_CLASS_SECMODEL
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
If the class is not
|
If the class is not
|
||||||
.Dv MODULE_CLASS_ANY ,
|
.Dv MODULE_CLASS_ANY ,
|
||||||
the class of the module being loaded
|
the class of the module being loaded
|
||||||
must match the requested class.
|
must match the requested
|
||||||
|
.Fa class .
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn module_load
|
.Fn module_load
|
||||||
|
@ -208,21 +228,22 @@ unload modules a short time (currently, 10 seconds) after being loaded by
|
||||||
.Fn module_autoload .
|
.Fn module_autoload .
|
||||||
Before the module is unloaded, its
|
Before the module is unloaded, its
|
||||||
.Fn modcmd
|
.Fn modcmd
|
||||||
is called with a
|
is called with the
|
||||||
.Fa cmd
|
.Fa cmd
|
||||||
argument of
|
argument specified as
|
||||||
.Dv MODULE_CMD_AUTOUNLOAD .
|
.Dv MODULE_CMD_AUTOUNLOAD .
|
||||||
A module can prevent itself from being unloaded by returning a non-zero
|
A module can prevent itself from being unloaded by returning a non-zero
|
||||||
value.
|
value.
|
||||||
.Pp
|
.Pp
|
||||||
|
The
|
||||||
.Fn module_autoload
|
.Fn module_autoload
|
||||||
is intended for use by kernel components to locate and load optional
|
function is intended for use by kernel components to locate and load optional
|
||||||
system components.
|
system components.
|
||||||
.Fn module_autoload
|
The function is also used to load modules that are required by other modules.
|
||||||
is also used to load modules that are required by other modules.
|
|
||||||
.It Fn module_unload "name"
|
.It Fn module_unload "name"
|
||||||
Unload a module.
|
Unload a module.
|
||||||
If the module's reference count is non-zero, returns EBUSY.
|
If the module's reference count is non-zero, the function returns
|
||||||
|
.Er EBUSY .
|
||||||
Otherwise, the module's
|
Otherwise, the module's
|
||||||
.Fn modcmd
|
.Fn modcmd
|
||||||
routine is called with a
|
routine is called with a
|
||||||
|
@ -230,14 +251,14 @@ routine is called with a
|
||||||
argument of
|
argument of
|
||||||
.Dv MODULE_CMD_FINI ,
|
.Dv MODULE_CMD_FINI ,
|
||||||
and the module is unloaded.
|
and the module is unloaded.
|
||||||
The reference counts of all modules that were required by this module are
|
|
||||||
decremented, however the required modules are not unloaded by this call to
|
|
||||||
.Fn module_unload .
|
|
||||||
(They may be unloaded by subsequent calls to
|
|
||||||
.Fn module_unload
|
|
||||||
.)
|
|
||||||
.Pp
|
.Pp
|
||||||
Unloading a built-in module causes that module to be marked disabled.
|
The reference counts of all modules that were required by this module are
|
||||||
|
decremented, but the required modules are not unloaded by the call to
|
||||||
|
.Fn module_unload .
|
||||||
|
Instead, the required modules may be unloaded by subsequent calls to
|
||||||
|
.Fn module_unload .
|
||||||
|
.Pp
|
||||||
|
Unloading a built-in module causes the module to be marked as disabled.
|
||||||
This prevents the module from being re-loaded, except by the
|
This prevents the module from being re-loaded, except by the
|
||||||
.Fn module_load
|
.Fn module_load
|
||||||
function with the
|
function with the
|
||||||
|
@ -245,8 +266,9 @@ function with the
|
||||||
argument set to
|
argument set to
|
||||||
.Dv MODULE_FORCE_LOAD .
|
.Dv MODULE_FORCE_LOAD .
|
||||||
.Pp
|
.Pp
|
||||||
|
The
|
||||||
.Fn module_unload
|
.Fn module_unload
|
||||||
may be called by the
|
function may be called by the
|
||||||
.Xr modctl 2
|
.Xr modctl 2
|
||||||
system call, by the module subsystem's internal auto-unload thread, or by
|
system call, by the module subsystem's internal auto-unload thread, or by
|
||||||
other kernel facilities.
|
other kernel facilities.
|
||||||
|
@ -260,19 +282,20 @@ Increment the reference count of a module.
|
||||||
A module cannot be unloaded if its reference count is non-zero.
|
A module cannot be unloaded if its reference count is non-zero.
|
||||||
.It Fn module_rele "name"
|
.It Fn module_rele "name"
|
||||||
Decrement the reference count of a module.
|
Decrement the reference count of a module.
|
||||||
.Pp
|
|
||||||
.El
|
.El
|
||||||
.Sh LOCK PROTOCOL
|
.Sh LOCK PROTOCOL
|
||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
subsystem is protected with the global
|
subsystem is protected with the global
|
||||||
.Vt module_mutex .
|
.Vt module_mutex .
|
||||||
This mutex must be acquired before calling any of these routines.
|
This
|
||||||
(As an exception, the
|
.Xr mutex 9
|
||||||
|
must be acquired before calling any of these routines.
|
||||||
|
As an exception, the
|
||||||
.Fn module_load
|
.Fn module_load
|
||||||
routine acquires the mutex itself, so one does not need to acquire it
|
routine acquires the mutex itself, so one does not need to acquire it
|
||||||
before calling
|
before calling
|
||||||
.Fn module_load ).
|
.Fn module_load .
|
||||||
Loading of a module and its required modules occurs as an atomic
|
Loading of a module and its required modules occurs as an atomic
|
||||||
operation, and either completely succeeds or completely fails.
|
operation, and either completely succeeds or completely fails.
|
||||||
.Sh CODE REFERENCES
|
.Sh CODE REFERENCES
|
||||||
|
@ -283,16 +306,18 @@ All pathnames are relative to
|
||||||
.Pa /usr/src .
|
.Pa /usr/src .
|
||||||
.Pp
|
.Pp
|
||||||
The core of the kernel module implementation is in
|
The core of the kernel module implementation is in
|
||||||
.Pa sys/kern/kern_module.c
|
.Pa sys/kern/kern_module.c
|
||||||
and
|
and
|
||||||
.Pa sys/kern/kerm_module_vfs.c .
|
.Pa sys/kern/kerm_module_vfs.c .
|
||||||
.Pp
|
.Pp
|
||||||
The header file
|
The header file
|
||||||
.Pa sys/sys/module.h
|
.In sys/sys/module.h
|
||||||
describes the public interface.
|
describes the public interface.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr modctl 2
|
.Xr modctl 2
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
The kernel module subsystem first appeared in
|
The kernel module subsystem first appeared in
|
||||||
.Nx 5.0 .
|
.Nx 5.0 .
|
||||||
It replaces the lkm subsystem from earlier releases.
|
It replaces the
|
||||||
|
.Dq Tn LKM
|
||||||
|
subsystem from earlier releases.
|
||||||
|
|
Loading…
Reference in New Issue