Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions task/control-plane-agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ enum MgsMessage {
slot: u16,
persist: bool,
},
ComponentGetPersistentSlot {
component: SpComponent,
},
SerialConsoleBreak,
SendHostNmi,
SetIpccKeyValue {
Expand Down
25 changes: 25 additions & 0 deletions task/control-plane-agent/src/mgs_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,31 @@ impl MgsCommon {
}
}

pub(crate) fn component_get_persistent_slot(
&mut self,
component: SpComponent,
) -> Result<u16, GwSpError> {
match component {
SpComponent::SP_ITSELF => {
Ok(self.update_sp.get_pending_boot_slot().into())
}
SpComponent::ROT => {
let slot = match self
.sprot
.rot_boot_info()?
.persistent_boot_preference
{
SpSlotId::A => 0,
SpSlotId::B => 1,
};
Ok(slot)
}
// We know that the LPC55S69 RoT bootloader does not have switchable banks.
SpComponent::STAGE0 => Ok(0),
_ => Err(GwSpError::RequestUnsupportedForComponent),
}
}

pub(crate) fn read_sensor(
&mut self,
req: SensorRequest,
Expand Down
16 changes: 16 additions & 0 deletions task/control-plane-agent/src/mgs_compute_sled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,22 @@ impl SpHandler for MgsHandler {
}
}

fn component_get_persistent_slot(
&mut self,
component: SpComponent,
) -> Result<u16, SpError> {
ringbuf_entry_root!(Log::MgsMessage(
MgsMessage::ComponentGetPersistentSlot { component }
));

match component {
SpComponent::HOST_CPU_BOOT_FLASH => {
self.host_flash_update.persistent_slot()
}
_ => self.common.component_get_persistent_slot(component),
}
}

fn component_clear_status(
&mut self,
component: SpComponent,
Expand Down
11 changes: 11 additions & 0 deletions task/control-plane-agent/src/mgs_psc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,17 @@ impl SpHandler for MgsHandler {
.component_set_active_slot(component, slot, persist)
}

fn component_get_persistent_slot(
&mut self,
component: SpComponent,
) -> Result<u16, SpError> {
ringbuf_entry_root!(Log::MgsMessage(
MgsMessage::ComponentGetPersistentSlot { component }
));

self.common.component_get_persistent_slot(component)
}

fn component_clear_status(
&mut self,
component: SpComponent,
Expand Down
11 changes: 11 additions & 0 deletions task/control-plane-agent/src/mgs_sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,17 @@ impl SpHandler for MgsHandler {
.component_set_active_slot(component, slot, persist)
}

fn component_get_persistent_slot(
&mut self,
component: SpComponent,
) -> Result<u16, SpError> {
ringbuf_entry_root!(Log::MgsMessage(
MgsMessage::ComponentGetPersistentSlot { component }
));

self.common.component_get_persistent_slot(component)
}

fn component_clear_status(
&mut self,
component: SpComponent,
Expand Down
22 changes: 16 additions & 6 deletions task/control-plane-agent/src/update/host_flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,23 @@ impl HostFlashUpdate {
}

pub(crate) fn active_slot(&self) -> Result<u16, SpError> {
match self
.task
self.task
.get_dev()
.map_err(|err| SpError::ComponentOperationFailed(err as u32))?
{
HfDevSelect::Flash0 => Ok(0),
HfDevSelect::Flash1 => Ok(1),
.map(Self::dev_to_slot)
.map_err(|err| SpError::ComponentOperationFailed(err as u32))
}

pub(crate) fn persistent_slot(&self) -> Result<u16, SpError> {
self.task
.get_persistent_data()
.map(|data| Self::dev_to_slot(data.dev_select))
.map_err(hf_to_gwhf)
}

fn dev_to_slot(dev: HfDevSelect) -> u16 {
match dev {
HfDevSelect::Flash0 => 0,
HfDevSelect::Flash1 => 1,
}
}

Expand Down