# SOME DESCRIPTIVE TITLE # Copyright (C) YEAR The FreeBSD Project # This file is distributed under the same license as the FreeBSD Documentation package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: FreeBSD Documentation VERSION\n" "POT-Creation-Date: 2025-05-01 19:56-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: Title = #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:1 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:14 #, no-wrap msgid "The SYSINIT Framework" msgstr "" #. type: YAML Front Matter: title #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:1 #, no-wrap msgid "Chapter 5. The SYSINIT Framework" msgstr "" #. type: Plain text #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:52 msgid "" "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 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 and recompile the kernel. This system also allows kernel modules, " "currently called _KLD's_, to be separately compiled, linked, and initialized " "at boot time and loaded even later while the system is already running. This " "is accomplished using the \"kernel linker\" and \"linker sets\"." msgstr "" #. type: Title == #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:54 #, no-wrap msgid "Terminology" msgstr "" #. type: Labeled list #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:56 #, no-wrap msgid "Linker Set" msgstr "" #. type: Plain text #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:58 msgid "" "A linker technique in which the linker gathers statically declared data " "throughout a program's source files into a single contiguously addressable " "unit of data." msgstr "" #. type: Title == #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:60 #, no-wrap msgid "SYSINIT Operation" msgstr "" #. type: Plain text #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:63 msgid "" "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 \"linker " "set\". 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." msgstr "" #. type: Plain text #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:65 msgid "" "SYSINIT uses two priorities when ordering the functions for execution. The " "first priority is a subsystem ID giving an overall order for SYSINIT's " "dispatch of functions. Current predeclared ID's are in [.filename]## in the enum list `sysinit_sub_id`. The second priority used is an " "element order within the subsystem. Current predeclared subsystem element " "orders are in [.filename]## in the enum list " "`sysinit_elem_order`." msgstr "" #. type: Plain text #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:67 msgid "" "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. Kernel subsystems often use system startup " "SYSINIT's to initialize data structures, for example the process scheduling " "subsystem uses a SYSINIT to initialize the run queue data structure. Device " "drivers should avoid using `SYSINIT()` directly. Instead drivers for real " "devices that are part of a bus structure should use `DRIVER_MODULE()` to " "provide a function that detects the device and, if it is present, " "initializes the device. It will do a few things specific to devices and then " "call `SYSINIT()` itself. For pseudo-devices, which are not part of a bus " "structure, use `DEV_MODULE()`." msgstr "" #. type: Title == #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:69 #, no-wrap msgid "Using SYSINIT" msgstr "" #. type: Title === #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:71 #, no-wrap msgid "Interface" msgstr "" #. type: Title ==== #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:73 #, no-wrap msgid "Headers" msgstr "" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:78 #, no-wrap msgid "\n" msgstr "" #. type: Title ==== #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:80 #, no-wrap msgid "Macros" msgstr "" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:86 #, no-wrap msgid "" "SYSINIT(uniquifier, subsystem, order, func, ident)\n" "SYSUNINIT(uniquifier, subsystem, order, func, ident)\n" msgstr "" #. type: Title === #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:88 #, no-wrap msgid "Startup" msgstr "" #. type: Plain text #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:91 msgid "" "The `SYSINIT()` macro creates the necessary SYSINIT data in SYSINIT's " "startup data set for SYSINIT to sort and dispatch a function at system " "startup and module load. `SYSINIT()` takes a uniquifier that SYSINIT uses to " "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." msgstr "" #. type: Block title #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:92 #, no-wrap msgid "Example of a `SYSINIT()`" msgstr "" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:98 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:148 #, no-wrap msgid "#include \n" msgstr "" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:104 #, no-wrap msgid "" "void foo_null(void *unused)\n" "{\n" " foo_doo();\n" "}\n" "SYSINIT(foo, SI_SUB_FOO, SI_ORDER_FOO, foo_null, NULL);\n" msgstr "" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:108 #, no-wrap msgid "" "struct foo foo_voodoo = {\n" " FOO_VOODOO;\n" "}\n" msgstr "" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:115 #, no-wrap msgid "" "void foo_arg(void *vdata)\n" "{\n" " struct foo *foo = (struct foo *)vdata;\n" " foo_data(foo);\n" "}\n" "SYSINIT(bar, SI_SUB_FOO, SI_ORDER_FOO, foo_arg, &foo_voodoo);\n" msgstr "" #. type: delimited block = 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:119 msgid "" "Note that `SI_SUB_FOO` and `SI_ORDER_FOO` need to be in the `sysinit_sub_id` " "and `sysinit_elem_order` enum's as mentioned above. Either use existing ones " "or add your own to the enum's. You can also use math for fine-tuning the " "order a SYSINIT will run in. This example shows a SYSINIT that needs to be " "run just barely before the SYSINIT's that handle tuning kernel parameters." msgstr "" #. type: Block title #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:120 #, no-wrap msgid "Example of Adjusting `SYSINIT()` Order" msgstr "" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:128 #, no-wrap msgid "" "static void\n" "mptable_register(void *dummy __unused)\n" "{\n" msgstr "" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:131 #, no-wrap msgid "" "\tapic_register_enumerator(&mptable_enumerator);\n" "}\n" msgstr "" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:134 #, no-wrap msgid "" "SYSINIT(mptable_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST,\n" " mptable_register, NULL);\n" msgstr "" #. type: Title === #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:138 #, no-wrap msgid "Shutdown" msgstr "" #. type: delimited block = 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:141 msgid "" "The `SYSUNINIT()` macro behaves similarly to the `SYSINIT()` macro except " "that it adds the SYSINIT data to SYSINIT's shutdown data set." msgstr "" #. type: Block title #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:142 #, no-wrap msgid "Example of a `SYSUNINIT()`" msgstr "" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:154 #, no-wrap msgid "" "void foo_cleanup(void *unused)\n" "{\n" " foo_kill();\n" "}\n" "SYSUNINIT(foobar, SI_SUB_FOO, SI_ORDER_FOO, foo_cleanup, NULL);\n" msgstr "" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:158 #, no-wrap msgid "" "struct foo_stack foo_stack = {\n" " FOO_STACK_VOODOO;\n" "}\n" msgstr "" #. type: delimited block . 4 #: documentation/content/en/books/arch-handbook/sysinit/_index.adoc:163 #, no-wrap msgid "" "void foo_flush(void *vdata)\n" "{\n" "}\n" "SYSUNINIT(barfoo, SI_SUB_FOO, SI_ORDER_FOO, foo_flush, &foo_stack);\n" msgstr ""