// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /******************************************************************************* * * Module Name: nssearch - Namespace search * ******************************************************************************/ #include <acpi/acpi.h> #include "accommon.h" #include "acnamesp.h" #ifdef ACPI_ASL_COMPILER #include "amlcode.h" #endif #define _COMPONENT … ACPI_MODULE_NAME("nssearch") /* Local prototypes */ static acpi_status acpi_ns_search_parent_tree(u32 target_name, struct acpi_namespace_node *node, acpi_object_type type, struct acpi_namespace_node **return_node); /******************************************************************************* * * FUNCTION: acpi_ns_search_one_scope * * PARAMETERS: target_name - Ascii ACPI name to search for * parent_node - Starting node where search will begin * type - Object type to match * return_node - Where the matched Named obj is returned * * RETURN: Status * * DESCRIPTION: Search a single level of the namespace. Performs a * simple search of the specified level, and does not add * entries or search parents. * * * Named object lists are built (and subsequently dumped) in the * order in which the names are encountered during the namespace load; * * All namespace searching is linear in this implementation, but * could be easily modified to support any improved search * algorithm. However, the linear search was chosen for simplicity * and because the trees are small and the other interpreter * execution overhead is relatively high. * * Note: CPU execution analysis has shown that the AML interpreter spends * a very small percentage of its time searching the namespace. Therefore, * the linear search seems to be sufficient, as there would seem to be * little value in improving the search. * ******************************************************************************/ acpi_status acpi_ns_search_one_scope(u32 target_name, struct acpi_namespace_node *parent_node, acpi_object_type type, struct acpi_namespace_node **return_node) { … } /******************************************************************************* * * FUNCTION: acpi_ns_search_parent_tree * * PARAMETERS: target_name - Ascii ACPI name to search for * node - Starting node where search will begin * type - Object type to match * return_node - Where the matched Node is returned * * RETURN: Status * * DESCRIPTION: Called when a name has not been found in the current namespace * level. Before adding it or giving up, ACPI scope rules require * searching enclosing scopes in cases identified by acpi_ns_local(). * * "A name is located by finding the matching name in the current * name space, and then in the parent name space. If the parent * name space does not contain the name, the search continues * recursively until either the name is found or the name space * does not have a parent (the root of the name space). This * indicates that the name is not found" (From ACPI Specification, * section 5.3) * ******************************************************************************/ static acpi_status acpi_ns_search_parent_tree(u32 target_name, struct acpi_namespace_node *node, acpi_object_type type, struct acpi_namespace_node **return_node) { … } /******************************************************************************* * * FUNCTION: acpi_ns_search_and_enter * * PARAMETERS: target_name - Ascii ACPI name to search for (4 chars) * walk_state - Current state of the walk * node - Starting node where search will begin * interpreter_mode - Add names only in ACPI_MODE_LOAD_PASS_x. * Otherwise,search only. * type - Object type to match * flags - Flags describing the search restrictions * return_node - Where the Node is returned * * RETURN: Status * * DESCRIPTION: Search for a name segment in a single namespace level, * optionally adding it if it is not found. If the passed * Type is not Any and the type previously stored in the * entry was Any (i.e. unknown), update the stored type. * * In ACPI_IMODE_EXECUTE, search only. * In other modes, search and add if not found. * ******************************************************************************/ acpi_status acpi_ns_search_and_enter(u32 target_name, struct acpi_walk_state *walk_state, struct acpi_namespace_node *node, acpi_interpreter_mode interpreter_mode, acpi_object_type type, u32 flags, struct acpi_namespace_node **return_node) { … }