Available on crate feature
full only.Expand description
Kernel modules.
§Examples
use kernel_api::modules::{kernel_module, Module};
use kernel_api::sync::OnceLock;
struct MyModuleContext {
// ...
}
static CONTEXT: OnceLock<MyModuleContext> = OnceLock::new();
kernel_module! {
type: MyModuleContext,
name: "My Custom Module",
author: "Popcorn Contributors",
license: "MPL-2.0",
}
impl Module for MyModuleContext {
fn early_init() -> Result<(), &'static str> {
debug!("early init of `My Custom Module`");
Ok(())
}
fn late_init() -> Result<(), &'static str> {
debug!("late init of `My Custom Module`");
// initialise context
CONTEXT.get_or_init(Self::new);
Ok(())
}
}
impl MyModuleContext {
fn new() -> Self {
// ...
}
}Traits§
- Module
- The top level trait for a kernel module.