diff --git a/kernel/include/kernel/ACPI/AML/Alias.h b/kernel/include/kernel/ACPI/AML/Alias.h index 9e32ce79..6b23ebc3 100644 --- a/kernel/include/kernel/ACPI/AML/Alias.h +++ b/kernel/include/kernel/ACPI/AML/Alias.h @@ -16,13 +16,27 @@ namespace Kernel::ACPI::AML , target(target) {} + BAN::RefPtr named_target() override { return target; } + bool is_scope() const override { return target->is_scope(); } - BAN::RefPtr convert(uint8_t) override { return {}; } + BAN::RefPtr convert(uint8_t mask) override + { + ASSERT(target); + return target->convert(mask); + } - BAN::RefPtr copy() override { return target->copy(); } + BAN::RefPtr copy() override + { + ASSERT(target); + return target->copy(); + } - BAN::RefPtr store(BAN::RefPtr node) override { ASSERT(target); return target->store(node); } + BAN::RefPtr store(BAN::RefPtr node) override + { + ASSERT(target); + return target->store(node); + } static ParseResult parse(ParseContext& context) { @@ -45,7 +59,7 @@ namespace Kernel::ACPI::AML return ParseResult::Success; } - auto alias = MUST(BAN::RefPtr::create(alias_string.value().path.back(), source_object)); + auto alias = MUST(BAN::RefPtr::create(alias_string.value().path.back(), source_object->named_target())); if (!Namespace::root_namespace()->add_named_object(context, alias_string.value(), alias)) return ParseResult::Success; diff --git a/kernel/include/kernel/ACPI/AML/NamedObject.h b/kernel/include/kernel/ACPI/AML/NamedObject.h index fe9e2469..8a9dfc81 100644 --- a/kernel/include/kernel/ACPI/AML/NamedObject.h +++ b/kernel/include/kernel/ACPI/AML/NamedObject.h @@ -12,6 +12,8 @@ namespace Kernel::ACPI::AML NameSeg name; NamedObject(Node::Type type, NameSeg name) : Node(type), name(name) {} + + [[nodiscard]] virtual BAN::RefPtr named_target() { return this; } }; struct Name final : public AML::NamedObject @@ -22,15 +24,19 @@ namespace Kernel::ACPI::AML : NamedObject(Node::Type::Name, name), object(BAN::move(object)) {} - BAN::RefPtr convert(uint8_t) override { return {}; } + BAN::RefPtr named_target() override { return object; } + + BAN::RefPtr convert(uint8_t mask) override + { + ASSERT(object); + return object->convert(mask); + } BAN::RefPtr store(BAN::RefPtr node) override { ASSERT(object); - if (object->type == AML::Node::Type::Reference) - return object->store(node); - object = node; - return node; + ASSERT(object->type != AML::Node::Type::Reference); + return object->store(node); } static ParseResult parse(ParseContext& context); diff --git a/kernel/include/kernel/ACPI/AML/Reference.h b/kernel/include/kernel/ACPI/AML/Reference.h index fade7dfa..dfe2b4be 100644 --- a/kernel/include/kernel/ACPI/AML/Reference.h +++ b/kernel/include/kernel/ACPI/AML/Reference.h @@ -23,21 +23,13 @@ namespace Kernel::ACPI::AML BAN::RefPtr convert(uint8_t mask) override { - if (!node) - { - AML_ERROR("Trying to convert null Reference"); - return {}; - } + ASSERT(node); return node->convert(mask); } BAN::RefPtr store(BAN::RefPtr value) override { - if (!node) - { - AML_ERROR("Storing to null Reference"); - return {}; - } + ASSERT(node); return node->store(value); }