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.Os 18.Dt SYSINIT 9 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 27is a mechanism used in the initialization of kernel subsystems. 28The function 29.Fa func 30is called with the argument 31.Fa ident 32either when the kernel is booted or when a module is loaded, depending on where 33the invocation is found. 34.Pp 35The 36.Fa subsystem 37and 38.Fa order 39parameters control when the function is called during initialization. 40The kernel 41calls all of the functions in a subsystem before advancing to the next one. 42.Pp 43Most 44.Nm 45invocations 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 49Device driver initialization 50.It Dv SI_SUB_VFS 51Virtual file system, vnodes, vnode recovery, namecache 52.It Dv SI_SUB_HELPER_THREADS 53Helper threads (used by random number generator) 54.It DV SI_SUB_KTHREAD_VM 55VM daemon initialization 56.It Dv SI_SUB_KTHREAD_IDLE 57Idle-time kernel threads 58.El 59.Pp 60These subsystems are initialized in the order they are listed. 61For the complete list of subsystems, consult 62.In sys/kernel.h . 63.Pp 64The 65.Fa order 66parameter controls when in a subsystem a function is called. 67The 68.Dv SI_ORDER_FIRST 69parameter marks a function to be called first in subsystem. 70The 71.Dv SI_ORDER_SECOND 72and 73.Dv SI_ORDER_THIRD 74flags mark a function to be called second and third, respectively. 75The 76.Dv SI_ORDER_MIDDLE 77flag marks a function to be called somewhere in the middle of a 78subsystem's initialization. 79The 80.Dv SI_ORDER_ANY 81flag marks a function to be called after all other types of functions. 82.Pp 83The 84.Fa uniquifier 85parameter is a unique identifier for this 86.Nm 87invocation. 88.Sh EXAMPLES 89This example calls the function 90.Fn rand_thread_init 91with a 92.Dv NULL 93argument at any point while initializing helper threads: 94.Bd -literal 95SYSINIT(rand, SI_SUB_HELPER_THREADS, SI_ORDER_ANY, rand_thread_init, NULL); 96.Ed 97