From f31d21847975d22112637248e13d0e1f3c4b2e12 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 3 Nov 2021 14:29:05 +0000 Subject: [PATCH] acpi_tables: aml: Implement Aml::append_aml_bytes() for Device For now it still relies on Aml::to_aml_bytes() for the children as not all structures have been ported. Signed-off-by: Rob Bradford --- acpi_tables/src/aml.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/acpi_tables/src/aml.rs b/acpi_tables/src/aml.rs index 15d196706..7547b5ca9 100644 --- a/acpi_tables/src/aml.rs +++ b/acpi_tables/src/aml.rs @@ -550,22 +550,19 @@ pub struct Device<'a> { } impl<'a> Aml for Device<'a> { - fn to_aml_bytes(&self) -> Vec { - let mut bytes = Vec::new(); - bytes.append(&mut self.path.to_aml_bytes()); + fn append_aml_bytes(&self, bytes: &mut Vec) { + let mut tmp = Vec::new(); + tmp.append(&mut self.path.to_aml_bytes()); for child in &self.children { - bytes.append(&mut child.to_aml_bytes()); + tmp.append(&mut child.to_aml_bytes()); } - let mut pkg_length = create_pkg_length(&bytes, true); - pkg_length.reverse(); - for byte in pkg_length { - bytes.insert(0, byte); - } + let mut pkg_length = create_pkg_length(&tmp, true); - bytes.insert(0, 0x82); /* DeviceOp */ - bytes.insert(0, 0x5b); /* ExtOpPrefix */ - bytes + bytes.push(0x5b); /* ExtOpPrefix */ + bytes.push(0x82); /* DeviceOp */ + bytes.append(&mut pkg_length); + bytes.append(&mut tmp); } }