acpi_tables: aml: Implement Aml::append_aml_bytes() for Scope

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 <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2021-11-03 14:29:05 +00:00
parent f31d218479
commit 95e63d5f44

View File

@ -578,21 +578,18 @@ pub struct Scope<'a> {
} }
impl<'a> Aml for Scope<'a> { impl<'a> Aml for Scope<'a> {
fn to_aml_bytes(&self) -> Vec<u8> { fn append_aml_bytes(&self, bytes: &mut Vec<u8>) {
let mut bytes = Vec::new(); let mut tmp = Vec::new();
bytes.append(&mut self.path.to_aml_bytes()); tmp.append(&mut self.path.to_aml_bytes());
for child in &self.children { 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); let mut pkg_length = create_pkg_length(&tmp, true);
pkg_length.reverse();
for byte in pkg_length {
bytes.insert(0, byte);
}
bytes.insert(0, 0x10); /* ScopeOp */ bytes.push(0x10); /* ScopeOp */
bytes bytes.append(&mut pkg_length);
bytes.append(&mut tmp)
} }
} }