Browse Source

Implement DefLGreaterEqual

Isaac Woods 4 years ago
parent
commit
ecf95e7af7
2 changed files with 23 additions and 0 deletions
  1. 2 0
      aml/src/opcode.rs
  2. 21 0
      aml/src/type2.rs

+ 2 - 0
aml/src/opcode.rs

@@ -47,8 +47,10 @@ pub const DEF_SHIFT_LEFT: u8 = 0x79;
 pub const DEF_SHIFT_RIGHT: u8 = 0x7a;
 pub const DEF_AND_OP: u8 = 0x7b;
 pub const DEF_L_OR_OP: u8 = 0x91;
+pub const DEF_L_NOT_OP: u8 = 0x92;
 pub const DEF_L_EQUAL_OP: u8 = 0x93;
 pub const DEF_L_GREATER_OP: u8 = 0x94;
+pub const DEF_L_LESS_OP: u8 = 0x95;
 
 /*
  * Miscellaneous objects

+ 21 - 0
aml/src/type2.rs

@@ -48,6 +48,7 @@ where
             make_parser_concrete!(def_buffer()),
             make_parser_concrete!(def_l_equal()),
             make_parser_concrete!(def_l_greater()),
+            make_parser_concrete!(def_l_greater_equal()),
             make_parser_concrete!(def_l_or()),
             make_parser_concrete!(def_package()),
             make_parser_concrete!(def_shift_left()),
@@ -167,6 +168,26 @@ where
         .map(|((), result)| Ok(result))
 }
 
+fn def_l_greater_equal<'a, 'c>() -> impl Parser<'a, 'c, AmlValue>
+where
+    'c: 'a,
+{
+    /*
+     * DefLGreaterEqual := LNotOp(0x92) LLessOp(0x95) Operand Operand
+     */
+    opcode(opcode::DEF_L_NOT_OP)
+        .then(opcode(opcode::DEF_L_LESS_OP))
+        .then(comment_scope(
+            DebugVerbosity::AllScopes,
+            "DefLGreaterEqual",
+            term_arg().then(term_arg()).map_with_context(|(left_arg, right_arg), context| {
+                let ord = try_with_context!(context, left_arg.cmp(right_arg, context));
+                (Ok(AmlValue::Boolean(ord != Ordering::Less)), context)
+            }),
+        ))
+        .map(|(((), ()), result)| Ok(result))
+}
+
 pub fn def_package<'a, 'c>() -> impl Parser<'a, 'c, AmlValue>
 where
     'c: 'a,