[PATCH 4/8] rust: module_param: add ObsKernelParam type
From: Matthew Wood
Date: Thu Feb 26 2026 - 18:50:03 EST
Add ObsKernelParam, a #[repr(C)] struct that mirrors the C
obs_kernel_param structure used by the __setup / early_param
infrastructure to register boot-time command-line handlers.
The struct contains:
- str_: pointer to the null-terminated setup string
- setup_func: the callback invoked when the kernel parses the
matching command-line token
- early: flag distinguishing early_param (1) from __setup (0)
Mark it Sync because instances are written at compile time and only
read during single-threaded early boot initialization.
This type will be used by the module! macro to emit __setup entries
in the .init.setup ELF section in subsequent patches.
Signed-off-by: Matthew Wood <thepacketgeek@xxxxxxxxx>
---
rust/kernel/module_param.rs | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/rust/kernel/module_param.rs b/rust/kernel/module_param.rs
index 67ff6f2ea9c2..54379a2bba51 100644
--- a/rust/kernel/module_param.rs
+++ b/rust/kernel/module_param.rs
@@ -26,6 +26,20 @@ pub const fn new(val: bindings::kernel_param) -> Self {
// from Rust module.
unsafe impl Sync for KernelParam {}
+/// Placed in the `.init.setup` ELF section by the `module!` macro.
+#[repr(C)]
+pub struct ObsKernelParam {
+ /// Pointer to the null-terminated setup string (e.g., `"netconsole=\0"`).
+ pub str_: *const c_char,
+ /// The setup callback function.
+ pub setup_func: Option<unsafe extern "C" fn(*mut c_char) -> c_int>,
+ /// Whether this is an early parameter (0 for `__setup`, 1 for `early_param`).
+ pub early: c_int,
+}
+
+// SAFETY: Only written at compile time, read during single-threaded boot init.
+unsafe impl Sync for ObsKernelParam {}
+
/// Types that can be used for module parameters.
// NOTE: This trait is `Copy` because drop could produce unsoundness during teardown.
pub trait ModuleParam: Sized + Copy {
--
2.52.0