Skip to main content

Crate os_dev_toolkit

Crate os_dev_toolkit 

Source
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_std by 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_std environments.
log
Minimal logging traits and a small Logger with level filtering. Minimal logging primitives for no_std kernels.
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) for no_std environments. Minimal synchronization primitives for no_std kernels.

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.