Kernel: Add easier api for evaluating ACPI nodes

This commit is contained in:
Bananymous 2025-04-01 22:43:29 +03:00
parent b8a3439219
commit b145c1ab64
2 changed files with 4 additions and 4 deletions

View File

@ -27,7 +27,8 @@ namespace Kernel::ACPI::AML
BAN::ErrorOr<void> parse(BAN::ConstByteSpan); BAN::ErrorOr<void> parse(BAN::ConstByteSpan);
BAN::ErrorOr<Node> evaluate(BAN::StringView); BAN::ErrorOr<Node> evaluate(BAN::StringView path) { return evaluate(Scope {}, path); }
BAN::ErrorOr<Node> evaluate(const Scope& scope, BAN::StringView);
// returns empty scope if object already exited // returns empty scope if object already exited
BAN::ErrorOr<Scope> add_named_object(const Scope& scope, const NameString& name_string, Node&& node); BAN::ErrorOr<Scope> add_named_object(const Scope& scope, const NameString& name_string, Node&& node);

View File

@ -547,11 +547,10 @@ namespace Kernel::ACPI::AML
return result; return result;
} }
BAN::ErrorOr<Node> Namespace::evaluate(BAN::StringView path) BAN::ErrorOr<Node> Namespace::evaluate(const Scope& scope, BAN::StringView path)
{ {
Scope root_scope;
auto name_string = TRY(NameString::from_string(path)); auto name_string = TRY(NameString::from_string(path));
auto [object_path, object] = TRY(find_named_object(root_scope, name_string)); auto [object_path, object] = TRY(find_named_object(scope, name_string));
if (object == nullptr) if (object == nullptr)
return BAN::Error::from_errno(ENOENT); return BAN::Error::from_errno(ENOENT);
return evaluate_node(object_path, object->node); return evaluate_node(object_path, object->node);