File tree 2 files changed +24
-11
lines changed
framework_lib/src/chromium_ec 2 files changed +24
-11
lines changed Original file line number Diff line number Diff line change @@ -90,14 +90,6 @@ fn init() -> bool {
90
90
Initialized :: NotYet => { }
91
91
}
92
92
93
- // First try on MEC
94
- portio_mec:: init ( ) ;
95
- let ec_id = portio_mec:: transfer_read ( MEC_MEMMAP_OFFSET + EC_MEMMAP_ID , 2 ) ;
96
- if ec_id[ 0 ] == b'E' && ec_id[ 1 ] == b'C' {
97
- * init = Initialized :: SucceededMec ;
98
- return true ;
99
- }
100
-
101
93
// In Linux userspace has to first request access to ioports
102
94
// TODO: Close these again after we're done
103
95
#[ cfg( target_os = "linux" ) ]
@@ -106,12 +98,25 @@ fn init() -> bool {
106
98
* init = Initialized :: Failed ;
107
99
return false ;
108
100
}
101
+
102
+ // First try on MEC
103
+ if !portio_mec:: init ( ) {
104
+ * init = Initialized :: Failed ;
105
+ return false ;
106
+ }
107
+ let ec_id = portio_mec:: transfer_read ( MEC_MEMMAP_OFFSET + EC_MEMMAP_ID , 2 ) ;
108
+ if ec_id[ 0 ] == b'E' && ec_id[ 1 ] == b'C' {
109
+ * init = Initialized :: SucceededMec ;
110
+ return true ;
111
+ }
112
+
109
113
#[ cfg( target_os = "linux" ) ]
110
114
unsafe {
111
115
// 8 for request/response header, 0xFF for response
112
116
let res = ioperm ( EC_LPC_ADDR_HOST_ARGS as u64 , 8 + 0xFF , 1 ) ;
113
117
if res != 0 {
114
118
error ! ( "ioperm failed. portio driver is likely block by Linux kernel lockdown mode" ) ;
119
+ * init = Initialized :: Failed ;
115
120
return false ;
116
121
}
117
122
Original file line number Diff line number Diff line change @@ -22,12 +22,20 @@ const _MEC_LPC_DATA_REGISTER1: u16 = 0x0805;
22
22
const MEC_LPC_DATA_REGISTER2 : u16 = 0x0806 ;
23
23
const _MEC_LPC_DATA_REGISTER3: u16 = 0x0807 ;
24
24
25
- pub fn init ( ) {
25
+ pub fn init ( ) -> bool {
26
26
#[ cfg( target_os = "linux" ) ]
27
27
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 ) ;
30
36
}
37
+
38
+ true
31
39
}
32
40
33
41
// TODO: Create a wrapper
You can’t perform that action at this time.
0 commit comments