nsutils.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. /******************************************************************************
  2. *
  3. * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
  4. * parents and siblings and Scope manipulation
  5. *
  6. *****************************************************************************/
  7. /*
  8. * Copyright (C) 2000 - 2013, Intel Corp.
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions, and the following disclaimer,
  16. * without modification.
  17. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18. * substantially similar to the "NO WARRANTY" disclaimer below
  19. * ("Disclaimer") and any redistribution must be conditioned upon
  20. * including a substantially similar Disclaimer requirement for further
  21. * binary redistribution.
  22. * 3. Neither the names of the above-listed copyright holders nor the names
  23. * of any contributors may be used to endorse or promote products derived
  24. * from this software without specific prior written permission.
  25. *
  26. * Alternatively, this software may be distributed under the terms of the
  27. * GNU General Public License ("GPL") version 2 as published by the Free
  28. * Software Foundation.
  29. *
  30. * NO WARRANTY
  31. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  32. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  33. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  34. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  35. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  36. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  37. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  40. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41. * POSSIBILITY OF SUCH DAMAGES.
  42. */
  43. #include <acpi/acpi.h>
  44. #include "accommon.h"
  45. #include "acnamesp.h"
  46. #include "amlcode.h"
  47. #define _COMPONENT ACPI_NAMESPACE
  48. ACPI_MODULE_NAME("nsutils")
  49. /* Local prototypes */
  50. #ifdef ACPI_OBSOLETE_FUNCTIONS
  51. acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
  52. #endif
  53. /*******************************************************************************
  54. *
  55. * FUNCTION: acpi_ns_print_node_pathname
  56. *
  57. * PARAMETERS: node - Object
  58. * message - Prefix message
  59. *
  60. * DESCRIPTION: Print an object's full namespace pathname
  61. * Manages allocation/freeing of a pathname buffer
  62. *
  63. ******************************************************************************/
  64. void
  65. acpi_ns_print_node_pathname(struct acpi_namespace_node *node,
  66. const char *message)
  67. {
  68. struct acpi_buffer buffer;
  69. acpi_status status;
  70. if (!node) {
  71. acpi_os_printf("[NULL NAME]");
  72. return;
  73. }
  74. /* Convert handle to full pathname and print it (with supplied message) */
  75. buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
  76. status = acpi_ns_handle_to_pathname(node, &buffer);
  77. if (ACPI_SUCCESS(status)) {
  78. if (message) {
  79. acpi_os_printf("%s ", message);
  80. }
  81. acpi_os_printf("[%s] (Node %p)", (char *)buffer.pointer, node);
  82. ACPI_FREE(buffer.pointer);
  83. }
  84. }
  85. /*******************************************************************************
  86. *
  87. * FUNCTION: acpi_ns_get_type
  88. *
  89. * PARAMETERS: node - Parent Node to be examined
  90. *
  91. * RETURN: Type field from Node whose handle is passed
  92. *
  93. * DESCRIPTION: Return the type of a Namespace node
  94. *
  95. ******************************************************************************/
  96. acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
  97. {
  98. ACPI_FUNCTION_TRACE(ns_get_type);
  99. if (!node) {
  100. ACPI_WARNING((AE_INFO, "Null Node parameter"));
  101. return_VALUE(ACPI_TYPE_ANY);
  102. }
  103. return_VALUE(node->type);
  104. }
  105. /*******************************************************************************
  106. *
  107. * FUNCTION: acpi_ns_local
  108. *
  109. * PARAMETERS: type - A namespace object type
  110. *
  111. * RETURN: LOCAL if names must be found locally in objects of the
  112. * passed type, 0 if enclosing scopes should be searched
  113. *
  114. * DESCRIPTION: Returns scope rule for the given object type.
  115. *
  116. ******************************************************************************/
  117. u32 acpi_ns_local(acpi_object_type type)
  118. {
  119. ACPI_FUNCTION_TRACE(ns_local);
  120. if (!acpi_ut_valid_object_type(type)) {
  121. /* Type code out of range */
  122. ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type));
  123. return_VALUE(ACPI_NS_NORMAL);
  124. }
  125. return_VALUE(acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
  126. }
  127. /*******************************************************************************
  128. *
  129. * FUNCTION: acpi_ns_get_internal_name_length
  130. *
  131. * PARAMETERS: info - Info struct initialized with the
  132. * external name pointer.
  133. *
  134. * RETURN: None
  135. *
  136. * DESCRIPTION: Calculate the length of the internal (AML) namestring
  137. * corresponding to the external (ASL) namestring.
  138. *
  139. ******************************************************************************/
  140. void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
  141. {
  142. const char *next_external_char;
  143. u32 i;
  144. ACPI_FUNCTION_ENTRY();
  145. next_external_char = info->external_name;
  146. info->num_carats = 0;
  147. info->num_segments = 0;
  148. info->fully_qualified = FALSE;
  149. /*
  150. * For the internal name, the required length is 4 bytes per segment, plus
  151. * 1 each for root_prefix, multi_name_prefix_op, segment count, trailing null
  152. * (which is not really needed, but no there's harm in putting it there)
  153. *
  154. * strlen() + 1 covers the first name_seg, which has no path separator
  155. */
  156. if (ACPI_IS_ROOT_PREFIX(*next_external_char)) {
  157. info->fully_qualified = TRUE;
  158. next_external_char++;
  159. /* Skip redundant root_prefix, like \\_SB.PCI0.SBRG.EC0 */
  160. while (ACPI_IS_ROOT_PREFIX(*next_external_char)) {
  161. next_external_char++;
  162. }
  163. } else {
  164. /* Handle Carat prefixes */
  165. while (ACPI_IS_PARENT_PREFIX(*next_external_char)) {
  166. info->num_carats++;
  167. next_external_char++;
  168. }
  169. }
  170. /*
  171. * Determine the number of ACPI name "segments" by counting the number of
  172. * path separators within the string. Start with one segment since the
  173. * segment count is [(# separators) + 1], and zero separators is ok.
  174. */
  175. if (*next_external_char) {
  176. info->num_segments = 1;
  177. for (i = 0; next_external_char[i]; i++) {
  178. if (ACPI_IS_PATH_SEPARATOR(next_external_char[i])) {
  179. info->num_segments++;
  180. }
  181. }
  182. }
  183. info->length = (ACPI_NAME_SIZE * info->num_segments) +
  184. 4 + info->num_carats;
  185. info->next_external_char = next_external_char;
  186. }
  187. /*******************************************************************************
  188. *
  189. * FUNCTION: acpi_ns_build_internal_name
  190. *
  191. * PARAMETERS: info - Info struct fully initialized
  192. *
  193. * RETURN: Status
  194. *
  195. * DESCRIPTION: Construct the internal (AML) namestring
  196. * corresponding to the external (ASL) namestring.
  197. *
  198. ******************************************************************************/
  199. acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
  200. {
  201. u32 num_segments = info->num_segments;
  202. char *internal_name = info->internal_name;
  203. const char *external_name = info->next_external_char;
  204. char *result = NULL;
  205. u32 i;
  206. ACPI_FUNCTION_TRACE(ns_build_internal_name);
  207. /* Setup the correct prefixes, counts, and pointers */
  208. if (info->fully_qualified) {
  209. internal_name[0] = AML_ROOT_PREFIX;
  210. if (num_segments <= 1) {
  211. result = &internal_name[1];
  212. } else if (num_segments == 2) {
  213. internal_name[1] = AML_DUAL_NAME_PREFIX;
  214. result = &internal_name[2];
  215. } else {
  216. internal_name[1] = AML_MULTI_NAME_PREFIX_OP;
  217. internal_name[2] = (char)num_segments;
  218. result = &internal_name[3];
  219. }
  220. } else {
  221. /*
  222. * Not fully qualified.
  223. * Handle Carats first, then append the name segments
  224. */
  225. i = 0;
  226. if (info->num_carats) {
  227. for (i = 0; i < info->num_carats; i++) {
  228. internal_name[i] = AML_PARENT_PREFIX;
  229. }
  230. }
  231. if (num_segments <= 1) {
  232. result = &internal_name[i];
  233. } else if (num_segments == 2) {
  234. internal_name[i] = AML_DUAL_NAME_PREFIX;
  235. result = &internal_name[(acpi_size) i + 1];
  236. } else {
  237. internal_name[i] = AML_MULTI_NAME_PREFIX_OP;
  238. internal_name[(acpi_size) i + 1] = (char)num_segments;
  239. result = &internal_name[(acpi_size) i + 2];
  240. }
  241. }
  242. /* Build the name (minus path separators) */
  243. for (; num_segments; num_segments--) {
  244. for (i = 0; i < ACPI_NAME_SIZE; i++) {
  245. if (ACPI_IS_PATH_SEPARATOR(*external_name) ||
  246. (*external_name == 0)) {
  247. /* Pad the segment with underscore(s) if segment is short */
  248. result[i] = '_';
  249. } else {
  250. /* Convert the character to uppercase and save it */
  251. result[i] =
  252. (char)ACPI_TOUPPER((int)*external_name);
  253. external_name++;
  254. }
  255. }
  256. /* Now we must have a path separator, or the pathname is bad */
  257. if (!ACPI_IS_PATH_SEPARATOR(*external_name) &&
  258. (*external_name != 0)) {
  259. return_ACPI_STATUS(AE_BAD_PATHNAME);
  260. }
  261. /* Move on the next segment */
  262. external_name++;
  263. result += ACPI_NAME_SIZE;
  264. }
  265. /* Terminate the string */
  266. *result = 0;
  267. if (info->fully_qualified) {
  268. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  269. "Returning [%p] (abs) \"\\%s\"\n",
  270. internal_name, internal_name));
  271. } else {
  272. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
  273. internal_name, internal_name));
  274. }
  275. return_ACPI_STATUS(AE_OK);
  276. }
  277. /*******************************************************************************
  278. *
  279. * FUNCTION: acpi_ns_internalize_name
  280. *
  281. * PARAMETERS: *external_name - External representation of name
  282. * **Converted name - Where to return the resulting
  283. * internal represention of the name
  284. *
  285. * RETURN: Status
  286. *
  287. * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0")
  288. * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
  289. *
  290. *******************************************************************************/
  291. acpi_status
  292. acpi_ns_internalize_name(const char *external_name, char **converted_name)
  293. {
  294. char *internal_name;
  295. struct acpi_namestring_info info;
  296. acpi_status status;
  297. ACPI_FUNCTION_TRACE(ns_internalize_name);
  298. if ((!external_name) || (*external_name == 0) || (!converted_name)) {
  299. return_ACPI_STATUS(AE_BAD_PARAMETER);
  300. }
  301. /* Get the length of the new internal name */
  302. info.external_name = external_name;
  303. acpi_ns_get_internal_name_length(&info);
  304. /* We need a segment to store the internal name */
  305. internal_name = ACPI_ALLOCATE_ZEROED(info.length);
  306. if (!internal_name) {
  307. return_ACPI_STATUS(AE_NO_MEMORY);
  308. }
  309. /* Build the name */
  310. info.internal_name = internal_name;
  311. status = acpi_ns_build_internal_name(&info);
  312. if (ACPI_FAILURE(status)) {
  313. ACPI_FREE(internal_name);
  314. return_ACPI_STATUS(status);
  315. }
  316. *converted_name = internal_name;
  317. return_ACPI_STATUS(AE_OK);
  318. }
  319. /*******************************************************************************
  320. *
  321. * FUNCTION: acpi_ns_externalize_name
  322. *
  323. * PARAMETERS: internal_name_length - Lenth of the internal name below
  324. * internal_name - Internal representation of name
  325. * converted_name_length - Where the length is returned
  326. * converted_name - Where the resulting external name
  327. * is returned
  328. *
  329. * RETURN: Status
  330. *
  331. * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
  332. * to its external (printable) form (e.g. "\_PR_.CPU0")
  333. *
  334. ******************************************************************************/
  335. acpi_status
  336. acpi_ns_externalize_name(u32 internal_name_length,
  337. const char *internal_name,
  338. u32 * converted_name_length, char **converted_name)
  339. {
  340. u32 names_index = 0;
  341. u32 num_segments = 0;
  342. u32 required_length;
  343. u32 prefix_length = 0;
  344. u32 i = 0;
  345. u32 j = 0;
  346. ACPI_FUNCTION_TRACE(ns_externalize_name);
  347. if (!internal_name_length || !internal_name || !converted_name) {
  348. return_ACPI_STATUS(AE_BAD_PARAMETER);
  349. }
  350. /* Check for a prefix (one '\' | one or more '^') */
  351. switch (internal_name[0]) {
  352. case AML_ROOT_PREFIX:
  353. prefix_length = 1;
  354. break;
  355. case AML_PARENT_PREFIX:
  356. for (i = 0; i < internal_name_length; i++) {
  357. if (ACPI_IS_PARENT_PREFIX(internal_name[i])) {
  358. prefix_length = i + 1;
  359. } else {
  360. break;
  361. }
  362. }
  363. if (i == internal_name_length) {
  364. prefix_length = i;
  365. }
  366. break;
  367. default:
  368. break;
  369. }
  370. /*
  371. * Check for object names. Note that there could be 0-255 of these
  372. * 4-byte elements.
  373. */
  374. if (prefix_length < internal_name_length) {
  375. switch (internal_name[prefix_length]) {
  376. case AML_MULTI_NAME_PREFIX_OP:
  377. /* <count> 4-byte names */
  378. names_index = prefix_length + 2;
  379. num_segments = (u8)
  380. internal_name[(acpi_size) prefix_length + 1];
  381. break;
  382. case AML_DUAL_NAME_PREFIX:
  383. /* Two 4-byte names */
  384. names_index = prefix_length + 1;
  385. num_segments = 2;
  386. break;
  387. case 0:
  388. /* null_name */
  389. names_index = 0;
  390. num_segments = 0;
  391. break;
  392. default:
  393. /* one 4-byte name */
  394. names_index = prefix_length;
  395. num_segments = 1;
  396. break;
  397. }
  398. }
  399. /*
  400. * Calculate the length of converted_name, which equals the length
  401. * of the prefix, length of all object names, length of any required
  402. * punctuation ('.') between object names, plus the NULL terminator.
  403. */
  404. required_length = prefix_length + (4 * num_segments) +
  405. ((num_segments > 0) ? (num_segments - 1) : 0) + 1;
  406. /*
  407. * Check to see if we're still in bounds. If not, there's a problem
  408. * with internal_name (invalid format).
  409. */
  410. if (required_length > internal_name_length) {
  411. ACPI_ERROR((AE_INFO, "Invalid internal name"));
  412. return_ACPI_STATUS(AE_BAD_PATHNAME);
  413. }
  414. /* Build the converted_name */
  415. *converted_name = ACPI_ALLOCATE_ZEROED(required_length);
  416. if (!(*converted_name)) {
  417. return_ACPI_STATUS(AE_NO_MEMORY);
  418. }
  419. j = 0;
  420. for (i = 0; i < prefix_length; i++) {
  421. (*converted_name)[j++] = internal_name[i];
  422. }
  423. if (num_segments > 0) {
  424. for (i = 0; i < num_segments; i++) {
  425. if (i > 0) {
  426. (*converted_name)[j++] = '.';
  427. }
  428. /* Copy and validate the 4-char name segment */
  429. ACPI_MOVE_NAME(&(*converted_name)[j],
  430. &internal_name[names_index]);
  431. acpi_ut_repair_name(&(*converted_name)[j]);
  432. j += ACPI_NAME_SIZE;
  433. names_index += ACPI_NAME_SIZE;
  434. }
  435. }
  436. if (converted_name_length) {
  437. *converted_name_length = (u32) required_length;
  438. }
  439. return_ACPI_STATUS(AE_OK);
  440. }
  441. /*******************************************************************************
  442. *
  443. * FUNCTION: acpi_ns_validate_handle
  444. *
  445. * PARAMETERS: handle - Handle to be validated and typecast to a
  446. * namespace node.
  447. *
  448. * RETURN: A pointer to a namespace node
  449. *
  450. * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special
  451. * cases for the root node.
  452. *
  453. * NOTE: Real integer handles would allow for more verification
  454. * and keep all pointers within this subsystem - however this introduces
  455. * more overhead and has not been necessary to this point. Drivers
  456. * holding handles are typically notified before a node becomes invalid
  457. * due to a table unload.
  458. *
  459. ******************************************************************************/
  460. struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle)
  461. {
  462. ACPI_FUNCTION_ENTRY();
  463. /* Parameter validation */
  464. if ((!handle) || (handle == ACPI_ROOT_OBJECT)) {
  465. return (acpi_gbl_root_node);
  466. }
  467. /* We can at least attempt to verify the handle */
  468. if (ACPI_GET_DESCRIPTOR_TYPE(handle) != ACPI_DESC_TYPE_NAMED) {
  469. return (NULL);
  470. }
  471. return (ACPI_CAST_PTR(struct acpi_namespace_node, handle));
  472. }
  473. /*******************************************************************************
  474. *
  475. * FUNCTION: acpi_ns_terminate
  476. *
  477. * PARAMETERS: none
  478. *
  479. * RETURN: none
  480. *
  481. * DESCRIPTION: free memory allocated for namespace and ACPI table storage.
  482. *
  483. ******************************************************************************/
  484. void acpi_ns_terminate(void)
  485. {
  486. union acpi_operand_object *obj_desc;
  487. ACPI_FUNCTION_TRACE(ns_terminate);
  488. /*
  489. * 1) Free the entire namespace -- all nodes and objects
  490. *
  491. * Delete all object descriptors attached to namepsace nodes
  492. */
  493. acpi_ns_delete_namespace_subtree(acpi_gbl_root_node);
  494. /* Detach any objects attached to the root */
  495. obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node);
  496. if (obj_desc) {
  497. acpi_ns_detach_object(acpi_gbl_root_node);
  498. }
  499. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n"));
  500. return_VOID;
  501. }
  502. /*******************************************************************************
  503. *
  504. * FUNCTION: acpi_ns_opens_scope
  505. *
  506. * PARAMETERS: type - A valid namespace type
  507. *
  508. * RETURN: NEWSCOPE if the passed type "opens a name scope" according
  509. * to the ACPI specification, else 0
  510. *
  511. ******************************************************************************/
  512. u32 acpi_ns_opens_scope(acpi_object_type type)
  513. {
  514. ACPI_FUNCTION_ENTRY();
  515. if (type > ACPI_TYPE_LOCAL_MAX) {
  516. /* type code out of range */
  517. ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type));
  518. return (ACPI_NS_NORMAL);
  519. }
  520. return (((u32)acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
  521. }
  522. /*******************************************************************************
  523. *
  524. * FUNCTION: acpi_ns_get_node
  525. *
  526. * PARAMETERS: *pathname - Name to be found, in external (ASL) format. The
  527. * \ (backslash) and ^ (carat) prefixes, and the
  528. * . (period) to separate segments are supported.
  529. * prefix_node - Root of subtree to be searched, or NS_ALL for the
  530. * root of the name space. If Name is fully
  531. * qualified (first s8 is '\'), the passed value
  532. * of Scope will not be accessed.
  533. * flags - Used to indicate whether to perform upsearch or
  534. * not.
  535. * return_node - Where the Node is returned
  536. *
  537. * DESCRIPTION: Look up a name relative to a given scope and return the
  538. * corresponding Node. NOTE: Scope can be null.
  539. *
  540. * MUTEX: Locks namespace
  541. *
  542. ******************************************************************************/
  543. acpi_status
  544. acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
  545. const char *pathname,
  546. u32 flags, struct acpi_namespace_node **return_node)
  547. {
  548. union acpi_generic_state scope_info;
  549. acpi_status status;
  550. char *internal_path;
  551. ACPI_FUNCTION_TRACE_PTR(ns_get_node, ACPI_CAST_PTR(char, pathname));
  552. /* Simplest case is a null pathname */
  553. if (!pathname) {
  554. *return_node = prefix_node;
  555. if (!prefix_node) {
  556. *return_node = acpi_gbl_root_node;
  557. }
  558. return_ACPI_STATUS(AE_OK);
  559. }
  560. /* Quick check for a reference to the root */
  561. if (ACPI_IS_ROOT_PREFIX(pathname[0]) && (!pathname[1])) {
  562. *return_node = acpi_gbl_root_node;
  563. return_ACPI_STATUS(AE_OK);
  564. }
  565. /* Convert path to internal representation */
  566. status = acpi_ns_internalize_name(pathname, &internal_path);
  567. if (ACPI_FAILURE(status)) {
  568. return_ACPI_STATUS(status);
  569. }
  570. /* Must lock namespace during lookup */
  571. status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
  572. if (ACPI_FAILURE(status)) {
  573. goto cleanup;
  574. }
  575. /* Setup lookup scope (search starting point) */
  576. scope_info.scope.node = prefix_node;
  577. /* Lookup the name in the namespace */
  578. status = acpi_ns_lookup(&scope_info, internal_path, ACPI_TYPE_ANY,
  579. ACPI_IMODE_EXECUTE,
  580. (flags | ACPI_NS_DONT_OPEN_SCOPE), NULL,
  581. return_node);
  582. if (ACPI_FAILURE(status)) {
  583. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s, %s\n",
  584. pathname, acpi_format_exception(status)));
  585. }
  586. (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  587. cleanup:
  588. ACPI_FREE(internal_path);
  589. return_ACPI_STATUS(status);
  590. }