From ada5ba6dbc8c60e68f527bff761c912e91f4fc84 Mon Sep 17 00:00:00 2001 From: Connor Wood Date: Tue, 25 Jul 2017 13:12:42 +0100 Subject: [PATCH] Implemented condrefof --- src/acpi/aml/type2opcode.rs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/acpi/aml/type2opcode.rs b/src/acpi/aml/type2opcode.rs index d4591ce..35f3faf 100644 --- a/src/acpi/aml/type2opcode.rs +++ b/src/acpi/aml/type2opcode.rs @@ -1077,16 +1077,30 @@ fn parse_def_cond_ref_of(data: &[u8], }) } - // TODO: Compute the result - // TODO: Store the result parser_opcode_extended!(data, 0x12); - let operand = parse_super_name(&data[2..], ctx)?; - let target = parse_target(&data[2 + operand.len..], ctx)?; + let obj = parse_super_name(&data[2..], ctx)?; + let target = parse_target(&data[2 + obj.len..], ctx)?; + let res = match obj.val { + AmlValue::String(ref s) => { + match ctx.get(AmlValue::String(s.clone())) { + AmlValue::None => return Ok(AmlParseType { + val: AmlValue::Integer(0), + len: 1 + obj.len + target.len + }), + _ => ObjectReference::Object(s.clone()) + } + }, + AmlValue::ObjectReference(ref o) => o.clone(), + _ => return Err(AmlError::AmlValueError) + }; + + ctx.modify(target.val, AmlValue::ObjectReference(res)); + Ok(AmlParseType { - val: AmlValue::Uninitialized, - len: 2 + operand.len + target.len + val: AmlValue::Integer(1), + len: 1 + obj.len + target.len }) }