瀏覽代碼

Introduce legacy mode to deal with ACPI 1.0

I'm not sure if this is the right path to go down, but we can always rip
it out if it's not. ACPI 1.0 seems different enough that I think it's worth
separating out as a 'legacy' mode.
Isaac Woods 4 年之前
父節點
當前提交
51d24b3b2c
共有 1 個文件被更改,包括 20 次插入3 次删除
  1. 20 3
      aml/src/lib.rs

+ 20 - 3
aml/src/lib.rs

@@ -87,6 +87,8 @@ pub enum DebugVerbosity {
 
 #[derive(Debug)]
 pub struct AmlContext {
+    legacy_mode: bool,
+
     pub namespace: Namespace,
 
     /*
@@ -115,8 +117,21 @@ pub struct AmlContext {
 }
 
 impl AmlContext {
-    pub fn new(debug_verbosity: DebugVerbosity) -> AmlContext {
-        AmlContext {
+    /// Creates a new `AmlContext` - the central type in managing the AML tables. Only one of these should be
+    /// created, and it should be passed the DSDT and all SSDTs defined by the hardware.
+    ///
+    /// ### Legacy mode
+    /// If `true` is passed in `legacy_mode`, the library will try and remain compatible with a ACPI 1.0
+    /// implementation. The following changes/assumptions are made:
+    ///     - Two extra root namespaces are predefined: `\_PR` and `_TZ`
+    ///     - Processors are expected to be defined with `DefProcessor`, instead of `DefDevice`
+    ///     - Processors are expected to be found in `\_PR`, instead of `\_SB`
+    ///     - Thermal zones are expected to be found in `\_TZ`, instead of `\_SB`
+    pub fn new(legacy_mode: bool, debug_verbosity: DebugVerbosity) -> AmlContext {
+        use namespace::LevelType;
+
+        let mut context = AmlContext {
+            legacy_mode,
             namespace: Namespace::new(),
             local_0: None,
             local_1: None,
@@ -131,7 +146,9 @@ impl AmlContext {
             current_scope: AmlName::root(),
             scope_indent: 0,
             debug_verbosity,
-        }
+        };
+
+        context
     }
 
     pub fn parse_table(&mut self, stream: &[u8]) -> Result<(), AmlError> {