Expand description
os_metal_primitives is a dependency-free collection of bare-metal primitives
for Rust-based operating systems.
This crate is intentionally small, strict, and no_std-first:
- It provides typed MMIO access with volatile semantics.
- It offers bitfield helpers and a small declarative
bitfield!macro. - It includes register block helpers for memory-mapped devices.
- It defines a minimal port I/O abstraction (useful on x86-style platforms).
- It provides small IRQ types and an allocation-free interrupt table.
- It includes a tiny driver state pattern that helps keep driver lifecycles explicit.
§What this crate is not
- It is not a kernel framework or boot pipeline (see your higher-level crates).
- It is not a logging/diagnostics toolkit.
- It is not tied to any architecture or bootloader.
§Safety model (high level)
This crate provides safe APIs around operations that are inherently unsafe (MMIO, port I/O, interrupt dispatch). The rule is:
- Creating handles to hardware is usually
unsafebecause it requires the caller to guarantee that addresses/ports are valid, mapped, aligned, and exclusive where needed. - Once such a handle exists, reading/writing registers can often be safe because the handle encapsulates the preconditions.
For more detail, see docs/SAFETY.md in the repository.
§Edition / dependencies
- Rust edition: 2024
- External dependencies: none
Modules§
- bitfield
- Bitfield helpers and the
bitfield!macro. Bitfield helpers for register manipulation. - driver_
state - Tiny, explicit driver lifecycle state helpers. Driver lifecycle state helpers.
- irq
- Small interrupt-related types and an allocation-free IRQ table. Interrupt-related helper types.
- mmio
- Typed memory-mapped I/O (MMIO) register primitives. Memory-mapped I/O (MMIO) primitives.
- port_io
- Minimal port I/O abstraction, intended to be implemented by an architecture layer. Port I/O abstraction.
- register
- Register access mode wrappers and the
define_register_block!macro. Register access mode wrappers and register block helper macro.
Macros§
- bitfield
- Declares a typed bitfield wrapper and emits flag/field constants.
- define_
register_ block - Generates an MMIO register block handle with typed accessors.