Skip to content

Commit 5185140

Browse files
committed
aml: fix package parsing (again)
1 parent 6d629b0 commit 5185140

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

aml/src/lib.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,21 @@ impl Interpreter {
170170
elements.push(object.clone());
171171
}
172172

173+
/*
174+
* We can end up completing a package's in-flight op in two circumstances:
175+
* - If the correct number of elements are supplied, we end up here
176+
* first, and then later in the block's finishing logic.
177+
* - If less elements are supplied, we end up in the block's finishing
178+
* logic to add some `Uninitialized`s, then go round again to complete
179+
* the in-flight operation.
180+
*
181+
* To make these consistent, we always remove the block here, making sure
182+
* we've finished it as a sanity check.
183+
*/
184+
assert_eq!(context.current_block.kind, BlockKind::Package);
185+
assert_eq!(context.peek(), Err(AmlError::RunOutOfStream));
186+
context.current_block = context.block_stack.pop().unwrap();
187+
173188
if let Some(prev_op) = context.in_flight.last_mut() {
174189
if prev_op.arguments.len() < prev_op.expected_arguments {
175190
prev_op.arguments.push(Argument::Object(Arc::new(Object::Package(elements))));
@@ -375,7 +390,8 @@ impl Interpreter {
375390
}
376391
}
377392

378-
context.current_block = context.block_stack.pop().unwrap();
393+
// XXX: don't remove the package's block. Refer to completion of
394+
// package ops for rationale here.
379395
continue;
380396
}
381397
BlockKind::IfThenBranch => {

tests/package.asl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,12 @@ DefinitionBlock("package.aml", "DSDT", 1, "RSACPI", "PACKGE", 1) {
1111
0x09,
1212
0x0a,
1313
})
14+
15+
Name(BAR, Package (5) {
16+
Package { 0x01, 0x02, 0x03 },
17+
Package { 0x04, 0x05, 0x06 },
18+
Package { 0x07, 0x08, 0x09 },
19+
Package { 0x0a, 0x0b, 0x0c },
20+
Package { 0x0d, 0x0e, 0x0f },
21+
})
1422
}

0 commit comments

Comments
 (0)