nsaccess.c 20 KB

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