diff --git a/kernel/include/kernel/ACPI/AML/Expression.h b/kernel/include/kernel/ACPI/AML/Expression.h index 1dff2aa0..bc5af507 100644 --- a/kernel/include/kernel/ACPI/AML/Expression.h +++ b/kernel/include/kernel/ACPI/AML/Expression.h @@ -44,8 +44,48 @@ namespace Kernel::ACPI::AML return ParseResult(source_node); } case AML::Byte::NotOp: - AML_TODO("NotOp", context.aml_data[0]); - return ParseResult::Failure; + { + auto source_result = AML::parse_object(context); + if (!source_result.success()) + return ParseResult::Failure; + auto source_conv = source_result.node() ? source_result.node()->convert(AML::Node::ConvInteger) : BAN::RefPtr(); + if (!source_conv) + { + AML_ERROR("NotOp source not an integer, type {}", + static_cast(source_result.node()->type) + ); + if (source_result.node()) + source_result.node()->debug_print(1); + AML_DEBUG_PRINTLN(""); + return ParseResult::Failure; + } + const auto source_value = static_cast(source_conv.ptr())->value; + + BAN::RefPtr target_node; + if (context.aml_data[0] == 0x00) + context.aml_data = context.aml_data.slice(1); + else + { + auto target_result = AML::parse_object(context); + if (!target_result.success()) + return ParseResult::Failure; + target_node = target_result.node(); + if (!target_node) + { + AML_ERROR("NotOp target invalid"); + return ParseResult::Failure; + } + } + + auto result_node = MUST(BAN::RefPtr::create(~source_value)); + if (target_node && !target_node->store(result_node)) + { + AML_ERROR("NotOp failed to store result"); + return ParseResult::Failure; + } + + return ParseResult(result_node); + } case AML::Byte::LNotOp: { context.aml_data = context.aml_data.slice(1);