ソースを参照

Add a namespace level for legacy Processor objects

Legacy `Processor` objects can contain sub-objects, but also contain data,
so we need to define both a value and a namespace level.
Isaac Woods 4 年 前
コミット
47aaea6610
2 ファイル変更20 行追加6 行削除
  1. 3 0
      aml/src/namespace.rs
  2. 17 6
      aml/src/term_object.rs

+ 3 - 0
aml/src/namespace.rs

@@ -27,6 +27,9 @@ impl AmlHandle {
 pub enum LevelType {
     Scope,
     Device,
+    /// A legacy `Processor` object's sub-objects are stored in a level of this type. Modern tables define
+    /// processors as `Device`s.
+    Processor,
 }
 
 pub struct NamespaceLevel {

+ 17 - 6
aml/src/term_object.rs

@@ -372,10 +372,13 @@ where
                 .then(name_string())
                 .map_with_context(|(length, name), context| {
                     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));
+                    try_with_context!(
+                        context,
+                        context.namespace.add_level(resolved_name.clone(), LevelType::Device)
+                    );
 
                     let previous_scope = context.current_scope.clone();
-                    context.current_scope = try_with_context!(context, name.resolve(&context.current_scope));
+                    context.current_scope = resolved_name;
 
                     (Ok((length, previous_scope)), context)
                 })
@@ -408,16 +411,24 @@ where
                 .then(take_u32())
                 .then(take())
                 .map_with_context(|((((pkg_length, name), proc_id), pblk_address), pblk_len), context| {
+                    /*
+                     * Legacy `Processor` objects contain data within themselves, and can also have sub-objects,
+                     * so we add both a level for the sub-objects, and a value for the data.
+                     */
+                    let resolved_name = try_with_context!(context, name.resolve(&context.current_scope));
                     try_with_context!(
                         context,
-                        context.namespace.add_value_at_resolved_path(
-                            name.clone(),
-                            &context.current_scope,
+                        context.namespace.add_level(resolved_name.clone(), LevelType::Processor)
+                    );
+                    try_with_context!(
+                        context,
+                        context.namespace.add_value(
+                            resolved_name.clone(),
                             AmlValue::Processor { id: proc_id, pblk_address, pblk_len }
                         )
                     );
                     let previous_scope = context.current_scope.clone();
-                    context.current_scope = try_with_context!(context, name.resolve(&context.current_scope));
+                    context.current_scope = resolved_name;
 
                     (Ok((previous_scope, pkg_length)), context)
                 })