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_PLATFORM_COMM,
  47. ACPI_ADR_SPACE_PLATFORM_RT,
  48. ACPI_ADR_SPACE_DATA_TABLE,
  49. ACPI_ADR_SPACE_FIXED_HARDWARE
  50. };
  51. /* Global handler information */
  52. typedef struct acpi_handler_info {
  53. void *handler;
  54. char *name;
  55. } acpi_handler_info;
  56. static struct acpi_handler_info acpi_gbl_handler_list[] = {
  57. {&acpi_gbl_global_notify[0].handler, "System Notifications"},
  58. {&acpi_gbl_global_notify[1].handler, "Device Notifications"},
  59. {&acpi_gbl_table_handler, "ACPI Table Events"},
  60. {&acpi_gbl_exception_handler, "Control Method Exceptions"},
  61. {&acpi_gbl_interface_handler, "OSI Invocations"}
  62. };
  63. /*******************************************************************************
  64. *
  65. * FUNCTION: acpi_db_get_pointer
  66. *
  67. * PARAMETERS: target - Pointer to string to be converted
  68. *
  69. * RETURN: Converted pointer
  70. *
  71. * DESCRIPTION: Convert an ascii pointer value to a real value
  72. *
  73. ******************************************************************************/
  74. static void *acpi_db_get_pointer(void *target)
  75. {
  76. void *obj_ptr;
  77. acpi_size address;
  78. address = strtoul(target, NULL, 16);
  79. obj_ptr = ACPI_TO_POINTER(address);
  80. return (obj_ptr);
  81. }
  82. /*******************************************************************************
  83. *
  84. * FUNCTION: acpi_db_dump_parser_descriptor
  85. *
  86. * PARAMETERS: op - A parser Op descriptor
  87. *
  88. * RETURN: None
  89. *
  90. * DESCRIPTION: Display a formatted parser object
  91. *
  92. ******************************************************************************/
  93. static void acpi_db_dump_parser_descriptor(union acpi_parse_object *op)
  94. {
  95. const struct acpi_opcode_info *info;
  96. info = acpi_ps_get_opcode_info(op->common.aml_opcode);
  97. acpi_os_printf("Parser Op Descriptor:\n");
  98. acpi_os_printf("%20.20s : %4.4X\n", "Opcode", op->common.aml_opcode);
  99. ACPI_DEBUG_ONLY_MEMBERS(acpi_os_printf("%20.20s : %s\n", "Opcode Name",
  100. info->name));
  101. acpi_os_printf("%20.20s : %p\n", "Value/ArgList", op->common.value.arg);
  102. acpi_os_printf("%20.20s : %p\n", "Parent", op->common.parent);
  103. acpi_os_printf("%20.20s : %p\n", "NextOp", op->common.next);
  104. }
  105. /*******************************************************************************
  106. *
  107. * FUNCTION: acpi_db_decode_and_display_object
  108. *
  109. * PARAMETERS: target - String with object to be displayed. Names
  110. * and hex pointers are supported.
  111. * output_type - Byte, Word, Dword, or Qword (B|W|D|Q)
  112. *
  113. * RETURN: None
  114. *
  115. * DESCRIPTION: Display a formatted ACPI object
  116. *
  117. ******************************************************************************/
  118. void acpi_db_decode_and_display_object(char *target, char *output_type)
  119. {
  120. void *obj_ptr;
  121. struct acpi_namespace_node *node;
  122. union acpi_operand_object *obj_desc;
  123. u32 display = DB_BYTE_DISPLAY;
  124. char buffer[80];
  125. struct acpi_buffer ret_buf;
  126. acpi_status status;
  127. u32 size;
  128. if (!target) {
  129. return;
  130. }
  131. /* Decode the output type */
  132. if (output_type) {
  133. acpi_ut_strupr(output_type);
  134. if (output_type[0] == 'W') {
  135. display = DB_WORD_DISPLAY;
  136. } else if (output_type[0] == 'D') {
  137. display = DB_DWORD_DISPLAY;
  138. } else if (output_type[0] == 'Q') {
  139. display = DB_QWORD_DISPLAY;
  140. }
  141. }
  142. ret_buf.length = sizeof(buffer);
  143. ret_buf.pointer = buffer;
  144. /* Differentiate between a number and a name */
  145. if ((target[0] >= 0x30) && (target[0] <= 0x39)) {
  146. obj_ptr = acpi_db_get_pointer(target);
  147. if (!acpi_os_readable(obj_ptr, 16)) {
  148. acpi_os_printf
  149. ("Address %p is invalid in this address space\n",
  150. obj_ptr);
  151. return;
  152. }
  153. /* Decode the object type */
  154. switch (ACPI_GET_DESCRIPTOR_TYPE(obj_ptr)) {
  155. case ACPI_DESC_TYPE_NAMED:
  156. /* This is a namespace Node */
  157. if (!acpi_os_readable
  158. (obj_ptr, sizeof(struct acpi_namespace_node))) {
  159. acpi_os_printf
  160. ("Cannot read entire Named object at address %p\n",
  161. obj_ptr);
  162. return;
  163. }
  164. node = obj_ptr;
  165. goto dump_node;
  166. case ACPI_DESC_TYPE_OPERAND:
  167. /* This is a ACPI OPERAND OBJECT */
  168. if (!acpi_os_readable
  169. (obj_ptr, sizeof(union acpi_operand_object))) {
  170. acpi_os_printf
  171. ("Cannot read entire ACPI object at address %p\n",
  172. obj_ptr);
  173. return;
  174. }
  175. acpi_ut_debug_dump_buffer(obj_ptr,
  176. sizeof(union
  177. acpi_operand_object),
  178. display, ACPI_UINT32_MAX);
  179. acpi_ex_dump_object_descriptor(obj_ptr, 1);
  180. break;
  181. case ACPI_DESC_TYPE_PARSER:
  182. /* This is a Parser Op object */
  183. if (!acpi_os_readable
  184. (obj_ptr, sizeof(union acpi_parse_object))) {
  185. acpi_os_printf
  186. ("Cannot read entire Parser object at address %p\n",
  187. obj_ptr);
  188. return;
  189. }
  190. acpi_ut_debug_dump_buffer(obj_ptr,
  191. sizeof(union
  192. acpi_parse_object),
  193. display, ACPI_UINT32_MAX);
  194. acpi_db_dump_parser_descriptor((union acpi_parse_object
  195. *)obj_ptr);
  196. break;
  197. default:
  198. /* Is not a recognizable object */
  199. acpi_os_printf
  200. ("Not a known ACPI internal object, descriptor type %2.2X\n",
  201. ACPI_GET_DESCRIPTOR_TYPE(obj_ptr));
  202. size = 16;
  203. if (acpi_os_readable(obj_ptr, 64)) {
  204. size = 64;
  205. }
  206. /* Just dump some memory */
  207. acpi_ut_debug_dump_buffer(obj_ptr, size, display,
  208. ACPI_UINT32_MAX);
  209. break;
  210. }
  211. return;
  212. }
  213. /* The parameter is a name string that must be resolved to a Named obj */
  214. node = acpi_db_local_ns_lookup(target);
  215. if (!node) {
  216. return;
  217. }
  218. dump_node:
  219. /* Now dump the NS node */
  220. status = acpi_get_name(node, ACPI_FULL_PATHNAME_NO_TRAILING, &ret_buf);
  221. if (ACPI_FAILURE(status)) {
  222. acpi_os_printf("Could not convert name to pathname\n");
  223. }
  224. else {
  225. acpi_os_printf("Object %p: Namespace Node - Pathname: %s\n",
  226. node, (char *)ret_buf.pointer);
  227. }
  228. if (!acpi_os_readable(node, sizeof(struct acpi_namespace_node))) {
  229. acpi_os_printf("Invalid Named object at address %p\n", node);
  230. return;
  231. }
  232. acpi_ut_debug_dump_buffer((void *)node,
  233. sizeof(struct acpi_namespace_node), display,
  234. ACPI_UINT32_MAX);
  235. acpi_ex_dump_namespace_node(node, 1);
  236. obj_desc = acpi_ns_get_attached_object(node);
  237. if (obj_desc) {
  238. acpi_os_printf("\nAttached Object %p:", obj_desc);
  239. if (!acpi_os_readable
  240. (obj_desc, sizeof(union acpi_operand_object))) {
  241. acpi_os_printf
  242. ("Invalid internal ACPI Object at address %p\n",
  243. obj_desc);
  244. return;
  245. }
  246. if (ACPI_GET_DESCRIPTOR_TYPE(((struct acpi_namespace_node *)
  247. obj_desc)) ==
  248. ACPI_DESC_TYPE_NAMED) {
  249. acpi_os_printf(" Namespace Node - ");
  250. status =
  251. acpi_get_name((struct acpi_namespace_node *)
  252. obj_desc,
  253. ACPI_FULL_PATHNAME_NO_TRAILING,
  254. &ret_buf);
  255. if (ACPI_FAILURE(status)) {
  256. acpi_os_printf
  257. ("Could not convert name to pathname\n");
  258. } else {
  259. acpi_os_printf("Pathname: %s",
  260. (char *)ret_buf.pointer);
  261. }
  262. acpi_os_printf("\n");
  263. acpi_ut_debug_dump_buffer((void *)obj_desc,
  264. sizeof(struct
  265. acpi_namespace_node),
  266. display, ACPI_UINT32_MAX);
  267. } else {
  268. acpi_os_printf("\n");
  269. acpi_ut_debug_dump_buffer((void *)obj_desc,
  270. sizeof(union
  271. acpi_operand_object),
  272. display, ACPI_UINT32_MAX);
  273. }
  274. acpi_ex_dump_object_descriptor(obj_desc, 1);
  275. }
  276. }
  277. /*******************************************************************************
  278. *
  279. * FUNCTION: acpi_db_display_method_info
  280. *
  281. * PARAMETERS: start_op - Root of the control method parse tree
  282. *
  283. * RETURN: None
  284. *
  285. * DESCRIPTION: Display information about the current method
  286. *
  287. ******************************************************************************/
  288. void acpi_db_display_method_info(union acpi_parse_object *start_op)
  289. {
  290. struct acpi_walk_state *walk_state;
  291. union acpi_operand_object *obj_desc;
  292. struct acpi_namespace_node *node;
  293. union acpi_parse_object *root_op;
  294. union acpi_parse_object *op;
  295. const struct acpi_opcode_info *op_info;
  296. u32 num_ops = 0;
  297. u32 num_operands = 0;
  298. u32 num_operators = 0;
  299. u32 num_remaining_ops = 0;
  300. u32 num_remaining_operands = 0;
  301. u32 num_remaining_operators = 0;
  302. u8 count_remaining = FALSE;
  303. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  304. if (!walk_state) {
  305. acpi_os_printf("There is no method currently executing\n");
  306. return;
  307. }
  308. obj_desc = walk_state->method_desc;
  309. node = walk_state->method_node;
  310. acpi_os_printf("Currently executing control method is [%4.4s]\n",
  311. acpi_ut_get_node_name(node));
  312. acpi_os_printf("%X Arguments, SyncLevel = %X\n",
  313. (u32)obj_desc->method.param_count,
  314. (u32)obj_desc->method.sync_level);
  315. root_op = start_op;
  316. while (root_op->common.parent) {
  317. root_op = root_op->common.parent;
  318. }
  319. op = root_op;
  320. while (op) {
  321. if (op == start_op) {
  322. count_remaining = TRUE;
  323. }
  324. num_ops++;
  325. if (count_remaining) {
  326. num_remaining_ops++;
  327. }
  328. /* Decode the opcode */
  329. op_info = acpi_ps_get_opcode_info(op->common.aml_opcode);
  330. switch (op_info->class) {
  331. case AML_CLASS_ARGUMENT:
  332. if (count_remaining) {
  333. num_remaining_operands++;
  334. }
  335. num_operands++;
  336. break;
  337. case AML_CLASS_UNKNOWN:
  338. /* Bad opcode or ASCII character */
  339. continue;
  340. default:
  341. if (count_remaining) {
  342. num_remaining_operators++;
  343. }
  344. num_operators++;
  345. break;
  346. }
  347. op = acpi_ps_get_depth_next(start_op, op);
  348. }
  349. acpi_os_printf
  350. ("Method contains: %X AML Opcodes - %X Operators, %X Operands\n",
  351. num_ops, num_operators, num_operands);
  352. acpi_os_printf
  353. ("Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n",
  354. num_remaining_ops, num_remaining_operators,
  355. num_remaining_operands);
  356. }
  357. /*******************************************************************************
  358. *
  359. * FUNCTION: acpi_db_display_locals
  360. *
  361. * PARAMETERS: None
  362. *
  363. * RETURN: None
  364. *
  365. * DESCRIPTION: Display all locals for the currently running control method
  366. *
  367. ******************************************************************************/
  368. void acpi_db_display_locals(void)
  369. {
  370. struct acpi_walk_state *walk_state;
  371. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  372. if (!walk_state) {
  373. acpi_os_printf("There is no method currently executing\n");
  374. return;
  375. }
  376. acpi_db_decode_locals(walk_state);
  377. }
  378. /*******************************************************************************
  379. *
  380. * FUNCTION: acpi_db_display_arguments
  381. *
  382. * PARAMETERS: None
  383. *
  384. * RETURN: None
  385. *
  386. * DESCRIPTION: Display all arguments for the currently running control method
  387. *
  388. ******************************************************************************/
  389. void acpi_db_display_arguments(void)
  390. {
  391. struct acpi_walk_state *walk_state;
  392. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  393. if (!walk_state) {
  394. acpi_os_printf("There is no method currently executing\n");
  395. return;
  396. }
  397. acpi_db_decode_arguments(walk_state);
  398. }
  399. /*******************************************************************************
  400. *
  401. * FUNCTION: acpi_db_display_results
  402. *
  403. * PARAMETERS: None
  404. *
  405. * RETURN: None
  406. *
  407. * DESCRIPTION: Display current contents of a method result stack
  408. *
  409. ******************************************************************************/
  410. void acpi_db_display_results(void)
  411. {
  412. u32 i;
  413. struct acpi_walk_state *walk_state;
  414. union acpi_operand_object *obj_desc;
  415. u32 result_count = 0;
  416. struct acpi_namespace_node *node;
  417. union acpi_generic_state *frame;
  418. u32 index; /* Index onto current frame */
  419. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  420. if (!walk_state) {
  421. acpi_os_printf("There is no method currently executing\n");
  422. return;
  423. }
  424. node = walk_state->method_node;
  425. if (walk_state->results) {
  426. result_count = walk_state->result_count;
  427. }
  428. acpi_os_printf("Method [%4.4s] has %X stacked result objects\n",
  429. acpi_ut_get_node_name(node), result_count);
  430. /* From the top element of result stack */
  431. frame = walk_state->results;
  432. index = (result_count - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
  433. for (i = 0; i < result_count; i++) {
  434. obj_desc = frame->results.obj_desc[index];
  435. acpi_os_printf("Result%u: ", i);
  436. acpi_db_display_internal_object(obj_desc, walk_state);
  437. if (index == 0) {
  438. frame = frame->results.next;
  439. index = ACPI_RESULTS_FRAME_OBJ_NUM;
  440. }
  441. index--;
  442. }
  443. }
  444. /*******************************************************************************
  445. *
  446. * FUNCTION: acpi_db_display_calling_tree
  447. *
  448. * PARAMETERS: None
  449. *
  450. * RETURN: None
  451. *
  452. * DESCRIPTION: Display current calling tree of nested control methods
  453. *
  454. ******************************************************************************/
  455. void acpi_db_display_calling_tree(void)
  456. {
  457. struct acpi_walk_state *walk_state;
  458. struct acpi_namespace_node *node;
  459. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  460. if (!walk_state) {
  461. acpi_os_printf("There is no method currently executing\n");
  462. return;
  463. }
  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: Currently 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. }