2
0

dsdt.rs 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. use core::{mem, slice};
  2. use sdt::SdtHeader;
  3. use {AcpiError, PhysicalMapping};
  4. /// Represents the Differentiated Definition Block (DSDT). This table contains the standard header,
  5. /// then an AML-encoded definition block.
  6. #[repr(C, packed)]
  7. pub struct Dsdt {
  8. header: SdtHeader,
  9. }
  10. impl Dsdt {
  11. pub fn validate(&self) -> Result<(), AcpiError> {
  12. self.header.validate(b"DSDT")
  13. }
  14. /// Get the AML stream encoded in this table so it can be safely accessed
  15. pub fn stream(&self) -> &[u8] {
  16. assert!(self.header.length() as usize > mem::size_of::<SdtHeader>());
  17. let stream_length = self.header.length() as usize - mem::size_of::<SdtHeader>();
  18. let stream_ptr =
  19. ((self as *const Dsdt as usize) + mem::size_of::<SdtHeader>()) as *const u8;
  20. unsafe { slice::from_raw_parts(stream_ptr, stream_length) }
  21. }
  22. }
  23. pub fn parse_dsdt(mapping: &PhysicalMapping<Dsdt>) -> Result<(), AcpiError> {
  24. (*mapping).validate()?;
  25. let stream = (*mapping).stream();
  26. // TODO: pass off to the AML parser
  27. unimplemented!();
  28. }