NAME
SYSINIT
—
Subsystem initialization
SYNOPSIS
#include
<sys/kernel.h>
SYSINIT
(uniquifier,
subsystem,
order,
func,
ident);
DESCRIPTION
SYSINIT
is a mechanism used in the initialization of
kernel subsystems. The function func is called with the
argument ident either when the kernel is booted or when
a module is loaded, depending on where the invocation is found.
The subsystem and order parameters control when the function is called during initialization. The kernel calls all of the functions in a subsystem before advancing to the next one.
Most SYSINIT
invocations will use one of
these identifiers for subsystem:
SI_SUB_DRIVERS
- Device driver initialization
SI_SUB_VFS
- Virtual file system, vnodes, vnode recovery, namecache
SI_SUB_HELPER_THREADS
- Helper threads (used by random number generator)
- DV SI_SUB_KTHREAD_VM
- VM daemon initialization
SI_SUB_KTHREAD_IDLE
- Idle-time kernel threads
These subsystems are initialized in the order they are listed. For
the complete list of subsystems, consult
<sys/kernel.h>
.
The order parameter controls when in a
subsystem a function is called. The SI_ORDER_FIRST
parameter marks a function to be called first in subsystem. The
SI_ORDER_SECOND
and
SI_ORDER_THIRD
flags mark a function to be called
second and third, respectively. The SI_ORDER_MIDDLE
flag marks a function to be called somewhere in the middle of a subsystem's
initialization. The SI_ORDER_ANY
flag marks a
function to be called after all other types of functions.
The uniquifier parameter is a unique
identifier for this SYSINIT
invocation.
EXAMPLES
This example calls the function
rand_thread_init
() with a
NULL
argument at any point while initializing helper
threads:
SYSINIT(rand, SI_SUB_HELPER_THREADS, SI_ORDER_ANY, rand_thread_init, NULL);