Skip to content

Commit 3a06a94

Browse files
committed
mec init: Fail if ioperm didn't succeed
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent 6a64d07 commit 3a06a94

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

framework_lib/src/chromium_ec/portio_mec.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ const _MEC_LPC_DATA_REGISTER3: u16 = 0x0807;
2525
pub fn init() {
2626
#[cfg(target_os = "linux")]
2727
unsafe {
28-
ioperm(EC_LPC_ADDR_HOST_DATA as u64, 8, 1);
29-
ioperm(MEC_LPC_ADDRESS_REGISTER0 as u64, 10, 1);
28+
println!("Init MEC");
29+
let res = ioperm(EC_LPC_ADDR_HOST_DATA as u64, 8, 1);
30+
if res != 0 {
31+
error!("ioperm failed. portio driver is likely block by Linux kernel lockdown mode");
32+
return false;
33+
}
34+
let res = ioperm(MEC_LPC_ADDRESS_REGISTER0 as u64, 10, 1);
35+
assert_eq!(res, 0);
3036
}
3137
}
3238

0 commit comments

Comments
 (0)