Add patina_sre crate (System Recovery Environment boot orchestrator)#91
Open
kat-perez wants to merge 1 commit into
Open
Add patina_sre crate (System Recovery Environment boot orchestrator)#91kat-perez wants to merge 1 commit into
kat-perez wants to merge 1 commit into
Conversation
Closed
5 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new uefi/crates/patina_sre crate providing SreBootManager, a reference patina_boot::BootOrchestrator implementation intended to drive a “normal boot” BDS-phase sequence for ODP platforms that ship an SRE alongside the main OS.
Changes:
- Introduces
SreBootManagerwith an interleave connect/dispatch loop plus a normal-bootexecute()implementation. - Adds unit tests covering the connect/dispatch interleave behavior and trait-object construction.
- Adds crate packaging/docs/tooling files (Cargo manifest, README, rust-toolchain, rustfmt config) and a crate-local lockfile.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| uefi/crates/patina_sre/src/lib.rs | Implements SreBootManager, interleave helper, and unit tests. |
| uefi/crates/patina_sre/Cargo.toml | Defines crate metadata and git-based dependencies for patina* crates. |
| uefi/crates/patina_sre/README.md | Documents intended boot sequence and adoption guidance. |
| uefi/crates/patina_sre/rust-toolchain.toml | Pins the nightly toolchain + UEFI targets/components for this crate. |
| uefi/crates/patina_sre/rustfmt.toml | Sets formatting configuration for the crate. |
| uefi/crates/patina_sre/Cargo.lock | Pins dependency resolution for the crate directory. |
| } | ||
|
|
||
| if let Err(e) = patina_nvme::lock_partition_write(boot_services, &self.boot_partition_path) { | ||
| log::error!("lock_partition_write failed: {:?}", e); |
Comment on lines
+119
to
+126
| match helpers::boot_from_device_path(boot_services, image_handle, &self.main_os_path) { | ||
| Ok(()) => log::warn!("Main OS boot returned control"), | ||
| Err(_) => log::warn!("Main OS boot failed"), | ||
| } | ||
|
|
||
| log::error!("SRE normal boot exhausted main OS path"); | ||
| Err(EfiError::NotFound) | ||
| } |
Comment on lines
+103
to
+105
| if let Err(e) = helpers::signal_bds_phase_entry(boot_services) { | ||
| log::error!("signal_bds_phase_entry failed: {:?}", e); | ||
| } |
Comment on lines
+6
to
+12
| [package] | ||
| name = "patina_sre" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
| rust-version = "1.89" | ||
| license = "MIT" | ||
| repository = "https://github.com/OpenDevicePartnership/odp-platform-common" |
debca5c to
b73e22a
Compare
b73e22a to
b140afe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a new `patina_sre` crate at `uefi/crates/patina_sre/` containing `SreBootManager` — a reference implementation of `patina_boot::BootOrchestrator` for ODP platforms shipping a System Recovery Environment alongside the main OS. The orchestrator is generic over a [`HotkeySource`] abstraction so vendors can wire platform-specific hotkey hardware while keeping the SRE flow itself portable.
The crate ships:
Platform vendors implement `HotkeySource` themselves to bridge their hotkey hardware (e.g. Surface's `MsButtonServicesProtocol`).
This supersedes patina#1492, which placed `SreBootManager` inside `patina_boot`. Per the reviewer thread on patina#1488, the SRE orchestrator is a platform-level component and doesn't belong in the generic `patina_boot` SDK crate.
Closes ODP-board #62 (`SreBootManager` skeleton), #63 (`HotkeySource` trait), and #68 (SRE boot path wiring).
How This Was Tested
`cargo test --lib` — all 9 tests pass:
```
test hotkey::tests::always_sre_returns_true ... ok
test hotkey::tests::never_sre_returns_false ... ok
test tests::test_new_constructs ... ok
test tests::test_new_with_always_sre ... ok
test tests::test_interleave_single_round_no_drivers_dispatched ... ok
test tests::test_interleave_dispatch_failure_propagates ... ok
test tests::test_interleave_stops_at_max_rounds ... ok
test tests::test_implements_boot_orchestrator ... ok
test tests::test_arc_dyn_construction ... ok
```
Coverage spans the interleave-connect-dispatch loop (single-round convergence, dispatch-error propagation, max-rounds graceful exit), the `HotkeySource` impls, `BootOrchestrator` trait conformance for both `SreBootManager` and `SreBootManager`, and `Arc` construction (matching the `BootDispatcher` consumption path).
End-to-end QEMU validation is a separate change on `patina-dxe-core-qemu` that wires `SreBootManager` into the Q35 platform component list and exercises both paths under `patina-qemu`.
Integration Instructions
Add `patina_sre` to your platform DXE core's component list, with a `HotkeySource` implementation appropriate to the platform:
```rust,ignore
use patina_boot::BootDispatcher;
use patina_sre::{NeverSre, SreBootManager};
Core::default()
.with_component(BootDispatcher::new(SreBootManager::new(
boot_partition_device_path,
main_os_device_path,
"\\SRE\\winvos.wim",
NeverSre, // replace with your platform's hotkey impl (e.g. SurfaceButtonHotkeySource)
)))
```
`patina`, `patina_boot`, `patina_nvme`, `patina_partition`, and `patina_ram_disk` are consumed as git dependencies because none of those releases are on crates.io yet. A `[patch]` block redirects transitive `patina` deps from upstream's `feature/patina-boot` onto a temporary combined branch (`kat-perez/sre-base` = `feature/patina-boot` + the EFI_RAM_DISK_PROTOCOL binding from patina#1490) so cargo sees one shared `patina` version across the dep tree. Once the corresponding patina release ships, the manifest moves to versioned crates.io references and downstream consumers won't need any patch glue.