nsdump.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  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 - 2018, 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_NAME_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. /* Check if the owner matches */
  141. if ((info->owner_id != ACPI_OWNER_ID_MAX) &&
  142. (info->owner_id != this_node->owner_id)) {
  143. return (AE_OK);
  144. }
  145. if (!(info->display_type & ACPI_DISPLAY_SHORT)) {
  146. /* Indent the object according to the level */
  147. acpi_os_printf("%2d%*s", (u32) level - 1, (int)level * 2, " ");
  148. /* Check the node type and name */
  149. if (type > ACPI_TYPE_LOCAL_MAX) {
  150. ACPI_WARNING((AE_INFO,
  151. "Invalid ACPI Object Type 0x%08X", type));
  152. }
  153. acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
  154. }
  155. /* Now we can print out the pertinent information */
  156. acpi_os_printf(" %-12s %p %2.2X ",
  157. acpi_ut_get_type_name(type), this_node,
  158. this_node->owner_id);
  159. dbg_level = acpi_dbg_level;
  160. acpi_dbg_level = 0;
  161. obj_desc = acpi_ns_get_attached_object(this_node);
  162. acpi_dbg_level = dbg_level;
  163. /* Temp nodes are those nodes created by a control method */
  164. if (this_node->flags & ANOBJ_TEMPORARY) {
  165. acpi_os_printf("(T) ");
  166. }
  167. switch (info->display_type & ACPI_DISPLAY_MASK) {
  168. case ACPI_DISPLAY_SUMMARY:
  169. if (!obj_desc) {
  170. /* No attached object. Some types should always have an object */
  171. switch (type) {
  172. case ACPI_TYPE_INTEGER:
  173. case ACPI_TYPE_PACKAGE:
  174. case ACPI_TYPE_BUFFER:
  175. case ACPI_TYPE_STRING:
  176. case ACPI_TYPE_METHOD:
  177. acpi_os_printf("<No attached object>");
  178. break;
  179. default:
  180. break;
  181. }
  182. acpi_os_printf("\n");
  183. return (AE_OK);
  184. }
  185. switch (type) {
  186. case ACPI_TYPE_PROCESSOR:
  187. acpi_os_printf("ID %02X Len %02X Addr %8.8X%8.8X\n",
  188. obj_desc->processor.proc_id,
  189. obj_desc->processor.length,
  190. ACPI_FORMAT_UINT64(obj_desc->processor.
  191. address));
  192. break;
  193. case ACPI_TYPE_DEVICE:
  194. acpi_os_printf("Notify Object: %p\n", obj_desc);
  195. break;
  196. case ACPI_TYPE_METHOD:
  197. acpi_os_printf("Args %X Len %.4X Aml %p\n",
  198. (u32) obj_desc->method.param_count,
  199. obj_desc->method.aml_length,
  200. obj_desc->method.aml_start);
  201. break;
  202. case ACPI_TYPE_INTEGER:
  203. acpi_os_printf("= %8.8X%8.8X\n",
  204. ACPI_FORMAT_UINT64(obj_desc->integer.
  205. value));
  206. break;
  207. case ACPI_TYPE_PACKAGE:
  208. if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
  209. acpi_os_printf("Elements %.2X\n",
  210. obj_desc->package.count);
  211. } else {
  212. acpi_os_printf("[Length not yet evaluated]\n");
  213. }
  214. break;
  215. case ACPI_TYPE_BUFFER:
  216. if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
  217. acpi_os_printf("Len %.2X",
  218. obj_desc->buffer.length);
  219. /* Dump some of the buffer */
  220. if (obj_desc->buffer.length > 0) {
  221. acpi_os_printf(" =");
  222. for (i = 0;
  223. (i < obj_desc->buffer.length
  224. && i < 12); i++) {
  225. acpi_os_printf(" %.2hX",
  226. obj_desc->buffer.
  227. pointer[i]);
  228. }
  229. }
  230. acpi_os_printf("\n");
  231. } else {
  232. acpi_os_printf("[Length not yet evaluated]\n");
  233. }
  234. break;
  235. case ACPI_TYPE_STRING:
  236. acpi_os_printf("Len %.2X ", obj_desc->string.length);
  237. acpi_ut_print_string(obj_desc->string.pointer, 80);
  238. acpi_os_printf("\n");
  239. break;
  240. case ACPI_TYPE_REGION:
  241. acpi_os_printf("[%s]",
  242. acpi_ut_get_region_name(obj_desc->region.
  243. space_id));
  244. if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
  245. acpi_os_printf(" Addr %8.8X%8.8X Len %.4X\n",
  246. ACPI_FORMAT_UINT64(obj_desc->
  247. region.
  248. address),
  249. obj_desc->region.length);
  250. } else {
  251. acpi_os_printf
  252. (" [Address/Length not yet evaluated]\n");
  253. }
  254. break;
  255. case ACPI_TYPE_LOCAL_REFERENCE:
  256. acpi_os_printf("[%s]\n",
  257. acpi_ut_get_reference_name(obj_desc));
  258. break;
  259. case ACPI_TYPE_BUFFER_FIELD:
  260. if (obj_desc->buffer_field.buffer_obj &&
  261. obj_desc->buffer_field.buffer_obj->buffer.node) {
  262. acpi_os_printf("Buf [%4.4s]",
  263. acpi_ut_get_node_name(obj_desc->
  264. buffer_field.
  265. buffer_obj->
  266. buffer.
  267. node));
  268. }
  269. break;
  270. case ACPI_TYPE_LOCAL_REGION_FIELD:
  271. acpi_os_printf("Rgn [%4.4s]",
  272. acpi_ut_get_node_name(obj_desc->
  273. common_field.
  274. region_obj->region.
  275. node));
  276. break;
  277. case ACPI_TYPE_LOCAL_BANK_FIELD:
  278. acpi_os_printf("Rgn [%4.4s] Bnk [%4.4s]",
  279. acpi_ut_get_node_name(obj_desc->
  280. common_field.
  281. region_obj->region.
  282. node),
  283. acpi_ut_get_node_name(obj_desc->
  284. bank_field.
  285. bank_obj->
  286. common_field.
  287. node));
  288. break;
  289. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  290. acpi_os_printf("Idx [%4.4s] Dat [%4.4s]",
  291. acpi_ut_get_node_name(obj_desc->
  292. index_field.
  293. index_obj->
  294. common_field.node),
  295. acpi_ut_get_node_name(obj_desc->
  296. index_field.
  297. data_obj->
  298. common_field.
  299. node));
  300. break;
  301. case ACPI_TYPE_LOCAL_ALIAS:
  302. case ACPI_TYPE_LOCAL_METHOD_ALIAS:
  303. acpi_os_printf("Target %4.4s (%p)\n",
  304. acpi_ut_get_node_name(obj_desc),
  305. obj_desc);
  306. break;
  307. default:
  308. acpi_os_printf("Object %p\n", obj_desc);
  309. break;
  310. }
  311. /* Common field handling */
  312. switch (type) {
  313. case ACPI_TYPE_BUFFER_FIELD:
  314. case ACPI_TYPE_LOCAL_REGION_FIELD:
  315. case ACPI_TYPE_LOCAL_BANK_FIELD:
  316. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  317. acpi_os_printf(" Off %.3X Len %.2X Acc %.2hd\n",
  318. (obj_desc->common_field.
  319. base_byte_offset * 8)
  320. +
  321. obj_desc->common_field.
  322. start_field_bit_offset,
  323. obj_desc->common_field.bit_length,
  324. obj_desc->common_field.
  325. access_byte_width);
  326. break;
  327. default:
  328. break;
  329. }
  330. break;
  331. case ACPI_DISPLAY_OBJECTS:
  332. acpi_os_printf("O:%p", obj_desc);
  333. if (!obj_desc) {
  334. /* No attached object, we are done */
  335. acpi_os_printf("\n");
  336. return (AE_OK);
  337. }
  338. acpi_os_printf("(R%u)", obj_desc->common.reference_count);
  339. switch (type) {
  340. case ACPI_TYPE_METHOD:
  341. /* Name is a Method and its AML offset/length are set */
  342. acpi_os_printf(" M:%p-%X\n", obj_desc->method.aml_start,
  343. obj_desc->method.aml_length);
  344. break;
  345. case ACPI_TYPE_INTEGER:
  346. acpi_os_printf(" I:%8.8X8.8%X\n",
  347. ACPI_FORMAT_UINT64(obj_desc->integer.
  348. value));
  349. break;
  350. case ACPI_TYPE_STRING:
  351. acpi_os_printf(" S:%p-%X\n", obj_desc->string.pointer,
  352. obj_desc->string.length);
  353. break;
  354. case ACPI_TYPE_BUFFER:
  355. acpi_os_printf(" B:%p-%X\n", obj_desc->buffer.pointer,
  356. obj_desc->buffer.length);
  357. break;
  358. default:
  359. acpi_os_printf("\n");
  360. break;
  361. }
  362. break;
  363. default:
  364. acpi_os_printf("\n");
  365. break;
  366. }
  367. /* If debug turned off, done */
  368. if (!(acpi_dbg_level & ACPI_LV_VALUES)) {
  369. return (AE_OK);
  370. }
  371. /* If there is an attached object, display it */
  372. dbg_level = acpi_dbg_level;
  373. acpi_dbg_level = 0;
  374. obj_desc = acpi_ns_get_attached_object(this_node);
  375. acpi_dbg_level = dbg_level;
  376. /* Dump attached objects */
  377. while (obj_desc) {
  378. obj_type = ACPI_TYPE_INVALID;
  379. acpi_os_printf("Attached Object %p: ", obj_desc);
  380. /* Decode the type of attached object and dump the contents */
  381. switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
  382. case ACPI_DESC_TYPE_NAMED:
  383. acpi_os_printf("(Ptr to Node)\n");
  384. bytes_to_dump = sizeof(struct acpi_namespace_node);
  385. ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
  386. break;
  387. case ACPI_DESC_TYPE_OPERAND:
  388. obj_type = obj_desc->common.type;
  389. if (obj_type > ACPI_TYPE_LOCAL_MAX) {
  390. acpi_os_printf
  391. ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
  392. obj_type);
  393. bytes_to_dump = 32;
  394. } else {
  395. acpi_os_printf
  396. ("(Pointer to ACPI Object type %.2X [%s])\n",
  397. obj_type, acpi_ut_get_type_name(obj_type));
  398. bytes_to_dump =
  399. sizeof(union acpi_operand_object);
  400. }
  401. ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
  402. break;
  403. default:
  404. break;
  405. }
  406. /* If value is NOT an internal object, we are done */
  407. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) !=
  408. ACPI_DESC_TYPE_OPERAND) {
  409. goto cleanup;
  410. }
  411. /* Valid object, get the pointer to next level, if any */
  412. switch (obj_type) {
  413. case ACPI_TYPE_BUFFER:
  414. case ACPI_TYPE_STRING:
  415. /*
  416. * NOTE: takes advantage of common fields between string/buffer
  417. */
  418. bytes_to_dump = obj_desc->string.length;
  419. obj_desc = (void *)obj_desc->string.pointer;
  420. acpi_os_printf("(Buffer/String pointer %p length %X)\n",
  421. obj_desc, bytes_to_dump);
  422. ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
  423. goto cleanup;
  424. case ACPI_TYPE_BUFFER_FIELD:
  425. obj_desc =
  426. (union acpi_operand_object *)obj_desc->buffer_field.
  427. buffer_obj;
  428. break;
  429. case ACPI_TYPE_PACKAGE:
  430. obj_desc = (void *)obj_desc->package.elements;
  431. break;
  432. case ACPI_TYPE_METHOD:
  433. obj_desc = (void *)obj_desc->method.aml_start;
  434. break;
  435. case ACPI_TYPE_LOCAL_REGION_FIELD:
  436. obj_desc = (void *)obj_desc->field.region_obj;
  437. break;
  438. case ACPI_TYPE_LOCAL_BANK_FIELD:
  439. obj_desc = (void *)obj_desc->bank_field.region_obj;
  440. break;
  441. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  442. obj_desc = (void *)obj_desc->index_field.index_obj;
  443. break;
  444. default:
  445. goto cleanup;
  446. }
  447. obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
  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.debug_level = ACPI_LV_TABLES;
  492. info.owner_id = owner_id;
  493. info.display_type = display_type;
  494. (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
  495. ACPI_NS_WALK_NO_UNLOCK |
  496. ACPI_NS_WALK_TEMP_NODES,
  497. acpi_ns_dump_one_object, NULL,
  498. (void *)&info, NULL);
  499. (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  500. }
  501. /*******************************************************************************
  502. *
  503. * FUNCTION: acpi_ns_dump_one_object_path, acpi_ns_get_max_depth
  504. *
  505. * PARAMETERS: obj_handle - Node to be dumped
  506. * level - Nesting level of the handle
  507. * context - Passed into walk_namespace
  508. * return_value - Not used
  509. *
  510. * RETURN: Status
  511. *
  512. * DESCRIPTION: Dump the full pathname to a namespace object. acp_ns_get_max_depth
  513. * computes the maximum nesting depth in the namespace tree, in
  514. * order to simplify formatting in acpi_ns_dump_one_object_path.
  515. * These procedures are user_functions called by acpi_ns_walk_namespace.
  516. *
  517. ******************************************************************************/
  518. static acpi_status
  519. acpi_ns_dump_one_object_path(acpi_handle obj_handle,
  520. u32 level, void *context, void **return_value)
  521. {
  522. u32 max_level = *((u32 *)context);
  523. char *pathname;
  524. struct acpi_namespace_node *node;
  525. int path_indent;
  526. if (!obj_handle) {
  527. return (AE_OK);
  528. }
  529. node = acpi_ns_validate_handle(obj_handle);
  530. if (!node) {
  531. /* Ignore bad node during namespace walk */
  532. return (AE_OK);
  533. }
  534. pathname = acpi_ns_get_normalized_pathname(node, TRUE);
  535. path_indent = 1;
  536. if (level <= max_level) {
  537. path_indent = max_level - level + 1;
  538. }
  539. acpi_os_printf("%2d%*s%-12s%*s",
  540. level, level, " ", acpi_ut_get_type_name(node->type),
  541. path_indent, " ");
  542. acpi_os_printf("%s\n", &pathname[1]);
  543. ACPI_FREE(pathname);
  544. return (AE_OK);
  545. }
  546. static acpi_status
  547. acpi_ns_get_max_depth(acpi_handle obj_handle,
  548. u32 level, void *context, void **return_value)
  549. {
  550. u32 *max_level = (u32 *)context;
  551. if (level > *max_level) {
  552. *max_level = level;
  553. }
  554. return (AE_OK);
  555. }
  556. /*******************************************************************************
  557. *
  558. * FUNCTION: acpi_ns_dump_object_paths
  559. *
  560. * PARAMETERS: type - Object type to be dumped
  561. * display_type - 0 or ACPI_DISPLAY_SUMMARY
  562. * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
  563. * for an effectively unlimited depth.
  564. * owner_id - Dump only objects owned by this ID. Use
  565. * ACPI_UINT32_MAX to match all owners.
  566. * start_handle - Where in namespace to start/end search
  567. *
  568. * RETURN: None
  569. *
  570. * DESCRIPTION: Dump full object pathnames within the loaded namespace. Uses
  571. * acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object_path.
  572. *
  573. ******************************************************************************/
  574. void
  575. acpi_ns_dump_object_paths(acpi_object_type type,
  576. u8 display_type,
  577. u32 max_depth,
  578. acpi_owner_id owner_id, acpi_handle start_handle)
  579. {
  580. acpi_status status;
  581. u32 max_level = 0;
  582. ACPI_FUNCTION_ENTRY();
  583. /*
  584. * Just lock the entire namespace for the duration of the dump.
  585. * We don't want any changes to the namespace during this time,
  586. * especially the temporary nodes since we are going to display
  587. * them also.
  588. */
  589. status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
  590. if (ACPI_FAILURE(status)) {
  591. acpi_os_printf("Could not acquire namespace mutex\n");
  592. return;
  593. }
  594. /* Get the max depth of the namespace tree, for formatting later */
  595. (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
  596. ACPI_NS_WALK_NO_UNLOCK |
  597. ACPI_NS_WALK_TEMP_NODES,
  598. acpi_ns_get_max_depth, NULL,
  599. (void *)&max_level, NULL);
  600. /* Now dump the entire namespace */
  601. (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
  602. ACPI_NS_WALK_NO_UNLOCK |
  603. ACPI_NS_WALK_TEMP_NODES,
  604. acpi_ns_dump_one_object_path, NULL,
  605. (void *)&max_level, NULL);
  606. (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
  607. }
  608. /*******************************************************************************
  609. *
  610. * FUNCTION: acpi_ns_dump_entry
  611. *
  612. * PARAMETERS: handle - Node to be dumped
  613. * debug_level - Output level
  614. *
  615. * RETURN: None
  616. *
  617. * DESCRIPTION: Dump a single Node
  618. *
  619. ******************************************************************************/
  620. void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level)
  621. {
  622. struct acpi_walk_info info;
  623. ACPI_FUNCTION_ENTRY();
  624. info.debug_level = debug_level;
  625. info.owner_id = ACPI_OWNER_ID_MAX;
  626. info.display_type = ACPI_DISPLAY_SUMMARY;
  627. (void)acpi_ns_dump_one_object(handle, 1, &info, NULL);
  628. }
  629. #ifdef ACPI_ASL_COMPILER
  630. /*******************************************************************************
  631. *
  632. * FUNCTION: acpi_ns_dump_tables
  633. *
  634. * PARAMETERS: search_base - Root of subtree to be dumped, or
  635. * NS_ALL to dump the entire namespace
  636. * max_depth - Maximum depth of dump. Use INT_MAX
  637. * for an effectively unlimited depth.
  638. *
  639. * RETURN: None
  640. *
  641. * DESCRIPTION: Dump the name space, or a portion of it.
  642. *
  643. ******************************************************************************/
  644. void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth)
  645. {
  646. acpi_handle search_handle = search_base;
  647. ACPI_FUNCTION_TRACE(ns_dump_tables);
  648. if (!acpi_gbl_root_node) {
  649. /*
  650. * If the name space has not been initialized,
  651. * there is nothing to dump.
  652. */
  653. ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
  654. "namespace not initialized!\n"));
  655. return_VOID;
  656. }
  657. if (ACPI_NS_ALL == search_base) {
  658. /* Entire namespace */
  659. search_handle = acpi_gbl_root_node;
  660. ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "\\\n"));
  661. }
  662. acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth,
  663. ACPI_OWNER_ID_MAX, search_handle);
  664. return_VOID;
  665. }
  666. #endif
  667. #endif