Selaa lähdekoodia

Remove Device variant of AmlValue and add scopes and devices to new namespace

In the new namespace, devices and scopes need to be registed as "levels"
before objects can be added to them. Devices also no longer exist as
`AmlValue`s, as they don't exist as leaf objects.
Isaac Woods 5 vuotta sitten
vanhempi
commit
c8ee3930c7
2 muutettua tiedostoa jossa 9 lisäystä ja 12 poistoa
  1. 9 9
      aml/src/term_object.rs
  2. 0 3
      aml/src/value.rs

+ 9 - 9
aml/src/term_object.rs

@@ -1,7 +1,7 @@
 use crate::{
     misc::{arg_obj, local_obj},
     name_object::{name_seg, name_string},
-    namespace::AmlName,
+    namespace::{AmlName, LevelType},
     opcode::{self, ext_opcode, opcode},
     parser::{
         choice,
@@ -132,6 +132,12 @@ where
                 .map_with_context(|(length, name), context| {
                     let previous_scope = context.current_scope.clone();
                     context.current_scope = try_with_context!(context, name.resolve(&context.current_scope));
+
+                    try_with_context!(
+                        context,
+                        context.namespace.add_level(context.current_scope.clone(), LevelType::Scope)
+                    );
+
                     (Ok((length, previous_scope)), context)
                 })
                 .feed(|(pkg_length, previous_scope)| {
@@ -352,14 +358,8 @@ where
             pkg_length()
                 .then(name_string())
                 .map_with_context(|(length, name), context| {
-                    try_with_context!(
-                        context,
-                        context.namespace.add_at_resolved_path(
-                            name.clone(),
-                            &context.current_scope,
-                            AmlValue::Device
-                        )
-                    );
+                    let resolved_name = try_with_context!(context, name.clone().resolve(&context.current_scope));
+                    try_with_context!(context, context.namespace.add_level(resolved_name, LevelType::Device));
 
                     let previous_scope = context.current_scope.clone();
                     context.current_scope = try_with_context!(context, name.resolve(&context.current_scope));

+ 0 - 3
aml/src/value.rs

@@ -99,7 +99,6 @@ pub enum AmlType {
     /// Handle to a definition block handle. Returned by the `Load` operator.
     DdbHandle,
     DebugObject,
-    Device,
     Event,
     FieldUnit,
     Integer,
@@ -122,7 +121,6 @@ pub enum AmlValue {
     String(String),
     OpRegion { region: RegionSpace, offset: u64, length: u64 },
     Field { region: AmlName, flags: FieldFlags, offset: u64, length: u64 },
-    Device,
     Method { flags: MethodFlags, code: Vec<u8> },
     Buffer { bytes: Vec<u8>, size: u64 },
     Processor { id: u8, pblk_address: u32, pblk_len: u8 },
@@ -139,7 +137,6 @@ impl AmlValue {
             AmlValue::String(_) => AmlType::String,
             AmlValue::OpRegion { .. } => AmlType::OpRegion,
             AmlValue::Field { .. } => AmlType::FieldUnit,
-            AmlValue::Device => AmlType::Device,
             AmlValue::Method { .. } => AmlType::Method,
             AmlValue::Buffer { .. } => AmlType::Buffer,
             AmlValue::Processor { .. } => AmlType::Processor,