1 /******************************************************************************
 
   3  * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
 
   4  *                        parents and siblings and Scope manipulation
 
   6  *****************************************************************************/
 
   9  * Copyright (C) 2000 - 2005, R. Byron Moore
 
  10  * All rights reserved.
 
  12  * Redistribution and use in source and binary forms, with or without
 
  13  * modification, are permitted provided that the following conditions
 
  15  * 1. Redistributions of source code must retain the above copyright
 
  16  *    notice, this list of conditions, and the following disclaimer,
 
  17  *    without modification.
 
  18  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 
  19  *    substantially similar to the "NO WARRANTY" disclaimer below
 
  20  *    ("Disclaimer") and any redistribution must be conditioned upon
 
  21  *    including a substantially similar Disclaimer requirement for further
 
  22  *    binary redistribution.
 
  23  * 3. Neither the names of the above-listed copyright holders nor the names
 
  24  *    of any contributors may be used to endorse or promote products derived
 
  25  *    from this software without specific prior written permission.
 
  27  * Alternatively, this software may be distributed under the terms of the
 
  28  * GNU General Public License ("GPL") version 2 as published by the Free
 
  29  * Software Foundation.
 
  32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
  33  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
  34  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
 
  35  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
  36  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
  37  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
  38  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
  39  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 
  40  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 
  41  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
  42  * POSSIBILITY OF SUCH DAMAGES.
 
  45 #include <acpi/acpi.h>
 
  46 #include <acpi/acnamesp.h>
 
  47 #include <acpi/amlcode.h>
 
  48 #include <acpi/actables.h>
 
  50 #define _COMPONENT          ACPI_NAMESPACE
 
  51 ACPI_MODULE_NAME("nsutils")
 
  53 /* Local prototypes */
 
  54 static u8 acpi_ns_valid_path_separator(char sep);
 
  56 #ifdef ACPI_OBSOLETE_FUNCTIONS
 
  57 acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
 
  60 /*******************************************************************************
 
  62  * FUNCTION:    acpi_ns_report_error
 
  64  * PARAMETERS:  module_name         - Caller's module name (for error output)
 
  65  *              line_number         - Caller's line number (for error output)
 
  66  *              component_id        - Caller's component ID (for error output)
 
  67  *              internal_name       - Name or path of the namespace node
 
  68  *              lookup_status       - Exception code from NS lookup
 
  72  * DESCRIPTION: Print warning message with full pathname
 
  74  ******************************************************************************/
 
  77 acpi_ns_report_error(char *module_name,
 
  80                      char *internal_name, acpi_status lookup_status)
 
  85         acpi_os_printf("%8s-%04d: *** Error: Looking up ",
 
  86                        module_name, line_number);
 
  88         if (lookup_status == AE_BAD_CHARACTER) {
 
  89                 /* There is a non-ascii character in the name */
 
  91                 acpi_os_printf("[0x%4.4X] (NON-ASCII)\n",
 
  92                                *(ACPI_CAST_PTR(u32, internal_name)));
 
  94                 /* Convert path to external format */
 
  96                 status = acpi_ns_externalize_name(ACPI_UINT32_MAX,
 
  97                                                   internal_name, NULL, &name);
 
  99                 /* Print target name */
 
 101                 if (ACPI_SUCCESS(status)) {
 
 102                         acpi_os_printf("[%s]", name);
 
 104                         acpi_os_printf("[COULD NOT EXTERNALIZE NAME]");
 
 112         acpi_os_printf(" in namespace, %s\n",
 
 113                        acpi_format_exception(lookup_status));
 
 116 /*******************************************************************************
 
 118  * FUNCTION:    acpi_ns_report_method_error
 
 120  * PARAMETERS:  module_name         - Caller's module name (for error output)
 
 121  *              line_number         - Caller's line number (for error output)
 
 122  *              component_id        - Caller's component ID (for error output)
 
 123  *              Message             - Error message to use on failure
 
 124  *              prefix_node         - Prefix relative to the path
 
 125  *              Path                - Path to the node
 
 126  *              method_status       - Execution status
 
 130  * DESCRIPTION: Print warning message with full pathname
 
 132  ******************************************************************************/
 
 135 acpi_ns_report_method_error(char *module_name,
 
 139                             struct acpi_namespace_node *prefix_node,
 
 140                             char *path, acpi_status method_status)
 
 143         struct acpi_namespace_node *node = prefix_node;
 
 146                 status = acpi_ns_get_node_by_path(path, prefix_node,
 
 147                                                   ACPI_NS_NO_UPSEARCH, &node);
 
 148                 if (ACPI_FAILURE(status)) {
 
 150                             ("report_method_error: Could not get node\n");
 
 155         acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number);
 
 156         acpi_ns_print_node_pathname(node, message);
 
 157         acpi_os_printf(", %s\n", acpi_format_exception(method_status));
 
 160 /*******************************************************************************
 
 162  * FUNCTION:    acpi_ns_print_node_pathname
 
 164  * PARAMETERS:  Node            - Object
 
 165  *              Message         - Prefix message
 
 167  * DESCRIPTION: Print an object's full namespace pathname
 
 168  *              Manages allocation/freeing of a pathname buffer
 
 170  ******************************************************************************/
 
 173 acpi_ns_print_node_pathname(struct acpi_namespace_node *node, char *message)
 
 175         struct acpi_buffer buffer;
 
 179                 acpi_os_printf("[NULL NAME]");
 
 183         /* Convert handle to full pathname and print it (with supplied message) */
 
 185         buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
 
 187         status = acpi_ns_handle_to_pathname(node, &buffer);
 
 188         if (ACPI_SUCCESS(status)) {
 
 190                         acpi_os_printf("%s ", message);
 
 193                 acpi_os_printf("[%s] (Node %p)", (char *)buffer.pointer, node);
 
 194                 ACPI_MEM_FREE(buffer.pointer);
 
 198 /*******************************************************************************
 
 200  * FUNCTION:    acpi_ns_valid_root_prefix
 
 202  * PARAMETERS:  Prefix          - Character to be checked
 
 204  * RETURN:      TRUE if a valid prefix
 
 206  * DESCRIPTION: Check if a character is a valid ACPI Root prefix
 
 208  ******************************************************************************/
 
 210 u8 acpi_ns_valid_root_prefix(char prefix)
 
 213         return ((u8) (prefix == '\\'));
 
 216 /*******************************************************************************
 
 218  * FUNCTION:    acpi_ns_valid_path_separator
 
 220  * PARAMETERS:  Sep         - Character to be checked
 
 222  * RETURN:      TRUE if a valid path separator
 
 224  * DESCRIPTION: Check if a character is a valid ACPI path separator
 
 226  ******************************************************************************/
 
 228 static u8 acpi_ns_valid_path_separator(char sep)
 
 231         return ((u8) (sep == '.'));
 
 234 /*******************************************************************************
 
 236  * FUNCTION:    acpi_ns_get_type
 
 238  * PARAMETERS:  Node        - Parent Node to be examined
 
 240  * RETURN:      Type field from Node whose handle is passed
 
 242  * DESCRIPTION: Return the type of a Namespace node
 
 244  ******************************************************************************/
 
 246 acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
 
 248         ACPI_FUNCTION_TRACE("ns_get_type");
 
 251                 ACPI_REPORT_WARNING(("ns_get_type: Null Node input pointer\n"));
 
 252                 return_VALUE(ACPI_TYPE_ANY);
 
 255         return_VALUE((acpi_object_type) node->type);
 
 258 /*******************************************************************************
 
 260  * FUNCTION:    acpi_ns_local
 
 262  * PARAMETERS:  Type        - A namespace object type
 
 264  * RETURN:      LOCAL if names must be found locally in objects of the
 
 265  *              passed type, 0 if enclosing scopes should be searched
 
 267  * DESCRIPTION: Returns scope rule for the given object type.
 
 269  ******************************************************************************/
 
 271 u32 acpi_ns_local(acpi_object_type type)
 
 273         ACPI_FUNCTION_TRACE("ns_local");
 
 275         if (!acpi_ut_valid_object_type(type)) {
 
 276                 /* Type code out of range  */
 
 278                 ACPI_REPORT_WARNING(("ns_local: Invalid Object Type\n"));
 
 279                 return_VALUE(ACPI_NS_NORMAL);
 
 282         return_VALUE((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
 
 285 /*******************************************************************************
 
 287  * FUNCTION:    acpi_ns_get_internal_name_length
 
 289  * PARAMETERS:  Info            - Info struct initialized with the
 
 290  *                                external name pointer.
 
 294  * DESCRIPTION: Calculate the length of the internal (AML) namestring
 
 295  *              corresponding to the external (ASL) namestring.
 
 297  ******************************************************************************/
 
 299 void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
 
 301         char *next_external_char;
 
 304         ACPI_FUNCTION_ENTRY();
 
 306         next_external_char = info->external_name;
 
 307         info->num_carats = 0;
 
 308         info->num_segments = 0;
 
 309         info->fully_qualified = FALSE;
 
 312          * For the internal name, the required length is 4 bytes per segment, plus
 
 313          * 1 each for root_prefix, multi_name_prefix_op, segment count, trailing null
 
 314          * (which is not really needed, but no there's harm in putting it there)
 
 316          * strlen() + 1 covers the first name_seg, which has no path separator
 
 318         if (acpi_ns_valid_root_prefix(next_external_char[0])) {
 
 319                 info->fully_qualified = TRUE;
 
 320                 next_external_char++;
 
 323                  * Handle Carat prefixes
 
 325                 while (*next_external_char == '^') {
 
 327                         next_external_char++;
 
 332          * Determine the number of ACPI name "segments" by counting the number of
 
 333          * path separators within the string. Start with one segment since the
 
 334          * segment count is [(# separators) + 1], and zero separators is ok.
 
 336         if (*next_external_char) {
 
 337                 info->num_segments = 1;
 
 338                 for (i = 0; next_external_char[i]; i++) {
 
 339                         if (acpi_ns_valid_path_separator(next_external_char[i])) {
 
 340                                 info->num_segments++;
 
 345         info->length = (ACPI_NAME_SIZE * info->num_segments) +
 
 346             4 + info->num_carats;
 
 348         info->next_external_char = next_external_char;
 
 351 /*******************************************************************************
 
 353  * FUNCTION:    acpi_ns_build_internal_name
 
 355  * PARAMETERS:  Info            - Info struct fully initialized
 
 359  * DESCRIPTION: Construct the internal (AML) namestring
 
 360  *              corresponding to the external (ASL) namestring.
 
 362  ******************************************************************************/
 
 364 acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
 
 366         u32 num_segments = info->num_segments;
 
 367         char *internal_name = info->internal_name;
 
 368         char *external_name = info->next_external_char;
 
 372         ACPI_FUNCTION_TRACE("ns_build_internal_name");
 
 374         /* Setup the correct prefixes, counts, and pointers */
 
 376         if (info->fully_qualified) {
 
 377                 internal_name[0] = '\\';
 
 379                 if (num_segments <= 1) {
 
 380                         result = &internal_name[1];
 
 381                 } else if (num_segments == 2) {
 
 382                         internal_name[1] = AML_DUAL_NAME_PREFIX;
 
 383                         result = &internal_name[2];
 
 385                         internal_name[1] = AML_MULTI_NAME_PREFIX_OP;
 
 386                         internal_name[2] = (char)num_segments;
 
 387                         result = &internal_name[3];
 
 391                  * Not fully qualified.
 
 392                  * Handle Carats first, then append the name segments
 
 395                 if (info->num_carats) {
 
 396                         for (i = 0; i < info->num_carats; i++) {
 
 397                                 internal_name[i] = '^';
 
 401                 if (num_segments <= 1) {
 
 402                         result = &internal_name[i];
 
 403                 } else if (num_segments == 2) {
 
 404                         internal_name[i] = AML_DUAL_NAME_PREFIX;
 
 405                         result = &internal_name[(acpi_native_uint) (i + 1)];
 
 407                         internal_name[i] = AML_MULTI_NAME_PREFIX_OP;
 
 408                         internal_name[(acpi_native_uint) (i + 1)] =
 
 410                         result = &internal_name[(acpi_native_uint) (i + 2)];
 
 414         /* Build the name (minus path separators) */
 
 416         for (; num_segments; num_segments--) {
 
 417                 for (i = 0; i < ACPI_NAME_SIZE; i++) {
 
 418                         if (acpi_ns_valid_path_separator(*external_name) ||
 
 419                             (*external_name == 0)) {
 
 420                                 /* Pad the segment with underscore(s) if segment is short */
 
 424                                 /* Convert the character to uppercase and save it */
 
 427                                     (char)ACPI_TOUPPER((int)*external_name);
 
 432                 /* Now we must have a path separator, or the pathname is bad */
 
 434                 if (!acpi_ns_valid_path_separator(*external_name) &&
 
 435                     (*external_name != 0)) {
 
 436                         return_ACPI_STATUS(AE_BAD_PARAMETER);
 
 439                 /* Move on the next segment */
 
 442                 result += ACPI_NAME_SIZE;
 
 445         /* Terminate the string */
 
 449         if (info->fully_qualified) {
 
 450                 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
 
 451                                   "Returning [%p] (abs) \"\\%s\"\n",
 
 452                                   internal_name, internal_name));
 
 454                 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
 
 455                                   internal_name, internal_name));
 
 458         return_ACPI_STATUS(AE_OK);
 
 461 /*******************************************************************************
 
 463  * FUNCTION:    acpi_ns_internalize_name
 
 465  * PARAMETERS:  *external_name          - External representation of name
 
 466  *              **Converted Name        - Where to return the resulting
 
 467  *                                        internal represention of the name
 
 471  * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0")
 
 472  *              to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
 
 474  *******************************************************************************/
 
 476 acpi_status acpi_ns_internalize_name(char *external_name, char **converted_name)
 
 479         struct acpi_namestring_info info;
 
 482         ACPI_FUNCTION_TRACE("ns_internalize_name");
 
 484         if ((!external_name) || (*external_name == 0) || (!converted_name)) {
 
 485                 return_ACPI_STATUS(AE_BAD_PARAMETER);
 
 488         /* Get the length of the new internal name */
 
 490         info.external_name = external_name;
 
 491         acpi_ns_get_internal_name_length(&info);
 
 493         /* We need a segment to store the internal  name */
 
 495         internal_name = ACPI_MEM_CALLOCATE(info.length);
 
 496         if (!internal_name) {
 
 497                 return_ACPI_STATUS(AE_NO_MEMORY);
 
 502         info.internal_name = internal_name;
 
 503         status = acpi_ns_build_internal_name(&info);
 
 504         if (ACPI_FAILURE(status)) {
 
 505                 ACPI_MEM_FREE(internal_name);
 
 506                 return_ACPI_STATUS(status);
 
 509         *converted_name = internal_name;
 
 510         return_ACPI_STATUS(AE_OK);
 
 513 /*******************************************************************************
 
 515  * FUNCTION:    acpi_ns_externalize_name
 
 517  * PARAMETERS:  internal_name_length - Lenth of the internal name below
 
 518  *              internal_name       - Internal representation of name
 
 519  *              converted_name_length - Where the length is returned
 
 520  *              converted_name      - Where the resulting external name
 
 525  * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
 
 526  *              to its external (printable) form (e.g. "\_PR_.CPU0")
 
 528  ******************************************************************************/
 
 531 acpi_ns_externalize_name(u32 internal_name_length,
 
 533                          u32 * converted_name_length, char **converted_name)
 
 535         acpi_native_uint names_index = 0;
 
 536         acpi_native_uint num_segments = 0;
 
 537         acpi_native_uint required_length;
 
 538         acpi_native_uint prefix_length = 0;
 
 539         acpi_native_uint i = 0;
 
 540         acpi_native_uint j = 0;
 
 542         ACPI_FUNCTION_TRACE("ns_externalize_name");
 
 544         if (!internal_name_length || !internal_name || !converted_name) {
 
 545                 return_ACPI_STATUS(AE_BAD_PARAMETER);
 
 549          * Check for a prefix (one '\' | one or more '^').
 
 551         switch (internal_name[0]) {
 
 557                 for (i = 0; i < internal_name_length; i++) {
 
 558                         if (internal_name[i] == '^') {
 
 559                                 prefix_length = i + 1;
 
 565                 if (i == internal_name_length) {
 
 576          * Check for object names.  Note that there could be 0-255 of these
 
 579         if (prefix_length < internal_name_length) {
 
 580                 switch (internal_name[prefix_length]) {
 
 581                 case AML_MULTI_NAME_PREFIX_OP:
 
 583                         /* <count> 4-byte names */
 
 585                         names_index = prefix_length + 2;
 
 586                         num_segments = (acpi_native_uint) (u8)
 
 587                             internal_name[(acpi_native_uint)
 
 588                                           (prefix_length + 1)];
 
 591                 case AML_DUAL_NAME_PREFIX:
 
 593                         /* Two 4-byte names */
 
 595                         names_index = prefix_length + 1;
 
 609                         /* one 4-byte name */
 
 611                         names_index = prefix_length;
 
 618          * Calculate the length of converted_name, which equals the length
 
 619          * of the prefix, length of all object names, length of any required
 
 620          * punctuation ('.') between object names, plus the NULL terminator.
 
 622         required_length = prefix_length + (4 * num_segments) +
 
 623             ((num_segments > 0) ? (num_segments - 1) : 0) + 1;
 
 626          * Check to see if we're still in bounds.  If not, there's a problem
 
 627          * with internal_name (invalid format).
 
 629         if (required_length > internal_name_length) {
 
 630                 ACPI_REPORT_ERROR(("ns_externalize_name: Invalid internal name\n"));
 
 631                 return_ACPI_STATUS(AE_BAD_PATHNAME);
 
 635          * Build converted_name
 
 637         *converted_name = ACPI_MEM_CALLOCATE(required_length);
 
 638         if (!(*converted_name)) {
 
 639                 return_ACPI_STATUS(AE_NO_MEMORY);
 
 644         for (i = 0; i < prefix_length; i++) {
 
 645                 (*converted_name)[j++] = internal_name[i];
 
 648         if (num_segments > 0) {
 
 649                 for (i = 0; i < num_segments; i++) {
 
 651                                 (*converted_name)[j++] = '.';
 
 654                         (*converted_name)[j++] = internal_name[names_index++];
 
 655                         (*converted_name)[j++] = internal_name[names_index++];
 
 656                         (*converted_name)[j++] = internal_name[names_index++];
 
 657                         (*converted_name)[j++] = internal_name[names_index++];
 
 661         if (converted_name_length) {
 
 662                 *converted_name_length = (u32) required_length;
 
 665         return_ACPI_STATUS(AE_OK);
 
 668 /*******************************************************************************
 
 670  * FUNCTION:    acpi_ns_map_handle_to_node
 
 672  * PARAMETERS:  Handle          - Handle to be converted to an Node
 
 674  * RETURN:      A Name table entry pointer
 
 676  * DESCRIPTION: Convert a namespace handle to a real Node
 
 678  * Note: Real integer handles would allow for more verification
 
 679  *       and keep all pointers within this subsystem - however this introduces
 
 680  *       more (and perhaps unnecessary) overhead.
 
 682  ******************************************************************************/
 
 684 struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle)
 
 687         ACPI_FUNCTION_ENTRY();
 
 690          * Simple implementation.
 
 696         if (handle == ACPI_ROOT_OBJECT) {
 
 697                 return (acpi_gbl_root_node);
 
 700         /* We can at least attempt to verify the handle */
 
 702         if (ACPI_GET_DESCRIPTOR_TYPE(handle) != ACPI_DESC_TYPE_NAMED) {
 
 706         return ((struct acpi_namespace_node *)handle);
 
 709 /*******************************************************************************
 
 711  * FUNCTION:    acpi_ns_convert_entry_to_handle
 
 713  * PARAMETERS:  Node          - Node to be converted to a Handle
 
 715  * RETURN:      A user handle
 
 717  * DESCRIPTION: Convert a real Node to a namespace handle
 
 719  ******************************************************************************/
 
 721 acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node)
 
 725          * Simple implementation for now;
 
 727         return ((acpi_handle) node);
 
 729 /* Example future implementation ---------------------
 
 736         if (Node == acpi_gbl_root_node)
 
 738                 return (ACPI_ROOT_OBJECT);
 
 741         return ((acpi_handle) Node);
 
 742 ------------------------------------------------------*/
 
 745 /*******************************************************************************
 
 747  * FUNCTION:    acpi_ns_terminate
 
 753  * DESCRIPTION: free memory allocated for namespace and ACPI table storage.
 
 755  ******************************************************************************/
 
 757 void acpi_ns_terminate(void)
 
 759         union acpi_operand_object *obj_desc;
 
 761         ACPI_FUNCTION_TRACE("ns_terminate");
 
 764          * 1) Free the entire namespace -- all nodes and objects
 
 766          * Delete all object descriptors attached to namepsace nodes
 
 768         acpi_ns_delete_namespace_subtree(acpi_gbl_root_node);
 
 770         /* Detach any objects attached to the root */
 
 772         obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node);
 
 774                 acpi_ns_detach_object(acpi_gbl_root_node);
 
 777         ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n"));
 
 780          * 2) Now we can delete the ACPI tables
 
 782         acpi_tb_delete_all_tables();
 
 783         ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
 
 788 /*******************************************************************************
 
 790  * FUNCTION:    acpi_ns_opens_scope
 
 792  * PARAMETERS:  Type        - A valid namespace type
 
 794  * RETURN:      NEWSCOPE if the passed type "opens a name scope" according
 
 795  *              to the ACPI specification, else 0
 
 797  ******************************************************************************/
 
 799 u32 acpi_ns_opens_scope(acpi_object_type type)
 
 801         ACPI_FUNCTION_TRACE_STR("ns_opens_scope", acpi_ut_get_type_name(type));
 
 803         if (!acpi_ut_valid_object_type(type)) {
 
 804                 /* type code out of range  */
 
 806                 ACPI_REPORT_WARNING(("ns_opens_scope: Invalid Object Type %X\n",
 
 808                 return_VALUE(ACPI_NS_NORMAL);
 
 811         return_VALUE(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
 
 814 /*******************************************************************************
 
 816  * FUNCTION:    acpi_ns_get_node_by_path
 
 818  * PARAMETERS:  *Pathname   - Name to be found, in external (ASL) format. The
 
 819  *                            \ (backslash) and ^ (carat) prefixes, and the
 
 820  *                            . (period) to separate segments are supported.
 
 821  *              start_node  - Root of subtree to be searched, or NS_ALL for the
 
 822  *                            root of the name space.  If Name is fully
 
 823  *                            qualified (first s8 is '\'), the passed value
 
 824  *                            of Scope will not be accessed.
 
 825  *              Flags       - Used to indicate whether to perform upsearch or
 
 827  *              return_node - Where the Node is returned
 
 829  * DESCRIPTION: Look up a name relative to a given scope and return the
 
 830  *              corresponding Node.  NOTE: Scope can be null.
 
 832  * MUTEX:       Locks namespace
 
 834  ******************************************************************************/
 
 837 acpi_ns_get_node_by_path(char *pathname,
 
 838                          struct acpi_namespace_node *start_node,
 
 839                          u32 flags, struct acpi_namespace_node **return_node)
 
 841         union acpi_generic_state scope_info;
 
 843         char *internal_path = NULL;
 
 845         ACPI_FUNCTION_TRACE_PTR("ns_get_node_by_path", pathname);
 
 848                 /* Convert path to internal representation */
 
 850                 status = acpi_ns_internalize_name(pathname, &internal_path);
 
 851                 if (ACPI_FAILURE(status)) {
 
 852                         return_ACPI_STATUS(status);
 
 856         /* Must lock namespace during lookup */
 
 858         status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
 
 859         if (ACPI_FAILURE(status)) {
 
 863         /* Setup lookup scope (search starting point) */
 
 865         scope_info.scope.node = start_node;
 
 867         /* Lookup the name in the namespace */
 
 869         status = acpi_ns_lookup(&scope_info, internal_path,
 
 870                                 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
 
 871                                 (flags | ACPI_NS_DONT_OPEN_SCOPE),
 
 873         if (ACPI_FAILURE(status)) {
 
 874                 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s, %s\n",
 
 876                                   acpi_format_exception(status)));
 
 879         (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
 
 883                 ACPI_MEM_FREE(internal_path);
 
 885         return_ACPI_STATUS(status);
 
 888 /*******************************************************************************
 
 890  * FUNCTION:    acpi_ns_get_parent_node
 
 892  * PARAMETERS:  Node       - Current table entry
 
 894  * RETURN:      Parent entry of the given entry
 
 896  * DESCRIPTION: Obtain the parent entry for a given entry in the namespace.
 
 898  ******************************************************************************/
 
 900 struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node
 
 903         ACPI_FUNCTION_ENTRY();
 
 910          * Walk to the end of this peer list. The last entry is marked with a flag
 
 911          * and the peer pointer is really a pointer back to the parent. This saves
 
 912          * putting a parent back pointer in each and every named object!
 
 914         while (!(node->flags & ANOBJ_END_OF_PEER_LIST)) {
 
 921 /*******************************************************************************
 
 923  * FUNCTION:    acpi_ns_get_next_valid_node
 
 925  * PARAMETERS:  Node       - Current table entry
 
 927  * RETURN:      Next valid Node in the linked node list. NULL if no more valid
 
 930  * DESCRIPTION: Find the next valid node within a name table.
 
 931  *              Useful for implementing NULL-end-of-list loops.
 
 933  ******************************************************************************/
 
 935 struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct
 
 940         /* If we are at the end of this peer list, return NULL */
 
 942         if (node->flags & ANOBJ_END_OF_PEER_LIST) {
 
 946         /* Otherwise just return the next peer */
 
 951 #ifdef ACPI_OBSOLETE_FUNCTIONS
 
 952 /*******************************************************************************
 
 954  * FUNCTION:    acpi_ns_find_parent_name
 
 956  * PARAMETERS:  *child_node            - Named Obj whose name is to be found
 
 958  * RETURN:      The ACPI name
 
 960  * DESCRIPTION: Search for the given obj in its parent scope and return the
 
 961  *              name segment, or "????" if the parent name can't be found
 
 962  *              (which "should not happen").
 
 964  ******************************************************************************/
 
 966 acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node * child_node)
 
 968         struct acpi_namespace_node *parent_node;
 
 970         ACPI_FUNCTION_TRACE("ns_find_parent_name");
 
 973                 /* Valid entry.  Get the parent Node */
 
 975                 parent_node = acpi_ns_get_parent_node(child_node);
 
 977                         ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
 
 978                                           "Parent of %p [%4.4s] is %p [%4.4s]\n",
 
 980                                           acpi_ut_get_node_name(child_node),
 
 982                                           acpi_ut_get_node_name(parent_node)));
 
 984                         if (parent_node->name.integer) {
 
 985                                 return_VALUE((acpi_name) parent_node->name.
 
 990                 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
 
 991                                   "Unable to find parent of %p (%4.4s)\n",
 
 993                                   acpi_ut_get_node_name(child_node)));
 
 996         return_VALUE(ACPI_UNKNOWN_NAME);