nsaccess.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /*******************************************************************************
  3. *
  4. * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
  5. *
  6. ******************************************************************************/
  7. #include <acpi/acpi.h>
  8. #include "accommon.h"
  9. #include "amlcode.h"
  10. #include "acnamesp.h"
  11. #include "acdispat.h"
  12. #ifdef ACPI_ASL_COMPILER
  13. #include "acdisasm.h"
  14. #endif
  15. #define _COMPONENT ACPI_NAMESPACE
  16. ACPI_MODULE_NAME("nsaccess")
  17. /*******************************************************************************
  18. *
  19. * FUNCTION: acpi_ns_root_initialize
  20. *
  21. * PARAMETERS: None
  22. *
  23. * RETURN: Status
  24. *
  25. * DESCRIPTION: Allocate and initialize the default root named objects
  26. *
  27. * MUTEX: Locks namespace for entire execution
  28. *
  29. ******************************************************************************/
  30. acpi_status acpi_ns_root_initialize(void)
  31. {
  32. acpi_status status;
  33. const struct acpi_predefined_names *init_val = NULL;
  34. struct acpi_namespace_node *new_node;
  35. struct acpi_namespace_node *prev_node = NULL;
  36. union acpi_operand_object *obj_desc;
  37. acpi_string val = NULL;
  38. ACPI_FUNCTION_TRACE(ns_root_initialize);
  39. status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
  40. if (ACPI_FAILURE(status)) {
  41. return_ACPI_STATUS(status);
  42. }
  43. /*
  44. * The global root ptr is initially NULL, so a non-NULL value indicates
  45. * that acpi_ns_root_initialize() has already been called; just return.
  46. */
  47. if (acpi_gbl_root_node) {
  48. status = AE_OK;
  49. goto unlock_and_exit;
  50. }
  51. /*
  52. * Tell the rest of the subsystem that the root is initialized
  53. * (This is OK because the namespace is locked)
  54. */
  55. acpi_gbl_root_node = &acpi_gbl_root_node_struct;
  56. /* Enter the predefined names in the name table */
  57. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  58. "Entering predefined entries into namespace\n"));
  59. /*
  60. * Create the initial (default) namespace.
  61. * This namespace looks like something similar to this:
  62. *
  63. * ACPI Namespace (from Namespace Root):
  64. * 0 _GPE Scope 00203160 00
  65. * 0 _PR_ Scope 002031D0 00
  66. * 0 _SB_ Device 00203240 00 Notify Object: 0020ADD8
  67. * 0 _SI_ Scope 002032B0 00
  68. * 0 _TZ_ Device 00203320 00
  69. * 0 _REV Integer 00203390 00 = 0000000000000002
  70. * 0 _OS_ String 00203488 00 Len 14 "Microsoft Windows NT"
  71. * 0 _GL_ Mutex 00203580 00 Object 002035F0
  72. * 0 _OSI Method 00203678 00 Args 1 Len 0000 Aml 00000000
  73. */
  74. for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) {
  75. status = AE_OK;
  76. /* _OSI is optional for now, will be permanent later */
  77. if (!strcmp(init_val->name, "_OSI")
  78. && !acpi_gbl_create_osi_method) {
  79. continue;
  80. }
  81. /*
  82. * Create, init, and link the new predefined name
  83. * Note: No need to use acpi_ns_lookup here because all the
  84. * predefined names are at the root level. It is much easier to
  85. * just create and link the new node(s) here.
  86. */
  87. new_node =
  88. acpi_ns_create_node(*ACPI_CAST_PTR(u32, init_val->name));
  89. if (!new_node) {
  90. status = AE_NO_MEMORY;
  91. goto unlock_and_exit;
  92. }
  93. new_node->descriptor_type = ACPI_DESC_TYPE_NAMED;
  94. new_node->type = init_val->type;
  95. if (!prev_node) {
  96. acpi_gbl_root_node_struct.child = new_node;
  97. } else {
  98. prev_node->peer = new_node;
  99. }
  100. new_node->parent = &acpi_gbl_root_node_struct;
  101. prev_node = new_node;
  102. /*
  103. * Name entered successfully. If entry in pre_defined_names[] specifies
  104. * an initial value, create the initial value.
  105. */
  106. if (init_val->val) {
  107. status = acpi_os_predefined_override(init_val, &val);
  108. if (ACPI_FAILURE(status)) {
  109. ACPI_ERROR((AE_INFO,
  110. "Could not override predefined %s",
  111. init_val->name));
  112. }
  113. if (!val) {
  114. val = init_val->val;
  115. }
  116. /*
  117. * Entry requests an initial value, allocate a
  118. * descriptor for it.
  119. */
  120. obj_desc =
  121. acpi_ut_create_internal_object(init_val->type);
  122. if (!obj_desc) {
  123. status = AE_NO_MEMORY;
  124. goto unlock_and_exit;
  125. }
  126. /*
  127. * Convert value string from table entry to
  128. * internal representation. Only types actually
  129. * used for initial values are implemented here.
  130. */
  131. switch (init_val->type) {
  132. case ACPI_TYPE_METHOD:
  133. obj_desc->method.param_count =
  134. (u8) ACPI_TO_INTEGER(val);
  135. obj_desc->common.flags |= AOPOBJ_DATA_VALID;
  136. #if defined (ACPI_ASL_COMPILER)
  137. /* Save the parameter count for the iASL compiler */
  138. new_node->value = obj_desc->method.param_count;
  139. #else
  140. /* Mark this as a very SPECIAL method (_OSI) */
  141. obj_desc->method.info_flags =
  142. ACPI_METHOD_INTERNAL_ONLY;
  143. obj_desc->method.dispatch.implementation =
  144. acpi_ut_osi_implementation;
  145. #endif
  146. break;
  147. case ACPI_TYPE_INTEGER:
  148. obj_desc->integer.value = ACPI_TO_INTEGER(val);
  149. break;
  150. case ACPI_TYPE_STRING:
  151. /* Build an object around the static string */
  152. obj_desc->string.length = (u32)strlen(val);
  153. obj_desc->string.pointer = val;
  154. obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
  155. break;
  156. case ACPI_TYPE_MUTEX:
  157. obj_desc->mutex.node = new_node;
  158. obj_desc->mutex.sync_level =
  159. (u8) (ACPI_TO_INTEGER(val) - 1);
  160. /* Create a mutex */
  161. status =
  162. acpi_os_create_mutex(&obj_desc->mutex.
  163. os_mutex);
  164. if (ACPI_FAILURE(status)) {
  165. acpi_ut_remove_reference(obj_desc);
  166. goto unlock_and_exit;
  167. }
  168. /* Special case for ACPI Global Lock */
  169. if (strcmp(init_val->name, "_GL_") == 0) {
  170. acpi_gbl_global_lock_mutex = obj_desc;
  171. /* Create additional counting semaphore for global lock */
  172. status =
  173. acpi_os_create_semaphore(1, 0,
  174. &acpi_gbl_global_lock_semaphore);
  175. if (ACPI_FAILURE(status)) {
  176. acpi_ut_remove_reference
  177. (obj_desc);
  178. goto unlock_and_exit;
  179. }
  180. }
  181. break;
  182. default:
  183. ACPI_ERROR((AE_INFO,
  184. "Unsupported initial type value 0x%X",
  185. init_val->type));
  186. acpi_ut_remove_reference(obj_desc);
  187. obj_desc = NULL;
  188. continue;
  189. }
  190. /* Store pointer to value descriptor in the Node */
  191. status = acpi_ns_attach_object(new_node, obj_desc,
  192. obj_desc->common.type);
  193. /* Remove local reference to the object */
  194. acpi_ut_remove_reference(obj_desc);
  195. }
  196. }
  197. unlock_and_exit:
  198. (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  199. /* Save a handle to "_GPE", it is always present */
  200. if (ACPI_SUCCESS(status)) {
  201. status = acpi_ns_get_node(NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH,
  202. &acpi_gbl_fadt_gpe_device);
  203. }
  204. return_ACPI_STATUS(status);
  205. }
  206. /*******************************************************************************
  207. *
  208. * FUNCTION: acpi_ns_lookup
  209. *
  210. * PARAMETERS: scope_info - Current scope info block
  211. * pathname - Search pathname, in internal format
  212. * (as represented in the AML stream)
  213. * type - Type associated with name
  214. * interpreter_mode - IMODE_LOAD_PASS2 => add name if not found
  215. * flags - Flags describing the search restrictions
  216. * walk_state - Current state of the walk
  217. * return_node - Where the Node is placed (if found
  218. * or created successfully)
  219. *
  220. * RETURN: Status
  221. *
  222. * DESCRIPTION: Find or enter the passed name in the name space.
  223. * Log an error if name not found in Exec mode.
  224. *
  225. * MUTEX: Assumes namespace is locked.
  226. *
  227. ******************************************************************************/
  228. acpi_status
  229. acpi_ns_lookup(union acpi_generic_state *scope_info,
  230. char *pathname,
  231. acpi_object_type type,
  232. acpi_interpreter_mode interpreter_mode,
  233. u32 flags,
  234. struct acpi_walk_state *walk_state,
  235. struct acpi_namespace_node **return_node)
  236. {
  237. acpi_status status;
  238. char *path = pathname;
  239. char *external_path;
  240. struct acpi_namespace_node *prefix_node;
  241. struct acpi_namespace_node *current_node = NULL;
  242. struct acpi_namespace_node *this_node = NULL;
  243. u32 num_segments;
  244. u32 num_carats;
  245. acpi_name simple_name;
  246. acpi_object_type type_to_check_for;
  247. acpi_object_type this_search_type;
  248. u32 search_parent_flag = ACPI_NS_SEARCH_PARENT;
  249. u32 local_flags;
  250. acpi_interpreter_mode local_interpreter_mode;
  251. ACPI_FUNCTION_TRACE(ns_lookup);
  252. if (!return_node) {
  253. return_ACPI_STATUS(AE_BAD_PARAMETER);
  254. }
  255. local_flags = flags &
  256. ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_OVERRIDE_IF_FOUND |
  257. ACPI_NS_SEARCH_PARENT);
  258. *return_node = ACPI_ENTRY_NOT_FOUND;
  259. acpi_gbl_ns_lookup_count++;
  260. if (!acpi_gbl_root_node) {
  261. return_ACPI_STATUS(AE_NO_NAMESPACE);
  262. }
  263. /* Get the prefix scope. A null scope means use the root scope */
  264. if ((!scope_info) || (!scope_info->scope.node)) {
  265. ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
  266. "Null scope prefix, using root node (%p)\n",
  267. acpi_gbl_root_node));
  268. prefix_node = acpi_gbl_root_node;
  269. } else {
  270. prefix_node = scope_info->scope.node;
  271. if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) !=
  272. ACPI_DESC_TYPE_NAMED) {
  273. ACPI_ERROR((AE_INFO, "%p is not a namespace node [%s]",
  274. prefix_node,
  275. acpi_ut_get_descriptor_name(prefix_node)));
  276. return_ACPI_STATUS(AE_AML_INTERNAL);
  277. }
  278. if (!(flags & ACPI_NS_PREFIX_IS_SCOPE)) {
  279. /*
  280. * This node might not be a actual "scope" node (such as a
  281. * Device/Method, etc.) It could be a Package or other object
  282. * node. Backup up the tree to find the containing scope node.
  283. */
  284. while (!acpi_ns_opens_scope(prefix_node->type) &&
  285. prefix_node->type != ACPI_TYPE_ANY) {
  286. prefix_node = prefix_node->parent;
  287. }
  288. }
  289. }
  290. /* Save type. TBD: may be no longer necessary */
  291. type_to_check_for = type;
  292. /*
  293. * Begin examination of the actual pathname
  294. */
  295. if (!pathname) {
  296. /* A Null name_path is allowed and refers to the root */
  297. num_segments = 0;
  298. this_node = acpi_gbl_root_node;
  299. path = "";
  300. ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
  301. "Null Pathname (Zero segments), Flags=%X\n",
  302. flags));
  303. } else {
  304. /*
  305. * Name pointer is valid (and must be in internal name format)
  306. *
  307. * Check for scope prefixes:
  308. *
  309. * As represented in the AML stream, a namepath consists of an
  310. * optional scope prefix followed by a name segment part.
  311. *
  312. * If present, the scope prefix is either a Root Prefix (in
  313. * which case the name is fully qualified), or one or more
  314. * Parent Prefixes (in which case the name's scope is relative
  315. * to the current scope).
  316. */
  317. if (*path == (u8) AML_ROOT_PREFIX) {
  318. /* Pathname is fully qualified, start from the root */
  319. this_node = acpi_gbl_root_node;
  320. search_parent_flag = ACPI_NS_NO_UPSEARCH;
  321. /* Point to name segment part */
  322. path++;
  323. ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
  324. "Path is absolute from root [%p]\n",
  325. this_node));
  326. } else {
  327. /* Pathname is relative to current scope, start there */
  328. ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
  329. "Searching relative to prefix scope [%4.4s] (%p)\n",
  330. acpi_ut_get_node_name(prefix_node),
  331. prefix_node));
  332. /*
  333. * Handle multiple Parent Prefixes (carat) by just getting
  334. * the parent node for each prefix instance.
  335. */
  336. this_node = prefix_node;
  337. num_carats = 0;
  338. while (*path == (u8) AML_PARENT_PREFIX) {
  339. /* Name is fully qualified, no search rules apply */
  340. search_parent_flag = ACPI_NS_NO_UPSEARCH;
  341. /*
  342. * Point past this prefix to the name segment
  343. * part or the next Parent Prefix
  344. */
  345. path++;
  346. /* Backup to the parent node */
  347. num_carats++;
  348. this_node = this_node->parent;
  349. if (!this_node) {
  350. /*
  351. * Current scope has no parent scope. Externalize
  352. * the internal path for error message.
  353. */
  354. status =
  355. acpi_ns_externalize_name
  356. (ACPI_UINT32_MAX, pathname, NULL,
  357. &external_path);
  358. if (ACPI_SUCCESS(status)) {
  359. ACPI_ERROR((AE_INFO,
  360. "%s: Path has too many parent prefixes (^)",
  361. external_path));
  362. ACPI_FREE(external_path);
  363. }
  364. return_ACPI_STATUS(AE_NOT_FOUND);
  365. }
  366. }
  367. if (search_parent_flag == ACPI_NS_NO_UPSEARCH) {
  368. ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
  369. "Search scope is [%4.4s], path has %u carat(s)\n",
  370. acpi_ut_get_node_name
  371. (this_node), num_carats));
  372. }
  373. }
  374. /*
  375. * Determine the number of ACPI name segments in this pathname.
  376. *
  377. * The segment part consists of either:
  378. * - A Null name segment (0)
  379. * - A dual_name_prefix followed by two 4-byte name segments
  380. * - A multi_name_prefix followed by a byte indicating the
  381. * number of segments and the segments themselves.
  382. * - A single 4-byte name segment
  383. *
  384. * Examine the name prefix opcode, if any, to determine the number of
  385. * segments.
  386. */
  387. switch (*path) {
  388. case 0:
  389. /*
  390. * Null name after a root or parent prefixes. We already
  391. * have the correct target node and there are no name segments.
  392. */
  393. num_segments = 0;
  394. type = this_node->type;
  395. ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
  396. "Prefix-only Pathname (Zero name segments), Flags=%X\n",
  397. flags));
  398. break;
  399. case AML_DUAL_NAME_PREFIX:
  400. /* More than one name_seg, search rules do not apply */
  401. search_parent_flag = ACPI_NS_NO_UPSEARCH;
  402. /* Two segments, point to first name segment */
  403. num_segments = 2;
  404. path++;
  405. ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
  406. "Dual Pathname (2 segments, Flags=%X)\n",
  407. flags));
  408. break;
  409. case AML_MULTI_NAME_PREFIX:
  410. /* More than one name_seg, search rules do not apply */
  411. search_parent_flag = ACPI_NS_NO_UPSEARCH;
  412. /* Extract segment count, point to first name segment */
  413. path++;
  414. num_segments = (u32) (u8) * path;
  415. path++;
  416. ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
  417. "Multi Pathname (%u Segments, Flags=%X)\n",
  418. num_segments, flags));
  419. break;
  420. default:
  421. /*
  422. * Not a Null name, no Dual or Multi prefix, hence there is
  423. * only one name segment and Pathname is already pointing to it.
  424. */
  425. num_segments = 1;
  426. ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
  427. "Simple Pathname (1 segment, Flags=%X)\n",
  428. flags));
  429. break;
  430. }
  431. ACPI_DEBUG_EXEC(acpi_ns_print_pathname(num_segments, path));
  432. }
  433. /*
  434. * Search namespace for each segment of the name. Loop through and
  435. * verify (or add to the namespace) each name segment.
  436. *
  437. * The object type is significant only at the last name
  438. * segment. (We don't care about the types along the path, only
  439. * the type of the final target object.)
  440. */
  441. this_search_type = ACPI_TYPE_ANY;
  442. current_node = this_node;
  443. while (num_segments && current_node) {
  444. num_segments--;
  445. if (!num_segments) {
  446. /* This is the last segment, enable typechecking */
  447. this_search_type = type;
  448. /*
  449. * Only allow automatic parent search (search rules) if the caller
  450. * requested it AND we have a single, non-fully-qualified name_seg
  451. */
  452. if ((search_parent_flag != ACPI_NS_NO_UPSEARCH) &&
  453. (flags & ACPI_NS_SEARCH_PARENT)) {
  454. local_flags |= ACPI_NS_SEARCH_PARENT;
  455. }
  456. /* Set error flag according to caller */
  457. if (flags & ACPI_NS_ERROR_IF_FOUND) {
  458. local_flags |= ACPI_NS_ERROR_IF_FOUND;
  459. }
  460. /* Set override flag according to caller */
  461. if (flags & ACPI_NS_OVERRIDE_IF_FOUND) {
  462. local_flags |= ACPI_NS_OVERRIDE_IF_FOUND;
  463. }
  464. }
  465. /* Handle opcodes that create a new name_seg via a full name_path */
  466. local_interpreter_mode = interpreter_mode;
  467. if ((flags & ACPI_NS_PREFIX_MUST_EXIST) && (num_segments > 0)) {
  468. /* Every element of the path must exist (except for the final name_seg) */
  469. local_interpreter_mode = ACPI_IMODE_EXECUTE;
  470. }
  471. /* Extract one ACPI name from the front of the pathname */
  472. ACPI_MOVE_32_TO_32(&simple_name, path);
  473. /* Try to find the single (4 character) ACPI name */
  474. status =
  475. acpi_ns_search_and_enter(simple_name, walk_state,
  476. current_node,
  477. local_interpreter_mode,
  478. this_search_type, local_flags,
  479. &this_node);
  480. if (ACPI_FAILURE(status)) {
  481. if (status == AE_NOT_FOUND) {
  482. #if !defined ACPI_ASL_COMPILER /* Note: iASL reports this error by itself, not needed here */
  483. if (flags & ACPI_NS_PREFIX_MUST_EXIST) {
  484. acpi_os_printf(ACPI_MSG_BIOS_ERROR
  485. "Object does not exist: %4.4s\n",
  486. (char *)&simple_name);
  487. }
  488. #endif
  489. /* Name not found in ACPI namespace */
  490. ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
  491. "Name [%4.4s] not found in scope [%4.4s] %p\n",
  492. (char *)&simple_name,
  493. (char *)&current_node->name,
  494. current_node));
  495. }
  496. #ifdef ACPI_EXEC_APP
  497. if ((status == AE_ALREADY_EXISTS) &&
  498. (this_node->flags & ANOBJ_NODE_EARLY_INIT)) {
  499. this_node->flags &= ~ANOBJ_NODE_EARLY_INIT;
  500. status = AE_OK;
  501. }
  502. #endif
  503. #ifdef ACPI_ASL_COMPILER
  504. /*
  505. * If this ACPI name already exists within the namespace as an
  506. * external declaration, then mark the external as a conflicting
  507. * declaration and proceed to process the current node as if it did
  508. * not exist in the namespace. If this node is not processed as
  509. * normal, then it could cause improper namespace resolution
  510. * by failing to open a new scope.
  511. */
  512. if (acpi_gbl_disasm_flag &&
  513. (status == AE_ALREADY_EXISTS) &&
  514. ((this_node->flags & ANOBJ_IS_EXTERNAL) ||
  515. (walk_state
  516. && walk_state->opcode == AML_EXTERNAL_OP))) {
  517. this_node->flags &= ~ANOBJ_IS_EXTERNAL;
  518. this_node->type = (u8)this_search_type;
  519. if (walk_state->opcode != AML_EXTERNAL_OP) {
  520. acpi_dm_mark_external_conflict
  521. (this_node);
  522. }
  523. break;
  524. }
  525. #endif
  526. *return_node = this_node;
  527. return_ACPI_STATUS(status);
  528. }
  529. /* More segments to follow? */
  530. if (num_segments > 0) {
  531. /*
  532. * If we have an alias to an object that opens a scope (such as a
  533. * device or processor), we need to dereference the alias here so
  534. * that we can access any children of the original node (via the
  535. * remaining segments).
  536. */
  537. if (this_node->type == ACPI_TYPE_LOCAL_ALIAS) {
  538. if (!this_node->object) {
  539. return_ACPI_STATUS(AE_NOT_EXIST);
  540. }
  541. if (acpi_ns_opens_scope
  542. (((struct acpi_namespace_node *)
  543. this_node->object)->type)) {
  544. this_node =
  545. (struct acpi_namespace_node *)
  546. this_node->object;
  547. }
  548. }
  549. }
  550. /* Special handling for the last segment (num_segments == 0) */
  551. else {
  552. /*
  553. * Sanity typecheck of the target object:
  554. *
  555. * If 1) This is the last segment (num_segments == 0)
  556. * 2) And we are looking for a specific type
  557. * (Not checking for TYPE_ANY)
  558. * 3) Which is not an alias
  559. * 4) Which is not a local type (TYPE_SCOPE)
  560. * 5) And the type of target object is known (not TYPE_ANY)
  561. * 6) And target object does not match what we are looking for
  562. *
  563. * Then we have a type mismatch. Just warn and ignore it.
  564. */
  565. if ((type_to_check_for != ACPI_TYPE_ANY) &&
  566. (type_to_check_for != ACPI_TYPE_LOCAL_ALIAS) &&
  567. (type_to_check_for != ACPI_TYPE_LOCAL_METHOD_ALIAS)
  568. && (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE)
  569. && (this_node->type != ACPI_TYPE_ANY)
  570. && (this_node->type != type_to_check_for)) {
  571. /* Complain about a type mismatch */
  572. ACPI_WARNING((AE_INFO,
  573. "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)",
  574. ACPI_CAST_PTR(char, &simple_name),
  575. acpi_ut_get_type_name(this_node->
  576. type),
  577. acpi_ut_get_type_name
  578. (type_to_check_for)));
  579. }
  580. /*
  581. * If this is the last name segment and we are not looking for a
  582. * specific type, but the type of found object is known, use that
  583. * type to (later) see if it opens a scope.
  584. */
  585. if (type == ACPI_TYPE_ANY) {
  586. type = this_node->type;
  587. }
  588. }
  589. /* Point to next name segment and make this node current */
  590. path += ACPI_NAMESEG_SIZE;
  591. current_node = this_node;
  592. }
  593. /* Always check if we need to open a new scope */
  594. if (!(flags & ACPI_NS_DONT_OPEN_SCOPE) && (walk_state)) {
  595. /*
  596. * If entry is a type which opens a scope, push the new scope on the
  597. * scope stack.
  598. */
  599. if (acpi_ns_opens_scope(type)) {
  600. status =
  601. acpi_ds_scope_stack_push(this_node, type,
  602. walk_state);
  603. if (ACPI_FAILURE(status)) {
  604. return_ACPI_STATUS(status);
  605. }
  606. }
  607. }
  608. #ifdef ACPI_EXEC_APP
  609. if (flags & ACPI_NS_EARLY_INIT) {
  610. this_node->flags |= ANOBJ_NODE_EARLY_INIT;
  611. }
  612. #endif
  613. *return_node = this_node;
  614. return_ACPI_STATUS(AE_OK);
  615. }