nsdump.c 23 KB

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