acpi_tables: aml: Implement Aml::append_aml_bytes() for number types

Including Byte, Word, DWord and QWord.

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 4bd0ac6623
commit 395929f1d4

View File

@ -98,40 +98,36 @@ impl From<&str> for Path {
pub type Byte = u8;
impl Aml for Byte {
fn to_aml_bytes(&self) -> Vec<u8> {
let mut bytes = vec![0x0a]; /* BytePrefix */
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) {
bytes.push(0x0a); /* BytePrefix */
bytes.push(*self);
bytes
}
}
pub type Word = u16;
impl Aml for Word {
fn to_aml_bytes(&self) -> Vec<u8> {
let mut bytes = vec![0x0bu8]; /* WordPrefix */
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) {
bytes.push(0x0b); /* WordPrefix */
bytes.append(&mut self.to_le_bytes().to_vec());
bytes
}
}
pub type DWord = u32;
impl Aml for DWord {
fn to_aml_bytes(&self) -> Vec<u8> {
let mut bytes = vec![0x0c]; /* DWordPrefix */
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) {
bytes.push(0x0c); /* DWordPrefix */
bytes.append(&mut self.to_le_bytes().to_vec());
bytes
}
}
pub type QWord = u64;
impl Aml for QWord {
fn to_aml_bytes(&self) -> Vec<u8> {
let mut bytes = vec![0x0e]; /* QWordPrefix */
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) {
bytes.push(0x0e); /* QWordPrefix */
bytes.append(&mut self.to_le_bytes().to_vec());
bytes
}
}