From 0fa16cf9822cd871a317ac72206a68287399b8ac Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 18 Aug 2024 20:44:51 +0300 Subject: [PATCH] Kernel: Fix and add some AML to_underlying functions --- kernel/include/kernel/ACPI/AML/Index.h | 2 +- kernel/include/kernel/ACPI/AML/Package.h | 12 ++++++++++++ kernel/include/kernel/ACPI/AML/Register.h | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/kernel/include/kernel/ACPI/AML/Index.h b/kernel/include/kernel/ACPI/AML/Index.h index c7fd1692d9..430bf0ebdf 100644 --- a/kernel/include/kernel/ACPI/AML/Index.h +++ b/kernel/include/kernel/ACPI/AML/Index.h @@ -67,7 +67,7 @@ namespace Kernel::ACPI::AML return ParseResult::Failure; } auto package_element = package->elements[index]; - result = MUST(BAN::RefPtr::create(package_element)); + result = MUST(BAN::RefPtr::create(package_element->to_underlying())); break; } case AML::Node::Type::String: diff --git a/kernel/include/kernel/ACPI/AML/Package.h b/kernel/include/kernel/ACPI/AML/Package.h index 0dd6ca290a..36add22553 100644 --- a/kernel/include/kernel/ACPI/AML/Package.h +++ b/kernel/include/kernel/ACPI/AML/Package.h @@ -92,6 +92,18 @@ namespace Kernel::ACPI::AML return element->convert(mask); } + BAN::RefPtr to_underlying() override + { + if (!initialized) + { + AML_ERROR("Trying to store into uninitialized PackageElement"); + return {}; + } + if (!resolved && !resolve()) + return {}; + return element; + } + BAN::RefPtr store(BAN::RefPtr node) override { if (!initialized) diff --git a/kernel/include/kernel/ACPI/AML/Register.h b/kernel/include/kernel/ACPI/AML/Register.h index c185758977..40e7b30704 100644 --- a/kernel/include/kernel/ACPI/AML/Register.h +++ b/kernel/include/kernel/ACPI/AML/Register.h @@ -12,7 +12,7 @@ namespace Kernel::ACPI::AML Register(); Register(BAN::RefPtr node); - BAN::RefPtr to_underlying() override { return value; } + BAN::RefPtr to_underlying() override { return value->to_underlying(); } BAN::RefPtr convert(uint8_t mask) override; BAN::RefPtr store(BAN::RefPtr source) override;