- bug fixes to code examples

- standardize on SYSINIT for name
	- markup fixes ">" to ">" for code examples (#include file names)

PR:		docs/57568
Approved:	blackend (mentor)
Reviewed:	jhb
This commit is contained in:
Ken Smith 2003-10-23 18:59:35 +00:00
parent 5751e78660
commit 1a145e51b3
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=18553

View file

@ -5,11 +5,11 @@
-->
<chapter id="sysinit">
<title>The Sysinit Framework</title>
<title>The SYSINIT Framework</title>
<para>Sysinit is the framework for a generic call sort and dispatch
<para>SYSINIT is the framework for a generic call sort and dispatch
mechanism. FreeBSD currently uses it for the dynamic
initialization of the kernel. Sysinit allows FreeBSD's kernel
initialization of the kernel. SYSINIT allows FreeBSD's kernel
subsystems to be reordered, and added, removed, and replaced at
kernel link time when the kernel or one of its modules is loaded
without having to edit a statically ordered initialization routing
@ -37,34 +37,34 @@
</sect1>
<sect1 id="sysinit-operation">
<title>Sysinit Operation</title>
<title>SYSINIT Operation</title>
<para>Sysinit relies on the ability of the linker to take static
<para>SYSINIT relies on the ability of the linker to take static
data declared at multiple locations throughout a program's
source and group it together as a single contiguous chunk of
data. This linker technique is called a <quote>linker
set</quote>. Sysinit uses two linker sets to maintain two data
set</quote>. SYSINIT uses two linker sets to maintain two data
sets containing each consumer's call order, function, and a
pointer to the data to pass to that function.</para>
<para>Sysinit uses two priorities when ordering the functions for
<para>SYSINIT uses two priorities when ordering the functions for
execution. The first priority is a subsystem ID giving an
overall order Sysinit's dispatch of functions. Current predeclared
ID's are in <filename>&lt;sys/kernel.h></filename> in the enum
overall order SYSINIT's dispatch of functions. Current predeclared
ID's are in <filename>&lt;sys/kernel.h&gt;</filename> in the enum
list <literal>sysinit_sub_id</literal>. The second priority used
is an element order within the subsystem. Current predeclared
subsystem element orders are in
<filename>&lt;sys/kernel.h></filename> in the enum list
<filename>&lt;sys/kernel.h&gt;</filename> in the enum list
<literal>sysinit_elem_order</literal>.</para>
<para>There are currently two uses for Sysinit. Function dispatch
<para>There are currently two uses for SYSINIT. Function dispatch
at system startup and kernel module loads, and function dispatch
at system shutdown and kernel module unload.</para>
</sect1>
<sect1 id="sysinit-using">
<title>Using Sysinit</title>
<title>Using SYSINIT</title>
<sect2>
<title>Interface</title>
@ -72,7 +72,7 @@
<sect3>
<title>Headers</title>
<programlisting>&lt;sys/kernel.h></programlisting>
<programlisting>&lt;sys/kernel.h&gt;</programlisting>
</sect3>
<sect3>
@ -87,24 +87,25 @@
<title>Startup</title>
<para>The <literal>SYSINIT()</literal> macro creates the
necessary sysinit data in Sysinit's startup data set for
Sysinit to sort and dispatch a function at system startup and
necessary SYSINIT data in SYSINIT's startup data set for
SYSINIT to sort and dispatch a function at system startup and
module load. <literal>SYSINIT()</literal> takes a uniquifier
that Sysinit uses identify the particular function dispatch
that SYSINIT uses identify the particular function dispatch
data, the subsystem order, the subsystem element order, the
function to call, and the data to pass the function. All
functions must take a constant pointer argument.
</para>
<para>For example:</para>
<example>
<title>Example of a <literal>SYSINIT()</literal></title>
<programlisting>#include &lt;sys/kernel.h>
<programlisting>#include &lt;sys/kernel.h&gt;
void foo_null(void *unused)
{
foo_doo();
}
SYSINIT(foo_null, SI_SUB_FOO, SI_ORDER_FOO, NULL);
SYSINIT(foo, SI_SUB_FOO, SI_ORDER_FOO, foo_null, NULL);
struct foo foo_voodoo = {
FOO_VOODOO;
@ -115,8 +116,9 @@ void foo_arg(void *vdata)
struct foo *foo = (struct foo *)vdata;
foo_data(foo);
}
SYSINIT(foo_arg, SI_SUB_FOO, SI_ORDER_FOO, foo_voodoo);
SYSINIT(bar, SI_SUB_FOO, SI_ORDER_FOO, foo_arg, foo_voodoo);
</programlisting>
</example>
</sect2>
<sect2>
@ -124,17 +126,18 @@ SYSINIT(foo_arg, SI_SUB_FOO, SI_ORDER_FOO, foo_voodoo);
<para>The <literal>SYSUNINIT()</literal> macro behaves similarly
to the <literal>SYSINIT()</literal> macro except that it adds
the Sysinit data to Sysinit's shutdown data set.</para>
the SYSINIT data to SYSINIT's shutdown data set.</para>
<para>For example:</para>
<example>
<title>Example of a <literal>SYSUNINIT()</literal></title>
<programlisting>#include &lt;sys/kernel.h>
<programlisting>#include &lt;sys/kernel.h&gt;
void foo_cleanup(void *unused)
{
foo_kill();
}
SYSUNINIT(foo_cleanup, SI_SUB_FOO, SI_ORDER_FOO, NULL);
SYSUNINIT(foobar, SI_SUB_FOO, SI_ORDER_FOO, foo_cleanup, NULL);
struct foo_stack foo_stack = {
FOO_STACK_VOODOO;
@ -143,8 +146,9 @@ struct foo_stack foo_stack = {
void foo_flush(void *vdata)
{
}
SYSUNINIT(foo_flush, SI_SUB_FOO, SI_ORDER_FOO, foo_stack);
SYSUNINIT(barfoo, SI_SUB_FOO, SI_ORDER_FOO, foo_flush, foo_stack);
</programlisting>
</example>
</sect2>
</sect1>
</chapter>