nsdump.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  1. /******************************************************************************
  2. *
  3. * Module Name: nsdump - table dumping routines for debug
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2013, 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 "acnamesp.h"
  45. #include <acpi/acoutput.h>
  46. #define _COMPONENT ACPI_NAMESPACE
  47. ACPI_MODULE_NAME("nsdump")
  48. /* Local prototypes */
  49. #ifdef ACPI_OBSOLETE_FUNCTIONS
  50. void acpi_ns_dump_root_devices(void);
  51. static acpi_status
  52. acpi_ns_dump_one_device(acpi_handle obj_handle,
  53. u32 level, void *context, void **return_value);
  54. #endif
  55. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  56. #ifdef ACPI_FUTURE_USAGE
  57. static acpi_status
  58. acpi_ns_dump_one_object_path(acpi_handle obj_handle,
  59. u32 level, void *context, void **return_value);
  60. static acpi_status
  61. acpi_ns_get_max_depth(acpi_handle obj_handle,
  62. u32 level, void *context, void **return_value);
  63. #endif /* ACPI_FUTURE_USAGE */
  64. /*******************************************************************************
  65. *
  66. * FUNCTION: acpi_ns_print_pathname
  67. *
  68. * PARAMETERS: num_segments - Number of ACPI name segments
  69. * pathname - The compressed (internal) path
  70. *
  71. * RETURN: None
  72. *
  73. * DESCRIPTION: Print an object's full namespace pathname
  74. *
  75. ******************************************************************************/
  76. void acpi_ns_print_pathname(u32 num_segments, char *pathname)
  77. {
  78. u32 i;
  79. ACPI_FUNCTION_NAME(ns_print_pathname);
  80. /* Check if debug output enabled */
  81. if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_NAMES, ACPI_NAMESPACE)) {
  82. return;
  83. }
  84. /* Print the entire name */
  85. ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "["));
  86. while (num_segments) {
  87. for (i = 0; i < 4; i++) {
  88. ACPI_IS_PRINT(pathname[i]) ?
  89. acpi_os_printf("%c", pathname[i]) :
  90. acpi_os_printf("?");
  91. }
  92. pathname += ACPI_NAME_SIZE;
  93. num_segments--;
  94. if (num_segments) {
  95. acpi_os_printf(".");
  96. }
  97. }
  98. acpi_os_printf("]\n");
  99. }
  100. /*******************************************************************************
  101. *
  102. * FUNCTION: acpi_ns_dump_pathname
  103. *
  104. * PARAMETERS: handle - Object
  105. * msg - Prefix message
  106. * level - Desired debug level
  107. * component - Caller's component ID
  108. *
  109. * RETURN: None
  110. *
  111. * DESCRIPTION: Print an object's full namespace pathname
  112. * Manages allocation/freeing of a pathname buffer
  113. *
  114. ******************************************************************************/
  115. void
  116. acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component)
  117. {
  118. ACPI_FUNCTION_TRACE(ns_dump_pathname);
  119. /* Do this only if the requested debug level and component are enabled */
  120. if (!ACPI_IS_DEBUG_ENABLED(level, component)) {
  121. return_VOID;
  122. }
  123. /* Convert handle to a full pathname and print it (with supplied message) */
  124. acpi_ns_print_node_pathname(handle, msg);
  125. acpi_os_printf("\n");
  126. return_VOID;
  127. }
  128. /*******************************************************************************
  129. *
  130. * FUNCTION: acpi_ns_dump_one_object
  131. *
  132. * PARAMETERS: obj_handle - Node to be dumped
  133. * level - Nesting level of the handle
  134. * context - Passed into walk_namespace
  135. * return_value - Not used
  136. *
  137. * RETURN: Status
  138. *
  139. * DESCRIPTION: Dump a single Node
  140. * This procedure is a user_function called by acpi_ns_walk_namespace.
  141. *
  142. ******************************************************************************/
  143. acpi_status
  144. acpi_ns_dump_one_object(acpi_handle obj_handle,
  145. u32 level, void *context, void **return_value)
  146. {
  147. struct acpi_walk_info *info = (struct acpi_walk_info *)context;
  148. struct acpi_namespace_node *this_node;
  149. union acpi_operand_object *obj_desc = NULL;
  150. acpi_object_type obj_type;
  151. acpi_object_type type;
  152. u32 bytes_to_dump;
  153. u32 dbg_level;
  154. u32 i;
  155. ACPI_FUNCTION_NAME(ns_dump_one_object);
  156. /* Is output enabled? */
  157. if (!(acpi_dbg_level & info->debug_level)) {
  158. return (AE_OK);
  159. }
  160. if (!obj_handle) {
  161. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Null object handle\n"));
  162. return (AE_OK);
  163. }
  164. this_node = acpi_ns_validate_handle(obj_handle);
  165. if (!this_node) {
  166. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid object handle %p\n",
  167. obj_handle));
  168. return (AE_OK);
  169. }
  170. type = this_node->type;
  171. /* Check if the owner matches */
  172. if ((info->owner_id != ACPI_OWNER_ID_MAX) &&
  173. (info->owner_id != this_node->owner_id)) {
  174. return (AE_OK);
  175. }
  176. if (!(info->display_type & ACPI_DISPLAY_SHORT)) {
  177. /* Indent the object according to the level */
  178. acpi_os_printf("%2d%*s", (u32) level - 1, (int)level * 2, " ");
  179. /* Check the node type and name */
  180. if (type > ACPI_TYPE_LOCAL_MAX) {
  181. ACPI_WARNING((AE_INFO,
  182. "Invalid ACPI Object Type 0x%08X", type));
  183. }
  184. acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
  185. }
  186. /* Now we can print out the pertinent information */
  187. acpi_os_printf(" %-12s %p %2.2X ",
  188. acpi_ut_get_type_name(type), this_node,
  189. this_node->owner_id);
  190. dbg_level = acpi_dbg_level;
  191. acpi_dbg_level = 0;
  192. obj_desc = acpi_ns_get_attached_object(this_node);
  193. acpi_dbg_level = dbg_level;
  194. /* Temp nodes are those nodes created by a control method */
  195. if (this_node->flags & ANOBJ_TEMPORARY) {
  196. acpi_os_printf("(T) ");
  197. }
  198. switch (info->display_type & ACPI_DISPLAY_MASK) {
  199. case ACPI_DISPLAY_SUMMARY:
  200. if (!obj_desc) {
  201. /* No attached object. Some types should always have an object */
  202. switch (type) {
  203. case ACPI_TYPE_INTEGER:
  204. case ACPI_TYPE_PACKAGE:
  205. case ACPI_TYPE_BUFFER:
  206. case ACPI_TYPE_STRING:
  207. case ACPI_TYPE_METHOD:
  208. acpi_os_printf("<No attached object>");
  209. break;
  210. default:
  211. break;
  212. }
  213. acpi_os_printf("\n");
  214. return (AE_OK);
  215. }
  216. switch (type) {
  217. case ACPI_TYPE_PROCESSOR:
  218. acpi_os_printf("ID %02X Len %02X Addr %p\n",
  219. obj_desc->processor.proc_id,
  220. obj_desc->processor.length,
  221. ACPI_CAST_PTR(void,
  222. obj_desc->processor.
  223. address));
  224. break;
  225. case ACPI_TYPE_DEVICE:
  226. acpi_os_printf("Notify Object: %p\n", obj_desc);
  227. break;
  228. case ACPI_TYPE_METHOD:
  229. acpi_os_printf("Args %X Len %.4X Aml %p\n",
  230. (u32) obj_desc->method.param_count,
  231. obj_desc->method.aml_length,
  232. obj_desc->method.aml_start);
  233. break;
  234. case ACPI_TYPE_INTEGER:
  235. acpi_os_printf("= %8.8X%8.8X\n",
  236. ACPI_FORMAT_UINT64(obj_desc->integer.
  237. value));
  238. break;
  239. case ACPI_TYPE_PACKAGE:
  240. if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
  241. acpi_os_printf("Elements %.2X\n",
  242. obj_desc->package.count);
  243. } else {
  244. acpi_os_printf("[Length not yet evaluated]\n");
  245. }
  246. break;
  247. case ACPI_TYPE_BUFFER:
  248. if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
  249. acpi_os_printf("Len %.2X",
  250. obj_desc->buffer.length);
  251. /* Dump some of the buffer */
  252. if (obj_desc->buffer.length > 0) {
  253. acpi_os_printf(" =");
  254. for (i = 0;
  255. (i < obj_desc->buffer.length
  256. && i < 12); i++) {
  257. acpi_os_printf(" %.2hX",
  258. obj_desc->buffer.
  259. pointer[i]);
  260. }
  261. }
  262. acpi_os_printf("\n");
  263. } else {
  264. acpi_os_printf("[Length not yet evaluated]\n");
  265. }
  266. break;
  267. case ACPI_TYPE_STRING:
  268. acpi_os_printf("Len %.2X ", obj_desc->string.length);
  269. acpi_ut_print_string(obj_desc->string.pointer, 32);
  270. acpi_os_printf("\n");
  271. break;
  272. case ACPI_TYPE_REGION:
  273. acpi_os_printf("[%s]",
  274. acpi_ut_get_region_name(obj_desc->region.
  275. space_id));
  276. if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
  277. acpi_os_printf(" Addr %8.8X%8.8X Len %.4X\n",
  278. ACPI_FORMAT_NATIVE_UINT
  279. (obj_desc->region.address),
  280. obj_desc->region.length);
  281. } else {
  282. acpi_os_printf
  283. (" [Address/Length not yet evaluated]\n");
  284. }
  285. break;
  286. case ACPI_TYPE_LOCAL_REFERENCE:
  287. acpi_os_printf("[%s]\n",
  288. acpi_ut_get_reference_name(obj_desc));
  289. break;
  290. case ACPI_TYPE_BUFFER_FIELD:
  291. if (obj_desc->buffer_field.buffer_obj &&
  292. obj_desc->buffer_field.buffer_obj->buffer.node) {
  293. acpi_os_printf("Buf [%4.4s]",
  294. acpi_ut_get_node_name(obj_desc->
  295. buffer_field.
  296. buffer_obj->
  297. buffer.
  298. node));
  299. }
  300. break;
  301. case ACPI_TYPE_LOCAL_REGION_FIELD:
  302. acpi_os_printf("Rgn [%4.4s]",
  303. acpi_ut_get_node_name(obj_desc->
  304. common_field.
  305. region_obj->region.
  306. node));
  307. break;
  308. case ACPI_TYPE_LOCAL_BANK_FIELD:
  309. acpi_os_printf("Rgn [%4.4s] Bnk [%4.4s]",
  310. acpi_ut_get_node_name(obj_desc->
  311. common_field.
  312. region_obj->region.
  313. node),
  314. acpi_ut_get_node_name(obj_desc->
  315. bank_field.
  316. bank_obj->
  317. common_field.
  318. node));
  319. break;
  320. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  321. acpi_os_printf("Idx [%4.4s] Dat [%4.4s]",
  322. acpi_ut_get_node_name(obj_desc->
  323. index_field.
  324. index_obj->
  325. common_field.node),
  326. acpi_ut_get_node_name(obj_desc->
  327. index_field.
  328. data_obj->
  329. common_field.
  330. node));
  331. break;
  332. case ACPI_TYPE_LOCAL_ALIAS:
  333. case ACPI_TYPE_LOCAL_METHOD_ALIAS:
  334. acpi_os_printf("Target %4.4s (%p)\n",
  335. acpi_ut_get_node_name(obj_desc),
  336. obj_desc);
  337. break;
  338. default:
  339. acpi_os_printf("Object %p\n", obj_desc);
  340. break;
  341. }
  342. /* Common field handling */
  343. switch (type) {
  344. case ACPI_TYPE_BUFFER_FIELD:
  345. case ACPI_TYPE_LOCAL_REGION_FIELD:
  346. case ACPI_TYPE_LOCAL_BANK_FIELD:
  347. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  348. acpi_os_printf(" Off %.3X Len %.2X Acc %.2hd\n",
  349. (obj_desc->common_field.
  350. base_byte_offset * 8)
  351. +
  352. obj_desc->common_field.
  353. start_field_bit_offset,
  354. obj_desc->common_field.bit_length,
  355. obj_desc->common_field.
  356. access_byte_width);
  357. break;
  358. default:
  359. break;
  360. }
  361. break;
  362. case ACPI_DISPLAY_OBJECTS:
  363. acpi_os_printf("O:%p", obj_desc);
  364. if (!obj_desc) {
  365. /* No attached object, we are done */
  366. acpi_os_printf("\n");
  367. return (AE_OK);
  368. }
  369. acpi_os_printf("(R%u)", obj_desc->common.reference_count);
  370. switch (type) {
  371. case ACPI_TYPE_METHOD:
  372. /* Name is a Method and its AML offset/length are set */
  373. acpi_os_printf(" M:%p-%X\n", obj_desc->method.aml_start,
  374. obj_desc->method.aml_length);
  375. break;
  376. case ACPI_TYPE_INTEGER:
  377. acpi_os_printf(" I:%8.8X8.8%X\n",
  378. ACPI_FORMAT_UINT64(obj_desc->integer.
  379. value));
  380. break;
  381. case ACPI_TYPE_STRING:
  382. acpi_os_printf(" S:%p-%X\n", obj_desc->string.pointer,
  383. obj_desc->string.length);
  384. break;
  385. case ACPI_TYPE_BUFFER:
  386. acpi_os_printf(" B:%p-%X\n", obj_desc->buffer.pointer,
  387. obj_desc->buffer.length);
  388. break;
  389. default:
  390. acpi_os_printf("\n");
  391. break;
  392. }
  393. break;
  394. default:
  395. acpi_os_printf("\n");
  396. break;
  397. }
  398. /* If debug turned off, done */
  399. if (!(acpi_dbg_level & ACPI_LV_VALUES)) {
  400. return (AE_OK);
  401. }
  402. /* If there is an attached object, display it */
  403. dbg_level = acpi_dbg_level;
  404. acpi_dbg_level = 0;
  405. obj_desc = acpi_ns_get_attached_object(this_node);
  406. acpi_dbg_level = dbg_level;
  407. /* Dump attached objects */
  408. while (obj_desc) {
  409. obj_type = ACPI_TYPE_INVALID;
  410. acpi_os_printf("Attached Object %p: ", obj_desc);
  411. /* Decode the type of attached object and dump the contents */
  412. switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
  413. case ACPI_DESC_TYPE_NAMED:
  414. acpi_os_printf("(Ptr to Node)\n");
  415. bytes_to_dump = sizeof(struct acpi_namespace_node);
  416. ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
  417. break;
  418. case ACPI_DESC_TYPE_OPERAND:
  419. obj_type = obj_desc->common.type;
  420. if (obj_type > ACPI_TYPE_LOCAL_MAX) {
  421. acpi_os_printf
  422. ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
  423. obj_type);
  424. bytes_to_dump = 32;
  425. } else {
  426. acpi_os_printf
  427. ("(Pointer to ACPI Object type %.2X [%s])\n",
  428. obj_type, acpi_ut_get_type_name(obj_type));
  429. bytes_to_dump =
  430. sizeof(union acpi_operand_object);
  431. }
  432. ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
  433. break;
  434. default:
  435. break;
  436. }
  437. /* If value is NOT an internal object, we are done */
  438. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) !=
  439. ACPI_DESC_TYPE_OPERAND) {
  440. goto cleanup;
  441. }
  442. /* Valid object, get the pointer to next level, if any */
  443. switch (obj_type) {
  444. case ACPI_TYPE_BUFFER:
  445. case ACPI_TYPE_STRING:
  446. /*
  447. * NOTE: takes advantage of common fields between string/buffer
  448. */
  449. bytes_to_dump = obj_desc->string.length;
  450. obj_desc = (void *)obj_desc->string.pointer;
  451. acpi_os_printf("(Buffer/String pointer %p length %X)\n",
  452. obj_desc, bytes_to_dump);
  453. ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
  454. goto cleanup;
  455. case ACPI_TYPE_BUFFER_FIELD:
  456. obj_desc =
  457. (union acpi_operand_object *)obj_desc->buffer_field.
  458. buffer_obj;
  459. break;
  460. case ACPI_TYPE_PACKAGE:
  461. obj_desc = (void *)obj_desc->package.elements;
  462. break;
  463. case ACPI_TYPE_METHOD:
  464. obj_desc = (void *)obj_desc->method.aml_start;
  465. break;
  466. case ACPI_TYPE_LOCAL_REGION_FIELD:
  467. obj_desc = (void *)obj_desc->field.region_obj;
  468. break;
  469. case ACPI_TYPE_LOCAL_BANK_FIELD:
  470. obj_desc = (void *)obj_desc->bank_field.region_obj;
  471. break;
  472. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  473. obj_desc = (void *)obj_desc->index_field.index_obj;
  474. break;
  475. default:
  476. goto cleanup;
  477. }
  478. obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
  479. }
  480. cleanup:
  481. acpi_os_printf("\n");
  482. return (AE_OK);
  483. }
  484. #ifdef ACPI_FUTURE_USAGE
  485. /*******************************************************************************
  486. *
  487. * FUNCTION: acpi_ns_dump_objects
  488. *
  489. * PARAMETERS: type - Object type to be dumped
  490. * display_type - 0 or ACPI_DISPLAY_SUMMARY
  491. * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
  492. * for an effectively unlimited depth.
  493. * owner_id - Dump only objects owned by this ID. Use
  494. * ACPI_UINT32_MAX to match all owners.
  495. * start_handle - Where in namespace to start/end search
  496. *
  497. * RETURN: None
  498. *
  499. * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
  500. * acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object.
  501. *
  502. ******************************************************************************/
  503. void
  504. acpi_ns_dump_objects(acpi_object_type type,
  505. u8 display_type,
  506. u32 max_depth,
  507. acpi_owner_id owner_id, acpi_handle start_handle)
  508. {
  509. struct acpi_walk_info info;
  510. acpi_status status;
  511. ACPI_FUNCTION_ENTRY();
  512. /*
  513. * Just lock the entire namespace for the duration of the dump.
  514. * We don't want any changes to the namespace during this time,
  515. * especially the temporary nodes since we are going to display
  516. * them also.
  517. */
  518. status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
  519. if (ACPI_FAILURE(status)) {
  520. acpi_os_printf("Could not acquire namespace mutex\n");
  521. return;
  522. }
  523. info.debug_level = ACPI_LV_TABLES;
  524. info.owner_id = owner_id;
  525. info.display_type = display_type;
  526. (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
  527. ACPI_NS_WALK_NO_UNLOCK |
  528. ACPI_NS_WALK_TEMP_NODES,
  529. acpi_ns_dump_one_object, NULL,
  530. (void *)&info, NULL);
  531. (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  532. }
  533. #endif /* ACPI_FUTURE_USAGE */
  534. #ifdef ACPI_FUTURE_USAGE
  535. /*******************************************************************************
  536. *
  537. * FUNCTION: acpi_ns_dump_one_object_path, acpi_ns_get_max_depth
  538. *
  539. * PARAMETERS: obj_handle - Node to be dumped
  540. * level - Nesting level of the handle
  541. * context - Passed into walk_namespace
  542. * return_value - Not used
  543. *
  544. * RETURN: Status
  545. *
  546. * DESCRIPTION: Dump the full pathname to a namespace object. acp_ns_get_max_depth
  547. * computes the maximum nesting depth in the namespace tree, in
  548. * order to simplify formatting in acpi_ns_dump_one_object_path.
  549. * These procedures are user_functions called by acpi_ns_walk_namespace.
  550. *
  551. ******************************************************************************/
  552. static acpi_status
  553. acpi_ns_dump_one_object_path(acpi_handle obj_handle,
  554. u32 level, void *context, void **return_value)
  555. {
  556. u32 max_level = *((u32 *)context);
  557. char *pathname;
  558. struct acpi_namespace_node *node;
  559. int path_indent;
  560. if (!obj_handle) {
  561. return (AE_OK);
  562. }
  563. node = acpi_ns_validate_handle(obj_handle);
  564. if (!node) {
  565. /* Ignore bad node during namespace walk */
  566. return (AE_OK);
  567. }
  568. pathname = acpi_ns_get_external_pathname(node);
  569. path_indent = 1;
  570. if (level <= max_level) {
  571. path_indent = max_level - level + 1;
  572. }
  573. acpi_os_printf("%2d%*s%-12s%*s",
  574. level, level, " ", acpi_ut_get_type_name(node->type),
  575. path_indent, " ");
  576. acpi_os_printf("%s\n", &pathname[1]);
  577. ACPI_FREE(pathname);
  578. return (AE_OK);
  579. }
  580. static acpi_status
  581. acpi_ns_get_max_depth(acpi_handle obj_handle,
  582. u32 level, void *context, void **return_value)
  583. {
  584. u32 *max_level = (u32 *)context;
  585. if (level > *max_level) {
  586. *max_level = level;
  587. }
  588. return (AE_OK);
  589. }
  590. /*******************************************************************************
  591. *
  592. * FUNCTION: acpi_ns_dump_object_paths
  593. *
  594. * PARAMETERS: type - Object type to be dumped
  595. * display_type - 0 or ACPI_DISPLAY_SUMMARY
  596. * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
  597. * for an effectively unlimited depth.
  598. * owner_id - Dump only objects owned by this ID. Use
  599. * ACPI_UINT32_MAX to match all owners.
  600. * start_handle - Where in namespace to start/end search
  601. *
  602. * RETURN: None
  603. *
  604. * DESCRIPTION: Dump full object pathnames within the loaded namespace. Uses
  605. * acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object_path.
  606. *
  607. ******************************************************************************/
  608. void
  609. acpi_ns_dump_object_paths(acpi_object_type type,
  610. u8 display_type,
  611. u32 max_depth,
  612. acpi_owner_id owner_id, acpi_handle start_handle)
  613. {
  614. acpi_status status;
  615. u32 max_level = 0;
  616. ACPI_FUNCTION_ENTRY();
  617. /*
  618. * Just lock the entire namespace for the duration of the dump.
  619. * We don't want any changes to the namespace during this time,
  620. * especially the temporary nodes since we are going to display
  621. * them also.
  622. */
  623. status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
  624. if (ACPI_FAILURE(status)) {
  625. acpi_os_printf("Could not acquire namespace mutex\n");
  626. return;
  627. }
  628. /* Get the max depth of the namespace tree, for formatting later */
  629. (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
  630. ACPI_NS_WALK_NO_UNLOCK |
  631. ACPI_NS_WALK_TEMP_NODES,
  632. acpi_ns_get_max_depth, NULL,
  633. (void *)&max_level, NULL);
  634. /* Now dump the entire namespace */
  635. (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
  636. ACPI_NS_WALK_NO_UNLOCK |
  637. ACPI_NS_WALK_TEMP_NODES,
  638. acpi_ns_dump_one_object_path, NULL,
  639. (void *)&max_level, NULL);
  640. (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  641. }
  642. #endif /* ACPI_FUTURE_USAGE */
  643. /*******************************************************************************
  644. *
  645. * FUNCTION: acpi_ns_dump_entry
  646. *
  647. * PARAMETERS: handle - Node to be dumped
  648. * debug_level - Output level
  649. *
  650. * RETURN: None
  651. *
  652. * DESCRIPTION: Dump a single Node
  653. *
  654. ******************************************************************************/
  655. void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level)
  656. {
  657. struct acpi_walk_info info;
  658. ACPI_FUNCTION_ENTRY();
  659. info.debug_level = debug_level;
  660. info.owner_id = ACPI_OWNER_ID_MAX;
  661. info.display_type = ACPI_DISPLAY_SUMMARY;
  662. (void)acpi_ns_dump_one_object(handle, 1, &info, NULL);
  663. }
  664. #ifdef ACPI_ASL_COMPILER
  665. /*******************************************************************************
  666. *
  667. * FUNCTION: acpi_ns_dump_tables
  668. *
  669. * PARAMETERS: search_base - Root of subtree to be dumped, or
  670. * NS_ALL to dump the entire namespace
  671. * max_depth - Maximum depth of dump. Use INT_MAX
  672. * for an effectively unlimited depth.
  673. *
  674. * RETURN: None
  675. *
  676. * DESCRIPTION: Dump the name space, or a portion of it.
  677. *
  678. ******************************************************************************/
  679. void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth)
  680. {
  681. acpi_handle search_handle = search_base;
  682. ACPI_FUNCTION_TRACE(ns_dump_tables);
  683. if (!acpi_gbl_root_node) {
  684. /*
  685. * If the name space has not been initialized,
  686. * there is nothing to dump.
  687. */
  688. ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
  689. "namespace not initialized!\n"));
  690. return_VOID;
  691. }
  692. if (ACPI_NS_ALL == search_base) {
  693. /* Entire namespace */
  694. search_handle = acpi_gbl_root_node;
  695. ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "\\\n"));
  696. }
  697. acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth,
  698. ACPI_OWNER_ID_MAX, search_handle);
  699. return_VOID;
  700. }
  701. #endif
  702. #endif