| 284 | } |
| 285 | |
| 286 | pub fn check_mem_magic(&self) -> EcResult<()> { |
| 287 | match self.read_memory(EC_MEMMAP_ID, 2) { |
| 288 | Some(ec_id) => { |
| 289 | if ec_id.len() != 2 { |
| 290 | Err(EcError::DeviceError(format!( |
| 291 | " Unexpected length returned: {:?}", |
| 292 | ec_id.len() |
| 293 | ))) |
| 294 | } else if ec_id[0] != b'E' || ec_id[1] != b'C' { |
| 295 | Err(EcError::DeviceError( |
| 296 | "This machine doesn't look like it has a Framework EC".to_string(), |
| 297 | )) |
| 298 | } else { |
| 299 | Ok(()) |
| 300 | } |
| 301 | } |
| 302 | None => Err(EcError::DeviceError( |
| 303 | "Failed to read EC ID from memory map".to_string(), |
| 304 | )), |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | pub fn cmd_version_supported(&self, cmd: u32, version: u8) -> EcResult<bool> { |
| 309 | let res = EcRequestGetCmdVersionsV1 { cmd }.send_command(self); |