Skip to content

Commit 44c0a12

Browse files
committed
AML: add predefined global lock mutex object to the namespace
1 parent ed550f6 commit 44c0a12

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/aml/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ use object::{
4848
use op_region::{OpRegion, RegionHandler, RegionSpace};
4949
use 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.
5154
pub struct Interpreter<H>
5255
where
5356
H: Handler,
@@ -58,6 +61,7 @@ where
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

6367
unsafe 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

src/aml/namespace.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::{
22
AmlError,
3+
Handle,
34
object::{Object, ObjectType, WrappedObject},
45
};
56
use alloc::{
@@ -19,7 +20,7 @@ pub struct Namespace {
1920

2021
impl Namespace {
2122
/// Create a new AML namespace, with the expected pre-defined objects.
22-
pub fn new() -> Namespace {
23+
pub fn new(global_lock_mutex: Handle) -> Namespace {
2324
let mut namespace = Namespace { root: NamespaceLevel::new(NamespaceLevelKind::Scope) };
2425

2526
namespace.add_level(AmlName::from_str("\\_GPE").unwrap(), NamespaceLevelKind::Scope).unwrap();
@@ -28,6 +29,13 @@ impl Namespace {
2829
namespace.add_level(AmlName::from_str("\\_PR").unwrap(), NamespaceLevelKind::Scope).unwrap();
2930
namespace.add_level(AmlName::from_str("\\_TZ").unwrap(), NamespaceLevelKind::Scope).unwrap();
3031

32+
namespace
33+
.insert(
34+
AmlName::from_str("\\_GL").unwrap(),
35+
Object::Mutex { mutex: global_lock_mutex, sync_level: 0 }.wrap(),
36+
)
37+
.unwrap();
38+
3139
/*
3240
* In the dark ages of ACPI 1.0, before `\_OSI`, `\_OS` was used to communicate to the firmware which OS
3341
* was running. This was predictably not very good, and so was replaced in ACPI 3.0 with `_OSI`, which
@@ -122,8 +130,6 @@ impl Namespace {
122130
*/
123131
namespace.insert(AmlName::from_str("\\_REV").unwrap(), Object::Integer(2).wrap()).unwrap();
124132

125-
// TODO: _GL
126-
127133
namespace
128134
}
129135

0 commit comments

Comments
 (0)