From c76fd6df21c3ca6a0740ba55b0901ce8bc8c567d Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 22 Oct 2019 18:47:58 +0100 Subject: [PATCH] acpi_tables: aml: Implement AML Zero, One, Ones These are special encodings for representing zero, one or all ones in a single byte. Signed-off-by: Rob Bradford --- acpi_tables/src/aml.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/acpi_tables/src/aml.rs b/acpi_tables/src/aml.rs index 86710d065..e44c02cfc 100644 --- a/acpi_tables/src/aml.rs +++ b/acpi_tables/src/aml.rs @@ -7,6 +7,33 @@ pub trait Aml { fn to_bytes(&self) -> Vec; } +pub const ZERO: Zero = Zero {}; +pub struct Zero {} + +impl Aml for Zero { + fn to_bytes(&self) -> Vec { + vec![0u8] + } +} + +pub const ONE: One = One {}; +pub struct One {} + +impl Aml for One { + fn to_bytes(&self) -> Vec { + vec![1u8] + } +} + +pub const ONES: Ones = Ones {}; +pub struct Ones {} + +impl Aml for Ones { + fn to_bytes(&self) -> Vec { + vec![0xffu8] + } +} + pub struct Path { root: bool, name_parts: Vec<[u8; 4]>,