Skip to content

Commit 7d3c852

Browse files
rw-vancIsaacWoods
authored andcommitted
Add minimal CondRefOf support - only handles checking for source, does not assign to target
1 parent b328d82 commit 7d3c852

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

aml/src/expression.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{
44
opcode::{self, opcode},
55
parser::{choice, comment_scope, n_of, take, take_to_end_of_pkglength, try_with_context, Parser, Propagate},
66
pkg_length::pkg_length,
7-
term_object::{data_ref_object, term_arg},
7+
term_object::{data_ref_object, term_arg, def_cond_ref_of},
88
value::{AmlType, AmlValue, Args},
99
AmlError,
1010
DebugVerbosity,
@@ -58,6 +58,7 @@ where
5858
def_shift_right(),
5959
def_store(),
6060
def_to_integer(),
61+
def_cond_ref_of(),
6162
method_invocation() // XXX: this must always appear last. See how we have to parse it to see why.
6263
),
6364
)

aml/src/opcode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub const DEF_CREATE_BYTE_FIELD_OP: u8 = 0x8c;
3333
pub const DEF_CREATE_BIT_FIELD_OP: u8 = 0x8d;
3434
pub const DEF_CREATE_QWORD_FIELD_OP: u8 = 0x8f;
3535
pub const EXT_DEF_MUTEX_OP: u8 = 0x01;
36+
pub const EXT_DEF_COND_REF_OF_OP: u8 = 0x12;
3637
pub const EXT_DEF_CREATE_FIELD_OP: u8 = 0x13;
3738
pub const EXT_REVISION_OP: u8 = 0x30;
3839
pub const EXT_DEF_FATAL_OP: u8 = 0x32;

aml/src/term_object.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
expression::{def_buffer, def_package, expression_opcode},
33
misc::{arg_obj, local_obj},
4-
name_object::{name_seg, name_string},
4+
name_object::{name_seg, name_string, target, Target},
55
namespace::{AmlName, LevelType},
66
opcode::{self, ext_opcode, opcode},
77
parser::{
@@ -851,6 +851,34 @@ where
851851
.discard_result()
852852
}
853853

854+
pub fn def_cond_ref_of<'a, 'c>() -> impl Parser<'a, 'c, AmlValue>
855+
where
856+
'c: 'a,
857+
{
858+
/*
859+
* DefCondRefOf := ExtOpPrefix 0x12 NameString Target => boolean
860+
*/
861+
ext_opcode(opcode::EXT_DEF_COND_REF_OF_OP)
862+
.then(comment_scope(
863+
DebugVerbosity::Scopes,
864+
"DefCondRefOf",
865+
name_string().then(target()).map_with_context(|(source, target), context| {
866+
let handle = context.namespace.search(&source, &context.current_scope);
867+
let result = AmlValue::Boolean(handle.is_ok());
868+
log::error!("{:?} was {}found", &source, if handle.is_ok() { "" } else { "not " });
869+
if let Ok((_name, _handle)) = handle {
870+
match target {
871+
Target::Null => { /* just return the result of the check */ }
872+
_ => todo!(),
873+
}
874+
875+
}
876+
(Ok(result), context)
877+
}),
878+
))
879+
.map(|((), result)| Ok(result))
880+
}
881+
854882
pub fn term_arg<'a, 'c>() -> impl Parser<'a, 'c, AmlValue>
855883
where
856884
'c: 'a,

0 commit comments

Comments
 (0)