|
NAMESYSINIT , SYSUNINIT —
a framework for dynamic kernel initialization
SYNOPSIS#include <sys/param.h>
#include <sys/kernel.h>
DESCRIPTIONSYSINIT is a mechanism for scheduling the execution of
initialization and teardown routines. This is similar to init and fini
routines with the addition of explicit ordering metadata. It allows runtime
ordering of subsystem initialization in the kernel as well as kernel modules
(KLDs).
The struct sysinit { enum sysinit_sub_id subsystem; /* subsystem identifier*/ enum sysinit_elem_order order; /* init order within subsystem*/ sysinit_cfunc_t func; /* function */ const void *udata; /* multiplexer/argument */ }; The The The startup linker set for the kernel is scanned during boot to build a sorted list of initialization routines. The initialization routines are then executed in the sorted order. The subsystem is used as the primary key and is sorted in ascending order. The order is used as the secondary key and is sorted in ascending order. The relative order of two routines that have the same subsystem and order is undefined. The startup linker sets for modules that are loaded together with
the kernel by the boot loader are scanned during the
The startup linker set for a kernel module loaded at runtime via kldload(2) is scanned, sorted, and executed when the module is loaded. The shutdown linker set for a kernel module is scanned, sorted, and executed when a kernel module is unloaded. The teardown routines are sorted in the reverse order of the initialization routines. The teardown routines of the kernel and any loaded modules are not executed during shutdown. EXAMPLESThis example shows the SYSINIT which displays the copyright notice during boot:static void print_caddr_t(void *data) { printf("%s", (char *)data); } SYSINIT(announce, SI_SUB_COPYRIGHT, SI_ORDER_FIRST, print_caddr_t, copyright); SEE ALSOkld(4), DECLARE_MODULE(9), DEV_MODULE(9), DRIVER_MODULE(9), MTX_SYSINIT(9), SYSCALL_MODULE(9)HISTORYTheSYSINIT framework first appeared in
FreeBSD 2.2.
AUTHORSTheSYSINIT framework was written by
Terrence Lambert
<terry@FreeBSD.org>.
This manual page was written by Hiten Pandya <hmp@FreeBSD.org>.
Visit the GSP FreeBSD Man Page Interface. |