Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
0002 /*******************************************************************************
0003  *
0004  * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
0005  *
0006  ******************************************************************************/
0007 
0008 #include <acpi/acpi.h>
0009 #include "accommon.h"
0010 #include "amlcode.h"
0011 #include "acnamesp.h"
0012 #include "acdispat.h"
0013 
0014 #ifdef ACPI_ASL_COMPILER
0015 #include "acdisasm.h"
0016 #endif
0017 
0018 #define _COMPONENT          ACPI_NAMESPACE
0019 ACPI_MODULE_NAME("nsaccess")
0020 
0021 /*******************************************************************************
0022  *
0023  * FUNCTION:    acpi_ns_root_initialize
0024  *
0025  * PARAMETERS:  None
0026  *
0027  * RETURN:      Status
0028  *
0029  * DESCRIPTION: Allocate and initialize the default root named objects
0030  *
0031  * MUTEX:       Locks namespace for entire execution
0032  *
0033  ******************************************************************************/
0034 acpi_status acpi_ns_root_initialize(void)
0035 {
0036     acpi_status status;
0037     const struct acpi_predefined_names *init_val = NULL;
0038     struct acpi_namespace_node *new_node;
0039     struct acpi_namespace_node *prev_node = NULL;
0040     union acpi_operand_object *obj_desc;
0041     acpi_string val = NULL;
0042 
0043     ACPI_FUNCTION_TRACE(ns_root_initialize);
0044 
0045     status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
0046     if (ACPI_FAILURE(status)) {
0047         return_ACPI_STATUS(status);
0048     }
0049 
0050     /*
0051      * The global root ptr is initially NULL, so a non-NULL value indicates
0052      * that acpi_ns_root_initialize() has already been called; just return.
0053      */
0054     if (acpi_gbl_root_node) {
0055         status = AE_OK;
0056         goto unlock_and_exit;
0057     }
0058 
0059     /*
0060      * Tell the rest of the subsystem that the root is initialized
0061      * (This is OK because the namespace is locked)
0062      */
0063     acpi_gbl_root_node = &acpi_gbl_root_node_struct;
0064 
0065     /* Enter the predefined names in the name table */
0066 
0067     ACPI_DEBUG_PRINT((ACPI_DB_INFO,
0068               "Entering predefined entries into namespace\n"));
0069 
0070     /*
0071      * Create the initial (default) namespace.
0072      * This namespace looks like something similar to this:
0073      *
0074      *   ACPI Namespace (from Namespace Root):
0075      *    0  _GPE Scope        00203160 00
0076      *    0  _PR_ Scope        002031D0 00
0077      *    0  _SB_ Device       00203240 00 Notify Object: 0020ADD8
0078      *    0  _SI_ Scope        002032B0 00
0079      *    0  _TZ_ Device       00203320 00
0080      *    0  _REV Integer      00203390 00 = 0000000000000002
0081      *    0  _OS_ String       00203488 00 Len 14 "Microsoft Windows NT"
0082      *    0  _GL_ Mutex        00203580 00 Object 002035F0
0083      *    0  _OSI Method       00203678 00 Args 1 Len 0000 Aml 00000000
0084      */
0085     for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) {
0086         status = AE_OK;
0087 
0088         /* _OSI is optional for now, will be permanent later */
0089 
0090         if (!strcmp(init_val->name, "_OSI")
0091             && !acpi_gbl_create_osi_method) {
0092             continue;
0093         }
0094 
0095         /*
0096          * Create, init, and link the new predefined name
0097          * Note: No need to use acpi_ns_lookup here because all the
0098          * predefined names are at the root level. It is much easier to
0099          * just create and link the new node(s) here.
0100          */
0101         new_node =
0102             acpi_ns_create_node(*ACPI_CAST_PTR(u32, init_val->name));
0103         if (!new_node) {
0104             status = AE_NO_MEMORY;
0105             goto unlock_and_exit;
0106         }
0107 
0108         new_node->descriptor_type = ACPI_DESC_TYPE_NAMED;
0109         new_node->type = init_val->type;
0110 
0111         if (!prev_node) {
0112             acpi_gbl_root_node_struct.child = new_node;
0113         } else {
0114             prev_node->peer = new_node;
0115         }
0116 
0117         new_node->parent = &acpi_gbl_root_node_struct;
0118         prev_node = new_node;
0119 
0120         /*
0121          * Name entered successfully. If entry in pre_defined_names[] specifies
0122          * an initial value, create the initial value.
0123          */
0124         if (init_val->val) {
0125             status = acpi_os_predefined_override(init_val, &val);
0126             if (ACPI_FAILURE(status)) {
0127                 ACPI_ERROR((AE_INFO,
0128                         "Could not override predefined %s",
0129                         init_val->name));
0130             }
0131 
0132             if (!val) {
0133                 val = init_val->val;
0134             }
0135 
0136             /*
0137              * Entry requests an initial value, allocate a
0138              * descriptor for it.
0139              */
0140             obj_desc =
0141                 acpi_ut_create_internal_object(init_val->type);
0142             if (!obj_desc) {
0143                 status = AE_NO_MEMORY;
0144                 goto unlock_and_exit;
0145             }
0146 
0147             /*
0148              * Convert value string from table entry to
0149              * internal representation. Only types actually
0150              * used for initial values are implemented here.
0151              */
0152             switch (init_val->type) {
0153             case ACPI_TYPE_METHOD:
0154 
0155                 obj_desc->method.param_count =
0156                     (u8) ACPI_TO_INTEGER(val);
0157                 obj_desc->common.flags |= AOPOBJ_DATA_VALID;
0158 
0159 #if defined (ACPI_ASL_COMPILER)
0160 
0161                 /* Save the parameter count for the iASL compiler */
0162 
0163                 new_node->value = obj_desc->method.param_count;
0164 #else
0165                 /* Mark this as a very SPECIAL method (_OSI) */
0166 
0167                 obj_desc->method.info_flags =
0168                     ACPI_METHOD_INTERNAL_ONLY;
0169                 obj_desc->method.dispatch.implementation =
0170                     acpi_ut_osi_implementation;
0171 #endif
0172                 break;
0173 
0174             case ACPI_TYPE_INTEGER:
0175 
0176                 obj_desc->integer.value = ACPI_TO_INTEGER(val);
0177                 break;
0178 
0179             case ACPI_TYPE_STRING:
0180 
0181                 /* Build an object around the static string */
0182 
0183                 obj_desc->string.length = (u32)strlen(val);
0184                 obj_desc->string.pointer = val;
0185                 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
0186                 break;
0187 
0188             case ACPI_TYPE_MUTEX:
0189 
0190                 obj_desc->mutex.node = new_node;
0191                 obj_desc->mutex.sync_level =
0192                     (u8) (ACPI_TO_INTEGER(val) - 1);
0193 
0194                 /* Create a mutex */
0195 
0196                 status =
0197                     acpi_os_create_mutex(&obj_desc->mutex.
0198                              os_mutex);
0199                 if (ACPI_FAILURE(status)) {
0200                     acpi_ut_remove_reference(obj_desc);
0201                     goto unlock_and_exit;
0202                 }
0203 
0204                 /* Special case for ACPI Global Lock */
0205 
0206                 if (strcmp(init_val->name, "_GL_") == 0) {
0207                     acpi_gbl_global_lock_mutex = obj_desc;
0208 
0209                     /* Create additional counting semaphore for global lock */
0210 
0211                     status =
0212                         acpi_os_create_semaphore(1, 0,
0213                                      &acpi_gbl_global_lock_semaphore);
0214                     if (ACPI_FAILURE(status)) {
0215                         acpi_ut_remove_reference
0216                             (obj_desc);
0217                         goto unlock_and_exit;
0218                     }
0219                 }
0220                 break;
0221 
0222             default:
0223 
0224                 ACPI_ERROR((AE_INFO,
0225                         "Unsupported initial type value 0x%X",
0226                         init_val->type));
0227                 acpi_ut_remove_reference(obj_desc);
0228                 obj_desc = NULL;
0229                 continue;
0230             }
0231 
0232             /* Store pointer to value descriptor in the Node */
0233 
0234             status = acpi_ns_attach_object(new_node, obj_desc,
0235                                obj_desc->common.type);
0236 
0237             /* Remove local reference to the object */
0238 
0239             acpi_ut_remove_reference(obj_desc);
0240         }
0241     }
0242 
0243 unlock_and_exit:
0244     (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
0245 
0246     /* Save a handle to "_GPE", it is always present */
0247 
0248     if (ACPI_SUCCESS(status)) {
0249         status = acpi_ns_get_node(NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH,
0250                       &acpi_gbl_fadt_gpe_device);
0251     }
0252 
0253     return_ACPI_STATUS(status);
0254 }
0255 
0256 /*******************************************************************************
0257  *
0258  * FUNCTION:    acpi_ns_lookup
0259  *
0260  * PARAMETERS:  scope_info      - Current scope info block
0261  *              pathname        - Search pathname, in internal format
0262  *                                (as represented in the AML stream)
0263  *              type            - Type associated with name
0264  *              interpreter_mode - IMODE_LOAD_PASS2 => add name if not found
0265  *              flags           - Flags describing the search restrictions
0266  *              walk_state      - Current state of the walk
0267  *              return_node     - Where the Node is placed (if found
0268  *                                or created successfully)
0269  *
0270  * RETURN:      Status
0271  *
0272  * DESCRIPTION: Find or enter the passed name in the name space.
0273  *              Log an error if name not found in Exec mode.
0274  *
0275  * MUTEX:       Assumes namespace is locked.
0276  *
0277  ******************************************************************************/
0278 
0279 acpi_status
0280 acpi_ns_lookup(union acpi_generic_state *scope_info,
0281            char *pathname,
0282            acpi_object_type type,
0283            acpi_interpreter_mode interpreter_mode,
0284            u32 flags,
0285            struct acpi_walk_state *walk_state,
0286            struct acpi_namespace_node **return_node)
0287 {
0288     acpi_status status;
0289     char *path = pathname;
0290     char *external_path;
0291     struct acpi_namespace_node *prefix_node;
0292     struct acpi_namespace_node *current_node = NULL;
0293     struct acpi_namespace_node *this_node = NULL;
0294     u32 num_segments;
0295     u32 num_carats;
0296     acpi_name simple_name;
0297     acpi_object_type type_to_check_for;
0298     acpi_object_type this_search_type;
0299     u32 search_parent_flag = ACPI_NS_SEARCH_PARENT;
0300     u32 local_flags;
0301     acpi_interpreter_mode local_interpreter_mode;
0302 
0303     ACPI_FUNCTION_TRACE(ns_lookup);
0304 
0305     if (!return_node) {
0306         return_ACPI_STATUS(AE_BAD_PARAMETER);
0307     }
0308 
0309     local_flags = flags &
0310         ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_OVERRIDE_IF_FOUND |
0311           ACPI_NS_SEARCH_PARENT);
0312     *return_node = ACPI_ENTRY_NOT_FOUND;
0313     acpi_gbl_ns_lookup_count++;
0314 
0315     if (!acpi_gbl_root_node) {
0316         return_ACPI_STATUS(AE_NO_NAMESPACE);
0317     }
0318 
0319     /* Get the prefix scope. A null scope means use the root scope */
0320 
0321     if ((!scope_info) || (!scope_info->scope.node)) {
0322         ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
0323                   "Null scope prefix, using root node (%p)\n",
0324                   acpi_gbl_root_node));
0325 
0326         prefix_node = acpi_gbl_root_node;
0327     } else {
0328         prefix_node = scope_info->scope.node;
0329         if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) !=
0330             ACPI_DESC_TYPE_NAMED) {
0331             ACPI_ERROR((AE_INFO, "%p is not a namespace node [%s]",
0332                     prefix_node,
0333                     acpi_ut_get_descriptor_name(prefix_node)));
0334             return_ACPI_STATUS(AE_AML_INTERNAL);
0335         }
0336 
0337         if (!(flags & ACPI_NS_PREFIX_IS_SCOPE)) {
0338             /*
0339              * This node might not be a actual "scope" node (such as a
0340              * Device/Method, etc.)  It could be a Package or other object
0341              * node. Backup up the tree to find the containing scope node.
0342              */
0343             while (!acpi_ns_opens_scope(prefix_node->type) &&
0344                    prefix_node->type != ACPI_TYPE_ANY) {
0345                 prefix_node = prefix_node->parent;
0346             }
0347         }
0348     }
0349 
0350     /* Save type. TBD: may be no longer necessary */
0351 
0352     type_to_check_for = type;
0353 
0354     /*
0355      * Begin examination of the actual pathname
0356      */
0357     if (!pathname) {
0358 
0359         /* A Null name_path is allowed and refers to the root */
0360 
0361         num_segments = 0;
0362         this_node = acpi_gbl_root_node;
0363         path = "";
0364 
0365         ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
0366                   "Null Pathname (Zero segments), Flags=%X\n",
0367                   flags));
0368     } else {
0369         /*
0370          * Name pointer is valid (and must be in internal name format)
0371          *
0372          * Check for scope prefixes:
0373          *
0374          * As represented in the AML stream, a namepath consists of an
0375          * optional scope prefix followed by a name segment part.
0376          *
0377          * If present, the scope prefix is either a Root Prefix (in
0378          * which case the name is fully qualified), or one or more
0379          * Parent Prefixes (in which case the name's scope is relative
0380          * to the current scope).
0381          */
0382         if (*path == (u8) AML_ROOT_PREFIX) {
0383 
0384             /* Pathname is fully qualified, start from the root */
0385 
0386             this_node = acpi_gbl_root_node;
0387             search_parent_flag = ACPI_NS_NO_UPSEARCH;
0388 
0389             /* Point to name segment part */
0390 
0391             path++;
0392 
0393             ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
0394                       "Path is absolute from root [%p]\n",
0395                       this_node));
0396         } else {
0397             /* Pathname is relative to current scope, start there */
0398 
0399             ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
0400                       "Searching relative to prefix scope [%4.4s] (%p)\n",
0401                       acpi_ut_get_node_name(prefix_node),
0402                       prefix_node));
0403 
0404             /*
0405              * Handle multiple Parent Prefixes (carat) by just getting
0406              * the parent node for each prefix instance.
0407              */
0408             this_node = prefix_node;
0409             num_carats = 0;
0410             while (*path == (u8) AML_PARENT_PREFIX) {
0411 
0412                 /* Name is fully qualified, no search rules apply */
0413 
0414                 search_parent_flag = ACPI_NS_NO_UPSEARCH;
0415 
0416                 /*
0417                  * Point past this prefix to the name segment
0418                  * part or the next Parent Prefix
0419                  */
0420                 path++;
0421 
0422                 /* Backup to the parent node */
0423 
0424                 num_carats++;
0425                 this_node = this_node->parent;
0426                 if (!this_node) {
0427                     /*
0428                      * Current scope has no parent scope. Externalize
0429                      * the internal path for error message.
0430                      */
0431                     status =
0432                         acpi_ns_externalize_name
0433                         (ACPI_UINT32_MAX, pathname, NULL,
0434                          &external_path);
0435                     if (ACPI_SUCCESS(status)) {
0436                         ACPI_ERROR((AE_INFO,
0437                                 "%s: Path has too many parent prefixes (^)",
0438                                 external_path));
0439 
0440                         ACPI_FREE(external_path);
0441                     }
0442 
0443                     return_ACPI_STATUS(AE_NOT_FOUND);
0444                 }
0445             }
0446 
0447             if (search_parent_flag == ACPI_NS_NO_UPSEARCH) {
0448                 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
0449                           "Search scope is [%4.4s], path has %u carat(s)\n",
0450                           acpi_ut_get_node_name
0451                           (this_node), num_carats));
0452             }
0453         }
0454 
0455         /*
0456          * Determine the number of ACPI name segments in this pathname.
0457          *
0458          * The segment part consists of either:
0459          *  - A Null name segment (0)
0460          *  - A dual_name_prefix followed by two 4-byte name segments
0461          *  - A multi_name_prefix followed by a byte indicating the
0462          *      number of segments and the segments themselves.
0463          *  - A single 4-byte name segment
0464          *
0465          * Examine the name prefix opcode, if any, to determine the number of
0466          * segments.
0467          */
0468         switch (*path) {
0469         case 0:
0470             /*
0471              * Null name after a root or parent prefixes. We already
0472              * have the correct target node and there are no name segments.
0473              */
0474             num_segments = 0;
0475             type = this_node->type;
0476 
0477             ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
0478                       "Prefix-only Pathname (Zero name segments), Flags=%X\n",
0479                       flags));
0480             break;
0481 
0482         case AML_DUAL_NAME_PREFIX:
0483 
0484             /* More than one name_seg, search rules do not apply */
0485 
0486             search_parent_flag = ACPI_NS_NO_UPSEARCH;
0487 
0488             /* Two segments, point to first name segment */
0489 
0490             num_segments = 2;
0491             path++;
0492 
0493             ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
0494                       "Dual Pathname (2 segments, Flags=%X)\n",
0495                       flags));
0496             break;
0497 
0498         case AML_MULTI_NAME_PREFIX:
0499 
0500             /* More than one name_seg, search rules do not apply */
0501 
0502             search_parent_flag = ACPI_NS_NO_UPSEARCH;
0503 
0504             /* Extract segment count, point to first name segment */
0505 
0506             path++;
0507             num_segments = (u32) (u8) * path;
0508             path++;
0509 
0510             ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
0511                       "Multi Pathname (%u Segments, Flags=%X)\n",
0512                       num_segments, flags));
0513             break;
0514 
0515         default:
0516             /*
0517              * Not a Null name, no Dual or Multi prefix, hence there is
0518              * only one name segment and Pathname is already pointing to it.
0519              */
0520             num_segments = 1;
0521 
0522             ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
0523                       "Simple Pathname (1 segment, Flags=%X)\n",
0524                       flags));
0525             break;
0526         }
0527 
0528         ACPI_DEBUG_EXEC(acpi_ns_print_pathname(num_segments, path));
0529     }
0530 
0531     /*
0532      * Search namespace for each segment of the name. Loop through and
0533      * verify (or add to the namespace) each name segment.
0534      *
0535      * The object type is significant only at the last name
0536      * segment. (We don't care about the types along the path, only
0537      * the type of the final target object.)
0538      */
0539     this_search_type = ACPI_TYPE_ANY;
0540     current_node = this_node;
0541 
0542     while (num_segments && current_node) {
0543         num_segments--;
0544         if (!num_segments) {
0545 
0546             /* This is the last segment, enable typechecking */
0547 
0548             this_search_type = type;
0549 
0550             /*
0551              * Only allow automatic parent search (search rules) if the caller
0552              * requested it AND we have a single, non-fully-qualified name_seg
0553              */
0554             if ((search_parent_flag != ACPI_NS_NO_UPSEARCH) &&
0555                 (flags & ACPI_NS_SEARCH_PARENT)) {
0556                 local_flags |= ACPI_NS_SEARCH_PARENT;
0557             }
0558 
0559             /* Set error flag according to caller */
0560 
0561             if (flags & ACPI_NS_ERROR_IF_FOUND) {
0562                 local_flags |= ACPI_NS_ERROR_IF_FOUND;
0563             }
0564 
0565             /* Set override flag according to caller */
0566 
0567             if (flags & ACPI_NS_OVERRIDE_IF_FOUND) {
0568                 local_flags |= ACPI_NS_OVERRIDE_IF_FOUND;
0569             }
0570         }
0571 
0572         /* Handle opcodes that create a new name_seg via a full name_path */
0573 
0574         local_interpreter_mode = interpreter_mode;
0575         if ((flags & ACPI_NS_PREFIX_MUST_EXIST) && (num_segments > 0)) {
0576 
0577             /* Every element of the path must exist (except for the final name_seg) */
0578 
0579             local_interpreter_mode = ACPI_IMODE_EXECUTE;
0580         }
0581 
0582         /* Extract one ACPI name from the front of the pathname */
0583 
0584         ACPI_MOVE_32_TO_32(&simple_name, path);
0585 
0586         /* Try to find the single (4 character) ACPI name */
0587 
0588         status =
0589             acpi_ns_search_and_enter(simple_name, walk_state,
0590                          current_node,
0591                          local_interpreter_mode,
0592                          this_search_type, local_flags,
0593                          &this_node);
0594         if (ACPI_FAILURE(status)) {
0595             if (status == AE_NOT_FOUND) {
0596 #if !defined ACPI_ASL_COMPILER  /* Note: iASL reports this error by itself, not needed here */
0597                 if (flags & ACPI_NS_PREFIX_MUST_EXIST) {
0598                     acpi_os_printf(ACPI_MSG_BIOS_ERROR
0599                                "Object does not exist: %4.4s\n",
0600                                (char *)&simple_name);
0601                 }
0602 #endif
0603                 /* Name not found in ACPI namespace */
0604 
0605                 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
0606                           "Name [%4.4s] not found in scope [%4.4s] %p\n",
0607                           (char *)&simple_name,
0608                           (char *)&current_node->name,
0609                           current_node));
0610             }
0611 #ifdef ACPI_EXEC_APP
0612             if ((status == AE_ALREADY_EXISTS) &&
0613                 (this_node->flags & ANOBJ_NODE_EARLY_INIT)) {
0614                 this_node->flags &= ~ANOBJ_NODE_EARLY_INIT;
0615                 status = AE_OK;
0616             }
0617 #endif
0618 
0619 #ifdef ACPI_ASL_COMPILER
0620             /*
0621              * If this ACPI name already exists within the namespace as an
0622              * external declaration, then mark the external as a conflicting
0623              * declaration and proceed to process the current node as if it did
0624              * not exist in the namespace. If this node is not processed as
0625              * normal, then it could cause improper namespace resolution
0626              * by failing to open a new scope.
0627              */
0628             if (acpi_gbl_disasm_flag &&
0629                 (status == AE_ALREADY_EXISTS) &&
0630                 ((this_node->flags & ANOBJ_IS_EXTERNAL) ||
0631                  (walk_state
0632                   && walk_state->opcode == AML_EXTERNAL_OP))) {
0633                 this_node->flags &= ~ANOBJ_IS_EXTERNAL;
0634                 this_node->type = (u8)this_search_type;
0635                 if (walk_state->opcode != AML_EXTERNAL_OP) {
0636                     acpi_dm_mark_external_conflict
0637                         (this_node);
0638                 }
0639                 break;
0640             }
0641 #endif
0642 
0643             *return_node = this_node;
0644             return_ACPI_STATUS(status);
0645         }
0646 
0647         /* More segments to follow? */
0648 
0649         if (num_segments > 0) {
0650             /*
0651              * If we have an alias to an object that opens a scope (such as a
0652              * device or processor), we need to dereference the alias here so
0653              * that we can access any children of the original node (via the
0654              * remaining segments).
0655              */
0656             if (this_node->type == ACPI_TYPE_LOCAL_ALIAS) {
0657                 if (!this_node->object) {
0658                     return_ACPI_STATUS(AE_NOT_EXIST);
0659                 }
0660 
0661                 if (acpi_ns_opens_scope
0662                     (((struct acpi_namespace_node *)
0663                       this_node->object)->type)) {
0664                     this_node =
0665                         (struct acpi_namespace_node *)
0666                         this_node->object;
0667                 }
0668             }
0669         }
0670 
0671         /* Special handling for the last segment (num_segments == 0) */
0672 
0673         else {
0674             /*
0675              * Sanity typecheck of the target object:
0676              *
0677              * If 1) This is the last segment (num_segments == 0)
0678              *    2) And we are looking for a specific type
0679              *       (Not checking for TYPE_ANY)
0680              *    3) Which is not an alias
0681              *    4) Which is not a local type (TYPE_SCOPE)
0682              *    5) And the type of target object is known (not TYPE_ANY)
0683              *    6) And target object does not match what we are looking for
0684              *
0685              * Then we have a type mismatch. Just warn and ignore it.
0686              */
0687             if ((type_to_check_for != ACPI_TYPE_ANY) &&
0688                 (type_to_check_for != ACPI_TYPE_LOCAL_ALIAS) &&
0689                 (type_to_check_for != ACPI_TYPE_LOCAL_METHOD_ALIAS)
0690                 && (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE)
0691                 && (this_node->type != ACPI_TYPE_ANY)
0692                 && (this_node->type != type_to_check_for)) {
0693 
0694                 /* Complain about a type mismatch */
0695 
0696                 ACPI_WARNING((AE_INFO,
0697                           "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)",
0698                           ACPI_CAST_PTR(char, &simple_name),
0699                           acpi_ut_get_type_name(this_node->
0700                                     type),
0701                           acpi_ut_get_type_name
0702                           (type_to_check_for)));
0703             }
0704 
0705             /*
0706              * If this is the last name segment and we are not looking for a
0707              * specific type, but the type of found object is known, use that
0708              * type to (later) see if it opens a scope.
0709              */
0710             if (type == ACPI_TYPE_ANY) {
0711                 type = this_node->type;
0712             }
0713         }
0714 
0715         /* Point to next name segment and make this node current */
0716 
0717         path += ACPI_NAMESEG_SIZE;
0718         current_node = this_node;
0719     }
0720 
0721     /* Always check if we need to open a new scope */
0722 
0723     if (!(flags & ACPI_NS_DONT_OPEN_SCOPE) && (walk_state)) {
0724         /*
0725          * If entry is a type which opens a scope, push the new scope on the
0726          * scope stack.
0727          */
0728         if (acpi_ns_opens_scope(type)) {
0729             status =
0730                 acpi_ds_scope_stack_push(this_node, type,
0731                              walk_state);
0732             if (ACPI_FAILURE(status)) {
0733                 return_ACPI_STATUS(status);
0734             }
0735         }
0736     }
0737 #ifdef ACPI_EXEC_APP
0738     if (flags & ACPI_NS_EARLY_INIT) {
0739         this_node->flags |= ANOBJ_NODE_EARLY_INIT;
0740     }
0741 #endif
0742 
0743     *return_node = this_node;
0744     return_ACPI_STATUS(AE_OK);
0745 }