Expand description
§os_dev_toolkit
Dependency-free, no_std-first building blocks intended to improve the developer experience
while writing operating systems and kernels in Rust.
§Design goals
no_stdby default: usable in kernels without a standard library.- No external dependencies: keeps builds deterministic and simplifies bring-up.
- Deterministic formatting/output: logging and diagnostics avoid allocation by default.
- Small, composable primitives: you decide integration details (serial/VGA/etc.).
§Features
alloc: reserved for future optional allocation-backed utilities.release_assertions: keeps assertion macros enabled in release builds.
§High-level usage
Most consumers will start with the crate::log module:
use os_dev_toolkit::log::{Level, LogSink, Logger};
struct MySink;
impl LogSink for MySink {
fn write_str(&mut self, s: &str) {
let _ = s;
// forward to serial/vga/etc.
}
}
fn demo() {
let mut sink = MySink;
let mut logger = Logger::new(&mut sink, Level::Info);
os_dev_toolkit::kinfo!(logger, "hello from the kernel side: {}", 123);
}§Safety and concurrency
This crate provides synchronization primitives such as sync::SpinLock and sync::Once.
These are intentionally minimal and do not attempt to be fair or preemption-safe; you must
apply the right interrupt/preemption masking strategy for your kernel.
Modules§
- assert
- Assertion macros suitable for kernel/OS environments. Assertion macros intended for OS/kernel contexts.
- buffer
- Fixed-capacity data structures (
RingBuffer,FixedStr) intended for allocation-free code. Fixed-capacity buffers for allocation-free environments. - config
- Compile-time configuration helpers. Small compile-time configuration helpers.
- fmt
- Deterministic formatting helpers such as hexdumps and byte-size formatters.
Formatting helpers for diagnostics in
no_stdenvironments. - log
- Minimal logging traits and a small
Loggerwith level filtering. Minimal logging primitives forno_stdkernels. - panic
- Panic helpers for routing panic output to a sink and halting. Panic and halt helpers.
- status
- OS-style status codes and small conversion helpers. Small OS-style status codes.
- sync
- Simple synchronization primitives (
SpinLock,Once) forno_stdenvironments. Minimal synchronization primitives forno_stdkernels.
Macros§
- kassert
- Kernel assertion.
- kassert_
eq - Kernel equality assertion.
- kassert_
ne - Kernel inequality assertion.
- kdebug
- Emits a debug-level log line.
- kerror
- Emits an error-level log line.
- kinfo
- Emits an info-level log line.
- ktrace
- Emits a trace-level log line.
- kwarn
- Emits a warning-level log line.