dbdisply.c 29 KB

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