Skip to content

Commit e28f13d

Browse files
committed
aml: fix handling of names within package definitions
To match NT's behaviour, we should just evaluate a namestring within a package definition to a string object. Also handles this change in PRT handling.
1 parent aa02318 commit e28f13d

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/aml/mod.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,15 +1171,22 @@ where
11711171

11721172
/*
11731173
* The desired behaviour when we encounter a name at the top-level differs
1174-
* depending on the context we're in. There are certain places where we want to
1175-
* evaluate things like methods and field units, and others where we simply
1176-
* want to reference the name (such as inside package definitions). In the
1177-
* latter case, we also allow undefined names to be used, and will resolve them
1178-
* at the time of use.
1174+
* depending on the context we're in.
1175+
* - Generally, we want to attempt to evaluate names to objects that should have
1176+
* already been defined. There are generally no forward definitions in AML.
1177+
* - In `CondRefOf`, we need to handle a name not referring to any object. For
1178+
* this, we emit an `Unresolved` reference.
1179+
* - In package definitions, all objects referred to by name should be referred
1180+
* to by a string. This is not well defined by the specification, but matches
1181+
* expected behaviour of other interpreters, and is most useful for downstream
1182+
* users.
11791183
*/
1180-
let do_not_resolve = context.current_block.kind == BlockKind::Package
1181-
|| context.in_flight.last().map(|op| op.op == Opcode::CondRefOf).unwrap_or(false);
1182-
if do_not_resolve {
1184+
if context.current_block.kind == BlockKind::Package {
1185+
context
1186+
.last_op()?
1187+
.arguments
1188+
.push(Argument::Object(Object::String(name.to_string()).wrap()));
1189+
} else if context.in_flight.last().map(|op| op.op == Opcode::CondRefOf).unwrap_or(false) {
11831190
let object = self.namespace.lock().search(&name, &context.current_scope);
11841191
match object {
11851192
Ok((_, object)) => {

src/aml/pci_routing.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::aml::{
44
Interpreter,
55
Operation,
66
namespace::AmlName,
7-
object::{Object, ReferenceKind},
7+
object::Object,
88
resource::{self, InterruptPolarity, InterruptTrigger, Resource},
99
};
1010
use alloc::{vec, vec::Vec};
@@ -121,8 +121,7 @@ impl PciRoutingTable {
121121
route_type: PciRouteType::Gsi(gsi as u32),
122122
});
123123
}
124-
Object::Reference { kind: ReferenceKind::Unresolved, ref inner } => {
125-
let Object::String(ref name) = **inner else { panic!() };
124+
Object::String(ref name) => {
126125
let link_object_name = interpreter
127126
.namespace
128127
.lock()

0 commit comments

Comments
 (0)