Browse Source

Parse DefProcessor

Isaac Woods 5 years ago
parent
commit
6ec412afdb
2 changed files with 30 additions and 0 deletions
  1. 1 0
      aml_parser/src/opcode.rs
  2. 29 0
      aml_parser/src/term_object.rs

+ 1 - 0
aml_parser/src/opcode.rs

@@ -29,6 +29,7 @@ pub const EXT_REVISION_OP: u8 = 0x30;
 pub const EXT_DEF_OP_REGION_OP: u8 = 0x80;
 pub const EXT_DEF_FIELD_OP: u8 = 0x81;
 pub const EXT_DEF_DEVICE_OP: u8 = 0x82;
+pub const EXT_DEF_PROCESSOR_OP: u8 = 0x83;
 
 pub const EXT_OPCODE_PREFIX: u8 = 0x5b;
 

+ 29 - 0
aml_parser/src/term_object.rs

@@ -83,6 +83,9 @@ where
             def_field(),
             def_method(),
             def_device(),
+            def_processor(),
+        ),
+    )
 }
 
 pub fn def_name<'a, 'c>() -> impl Parser<'a, 'c, ()>
@@ -377,6 +380,32 @@ where
 {
     choice!(data_ref_object(), name_string().map(|string| Ok(AmlValue::String(string))))
 }
+
+pub fn def_processor<'a, 'c>() -> impl Parser<'a, 'c, ()>
+where
+    'c: 'a,
+{
+    /*
+     * DefProcessor := ExtOpPrefix 0x83 PkgLength NameString ProcID PblkAddress PblkLen TermList
+     * ProcID := ByteData
+     * PblkAddress := DWordData
+     * PblkLen := ByteData
+     */
+    // TODO: do something sensible with the result of this
+    ext_opcode(opcode::EXT_DEF_PROCESSOR_OP)
+        .then(comment_scope(
+            "DefProcessor",
+            pkg_length().then(name_string()).then(take()).then(take_u32()).then(take()).feed(
+                |((((pkg_length, name), proc_id), pblk_address), pblk_len)| {
+                    trace!("Defined processor called {} with id {}", name, proc_id);
+                    term_list(pkg_length).map(move |result| {
+                        Ok((result, name.clone(), proc_id, pblk_address, pblk_len))
+                    })
+                },
+            ),
+        ))
+        .discard_result()
+}
 pub fn term_arg<'a, 'c>() -> impl Parser<'a, 'c, AmlValue>
 where
     'c: 'a,