How rust-osdev/uefi-rs works
Project Type and Purpose
• This is a multi-crate Rust workspace providing:
• A high-level UEFI library (the uefi crate)
• A low-level, ABI-compatible layer (uefi-raw)
• Proc-macros for ergonomic entry points (uefi-macros)
• Support crates and examples (uefi-services, uefi-std-example, template)
• An integration-test runner binary (uefi-test-runner)
• A custom build/test helper (xtask)
• Purpose: Enable safe, convenient UEFI applications in Rust, plus tooling to build, test, and document them.
File-Structure Highlights
• Top-level is a Cargo workspace (Cargo.toml, Cargo.lock) with sub-directories for each crate.
• uefi/, uefi-raw/, uefi-macros/, uefi-test-runner/, uefi-std-example/, uefi-services/, template/ each contain their own Cargo.toml and source.
• xtask/ provides a custom CLI over cargo to simplify cross-crate build, test, doc, and run in QEMU with OVMF.
• book/ and docs/ hold user documentation and tutorials.
• GitHub Actions workflows orchestrate CI build, test, docs, and releases.
Key Dependencies and Relationships
• uefi (high level) → depends on → uefi-raw + uefi-macros
• uefi-test-runner and uefi-std-example → depend on → uefi
• xtask → orchestrates building/testing all crates (invokes cargo build, cargo test, QEMU runs)
• External services: QEMU + OVMF (for UEFI environment), docs.rs (for publishing docs), crates.io (publishing crates).
Architectural Patterns
• Monorepo/Cargo-workspace pattern: shared dependency management, provenance.
• Layered abstraction: raw FFI types (uefi-raw) → proc macros (uefi-macros) → safe Rust wrapper (uefi).
• Custom task runner (xtask): encapsulates repetitive build/test commands.
• Test-harness binary (uefi-test-runner): integration tests in UEFI environment.
a. Components to include:
• Developer Workstation: IDE/editor, cargo, xtask.
• Cargo Workspace: the collection of crates.
• Crates:
• uefi-raw
• uefi-macros
• uefi (high-level wrapper)
• uefi-services (helper utilities)
• uefi-test-runner (integration test binary)
• uefi-std-example (sample binary)
• template (starter project)
• Documentation subsystem (book/, docs/)
• CI/CD pipelines (GitHub Actions workflows)
• External Runtime: QEMU + OVMF firmware
• Publishing targets: crates.io, docs.rs
b. Relationships and Data Flow:
• Documentation sources feed into static site/book.
c. Important Patterns:
• Layered crates (dep-graph).
• Custom orchestration (xtask) vs. standard cargo.
• External emulation environment (QEMU).
d. Technologies and Frameworks:
• Rust/Cargo workspace
• Proc macro system for entry point annotations
• QEMU + OVMF firmware images
• GitHub Actions for CI
Final Advice
• Be exhaustive: show every crate and its immediate dependents.
• Clearly demarcate build-time vs. run-time interactions.
• Custom orchestration (xtask) and the external UEFI environment.
• Keep the layout hierarchical: low-level crates at the bottom, plugins/macros next, core wrapper in the middle, consumers on top, then external services and CI around the perimeter.