nsdump.c 21 KB

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