Kernel: Add easier api for evaluating ACPI nodes
This commit is contained in:
parent
b8a3439219
commit
b145c1ab64
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue