diff --git a/kernel/include/kernel/ACPI/AML/Index.h b/kernel/include/kernel/ACPI/AML/Index.h index c7fd1692..430bf0eb 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 0dd6ca29..36add225 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 c1857589..40e7b307 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;