@@ -48,6 +48,9 @@ use object::{
4848use op_region:: { OpRegion , RegionHandler , RegionSpace } ;
4949use spinning_top:: Spinlock ;
5050
51+ /// `Interpreter` implements a virtual machine for the dynamic AML bytecode. It can be used by a
52+ /// host operating system to load tables containing AML bytecode (generally the DSDT and SSDTs) and
53+ /// will then manage the AML namespace and all objects created during the life of the system.
5154pub struct Interpreter < H >
5255where
5356 H : Handler ,
5861 context_stack : Spinlock < Vec < MethodContext > > ,
5962 dsdt_revision : u8 ,
6063 region_handlers : Spinlock < BTreeMap < RegionSpace , Box < dyn RegionHandler > > > ,
64+ global_lock_mutex : Handle ,
6165}
6266
6367unsafe impl < H > Send for Interpreter < H > where H : Handler + Send { }
@@ -74,13 +78,17 @@ where
7478 /// already, use [`Interpreter::new_from_tables`] instead.
7579 pub fn new ( handler : H , dsdt_revision : u8 ) -> Interpreter < H > {
7680 info ! ( "Initializing AML interpreter v{}" , env!( "CARGO_PKG_VERSION" ) ) ;
81+
82+ let global_lock_mutex = handler. create_mutex ( ) ;
83+
7784 Interpreter {
7885 handler,
79- namespace : Spinlock :: new ( Namespace :: new ( ) ) ,
86+ namespace : Spinlock :: new ( Namespace :: new ( global_lock_mutex ) ) ,
8087 object_token : Spinlock :: new ( unsafe { ObjectToken :: create_interpreter_token ( ) } ) ,
8188 context_stack : Spinlock :: new ( Vec :: new ( ) ) ,
8289 dsdt_revision,
8390 region_handlers : Spinlock :: new ( BTreeMap :: new ( ) ) ,
91+ global_lock_mutex,
8492 }
8593 }
8694
0 commit comments