Kernel: Add AML API for getting underlying value of nodes

This commit is contained in:
Bananymous 2024-08-15 23:11:59 +03:00
parent d8dabab4fb
commit 6408bb2efa
5 changed files with 9 additions and 6 deletions

View File

@ -16,7 +16,7 @@ namespace Kernel::ACPI::AML
, target(target) , target(target)
{} {}
BAN::RefPtr<AML::Node> named_target() override { return target; } BAN::RefPtr<AML::Node> to_underlying() override { return target; }
bool is_scope() const override { return target->is_scope(); } bool is_scope() const override { return target->is_scope(); }
@ -59,7 +59,7 @@ namespace Kernel::ACPI::AML
return ParseResult::Success; return ParseResult::Success;
} }
auto alias = MUST(BAN::RefPtr<Alias>::create(alias_string.value().path.back(), source_object->named_target())); auto alias = MUST(BAN::RefPtr<Alias>::create(alias_string.value().path.back(), source_object->to_underlying()));
if (!Namespace::root_namespace()->add_named_object(context, alias_string.value(), alias)) if (!Namespace::root_namespace()->add_named_object(context, alias_string.value(), alias))
return ParseResult::Success; return ParseResult::Success;

View File

@ -19,7 +19,9 @@ namespace Kernel::ACPI::AML
auto source_result = AML::parse_object(context); auto source_result = AML::parse_object(context);
if (!source_result.success()) if (!source_result.success())
return ParseResult::Failure; return ParseResult::Failure;
auto source = source_result.node(); auto source = source_result.node()
? source_result.node()->to_underlying()
: BAN::RefPtr<AML::Node>();
if (!source) if (!source)
{ {
AML_ERROR("CopyObject source is null"); AML_ERROR("CopyObject source is null");

View File

@ -12,8 +12,6 @@ namespace Kernel::ACPI::AML
NameSeg name; NameSeg name;
NamedObject(Node::Type type, NameSeg name) : Node(type), name(name) {} NamedObject(Node::Type type, NameSeg name) : Node(type), name(name) {}
[[nodiscard]] virtual BAN::RefPtr<AML::Node> named_target() { return this; }
}; };
struct Name final : public AML::NamedObject struct Name final : public AML::NamedObject
@ -24,7 +22,7 @@ namespace Kernel::ACPI::AML
: NamedObject(Node::Type::Name, name), object(BAN::move(object)) : NamedObject(Node::Type::Name, name), object(BAN::move(object))
{} {}
BAN::RefPtr<AML::Node> named_target() override { return object; } BAN::RefPtr<AML::Node> to_underlying() override { return object; }
BAN::RefPtr<AML::Node> convert(uint8_t mask) override BAN::RefPtr<AML::Node> convert(uint8_t mask) override
{ {

View File

@ -60,6 +60,7 @@ namespace Kernel::ACPI::AML
virtual bool is_scope() const { return false; } virtual bool is_scope() const { return false; }
[[nodiscard]] virtual BAN::RefPtr<AML::Node> to_underlying() { return this; }
[[nodiscard]] virtual BAN::RefPtr<AML::Node> convert(uint8_t mask) = 0; [[nodiscard]] virtual BAN::RefPtr<AML::Node> convert(uint8_t mask) = 0;
[[nodiscard]] virtual BAN::RefPtr<Node> copy() { return this; } [[nodiscard]] virtual BAN::RefPtr<Node> copy() { return this; }
[[nodiscard]] virtual BAN::RefPtr<AML::Node> store(BAN::RefPtr<AML::Node>) { AML_TODO("store, type {}", static_cast<uint8_t>(type)); return {}; } [[nodiscard]] virtual BAN::RefPtr<AML::Node> store(BAN::RefPtr<AML::Node>) { AML_TODO("store, type {}", static_cast<uint8_t>(type)); return {}; }

View File

@ -12,6 +12,8 @@ namespace Kernel::ACPI::AML
Register(); Register();
Register(BAN::RefPtr<AML::Node> node); Register(BAN::RefPtr<AML::Node> node);
BAN::RefPtr<AML::Node> to_underlying() override { return value; }
BAN::RefPtr<AML::Node> convert(uint8_t mask) override; BAN::RefPtr<AML::Node> convert(uint8_t mask) override;
BAN::RefPtr<AML::Node> store(BAN::RefPtr<AML::Node> source) override; BAN::RefPtr<AML::Node> store(BAN::RefPtr<AML::Node> source) override;