-
Notifications
You must be signed in to change notification settings - Fork 62
Add cosmo ignition support #9076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| use schemars::JsonSchema; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| pub mod v1; | ||
| pub mod v2; | ||
|
|
||
| pub use v2::*; | ||
|
|
||
| /// Ignition command. | ||
| #[derive( | ||
| Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, JsonSchema, | ||
| )] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum IgnitionCommand { | ||
| PowerOn, | ||
| PowerOff, | ||
| PowerReset, | ||
| } | ||
|
|
||
| impl From<IgnitionCommand> for gateway_messages::IgnitionCommand { | ||
| fn from(cmd: IgnitionCommand) -> Self { | ||
| match cmd { | ||
| IgnitionCommand::PowerOn => { | ||
| gateway_messages::IgnitionCommand::PowerOn | ||
| } | ||
| IgnitionCommand::PowerOff => { | ||
| gateway_messages::IgnitionCommand::PowerOff | ||
| } | ||
| IgnitionCommand::PowerReset => { | ||
| gateway_messages::IgnitionCommand::PowerReset | ||
| } | ||
| } | ||
| } | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| use schemars::JsonSchema; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| use crate::component::SpIdentifier; | ||
|
|
||
| #[derive( | ||
| Debug, | ||
| Clone, | ||
| PartialEq, | ||
| Eq, | ||
| PartialOrd, | ||
| Ord, | ||
| Deserialize, | ||
| Serialize, | ||
| JsonSchema, | ||
| )] | ||
| pub struct SpIgnitionInfo { | ||
| pub id: SpIdentifier, | ||
| pub details: SpIgnition, | ||
| } | ||
|
|
||
| impl From<SpIgnitionInfo> for crate::ignition::v1::SpIgnitionInfo { | ||
| fn from(s: SpIgnitionInfo) -> Self { | ||
| Self { id: s.id, details: s.details.into() } | ||
| } | ||
| } | ||
|
|
||
| /// State of an ignition target. | ||
| // | ||
| // TODO: Ignition returns much more information than we're reporting here: do | ||
| // we want to expand this? | ||
| #[derive( | ||
| Debug, | ||
| Clone, | ||
| PartialEq, | ||
| Eq, | ||
| PartialOrd, | ||
| Ord, | ||
| Deserialize, | ||
| Serialize, | ||
| JsonSchema, | ||
| )] | ||
| #[serde(tag = "present")] | ||
| pub enum SpIgnition { | ||
| #[serde(rename = "no")] | ||
| Absent, | ||
| #[serde(rename = "yes")] | ||
| Present { | ||
| id: SpIgnitionSystemType, | ||
| power: bool, | ||
| ctrl_detect_0: bool, | ||
| ctrl_detect_1: bool, | ||
| /// Fault from the A3 power domain | ||
| flt_a3: bool, | ||
| /// Fault from the A2 power domain | ||
| flt_a2: bool, | ||
| /// Fault from the RoT | ||
| flt_rot: bool, | ||
| /// Fault from the SP | ||
| flt_sp: bool, | ||
| }, | ||
| } | ||
|
|
||
| impl From<gateway_messages::IgnitionState> for SpIgnition { | ||
| fn from(state: gateway_messages::IgnitionState) -> Self { | ||
| use gateway_messages::ignition::SystemPowerState; | ||
|
|
||
| if let Some(target_state) = state.target { | ||
| Self::Present { | ||
| id: target_state.system_type.into(), | ||
| power: matches!( | ||
| target_state.power_state, | ||
| SystemPowerState::On | SystemPowerState::PoweringOn | ||
| ), | ||
| ctrl_detect_0: target_state.controller0_present, | ||
| ctrl_detect_1: target_state.controller1_present, | ||
| flt_a3: target_state.faults.power_a3, | ||
| flt_a2: target_state.faults.power_a2, | ||
| flt_rot: target_state.faults.rot, | ||
| flt_sp: target_state.faults.sp, | ||
| } | ||
| } else { | ||
| Self::Absent | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<SpIgnition> for crate::ignition::v1::SpIgnition { | ||
| fn from(state: SpIgnition) -> Self { | ||
| match state { | ||
| SpIgnition::Absent => Self::Absent, | ||
| SpIgnition::Present { | ||
| id, | ||
| power, | ||
| ctrl_detect_0, | ||
| ctrl_detect_1, | ||
| flt_a3, | ||
| flt_a2, | ||
| flt_rot, | ||
| flt_sp, | ||
| } => Self::Present { | ||
| id: id.into(), | ||
| power, | ||
| ctrl_detect_0, | ||
| ctrl_detect_1, | ||
| flt_a3, | ||
| flt_a2, | ||
| flt_rot, | ||
| flt_sp, | ||
| }, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive( | ||
| Debug, | ||
| Clone, | ||
| Copy, | ||
| PartialEq, | ||
| Eq, | ||
| PartialOrd, | ||
| Ord, | ||
| Deserialize, | ||
| Serialize, | ||
| JsonSchema, | ||
| )] | ||
| #[serde(tag = "system_type", rename_all = "snake_case")] | ||
| pub enum SpIgnitionSystemType { | ||
| Gimlet, | ||
| Sidecar, | ||
| Psc, | ||
| Unknown { id: u16 }, | ||
| Cosmo, | ||
| } | ||
|
|
||
| impl From<gateway_messages::ignition::SystemType> for SpIgnitionSystemType { | ||
| fn from(st: gateway_messages::ignition::SystemType) -> Self { | ||
| use gateway_messages::ignition::SystemType; | ||
| match st { | ||
| SystemType::Gimlet => Self::Gimlet, | ||
| SystemType::Sidecar => Self::Sidecar, | ||
| SystemType::Psc => Self::Psc, | ||
| SystemType::Unknown(id) => Self::Unknown { id }, | ||
| SystemType::Cosmo => Self::Cosmo, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<SpIgnitionSystemType> for crate::ignition::v1::SpIgnitionSystemType { | ||
| fn from(st: SpIgnitionSystemType) -> Self { | ||
| match st { | ||
| SpIgnitionSystemType::Gimlet => Self::Gimlet, | ||
| SpIgnitionSystemType::Sidecar => Self::Sidecar, | ||
| SpIgnitionSystemType::Psc => Self::Psc, | ||
| // Cosmo system id is 0x4 | ||
| SpIgnitionSystemType::Cosmo => Self::Unknown { id: 0x4 }, | ||
| SpIgnitionSystemType::Unknown { id } => Self::Unknown { id }, | ||
| } | ||
| } | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also bump this hash in
package-manifest.tomlwhere pull inpackage.omicron-faux-mgs. (Always shipping an up-to-date faux-mgs is not critical, but it's nice to have.)