Skip to main content

init_component

Attribute Macro init_component 

Source
#[init_component]
Expand description

Register a function as a kernel component initializer.

§Syntax

#[init_component]
#[init_component(bootstrap)]
#[init_component(bootstrap, priority = 1)]
#[init_component(kthread, priority = 2, depends_on = vfs_init)]
#[init_component(kthread, priority = 3, depends_on = [vfs_init, ipc_init])]
ArgumentTypeDefaultDescription
stagepositional identbootstrapbootstrap, kthread, or process
priorityinteger0Lower = earlier (tiebreaker within topo level)
depends_onident or list[]Functions that must complete before this one

§Example

#[init_component(bootstrap, priority = 1)]
fn vfs_init() -> Result<(), component::ComponentInitError> {
    vfs::init();
    Ok(())
}

#[init_component(kthread, priority = 2, depends_on = vfs_init)]
fn fs_ext4_init() -> Result<(), component::ComponentInitError> {
    fs_ext4::init();
    Ok(())
}

The annotated function is emitted unchanged; a companion #[used] static is placed in .component_entries so component::init_all() can discover, topologically sort, and call all registered components at runtime.