mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-03-20 07:58:55 +00:00
acpi_tables: Add support for Buffer objects
These are necessary to populate "_MAT" entries for CPU devices. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
1da0ff395d
commit
e51ebe045f
@ -1109,6 +1109,34 @@ impl<'a> Aml for MethodCall<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Buffer {
|
||||
data: Vec<u8>,
|
||||
}
|
||||
|
||||
impl Buffer {
|
||||
pub fn new(data: Vec<u8>) -> Self {
|
||||
Buffer { data }
|
||||
}
|
||||
}
|
||||
|
||||
impl Aml for Buffer {
|
||||
fn to_aml_bytes(&self) -> Vec<u8> {
|
||||
let mut bytes = Vec::new();
|
||||
bytes.extend_from_slice(&self.data.len().to_aml_bytes());
|
||||
bytes.extend_from_slice(&self.data);
|
||||
|
||||
let mut pkg_length = create_pkg_length(&bytes, true);
|
||||
pkg_length.reverse();
|
||||
for byte in pkg_length {
|
||||
bytes.insert(0, byte);
|
||||
}
|
||||
|
||||
bytes.insert(0, 0x11); /* BufferOp */
|
||||
|
||||
bytes
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@ -1816,4 +1844,27 @@ mod tests {
|
||||
);
|
||||
assert_eq!(&methods[..], &test_data[..])
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_buffer() {
|
||||
/*
|
||||
Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table Entry
|
||||
{
|
||||
0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 /* ........ */
|
||||
})
|
||||
*/
|
||||
let buffer_data = [
|
||||
0x08, 0x5F, 0x4D, 0x41, 0x54, 0x11, 0x0B, 0x0A, 0x08, 0x00, 0x08, 0x00, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00,
|
||||
];
|
||||
|
||||
assert_eq!(
|
||||
Name::new(
|
||||
"_MAT".into(),
|
||||
&Buffer::new(vec![0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00])
|
||||
)
|
||||
.to_aml_bytes(),
|
||||
&buffer_data[..]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user