From ee3e0e6257750312ca459c0a92c13bc5500fecde Mon Sep 17 00:00:00 2001 From: Rajas Paranjpe <52586855+ChocolateLoverRaj@users.noreply.github.com> Date: Fri, 17 May 2024 16:01:36 -0700 Subject: [PATCH] Get EC features --- crosec/src/commands/get_features.rs | 15 +++++++++++++++ crosec/src/commands/mod.rs | 2 ++ ectool/src/main.rs | 9 ++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 crosec/src/commands/get_features.rs diff --git a/crosec/src/commands/get_features.rs b/crosec/src/commands/get_features.rs new file mode 100644 index 0000000..a8a83ea --- /dev/null +++ b/crosec/src/commands/get_features.rs @@ -0,0 +1,15 @@ +use bytemuck::{Pod, Zeroable}; +use crate::{ec_command, EcCmdResult, EcInterface}; +use crate::commands::CrosEcCmd; + +#[repr(C)] +#[derive(Pod, Zeroable, Copy, Clone)] +struct EcResponseGetFeatures { + flags: u64, +} + +pub fn ec_cmd_get_features() -> EcCmdResult { + let response = ec_command(CrosEcCmd::GetFeatures, 0, Default::default(), EcInterface::Default)?; + let response = bytemuck::from_bytes::(&response); + Ok(response.flags) +} \ No newline at end of file diff --git a/crosec/src/commands/mod.rs b/crosec/src/commands/mod.rs index cdc48b0..a0c1016 100644 --- a/crosec/src/commands/mod.rs +++ b/crosec/src/commands/mod.rs @@ -9,6 +9,7 @@ pub enum CrosEcCmd { GetChipInfo = 0x0005, GetBoardVersion = 0x0006, GetCmdVersions = 0x0008, + GetFeatures = 0x000D, SetFanTargetRpm = 0x0021, } @@ -18,3 +19,4 @@ pub mod version; pub mod board_version; pub mod set_fan_target_rpm; pub mod get_cmd_versions; +pub mod get_features; diff --git a/ectool/src/main.rs b/ectool/src/main.rs index 6a1d52a..695b1f3 100644 --- a/ectool/src/main.rs +++ b/ectool/src/main.rs @@ -4,6 +4,7 @@ use crosec::commands::{CrosEcCmd, get_chip_info::ec_cmd_get_chip_info, hello::ec use crosec::commands::board_version::ec_cmd_board_version; use crosec::commands::get_cmd_versions::ec_cmd_get_cmd_versions; use num_traits::cast::FromPrimitive; +use crosec::commands::get_features::ec_cmd_get_features; use crosec::commands::set_fan_target_rpm::ec_cmd_set_fan_target_rpm; #[derive(Parser)] @@ -31,7 +32,9 @@ enum Commands { rpm: u32, #[arg()] index: Option - } + }, + /// Get supported features + GetFeatures } fn main() -> Result<()> { @@ -88,6 +91,10 @@ fn main() -> Result<()> { println!("Set RPM to {rpm} for all fans"); } } + }, + Commands::GetFeatures => { + let features = ec_cmd_get_features()?; + println!("EC supported features: {features:#b}"); } }