@@ -48,6 +48,9 @@ use object::{
48
48
use op_region:: { OpRegion , RegionHandler , RegionSpace } ;
49
49
use spinning_top:: Spinlock ;
50
50
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.
51
54
pub struct Interpreter < H >
52
55
where
53
56
H : Handler ,
58
61
context_stack : Spinlock < Vec < MethodContext > > ,
59
62
dsdt_revision : u8 ,
60
63
region_handlers : Spinlock < BTreeMap < RegionSpace , Box < dyn RegionHandler > > > ,
64
+ global_lock_mutex : Handle ,
61
65
}
62
66
63
67
unsafe impl < H > Send for Interpreter < H > where H : Handler + Send { }
@@ -74,13 +78,17 @@ where
74
78
/// already, use [`Interpreter::new_from_tables`] instead.
75
79
pub fn new ( handler : H , dsdt_revision : u8 ) -> Interpreter < H > {
76
80
info ! ( "Initializing AML interpreter v{}" , env!( "CARGO_PKG_VERSION" ) ) ;
81
+
82
+ let global_lock_mutex = handler. create_mutex ( ) ;
83
+
77
84
Interpreter {
78
85
handler,
79
- namespace : Spinlock :: new ( Namespace :: new ( ) ) ,
86
+ namespace : Spinlock :: new ( Namespace :: new ( global_lock_mutex ) ) ,
80
87
object_token : Spinlock :: new ( unsafe { ObjectToken :: create_interpreter_token ( ) } ) ,
81
88
context_stack : Spinlock :: new ( Vec :: new ( ) ) ,
82
89
dsdt_revision,
83
90
region_handlers : Spinlock :: new ( BTreeMap :: new ( ) ) ,
91
+ global_lock_mutex,
84
92
}
85
93
}
86
94
0 commit comments