Skip to content

Commit

Permalink
WIP: Add API to check if the driver is currently supported
Browse files Browse the repository at this point in the history
- [x] portio (Kernel not locked down)
- [ ] cros_ec Linux (/dev/cros_ec available)
- [ ] Windows (Kernel API available)

Signed-off-by: Daniel Schaefer <[email protected]>
  • Loading branch information
JohnAZoidberg committed Oct 30, 2023
1 parent aaee360 commit 405a1cc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions framework_lib/src/chromium_ec/portio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,18 @@ lazy_static! {
static ref INITIALIZED: Arc<Mutex<Initialized>> = Arc::new(Mutex::new(Initialized::NotYet));
}

fn _supported() -> bool {
#[cfg(feature = "linux_pio")]
unsafe {
if ioperm(EC_LPC_ADDR_HOST_ARGS as u64, 8 + 0xFF, 1) != 0 {
error!("ioperm failed. portio driver is likely block by Linux kernel lockdown mode");
return false;
}
}

true
}

#[cfg(not(feature = "linux_pio"))]
fn init() -> bool {
// Nothing to do for bare-metal (UEFI) port I/O
Expand Down

0 comments on commit 405a1cc

Please sign in to comment.