services: com: add discriminants to opcodes

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2022-03-17 11:30:03 +08:00
parent 331a0a120d
commit e91705c0ae

View file

@ -1,7 +1,7 @@
// NOTE: the use of ComState "verbs" as commands is not meant as a 1:1 mapping of commands // NOTE: the use of ComState "verbs" as commands is not meant as a 1:1 mapping of commands
// It's just a convenient abuse of already-defined constants. However, it's intended that // It's just a convenient abuse of already-defined constants. However, it's intended that
// the COM server on the SoC side abstracts much of the EC bus complexity away. // the COM server on the SoC side abstracts much of the EC bus complexity away.
pub(crate) const SERVER_NAME_COM: &str = "_COM manager_"; pub(crate) const SERVER_NAME_COM: &str = "_COM manager_";
pub use com_rs_ref::serdes::Ipv4Conf; pub use com_rs_ref::serdes::Ipv4Conf;
#[allow(dead_code)] #[allow(dead_code)]
pub const WF200_PASS_MAX_LEN: usize = 64; pub const WF200_PASS_MAX_LEN: usize = 64;
@ -51,7 +51,7 @@ pub(crate) enum FlashOp {
/// programming more efficient, while taking full advantage of the 1280-deep receive FIFO on the EC. /// programming more efficient, while taking full advantage of the 1280-deep receive FIFO on the EC.
/// Address + up to 4 pages. page 0 is at address, page 1 is at address + 256, etc. /// Address + up to 4 pages. page 0 is at address, page 1 is at address + 256, etc.
/// Pages stored as None are skipped, yet the address pointer is still incremented. /// Pages stored as None are skipped, yet the address pointer is still incremented.
Program(u32, [Option<[u8; 256]>; 4]) Program(u32, [Option<[u8; 256]>; 4]),
} }
#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] #[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
pub(crate) enum FlashResult { pub(crate) enum FlashResult {
@ -67,13 +67,16 @@ pub(crate) struct FlashRecord {
} }
#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] #[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
pub struct SsidRecord { pub struct SsidRecord {
pub name: xous_ipc::String::<32>, pub name: xous_ipc::String<32>,
/// rssi is reported as the negative of actual rssi in dBm. Example: an rssi of -42dBm is reported as `42u8`. /// rssi is reported as the negative of actual rssi in dBm. Example: an rssi of -42dBm is reported as `42u8`.
pub rssi: u8, pub rssi: u8,
} }
impl Default for SsidRecord { impl Default for SsidRecord {
fn default() -> Self { fn default() -> Self {
SsidRecord { name: xous_ipc::String::<32>::new(), rssi: 0 } SsidRecord {
name: xous_ipc::String::<32>::new(),
rssi: 0,
}
} }
} }
#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] #[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
@ -141,156 +144,156 @@ pub struct WlanDebug {
pub alloc_free_count: u16, pub alloc_free_count: u16,
} }
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)] #[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
#[repr(C)]
pub(crate) enum Opcode { pub(crate) enum Opcode {
/// A ping back, used to determine when the COM has finished initializing /// A ping back, used to determine when the COM has finished initializing
Ping, Ping = 0,
/// Reset the COM link - useful after an EC reset /// Reset the COM link - useful after an EC reset
LinkReset, LinkReset = 1,
/// Refresh the TRNG seed for the EC /// Refresh the TRNG seed for the EC
ReseedTrng, ReseedTrng = 2,
/// Fetch the uptime of the EC /// Fetch the uptime of the EC
GetUptime, GetUptime = 3,
/// Battery stats /// Battery stats
BattStats, BattStats = 4,
/// Standby current -- only valid if a BattStats command was previously issued /// Standby current -- only valid if a BattStats command was previously issued
StandbyCurrent, StandbyCurrent = 5,
/// Battery stats, non-blocking /// Battery stats, non-blocking
BattStatsNb, BattStatsNb = 6,
/// Query Full charge capacity of the battery /// Query Full charge capacity of the battery
//BattFullCapacity, //BattFullCapacity = 7,
/// More charger and gas gauge status, primarily for diagnostics /// More charger and gas gauge status, primarily for diagnostics
MoreStats, MoreStats = 8,
/// Poll the USB CC chip /// Poll the USB CC chip
PollUsbCc, PollUsbCc = 9,
/// Turn Boost Mode On /// Turn Boost Mode On
BoostOn, BoostOn = 10,
/// Turn Boost Mode Off /// Turn Boost Mode Off
BoostOff, BoostOff = 11,
/// Read the current accelerations off the IMU; this blocks while the read takes place /// Read the current accelerations off the IMU; this blocks while the read takes place
ImuAccelReadBlocking, ImuAccelReadBlocking = 12,
/// Power off the SoC /// Power off the SoC
PowerOffSoc, PowerOffSoc = 13,
/// Ship mode (battery disconnect) /// Ship mode (battery disconnect)
ShipMode, ShipMode = 14,
/// Is the battery charging? /// Is the battery charging?
IsCharging, IsCharging = 15,
/// Set the backlight brightness /// Set the backlight brightness
SetBackLight, SetBackLight = 16,
/// Request charging /// Request charging
RequestCharging, RequestCharging = 17,
/// Erase or program a region of EC FLASH /// Erase or program a region of EC FLASH
FlashOp, FlashOp = 18,
/// Take the mutex on EC update operations. /// Take the mutex on EC update operations.
/// Only one process is allowed to acquire this ever, right now, for security reasons. /// Only one process is allowed to acquire this ever, right now, for security reasons.
FlashAcquire, FlashAcquire = 19,
/// Checks if an updated SSID list is available /// Checks if an updated SSID list is available
SsidCheckUpdate, SsidCheckUpdate = 20,
/// Return the latest SSID list /// Return the latest SSID list
SsidFetchAsString, SsidFetchAsString = 21,
SsidFetchAsStringV2, SsidFetchAsStringV2 = 22,
/// Fetch the git ID of the EC /// Fetch the git ID of the EC
EcGitRev, EcGitRev = 23,
/// Fetch the SW tag of the EC as a {00|maj|min|rev} u32 /// Fetch the SW tag of the EC as a {00|maj|min|rev} u32
EcSwTag, EcSwTag = 24,
/// Fetch the firmware rev of the WF200 /// Fetch the firmware rev of the WF200
Wf200Rev, Wf200Rev = 25,
/// Send a line of PDS data /// Send a line of PDS data
Wf200PdsLine, //String<512> Wf200PdsLine = 26, //String<512>
/// request for a listener to BattStats events /// request for a listener to BattStats events
RegisterBattStatsListener, //String<64> RegisterBattStatsListener = 27, //String<64>
/// Reset the wifi chip /// Reset the wifi chip
Wf200Reset, Wf200Reset = 28,
/// Disable the wifi chip /// Disable the wifi chip
Wf200Disable, Wf200Disable = 29,
/// start passive SSID scanning /// start passive SSID scanning
ScanOn, ScanOn = 30,
/// stop passive SSID scanning /// stop passive SSID scanning
ScanOff, ScanOff = 31,
/// suspend/resume callback /// suspend/resume callback
SuspendResume, SuspendResume = 32,
/// wlan: make sure radio is on (reset from standby if needed) /// wlan: make sure radio is on (reset from standby if needed)
WlanOn, WlanOn = 33,
/// wlan: switch radio to lowest power standby mode /// wlan: switch radio to lowest power standby mode
WlanOff, WlanOff = 34,
/// wlan: set SSID to use for joining AP /// wlan: set SSID to use for joining AP
WlanSetSSID, WlanSetSSID = 35,
/// wlan: set password to use for joining AP /// wlan: set password to use for joining AP
WlanSetPass, WlanSetPass = 36,
/// wlan: join AP using previously set SSID & password /// wlan: join AP using previously set SSID & password
WlanJoin, WlanJoin = 37,
/// wlan: disconnect from AP /// wlan: disconnect from AP
WlanLeave, WlanLeave = 38,
/// wlan: get wlan radio status (power state? connected? AP info?) /// wlan: get wlan radio status (power state? connected? AP info?)
WlanStatus, WlanStatus = 39,
/// wlan: get current config /// wlan: get current config
WlanGetConfig, WlanGetConfig = 40,
/// wlan: get net packet /// wlan: get net packet
WlanFetchPacket, WlanFetchPacket = 41,
/// wlan: send net packet /// wlan: send net packet
WlanSendPacket, WlanSendPacket = 42,
/// wlan: debug infos /// wlan: debug infos
WlanDebug, WlanDebug = 43,
/// wlan: get RSSI /// wlan: get RSSI
WlanRssi, WlanRssi = 44,
/// wlan: sync state (for resume) /// wlan: sync state (for resume)
WlanSyncState, WlanSyncState = 45,
/// sets the EC-side com interrupt mask /// sets the EC-side com interrupt mask
IntSetMask, IntSetMask = 46,
/// gets the EC-side com interrupt mask /// gets the EC-side com interrupt mask
IntGetMask, IntGetMask = 47,
/// acknowledges interrupts with the given mask /// acknowledges interrupts with the given mask
IntAck, IntAck = 48,
/// gets more details on the latest interrupt /// gets more details on the latest interrupt
IntFetchVector, IntFetchVector = 49,
} }
/// These enums indicate what kind of callback type we're sending. /// These enums indicate what kind of callback type we're sending.