fwmanager: make DeviceConfig generic over the reset signal type HalBootControl is generic over its controller's ResetId, so a hardcoded u8 only fits controllers whose id type happens to be u8 — and reset may not even be line-addressed. Parameterize the table over the board's reset signal type so a mismatch fails to compile, and call the field reset_signal rather than reset_line. The mock board uses u8. Assisted-by: Claude:claude-fable-5 Signed-off-by: Christina Quast <christina.quast@9elements.com> Refs: 9elements/openprot#1
diff --git a/services/fwmanager/api/src/config.rs b/services/fwmanager/api/src/config.rs index b60edd6..f0b8d91 100644 --- a/services/fwmanager/api/src/config.rs +++ b/services/fwmanager/api/src/config.rs
@@ -15,11 +15,16 @@ } /// One managed downstream device, as declared by the board config. +/// +/// Generic over the board's reset signal type `R`, which must match the +/// `ResetId` of the reset controller behind the board's `BootControl` +/// implementation — the compiler rejects a table whose ids the controller +/// cannot accept. #[derive(Debug, Clone, Copy)] -pub struct DeviceConfig { +pub struct DeviceConfig<R> { pub name: &'static str, - /// Reset line id, passed to HalBootControl::new. - pub reset_line: u8, + /// Reset signal id, passed to HalBootControl::new. + pub reset_signal: R, /// How long the orchestrator waits for this device to report Booted /// before it declares a timeout. pub boot_timeout: core::time::Duration, @@ -28,7 +33,7 @@ /// Checks a device table. Board configs call this in a const context so a /// bad table fails the build. -pub const fn validate(devices: &[DeviceConfig]) { +pub const fn validate<R>(devices: &[DeviceConfig<R>]) { let mut i = 0; while i < devices.len() { assert!(!devices[i].name.is_empty(), "device name must not be empty");
diff --git a/target/mock/devices.rs b/target/mock/devices.rs index 7e9309b..5f9fa17 100644 --- a/target/mock/devices.rs +++ b/target/mock/devices.rs
@@ -11,18 +11,21 @@ /// Declaration order is the boot order: the orchestrator releases devices /// top to bottom, one at a time. -pub const MANAGED_DEVICES: &[DeviceConfig] = &[ +/// +/// The mock board's reset controller addresses lines by plain index, so its +/// reset id type is `u8`. +pub const MANAGED_DEVICES: &[DeviceConfig<u8>] = &[ // Direct-flash SPI device (BMC archetype): the eRoT fronts its flash. DeviceConfig { name: "bmc", - reset_line: 7, + reset_signal: 7, boot_timeout: core::time::Duration::from_secs(90), commit_policy: CommitPolicy::Liveness, }, // PLDM device (NIC archetype): self-updating, SPDM-capable. DeviceConfig { name: "nic", - reset_line: 3, + reset_signal: 3, boot_timeout: core::time::Duration::from_secs(30), commit_policy: CommitPolicy::LivenessAndAttestation, },