manpages: Uniformly order the prologue macros by Dd/Dt/Os.
[dragonfly.git] / share / man / man9 / SYSINIT.9
1 .\"
2 .\" Copyright (c) 2010, Venkatesh Srinivas <me@endeavour.zapto.org>
3 .\"
4 .\" Permission to use, copy, modify, or distribute this software for any
5 .\" purpose with or without fee is hereby granted, provided that the above
6 .\" copyright notice and this permission notice appear in all copies.
7 .\"
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 .\"
16 .Dd September 29, 2010
17 .Dt SYSINIT 9
18 .Os
19 .Sh NAME
20 .Nm SYSINIT
21 .Nd Subsystem initialization
22 .Sh SYNOPSIS
23 .In sys/kernel.h
24 .Fn SYSINIT "uniquifier" "subsystem" "order" "func" "ident"
25 .Sh DESCRIPTION
26 .Nm
27 is a mechanism used in the initialization of kernel subsystems.
28 The function
29 .Fa func
30 is called with the argument
31 .Fa ident
32 either when the kernel is booted or when a module is loaded, depending on where
33 the invocation is found.
34 .Pp
35 The
36 .Fa subsystem
37 and
38 .Fa order
39 parameters control when the function is called during initialization.
40 The kernel
41 calls all of the functions in a subsystem before advancing to the next one.
42 .Pp
43 Most
44 .Nm
45 invocations will use one of these identifiers for
46 .Fa subsystem :
47 .Bl -tag -width ".Dv SI_SUB_HELPER_THREADS"
48 .It Dv SI_SUB_DRIVERS
49 Device driver initialization
50 .It Dv SI_SUB_VFS
51 Virtual file system, vnodes, vnode recovery, namecache
52 .It Dv SI_SUB_HELPER_THREADS
53 Helper threads (used by random number generator)
54 .It DV SI_SUB_KTHREAD_VM
55 VM daemon initialization
56 .It Dv SI_SUB_KTHREAD_IDLE
57 Idle-time kernel threads
58 .El
59 .Pp
60 These subsystems are initialized in the order they are listed.
61 For the complete list of subsystems, consult
62 .In sys/kernel.h .
63 .Pp
64 The
65 .Fa order
66 parameter controls when in a subsystem a function is called.
67 The
68 .Dv SI_ORDER_FIRST
69 parameter marks a function to be called first in subsystem.
70 The
71 .Dv SI_ORDER_SECOND
72 and
73 .Dv SI_ORDER_THIRD
74 flags mark a function to be called second and third, respectively.
75 The
76 .Dv SI_ORDER_MIDDLE
77 flag marks a function to be called somewhere in the middle of a
78 subsystem's initialization.
79 The
80 .Dv SI_ORDER_ANY
81 flag marks a function to be called after all other types of functions.
82 .Pp
83 The
84 .Fa uniquifier
85 parameter is a unique identifier for this
86 .Nm
87 invocation.
88 .Sh EXAMPLES
89 This example calls the function
90 .Fn rand_thread_init
91 with a
92 .Dv NULL
93 argument at any point while initializing helper threads:
94 .Bd -literal
95 SYSINIT(rand, SI_SUB_HELPER_THREADS, SI_ORDER_ANY, rand_thread_init, NULL);
96 .Ed