dbdisply.c 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /*******************************************************************************
  3. *
  4. * Module Name: dbdisply - debug display commands
  5. *
  6. ******************************************************************************/
  7. #include <acpi/acpi.h>
  8. #include "accommon.h"
  9. #include "amlcode.h"
  10. #include "acdispat.h"
  11. #include "acnamesp.h"
  12. #include "acparser.h"
  13. #include "acinterp.h"
  14. #include "acevents.h"
  15. #include "acdebug.h"
  16. #define _COMPONENT ACPI_CA_DEBUGGER
  17. ACPI_MODULE_NAME("dbdisply")
  18. /* Local prototypes */
  19. static void acpi_db_dump_parser_descriptor(union acpi_parse_object *op);
  20. static void *acpi_db_get_pointer(void *target);
  21. static acpi_status
  22. acpi_db_display_non_root_handlers(acpi_handle obj_handle,
  23. u32 nesting_level,
  24. void *context, void **return_value);
  25. /*
  26. * System handler information.
  27. * Used for Handlers command, in acpi_db_display_handlers.
  28. */
  29. #define ACPI_PREDEFINED_PREFIX "%25s (%.2X) : "
  30. #define ACPI_HANDLER_NAME_STRING "%30s : "
  31. #define ACPI_HANDLER_PRESENT_STRING "%-9s (%p)\n"
  32. #define ACPI_HANDLER_PRESENT_STRING2 "%-9s (%p)"
  33. #define ACPI_HANDLER_NOT_PRESENT_STRING "%-9s\n"
  34. /* All predefined Address Space IDs */
  35. static acpi_adr_space_type acpi_gbl_space_id_list[] = {
  36. ACPI_ADR_SPACE_SYSTEM_MEMORY,
  37. ACPI_ADR_SPACE_SYSTEM_IO,
  38. ACPI_ADR_SPACE_PCI_CONFIG,
  39. ACPI_ADR_SPACE_EC,
  40. ACPI_ADR_SPACE_SMBUS,
  41. ACPI_ADR_SPACE_CMOS,
  42. ACPI_ADR_SPACE_PCI_BAR_TARGET,
  43. ACPI_ADR_SPACE_IPMI,
  44. ACPI_ADR_SPACE_GPIO,
  45. ACPI_ADR_SPACE_GSBUS,
  46. ACPI_ADR_SPACE_DATA_TABLE,
  47. ACPI_ADR_SPACE_FIXED_HARDWARE
  48. };
  49. /* Global handler information */
  50. typedef struct acpi_handler_info {
  51. void *handler;
  52. char *name;
  53. } acpi_handler_info;
  54. static struct acpi_handler_info acpi_gbl_handler_list[] = {
  55. {&acpi_gbl_global_notify[0].handler, "System Notifications"},
  56. {&acpi_gbl_global_notify[1].handler, "Device Notifications"},
  57. {&acpi_gbl_table_handler, "ACPI Table Events"},
  58. {&acpi_gbl_exception_handler, "Control Method Exceptions"},
  59. {&acpi_gbl_interface_handler, "OSI Invocations"}
  60. };
  61. /*******************************************************************************
  62. *
  63. * FUNCTION: acpi_db_get_pointer
  64. *
  65. * PARAMETERS: target - Pointer to string to be converted
  66. *
  67. * RETURN: Converted pointer
  68. *
  69. * DESCRIPTION: Convert an ascii pointer value to a real value
  70. *
  71. ******************************************************************************/
  72. static void *acpi_db_get_pointer(void *target)
  73. {
  74. void *obj_ptr;
  75. acpi_size address;
  76. address = strtoul(target, NULL, 16);
  77. obj_ptr = ACPI_TO_POINTER(address);
  78. return (obj_ptr);
  79. }
  80. /*******************************************************************************
  81. *
  82. * FUNCTION: acpi_db_dump_parser_descriptor
  83. *
  84. * PARAMETERS: op - A parser Op descriptor
  85. *
  86. * RETURN: None
  87. *
  88. * DESCRIPTION: Display a formatted parser object
  89. *
  90. ******************************************************************************/
  91. static void acpi_db_dump_parser_descriptor(union acpi_parse_object *op)
  92. {
  93. const struct acpi_opcode_info *info;
  94. info = acpi_ps_get_opcode_info(op->common.aml_opcode);
  95. acpi_os_printf("Parser Op Descriptor:\n");
  96. acpi_os_printf("%20.20s : %4.4X\n", "Opcode", op->common.aml_opcode);
  97. ACPI_DEBUG_ONLY_MEMBERS(acpi_os_printf("%20.20s : %s\n", "Opcode Name",
  98. info->name));
  99. acpi_os_printf("%20.20s : %p\n", "Value/ArgList", op->common.value.arg);
  100. acpi_os_printf("%20.20s : %p\n", "Parent", op->common.parent);
  101. acpi_os_printf("%20.20s : %p\n", "NextOp", op->common.next);
  102. }
  103. /*******************************************************************************
  104. *
  105. * FUNCTION: acpi_db_decode_and_display_object
  106. *
  107. * PARAMETERS: target - String with object to be displayed. Names
  108. * and hex pointers are supported.
  109. * output_type - Byte, Word, Dword, or Qword (B|W|D|Q)
  110. *
  111. * RETURN: None
  112. *
  113. * DESCRIPTION: Display a formatted ACPI object
  114. *
  115. ******************************************************************************/
  116. void acpi_db_decode_and_display_object(char *target, char *output_type)
  117. {
  118. void *obj_ptr;
  119. struct acpi_namespace_node *node;
  120. union acpi_operand_object *obj_desc;
  121. u32 display = DB_BYTE_DISPLAY;
  122. char buffer[80];
  123. struct acpi_buffer ret_buf;
  124. acpi_status status;
  125. u32 size;
  126. if (!target) {
  127. return;
  128. }
  129. /* Decode the output type */
  130. if (output_type) {
  131. acpi_ut_strupr(output_type);
  132. if (output_type[0] == 'W') {
  133. display = DB_WORD_DISPLAY;
  134. } else if (output_type[0] == 'D') {
  135. display = DB_DWORD_DISPLAY;
  136. } else if (output_type[0] == 'Q') {
  137. display = DB_QWORD_DISPLAY;
  138. }
  139. }
  140. ret_buf.length = sizeof(buffer);
  141. ret_buf.pointer = buffer;
  142. /* Differentiate between a number and a name */
  143. if ((target[0] >= 0x30) && (target[0] <= 0x39)) {
  144. obj_ptr = acpi_db_get_pointer(target);
  145. if (!acpi_os_readable(obj_ptr, 16)) {
  146. acpi_os_printf
  147. ("Address %p is invalid in this address space\n",
  148. obj_ptr);
  149. return;
  150. }
  151. /* Decode the object type */
  152. switch (ACPI_GET_DESCRIPTOR_TYPE(obj_ptr)) {
  153. case ACPI_DESC_TYPE_NAMED:
  154. /* This is a namespace Node */
  155. if (!acpi_os_readable
  156. (obj_ptr, sizeof(struct acpi_namespace_node))) {
  157. acpi_os_printf
  158. ("Cannot read entire Named object at address %p\n",
  159. obj_ptr);
  160. return;
  161. }
  162. node = obj_ptr;
  163. goto dump_node;
  164. case ACPI_DESC_TYPE_OPERAND:
  165. /* This is a ACPI OPERAND OBJECT */
  166. if (!acpi_os_readable
  167. (obj_ptr, sizeof(union acpi_operand_object))) {
  168. acpi_os_printf
  169. ("Cannot read entire ACPI object at address %p\n",
  170. obj_ptr);
  171. return;
  172. }
  173. acpi_ut_debug_dump_buffer(obj_ptr,
  174. sizeof(union
  175. acpi_operand_object),
  176. display, ACPI_UINT32_MAX);
  177. acpi_ex_dump_object_descriptor(obj_ptr, 1);
  178. break;
  179. case ACPI_DESC_TYPE_PARSER:
  180. /* This is a Parser Op object */
  181. if (!acpi_os_readable
  182. (obj_ptr, sizeof(union acpi_parse_object))) {
  183. acpi_os_printf
  184. ("Cannot read entire Parser object at address %p\n",
  185. obj_ptr);
  186. return;
  187. }
  188. acpi_ut_debug_dump_buffer(obj_ptr,
  189. sizeof(union
  190. acpi_parse_object),
  191. display, ACPI_UINT32_MAX);
  192. acpi_db_dump_parser_descriptor((union acpi_parse_object
  193. *)obj_ptr);
  194. break;
  195. default:
  196. /* Is not a recognizeable object */
  197. acpi_os_printf
  198. ("Not a known ACPI internal object, descriptor type %2.2X\n",
  199. ACPI_GET_DESCRIPTOR_TYPE(obj_ptr));
  200. size = 16;
  201. if (acpi_os_readable(obj_ptr, 64)) {
  202. size = 64;
  203. }
  204. /* Just dump some memory */
  205. acpi_ut_debug_dump_buffer(obj_ptr, size, display,
  206. ACPI_UINT32_MAX);
  207. break;
  208. }
  209. return;
  210. }
  211. /* The parameter is a name string that must be resolved to a Named obj */
  212. node = acpi_db_local_ns_lookup(target);
  213. if (!node) {
  214. return;
  215. }
  216. dump_node:
  217. /* Now dump the NS node */
  218. status = acpi_get_name(node, ACPI_FULL_PATHNAME_NO_TRAILING, &ret_buf);
  219. if (ACPI_FAILURE(status)) {
  220. acpi_os_printf("Could not convert name to pathname\n");
  221. }
  222. else {
  223. acpi_os_printf("Object %p: Namespace Node - Pathname: %s\n",
  224. node, (char *)ret_buf.pointer);
  225. }
  226. if (!acpi_os_readable(node, sizeof(struct acpi_namespace_node))) {
  227. acpi_os_printf("Invalid Named object at address %p\n", node);
  228. return;
  229. }
  230. acpi_ut_debug_dump_buffer((void *)node,
  231. sizeof(struct acpi_namespace_node), display,
  232. ACPI_UINT32_MAX);
  233. acpi_ex_dump_namespace_node(node, 1);
  234. obj_desc = acpi_ns_get_attached_object(node);
  235. if (obj_desc) {
  236. acpi_os_printf("\nAttached Object %p:", obj_desc);
  237. if (!acpi_os_readable
  238. (obj_desc, sizeof(union acpi_operand_object))) {
  239. acpi_os_printf
  240. ("Invalid internal ACPI Object at address %p\n",
  241. obj_desc);
  242. return;
  243. }
  244. if (ACPI_GET_DESCRIPTOR_TYPE(((struct acpi_namespace_node *)
  245. obj_desc)) ==
  246. ACPI_DESC_TYPE_NAMED) {
  247. acpi_os_printf(" Namespace Node - ");
  248. status =
  249. acpi_get_name((struct acpi_namespace_node *)
  250. obj_desc,
  251. ACPI_FULL_PATHNAME_NO_TRAILING,
  252. &ret_buf);
  253. if (ACPI_FAILURE(status)) {
  254. acpi_os_printf
  255. ("Could not convert name to pathname\n");
  256. } else {
  257. acpi_os_printf("Pathname: %s",
  258. (char *)ret_buf.pointer);
  259. }
  260. acpi_os_printf("\n");
  261. acpi_ut_debug_dump_buffer((void *)obj_desc,
  262. sizeof(struct
  263. acpi_namespace_node),
  264. display, ACPI_UINT32_MAX);
  265. } else {
  266. acpi_os_printf("\n");
  267. acpi_ut_debug_dump_buffer((void *)obj_desc,
  268. sizeof(union
  269. acpi_operand_object),
  270. display, ACPI_UINT32_MAX);
  271. }
  272. acpi_ex_dump_object_descriptor(obj_desc, 1);
  273. }
  274. }
  275. /*******************************************************************************
  276. *
  277. * FUNCTION: acpi_db_display_method_info
  278. *
  279. * PARAMETERS: start_op - Root of the control method parse tree
  280. *
  281. * RETURN: None
  282. *
  283. * DESCRIPTION: Display information about the current method
  284. *
  285. ******************************************************************************/
  286. void acpi_db_display_method_info(union acpi_parse_object *start_op)
  287. {
  288. struct acpi_walk_state *walk_state;
  289. union acpi_operand_object *obj_desc;
  290. struct acpi_namespace_node *node;
  291. union acpi_parse_object *root_op;
  292. union acpi_parse_object *op;
  293. const struct acpi_opcode_info *op_info;
  294. u32 num_ops = 0;
  295. u32 num_operands = 0;
  296. u32 num_operators = 0;
  297. u32 num_remaining_ops = 0;
  298. u32 num_remaining_operands = 0;
  299. u32 num_remaining_operators = 0;
  300. u8 count_remaining = FALSE;
  301. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  302. if (!walk_state) {
  303. acpi_os_printf("There is no method currently executing\n");
  304. return;
  305. }
  306. obj_desc = walk_state->method_desc;
  307. node = walk_state->method_node;
  308. acpi_os_printf("Currently executing control method is [%4.4s]\n",
  309. acpi_ut_get_node_name(node));
  310. acpi_os_printf("%X Arguments, SyncLevel = %X\n",
  311. (u32)obj_desc->method.param_count,
  312. (u32)obj_desc->method.sync_level);
  313. root_op = start_op;
  314. while (root_op->common.parent) {
  315. root_op = root_op->common.parent;
  316. }
  317. op = root_op;
  318. while (op) {
  319. if (op == start_op) {
  320. count_remaining = TRUE;
  321. }
  322. num_ops++;
  323. if (count_remaining) {
  324. num_remaining_ops++;
  325. }
  326. /* Decode the opcode */
  327. op_info = acpi_ps_get_opcode_info(op->common.aml_opcode);
  328. switch (op_info->class) {
  329. case AML_CLASS_ARGUMENT:
  330. if (count_remaining) {
  331. num_remaining_operands++;
  332. }
  333. num_operands++;
  334. break;
  335. case AML_CLASS_UNKNOWN:
  336. /* Bad opcode or ASCII character */
  337. continue;
  338. default:
  339. if (count_remaining) {
  340. num_remaining_operators++;
  341. }
  342. num_operators++;
  343. break;
  344. }
  345. op = acpi_ps_get_depth_next(start_op, op);
  346. }
  347. acpi_os_printf
  348. ("Method contains: %X AML Opcodes - %X Operators, %X Operands\n",
  349. num_ops, num_operators, num_operands);
  350. acpi_os_printf
  351. ("Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n",
  352. num_remaining_ops, num_remaining_operators,
  353. num_remaining_operands);
  354. }
  355. /*******************************************************************************
  356. *
  357. * FUNCTION: acpi_db_display_locals
  358. *
  359. * PARAMETERS: None
  360. *
  361. * RETURN: None
  362. *
  363. * DESCRIPTION: Display all locals for the currently running control method
  364. *
  365. ******************************************************************************/
  366. void acpi_db_display_locals(void)
  367. {
  368. struct acpi_walk_state *walk_state;
  369. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  370. if (!walk_state) {
  371. acpi_os_printf("There is no method currently executing\n");
  372. return;
  373. }
  374. acpi_db_decode_locals(walk_state);
  375. }
  376. /*******************************************************************************
  377. *
  378. * FUNCTION: acpi_db_display_arguments
  379. *
  380. * PARAMETERS: None
  381. *
  382. * RETURN: None
  383. *
  384. * DESCRIPTION: Display all arguments for the currently running control method
  385. *
  386. ******************************************************************************/
  387. void acpi_db_display_arguments(void)
  388. {
  389. struct acpi_walk_state *walk_state;
  390. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  391. if (!walk_state) {
  392. acpi_os_printf("There is no method currently executing\n");
  393. return;
  394. }
  395. acpi_db_decode_arguments(walk_state);
  396. }
  397. /*******************************************************************************
  398. *
  399. * FUNCTION: acpi_db_display_results
  400. *
  401. * PARAMETERS: None
  402. *
  403. * RETURN: None
  404. *
  405. * DESCRIPTION: Display current contents of a method result stack
  406. *
  407. ******************************************************************************/
  408. void acpi_db_display_results(void)
  409. {
  410. u32 i;
  411. struct acpi_walk_state *walk_state;
  412. union acpi_operand_object *obj_desc;
  413. u32 result_count = 0;
  414. struct acpi_namespace_node *node;
  415. union acpi_generic_state *frame;
  416. u32 index; /* Index onto current frame */
  417. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  418. if (!walk_state) {
  419. acpi_os_printf("There is no method currently executing\n");
  420. return;
  421. }
  422. obj_desc = walk_state->method_desc;
  423. node = walk_state->method_node;
  424. if (walk_state->results) {
  425. result_count = walk_state->result_count;
  426. }
  427. acpi_os_printf("Method [%4.4s] has %X stacked result objects\n",
  428. acpi_ut_get_node_name(node), result_count);
  429. /* From the top element of result stack */
  430. frame = walk_state->results;
  431. index = (result_count - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
  432. for (i = 0; i < result_count; i++) {
  433. obj_desc = frame->results.obj_desc[index];
  434. acpi_os_printf("Result%u: ", i);
  435. acpi_db_display_internal_object(obj_desc, walk_state);
  436. if (index == 0) {
  437. frame = frame->results.next;
  438. index = ACPI_RESULTS_FRAME_OBJ_NUM;
  439. }
  440. index--;
  441. }
  442. }
  443. /*******************************************************************************
  444. *
  445. * FUNCTION: acpi_db_display_calling_tree
  446. *
  447. * PARAMETERS: None
  448. *
  449. * RETURN: None
  450. *
  451. * DESCRIPTION: Display current calling tree of nested control methods
  452. *
  453. ******************************************************************************/
  454. void acpi_db_display_calling_tree(void)
  455. {
  456. struct acpi_walk_state *walk_state;
  457. struct acpi_namespace_node *node;
  458. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  459. if (!walk_state) {
  460. acpi_os_printf("There is no method currently executing\n");
  461. return;
  462. }
  463. node = walk_state->method_node;
  464. acpi_os_printf("Current Control Method Call Tree\n");
  465. while (walk_state) {
  466. node = walk_state->method_node;
  467. acpi_os_printf(" [%4.4s]\n", acpi_ut_get_node_name(node));
  468. walk_state = walk_state->next;
  469. }
  470. }
  471. /*******************************************************************************
  472. *
  473. * FUNCTION: acpi_db_display_object_type
  474. *
  475. * PARAMETERS: object_arg - User entered NS node handle
  476. *
  477. * RETURN: None
  478. *
  479. * DESCRIPTION: Display type of an arbitrary NS node
  480. *
  481. ******************************************************************************/
  482. void acpi_db_display_object_type(char *object_arg)
  483. {
  484. acpi_size arg;
  485. acpi_handle handle;
  486. struct acpi_device_info *info;
  487. acpi_status status;
  488. u32 i;
  489. arg = strtoul(object_arg, NULL, 16);
  490. handle = ACPI_TO_POINTER(arg);
  491. status = acpi_get_object_info(handle, &info);
  492. if (ACPI_FAILURE(status)) {
  493. acpi_os_printf("Could not get object info, %s\n",
  494. acpi_format_exception(status));
  495. return;
  496. }
  497. acpi_os_printf("ADR: %8.8X%8.8X, Flags: %X\n",
  498. ACPI_FORMAT_UINT64(info->address), info->flags);
  499. acpi_os_printf("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",
  500. info->highest_dstates[0], info->highest_dstates[1],
  501. info->highest_dstates[2], info->highest_dstates[3]);
  502. acpi_os_printf("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",
  503. info->lowest_dstates[0], info->lowest_dstates[1],
  504. info->lowest_dstates[2], info->lowest_dstates[3],
  505. info->lowest_dstates[4]);
  506. if (info->valid & ACPI_VALID_HID) {
  507. acpi_os_printf("HID: %s\n", info->hardware_id.string);
  508. }
  509. if (info->valid & ACPI_VALID_UID) {
  510. acpi_os_printf("UID: %s\n", info->unique_id.string);
  511. }
  512. if (info->valid & ACPI_VALID_CID) {
  513. for (i = 0; i < info->compatible_id_list.count; i++) {
  514. acpi_os_printf("CID %u: %s\n", i,
  515. info->compatible_id_list.ids[i].string);
  516. }
  517. }
  518. ACPI_FREE(info);
  519. }
  520. /*******************************************************************************
  521. *
  522. * FUNCTION: acpi_db_display_result_object
  523. *
  524. * PARAMETERS: obj_desc - Object to be displayed
  525. * walk_state - Current walk state
  526. *
  527. * RETURN: None
  528. *
  529. * DESCRIPTION: Display the result of an AML opcode
  530. *
  531. * Note: Curently only displays the result object if we are single stepping.
  532. * However, this output may be useful in other contexts and could be enabled
  533. * to do so if needed.
  534. *
  535. ******************************************************************************/
  536. void
  537. acpi_db_display_result_object(union acpi_operand_object *obj_desc,
  538. struct acpi_walk_state *walk_state)
  539. {
  540. #ifndef ACPI_APPLICATION
  541. if (acpi_gbl_db_thread_id != acpi_os_get_thread_id()) {
  542. return;
  543. }
  544. #endif
  545. /* Only display if single stepping */
  546. if (!acpi_gbl_cm_single_step) {
  547. return;
  548. }
  549. acpi_os_printf("ResultObj: ");
  550. acpi_db_display_internal_object(obj_desc, walk_state);
  551. acpi_os_printf("\n");
  552. }
  553. /*******************************************************************************
  554. *
  555. * FUNCTION: acpi_db_display_argument_object
  556. *
  557. * PARAMETERS: obj_desc - Object to be displayed
  558. * walk_state - Current walk state
  559. *
  560. * RETURN: None
  561. *
  562. * DESCRIPTION: Display the result of an AML opcode
  563. *
  564. ******************************************************************************/
  565. void
  566. acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
  567. struct acpi_walk_state *walk_state)
  568. {
  569. #ifndef ACPI_APPLICATION
  570. if (acpi_gbl_db_thread_id != acpi_os_get_thread_id()) {
  571. return;
  572. }
  573. #endif
  574. if (!acpi_gbl_cm_single_step) {
  575. return;
  576. }
  577. acpi_os_printf("ArgObj: ");
  578. acpi_db_display_internal_object(obj_desc, walk_state);
  579. }
  580. #if (!ACPI_REDUCED_HARDWARE)
  581. /*******************************************************************************
  582. *
  583. * FUNCTION: acpi_db_display_gpes
  584. *
  585. * PARAMETERS: None
  586. *
  587. * RETURN: None
  588. *
  589. * DESCRIPTION: Display the current GPE structures
  590. *
  591. ******************************************************************************/
  592. void acpi_db_display_gpes(void)
  593. {
  594. struct acpi_gpe_block_info *gpe_block;
  595. struct acpi_gpe_xrupt_info *gpe_xrupt_info;
  596. struct acpi_gpe_event_info *gpe_event_info;
  597. struct acpi_gpe_register_info *gpe_register_info;
  598. char *gpe_type;
  599. struct acpi_gpe_notify_info *notify;
  600. u32 gpe_index;
  601. u32 block = 0;
  602. u32 i;
  603. u32 j;
  604. u32 count;
  605. char buffer[80];
  606. struct acpi_buffer ret_buf;
  607. acpi_status status;
  608. ret_buf.length = sizeof(buffer);
  609. ret_buf.pointer = buffer;
  610. block = 0;
  611. /* Walk the GPE lists */
  612. gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
  613. while (gpe_xrupt_info) {
  614. gpe_block = gpe_xrupt_info->gpe_block_list_head;
  615. while (gpe_block) {
  616. status = acpi_get_name(gpe_block->node,
  617. ACPI_FULL_PATHNAME_NO_TRAILING,
  618. &ret_buf);
  619. if (ACPI_FAILURE(status)) {
  620. acpi_os_printf
  621. ("Could not convert name to pathname\n");
  622. }
  623. if (gpe_block->node == acpi_gbl_fadt_gpe_device) {
  624. gpe_type = "FADT-defined GPE block";
  625. } else {
  626. gpe_type = "GPE Block Device";
  627. }
  628. acpi_os_printf
  629. ("\nBlock %u - Info %p DeviceNode %p [%s] - %s\n",
  630. block, gpe_block, gpe_block->node, buffer,
  631. gpe_type);
  632. acpi_os_printf(" Registers: %u (%u GPEs)\n",
  633. gpe_block->register_count,
  634. gpe_block->gpe_count);
  635. acpi_os_printf
  636. (" GPE range: 0x%X to 0x%X on interrupt %u\n",
  637. gpe_block->block_base_number,
  638. gpe_block->block_base_number +
  639. (gpe_block->gpe_count - 1),
  640. gpe_xrupt_info->interrupt_number);
  641. acpi_os_printf
  642. (" RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n",
  643. gpe_block->register_info,
  644. ACPI_FORMAT_UINT64(gpe_block->register_info->
  645. status_address.address),
  646. ACPI_FORMAT_UINT64(gpe_block->register_info->
  647. enable_address.address));
  648. acpi_os_printf(" EventInfo: %p\n",
  649. gpe_block->event_info);
  650. /* Examine each GPE Register within the block */
  651. for (i = 0; i < gpe_block->register_count; i++) {
  652. gpe_register_info =
  653. &gpe_block->register_info[i];
  654. acpi_os_printf(" Reg %u: (GPE %.2X-%.2X) "
  655. "RunEnable %2.2X WakeEnable %2.2X"
  656. " Status %8.8X%8.8X Enable %8.8X%8.8X\n",
  657. i,
  658. gpe_register_info->
  659. base_gpe_number,
  660. gpe_register_info->
  661. base_gpe_number +
  662. (ACPI_GPE_REGISTER_WIDTH - 1),
  663. gpe_register_info->
  664. enable_for_run,
  665. gpe_register_info->
  666. enable_for_wake,
  667. ACPI_FORMAT_UINT64
  668. (gpe_register_info->
  669. status_address.address),
  670. ACPI_FORMAT_UINT64
  671. (gpe_register_info->
  672. enable_address.address));
  673. /* Now look at the individual GPEs in this byte register */
  674. for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
  675. gpe_index =
  676. (i * ACPI_GPE_REGISTER_WIDTH) + j;
  677. gpe_event_info =
  678. &gpe_block->event_info[gpe_index];
  679. if (ACPI_GPE_DISPATCH_TYPE
  680. (gpe_event_info->flags) ==
  681. ACPI_GPE_DISPATCH_NONE) {
  682. /* This GPE is not used (no method or handler), ignore it */
  683. continue;
  684. }
  685. acpi_os_printf
  686. (" GPE %.2X: %p RunRefs %2.2X Flags %2.2X (",
  687. gpe_block->block_base_number +
  688. gpe_index, gpe_event_info,
  689. gpe_event_info->runtime_count,
  690. gpe_event_info->flags);
  691. /* Decode the flags byte */
  692. if (gpe_event_info->
  693. flags & ACPI_GPE_LEVEL_TRIGGERED) {
  694. acpi_os_printf("Level, ");
  695. } else {
  696. acpi_os_printf("Edge, ");
  697. }
  698. if (gpe_event_info->
  699. flags & ACPI_GPE_CAN_WAKE) {
  700. acpi_os_printf("CanWake, ");
  701. } else {
  702. acpi_os_printf("RunOnly, ");
  703. }
  704. switch (ACPI_GPE_DISPATCH_TYPE
  705. (gpe_event_info->flags)) {
  706. case ACPI_GPE_DISPATCH_NONE:
  707. acpi_os_printf("NotUsed");
  708. break;
  709. case ACPI_GPE_DISPATCH_METHOD:
  710. acpi_os_printf("Method");
  711. break;
  712. case ACPI_GPE_DISPATCH_HANDLER:
  713. acpi_os_printf("Handler");
  714. break;
  715. case ACPI_GPE_DISPATCH_NOTIFY:
  716. count = 0;
  717. notify =
  718. gpe_event_info->dispatch.
  719. notify_list;
  720. while (notify) {
  721. count++;
  722. notify = notify->next;
  723. }
  724. acpi_os_printf
  725. ("Implicit Notify on %u devices",
  726. count);
  727. break;
  728. case ACPI_GPE_DISPATCH_RAW_HANDLER:
  729. acpi_os_printf("RawHandler");
  730. break;
  731. default:
  732. acpi_os_printf("UNKNOWN: %X",
  733. ACPI_GPE_DISPATCH_TYPE
  734. (gpe_event_info->
  735. flags));
  736. break;
  737. }
  738. acpi_os_printf(")\n");
  739. }
  740. }
  741. block++;
  742. gpe_block = gpe_block->next;
  743. }
  744. gpe_xrupt_info = gpe_xrupt_info->next;
  745. }
  746. }
  747. #endif /* !ACPI_REDUCED_HARDWARE */
  748. /*******************************************************************************
  749. *
  750. * FUNCTION: acpi_db_display_handlers
  751. *
  752. * PARAMETERS: None
  753. *
  754. * RETURN: None
  755. *
  756. * DESCRIPTION: Display the currently installed global handlers
  757. *
  758. ******************************************************************************/
  759. void acpi_db_display_handlers(void)
  760. {
  761. union acpi_operand_object *obj_desc;
  762. union acpi_operand_object *handler_obj;
  763. acpi_adr_space_type space_id;
  764. u32 i;
  765. /* Operation region handlers */
  766. acpi_os_printf("\nOperation Region Handlers at the namespace root:\n");
  767. obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node);
  768. if (obj_desc) {
  769. for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_space_id_list); i++) {
  770. space_id = acpi_gbl_space_id_list[i];
  771. acpi_os_printf(ACPI_PREDEFINED_PREFIX,
  772. acpi_ut_get_region_name((u8)space_id),
  773. space_id);
  774. handler_obj =
  775. acpi_ev_find_region_handler(space_id,
  776. obj_desc->common_notify.
  777. handler);
  778. if (handler_obj) {
  779. acpi_os_printf(ACPI_HANDLER_PRESENT_STRING,
  780. (handler_obj->address_space.
  781. handler_flags &
  782. ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
  783. ? "Default" : "User",
  784. handler_obj->address_space.
  785. handler);
  786. goto found_handler;
  787. }
  788. /* There is no handler for this space_id */
  789. acpi_os_printf("None\n");
  790. found_handler: ;
  791. }
  792. /* Find all handlers for user-defined space_IDs */
  793. handler_obj = obj_desc->common_notify.handler;
  794. while (handler_obj) {
  795. if (handler_obj->address_space.space_id >=
  796. ACPI_USER_REGION_BEGIN) {
  797. acpi_os_printf(ACPI_PREDEFINED_PREFIX,
  798. "User-defined ID",
  799. handler_obj->address_space.
  800. space_id);
  801. acpi_os_printf(ACPI_HANDLER_PRESENT_STRING,
  802. (handler_obj->address_space.
  803. handler_flags &
  804. ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
  805. ? "Default" : "User",
  806. handler_obj->address_space.
  807. handler);
  808. }
  809. handler_obj = handler_obj->address_space.next;
  810. }
  811. }
  812. #if (!ACPI_REDUCED_HARDWARE)
  813. /* Fixed event handlers */
  814. acpi_os_printf("\nFixed Event Handlers:\n");
  815. for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
  816. acpi_os_printf(ACPI_PREDEFINED_PREFIX,
  817. acpi_ut_get_event_name(i), i);
  818. if (acpi_gbl_fixed_event_handlers[i].handler) {
  819. acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, "User",
  820. acpi_gbl_fixed_event_handlers[i].
  821. handler);
  822. } else {
  823. acpi_os_printf(ACPI_HANDLER_NOT_PRESENT_STRING, "None");
  824. }
  825. }
  826. #endif /* !ACPI_REDUCED_HARDWARE */
  827. /* Miscellaneous global handlers */
  828. acpi_os_printf("\nMiscellaneous Global Handlers:\n");
  829. for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_handler_list); i++) {
  830. acpi_os_printf(ACPI_HANDLER_NAME_STRING,
  831. acpi_gbl_handler_list[i].name);
  832. if (acpi_gbl_handler_list[i].handler) {
  833. acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, "User",
  834. acpi_gbl_handler_list[i].handler);
  835. } else {
  836. acpi_os_printf(ACPI_HANDLER_NOT_PRESENT_STRING, "None");
  837. }
  838. }
  839. /* Other handlers that are installed throughout the namespace */
  840. acpi_os_printf("\nOperation Region Handlers for specific devices:\n");
  841. (void)acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
  842. ACPI_UINT32_MAX,
  843. acpi_db_display_non_root_handlers, NULL, NULL,
  844. NULL);
  845. }
  846. /*******************************************************************************
  847. *
  848. * FUNCTION: acpi_db_display_non_root_handlers
  849. *
  850. * PARAMETERS: acpi_walk_callback
  851. *
  852. * RETURN: Status
  853. *
  854. * DESCRIPTION: Display information about all handlers installed for a
  855. * device object.
  856. *
  857. ******************************************************************************/
  858. static acpi_status
  859. acpi_db_display_non_root_handlers(acpi_handle obj_handle,
  860. u32 nesting_level,
  861. void *context, void **return_value)
  862. {
  863. struct acpi_namespace_node *node =
  864. ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle);
  865. union acpi_operand_object *obj_desc;
  866. union acpi_operand_object *handler_obj;
  867. char *pathname;
  868. obj_desc = acpi_ns_get_attached_object(node);
  869. if (!obj_desc) {
  870. return (AE_OK);
  871. }
  872. pathname = acpi_ns_get_normalized_pathname(node, TRUE);
  873. if (!pathname) {
  874. return (AE_OK);
  875. }
  876. /* Display all handlers associated with this device */
  877. handler_obj = obj_desc->common_notify.handler;
  878. while (handler_obj) {
  879. acpi_os_printf(ACPI_PREDEFINED_PREFIX,
  880. acpi_ut_get_region_name((u8)handler_obj->
  881. address_space.space_id),
  882. handler_obj->address_space.space_id);
  883. acpi_os_printf(ACPI_HANDLER_PRESENT_STRING2,
  884. (handler_obj->address_space.handler_flags &
  885. ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default"
  886. : "User", handler_obj->address_space.handler);
  887. acpi_os_printf(" Device Name: %s (%p)\n", pathname, node);
  888. handler_obj = handler_obj->address_space.next;
  889. }
  890. ACPI_FREE(pathname);
  891. return (AE_OK);
  892. }