#pragma once #include #include #include #include #include #include #include namespace Kernel::ACPI::AML { struct Namespace { BAN_NON_COPYABLE(Namespace); BAN_NON_MOVABLE(Namespace); public: Namespace() = default; ~Namespace(); static BAN::ErrorOr prepare_root_namespace(); static Namespace& root_namespace(); BAN::ErrorOr post_load_initialize(); BAN::ErrorOr parse(BAN::ConstByteSpan); BAN::ErrorOr evaluate(BAN::StringView path) { return evaluate(Scope {}, path); } BAN::ErrorOr evaluate(const Scope& scope, BAN::StringView); // returns empty scope if object already exited BAN::ErrorOr add_named_object(ParseContext& context, const NameString& name_string, Node&& node); BAN::ErrorOr add_alias(ParseContext& scope, const NameString& name_string, Reference* reference); BAN::ErrorOr remove_named_object(const Scope& absolute_path); // node is nullptr if it is not found struct FindResult { Scope path; Reference* node { nullptr }; }; BAN::ErrorOr find_named_object(const Scope& scope, const NameString& name_string, bool force_absolute = false); BAN::ErrorOr find_reference_scope(const Reference* reference); BAN::ErrorOr for_each_child(const Scope&, const BAN::Function&); BAN::ErrorOr for_each_child(const Scope&, const BAN::Function&); BAN::ErrorOr> find_device_with_eisa_id(BAN::StringView eisa_id); BAN::ErrorOr> find_device_with_eisa_id(BAN::Span eisa_ids); private: BAN::ErrorOr resolve_path(const Scope& scope, const NameString& name_string); BAN::ErrorOr initialize_scope(const Scope& scope); BAN::ErrorOr opregion_call_reg(const Scope& scope, const Node& opregion); BAN::ErrorOr evaluate_sta(const Scope& scope); BAN::ErrorOr evaluate_ini(const Scope& scope); BAN::ErrorOr initialize_op_regions(); private: bool m_has_initialized_namespace { false }; BAN::HashMap m_named_objects; BAN::HashMap m_called_reg_bitmaps; BAN::HashSet m_aliases; }; }