浏览代码

Remove artefacts of AML parser from acpi crate

Isaac Woods 6 年之前
父节点
当前提交
d59de7fc86
共有 3 个文件被更改,包括 17 次插入32 次删除
  1. 3 20
      acpi/src/fadt.rs
  2. 10 10
      acpi/src/lib.rs
  3. 4 2
      acpi/src/sdt.rs

+ 3 - 20
acpi/src/fadt.rs

@@ -1,12 +1,4 @@
-use crate::{
-    aml::{parse_aml_table, AmlTable},
-    sdt::{self, SdtHeader},
-    Acpi,
-    AcpiError,
-    AcpiHandler,
-    GenericAddress,
-    PhysicalMapping,
-};
+use crate::{sdt::SdtHeader, Acpi, AcpiError, AcpiHandler, GenericAddress, PhysicalMapping};
 
 /// Represents the Fixed ACPI Description Table (FADT). This table contains various fixed hardware
 /// details, such as the addresses of the hardware register blocks. It also contains a pointer to
@@ -91,20 +83,11 @@ where
     fadt.header.validate(b"FACP")?;
 
     // TODO more generic typesafe way of accessing the x_ fields
-    let dsdt_physical_address: usize = if fadt.header.revision() > 1 && fadt.x_dsdt_address != 0 {
+    acpi.dsdt_address = Some(if fadt.header.revision() > 1 && fadt.x_dsdt_address != 0 {
         fadt.x_dsdt_address as usize
     } else {
         fadt.dsdt_address as usize
-    };
-
-    // Parse the DSDT
-    let dsdt_header = sdt::peek_at_sdt_header(handler, dsdt_physical_address);
-    let dsdt_mapping = handler
-        .map_physical_region::<AmlTable>(dsdt_physical_address, dsdt_header.length() as usize);
-    if let Err(error) = parse_aml_table(acpi, handler, &dsdt_mapping, b"DSDT") {
-        error!("Failed to parse DSDT: {:?}. At this stage, this is expected, but should be fatal in the future", error);
-    }
-    handler.unmap_physical_region(dsdt_mapping);
+    });
 
     Ok(())
 }

+ 10 - 10
acpi/src/lib.rs

@@ -35,7 +35,6 @@ extern crate log;
 extern crate alloc;
 extern crate bit_field;
 
-mod aml;
 mod fadt;
 pub mod handler;
 mod hpet;
@@ -46,14 +45,13 @@ mod rsdp_search;
 mod sdt;
 
 pub use crate::{
-    aml::AmlError,
     handler::{AcpiHandler, PhysicalMapping},
     madt::MadtError,
     rsdp_search::search_for_rsdp_bios,
 };
 
-use crate::{aml::AmlValue, interrupt::InterruptModel, rsdp::Rsdp, sdt::SdtHeader};
-use alloc::{collections::BTreeMap, string::String, vec::Vec};
+use crate::{interrupt::InterruptModel, rsdp::Rsdp, sdt::SdtHeader};
+use alloc::vec::Vec;
 use core::mem;
 
 #[derive(Debug)]
@@ -69,8 +67,6 @@ pub enum AcpiError {
     SdtInvalidTableId([u8; 4]),
     SdtInvalidChecksum([u8; 4]),
 
-    InvalidAmlTable([u8; 4], AmlError),
-
     InvalidMadt(MadtError),
 }
 
@@ -125,7 +121,6 @@ impl Processor {
 #[derive(Debug)]
 pub struct Acpi {
     acpi_revision: u8,
-    namespace: BTreeMap<String, AmlValue>,
     boot_processor: Option<Processor>,
     application_processors: Vec<Processor>,
 
@@ -133,6 +128,12 @@ pub struct Acpi {
     /// hardware. For simplicity and because hardware practically will only support one model, we
     /// just error in cases that the tables detail more than one.
     interrupt_model: Option<InterruptModel>,
+
+    /// The physical address of the DSDT, if we manage to find it.
+    dsdt_address: Option<usize>,
+
+    /// The physical addresses of the SSDTs, if there are any,
+    ssdt_addresses: Vec<usize>,
 }
 
 impl Acpi {
@@ -211,10 +212,11 @@ where
 {
     let mut acpi = Acpi {
         acpi_revision: revision,
-        namespace: BTreeMap::new(),
         boot_processor: None,
         application_processors: Vec::new(),
         interrupt_model: None,
+        dsdt_address: None,
+        ssdt_addresses: Vec::with_capacity(0),
     };
 
     let header = sdt::peek_at_sdt_header(handler, physical_address);
@@ -253,8 +255,6 @@ where
         }
     }
 
-    info!("Parsed namespace: {:#?}", acpi.namespace);
-
     handler.unmap_physical_region(mapping);
     Ok(acpi)
 }

+ 4 - 2
acpi/src/sdt.rs

@@ -137,8 +137,8 @@ where
     H: AcpiHandler,
 {
     let header = peek_at_sdt_header(handler, physical_address);
-    info!(
-        "Dispatching SDT with signature {:?} and length {:?}",
+    trace!(
+        "Found ACPI table with signature {:?} and length {:?}",
         header.signature(),
         header.length()
     );
@@ -169,6 +169,8 @@ where
             handler.unmap_physical_region(madt_mapping);
         }
 
+        "SSDT" => acpi.ssdt_addresses.push(physical_address),
+
         signature => {
             /*
              * We don't recognise this signature. Early on, this probably just means we don't