SYSINIT() fixes for Architecture Manual
John Baldwin
jhb at FreeBSD.org
Tue Oct 14 21:38:23 UTC 2003
On 14-Oct-2003 Ken Smith wrote:
>
> Murray suggested I just send this here, and he'd chime in if nobody
> else feels like enough of an authority to say whether or not I'm
> lying. :-)
>
> While working on PR docs/57568 to fix the SYSINIT() examples I
> decided to try and clarify a little bit what SYSINIT() is/isn't
> used for. Can anyone say one way or another if I hit the target?
>
> Thanks.
>
> [ snip ]
>
> 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,26 +126,34 @@
> struct foo *foo = (struct foo *)vdata;
> foo_data(foo);
> }
> -SYSINIT(foo_arg, SI_SUB_FOO, SI_ORDER_FOO, foo_voodoo);
> - </programlisting>
> +SYSINIT(foo, SI_SUB_FOO, SI_ORDER_FOO, foo_arg, foo_voodoo);
> + </programlisting>
> + </example>
> +
> + <para>Note that <literal>SI_SUB_FOO</literal> and
> + <literal>SI_ORDER_FOO</literal> need to be in the
> + <literal>sysinit_sub_id</literal> and
> + <literal>sysinit_elem_order</literal> enum's as mentioned above.
> + Either use existing ones or add your own to the enum's.</para>
> </sect2>
You should make sure both SYSINITs have uniqe uniqifiers, maybe
use 'bar' instead of 'foo' for the second example. Also, you might
want to note that you can do math on the SYSINITs. For example,
you can do something like this:
static void
mptable_register(void *dummy __unused)
{
apic_register_enumerator(&mptable_enumerator);
}
SYSINIT(mptable_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST,
mptable_register, NULL)
Also, using 'Sysinit' seems really odd. I would either go with
'sysinit', 'SYSINIT', or 'system initialization function'.
> <sect2>
> <title>Shutdown</title>
>
> - <para>The <literal>SYSUNINIT()</literal> macro behaves similarly
> + <para>The <literal>SYSUNINIT()</literal> macro behaves similar
> to the <literal>SYSINIT()</literal> macro except that it adds
> the Sysinit data to Sysinit's shutdown data set.</para>
similar is an adjective, not an adverb. You are describing how it
behaves, so it should be the adverb form: similarly. Even if it is
a mouthful to say. :)
> @@ -143,8 +162,9 @@
> void foo_flush(void *vdata)
> {
> }
> -SYSUNINIT(foo_flush, SI_SUB_FOO, SI_ORDER_FOO, foo_stack);
> - </programlisting>
> +SYSUNINIT(foo, SI_SUB_FOO, SI_ORDER_FOO, foo_flush, foo_stack);
> + </programlisting>
> + </example>
> </sect2>
> </sect1>
> </chapter>
Again, make sure you have uniqe uniqifiers in this example as
well.
--
John Baldwin <jhb at FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!" - http://www.FreeBSD.org/
More information about the freebsd-doc
mailing list