8282
8383 global_lock_mutex : Handle ,
8484 registers : Arc < FixedRegisters < H > > ,
85- facs : PhysicalMapping < H , Facs > ,
85+ facs : Option < PhysicalMapping < H , Facs > > ,
8686}
8787
8888unsafe impl < H > Send for Interpreter < H > where H : Handler + Send { }
@@ -101,7 +101,7 @@ where
101101 handler : H ,
102102 dsdt_revision : u8 ,
103103 registers : Arc < FixedRegisters < H > > ,
104- facs : PhysicalMapping < H , Facs > ,
104+ facs : Option < PhysicalMapping < H , Facs > > ,
105105 ) -> Interpreter < H > {
106106 info ! ( "Initializing AML interpreter v{}" , env!( "CARGO_PKG_VERSION" ) ) ;
107107
@@ -139,8 +139,11 @@ where
139139
140140 let registers = platform. registers . clone ( ) ;
141141 let facs = {
142- let fadt = platform. tables . find_table :: < Fadt > ( ) . unwrap ( ) ;
143- unsafe { platform. handler . map_physical_region ( fadt. facs_address ( ) ?, mem:: size_of :: < Facs > ( ) ) }
142+ platform. tables . find_table :: < Fadt > ( ) . and_then ( |fadt| fadt. facs_address ( ) . ok ( ) ) . map (
143+ |facs_address| unsafe {
144+ platform. handler . map_physical_region ( facs_address, mem:: size_of :: < Facs > ( ) )
145+ } ,
146+ )
144147 } ;
145148
146149 let dsdt = platform. tables . dsdt ( ) ?;
@@ -313,8 +316,9 @@ where
313316 /// attempt to take ownership of the lock again. Returns `true` if we now have ownership of the
314317 /// lock, and `false` if we need to wait for firmware to release it.
315318 fn try_do_acquire_firmware_lock ( & self ) -> bool {
319+ let Some ( facs) = & self . facs else { return true } ;
316320 loop {
317- let global_lock = self . facs . global_lock . load ( Ordering :: Relaxed ) ;
321+ let global_lock = facs. global_lock . load ( Ordering :: Relaxed ) ;
318322 let is_owned = global_lock. get_bit ( 1 ) ;
319323
320324 /*
@@ -327,8 +331,7 @@ where
327331 new_value. set_bit ( 0 , is_owned) ;
328332 new_value. set_bit ( 1 , true ) ;
329333
330- if self
331- . facs
334+ if facs
332335 . global_lock
333336 . compare_exchange ( global_lock, new_value, Ordering :: AcqRel , Ordering :: Acquire )
334337 . is_ok ( )
@@ -350,15 +353,15 @@ where
350353 /// pending bit was set (this means the firmware is waiting to acquire the lock, and should be
351354 /// informed we're finished with it).
352355 fn do_release_firmware_lock ( & self ) -> bool {
356+ let Some ( facs) = & self . facs else { return false } ;
353357 loop {
354- let global_lock = self . facs . global_lock . load ( Ordering :: Relaxed ) ;
358+ let global_lock = facs. global_lock . load ( Ordering :: Relaxed ) ;
355359 let is_pending = global_lock. get_bit ( 0 ) ;
356360 let mut new_value = global_lock;
357361 new_value. set_bit ( 0 , false ) ;
358362 new_value. set_bit ( 1 , false ) ;
359363
360- if self
361- . facs
364+ if facs
362365 . global_lock
363366 . compare_exchange ( global_lock, new_value, Ordering :: AcqRel , Ordering :: Acquire )
364367 . is_ok ( )
0 commit comments