Skip to content

Commit 05c5578

Browse files
alnyanIsaacWoods
authored andcommitted
AML: Fix DefPackage len < NumElements failing
1 parent 2010bb8 commit 05c5578

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

aml/src/expression.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,10 +624,15 @@ where
624624
package_contents.push(value);
625625
}
626626

627-
if package_contents.len() != num_elements as usize {
627+
// ACPI6.2, §19.6.101 specifies that if NumElements is present and is greater
628+
// than the number of entries in the PackageList, the default entry of type
629+
// Uninitialized is used
630+
if package_contents.len() > num_elements as usize {
628631
return Err((input, context, Propagate::Err(AmlError::MalformedPackage)));
629632
}
630633

634+
package_contents.resize(num_elements as usize, AmlValue::Uninitialized);
635+
631636
Ok((input, context, AmlValue::Package(package_contents)))
632637
}
633638
}),

aml/src/value.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ impl fmt::Debug for MethodCode {
174174

175175
#[derive(Clone, Debug)]
176176
pub enum AmlValue {
177+
Uninitialized,
177178
Boolean(bool),
178179
Integer(u64),
179180
String(String),
@@ -246,6 +247,7 @@ impl AmlValue {
246247

247248
pub fn type_of(&self) -> AmlType {
248249
match self {
250+
AmlValue::Uninitialized => AmlType::Uninitialized,
249251
AmlValue::Boolean(_) => AmlType::Integer,
250252
AmlValue::Integer(_) => AmlType::Integer,
251253
AmlValue::String(_) => AmlType::String,

0 commit comments

Comments
 (0)