dbdisply.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106
  1. /*******************************************************************************
  2. *
  3. * Module Name: dbdisply - debug display commands
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2016, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include "accommon.h"
  44. #include "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) 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):\n", 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. acpi_ut_debug_dump_buffer((void *)obj_desc,
  280. sizeof(union acpi_operand_object),
  281. display, ACPI_UINT32_MAX);
  282. acpi_ex_dump_object_descriptor(obj_desc, 1);
  283. }
  284. }
  285. /*******************************************************************************
  286. *
  287. * FUNCTION: acpi_db_display_method_info
  288. *
  289. * PARAMETERS: start_op - Root of the control method parse tree
  290. *
  291. * RETURN: None
  292. *
  293. * DESCRIPTION: Display information about the current method
  294. *
  295. ******************************************************************************/
  296. void acpi_db_display_method_info(union acpi_parse_object *start_op)
  297. {
  298. struct acpi_walk_state *walk_state;
  299. union acpi_operand_object *obj_desc;
  300. struct acpi_namespace_node *node;
  301. union acpi_parse_object *root_op;
  302. union acpi_parse_object *op;
  303. const struct acpi_opcode_info *op_info;
  304. u32 num_ops = 0;
  305. u32 num_operands = 0;
  306. u32 num_operators = 0;
  307. u32 num_remaining_ops = 0;
  308. u32 num_remaining_operands = 0;
  309. u32 num_remaining_operators = 0;
  310. u8 count_remaining = FALSE;
  311. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  312. if (!walk_state) {
  313. acpi_os_printf("There is no method currently executing\n");
  314. return;
  315. }
  316. obj_desc = walk_state->method_desc;
  317. node = walk_state->method_node;
  318. acpi_os_printf("Currently executing control method is [%4.4s]\n",
  319. acpi_ut_get_node_name(node));
  320. acpi_os_printf("%X Arguments, SyncLevel = %X\n",
  321. (u32)obj_desc->method.param_count,
  322. (u32)obj_desc->method.sync_level);
  323. root_op = start_op;
  324. while (root_op->common.parent) {
  325. root_op = root_op->common.parent;
  326. }
  327. op = root_op;
  328. while (op) {
  329. if (op == start_op) {
  330. count_remaining = TRUE;
  331. }
  332. num_ops++;
  333. if (count_remaining) {
  334. num_remaining_ops++;
  335. }
  336. /* Decode the opcode */
  337. op_info = acpi_ps_get_opcode_info(op->common.aml_opcode);
  338. switch (op_info->class) {
  339. case AML_CLASS_ARGUMENT:
  340. if (count_remaining) {
  341. num_remaining_operands++;
  342. }
  343. num_operands++;
  344. break;
  345. case AML_CLASS_UNKNOWN:
  346. /* Bad opcode or ASCII character */
  347. continue;
  348. default:
  349. if (count_remaining) {
  350. num_remaining_operators++;
  351. }
  352. num_operators++;
  353. break;
  354. }
  355. op = acpi_ps_get_depth_next(start_op, op);
  356. }
  357. acpi_os_printf
  358. ("Method contains: %X AML Opcodes - %X Operators, %X Operands\n",
  359. num_ops, num_operators, num_operands);
  360. acpi_os_printf
  361. ("Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n",
  362. num_remaining_ops, num_remaining_operators,
  363. num_remaining_operands);
  364. }
  365. /*******************************************************************************
  366. *
  367. * FUNCTION: acpi_db_display_locals
  368. *
  369. * PARAMETERS: None
  370. *
  371. * RETURN: None
  372. *
  373. * DESCRIPTION: Display all locals for the currently running control method
  374. *
  375. ******************************************************************************/
  376. void acpi_db_display_locals(void)
  377. {
  378. struct acpi_walk_state *walk_state;
  379. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  380. if (!walk_state) {
  381. acpi_os_printf("There is no method currently executing\n");
  382. return;
  383. }
  384. acpi_db_decode_locals(walk_state);
  385. }
  386. /*******************************************************************************
  387. *
  388. * FUNCTION: acpi_db_display_arguments
  389. *
  390. * PARAMETERS: None
  391. *
  392. * RETURN: None
  393. *
  394. * DESCRIPTION: Display all arguments for the currently running control method
  395. *
  396. ******************************************************************************/
  397. void acpi_db_display_arguments(void)
  398. {
  399. struct acpi_walk_state *walk_state;
  400. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  401. if (!walk_state) {
  402. acpi_os_printf("There is no method currently executing\n");
  403. return;
  404. }
  405. acpi_db_decode_arguments(walk_state);
  406. }
  407. /*******************************************************************************
  408. *
  409. * FUNCTION: acpi_db_display_results
  410. *
  411. * PARAMETERS: None
  412. *
  413. * RETURN: None
  414. *
  415. * DESCRIPTION: Display current contents of a method result stack
  416. *
  417. ******************************************************************************/
  418. void acpi_db_display_results(void)
  419. {
  420. u32 i;
  421. struct acpi_walk_state *walk_state;
  422. union acpi_operand_object *obj_desc;
  423. u32 result_count = 0;
  424. struct acpi_namespace_node *node;
  425. union acpi_generic_state *frame;
  426. u32 index; /* Index onto current frame */
  427. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  428. if (!walk_state) {
  429. acpi_os_printf("There is no method currently executing\n");
  430. return;
  431. }
  432. obj_desc = walk_state->method_desc;
  433. node = walk_state->method_node;
  434. if (walk_state->results) {
  435. result_count = walk_state->result_count;
  436. }
  437. acpi_os_printf("Method [%4.4s] has %X stacked result objects\n",
  438. acpi_ut_get_node_name(node), result_count);
  439. /* From the top element of result stack */
  440. frame = walk_state->results;
  441. index = (result_count - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
  442. for (i = 0; i < result_count; i++) {
  443. obj_desc = frame->results.obj_desc[index];
  444. acpi_os_printf("Result%u: ", i);
  445. acpi_db_display_internal_object(obj_desc, walk_state);
  446. if (index == 0) {
  447. frame = frame->results.next;
  448. index = ACPI_RESULTS_FRAME_OBJ_NUM;
  449. }
  450. index--;
  451. }
  452. }
  453. /*******************************************************************************
  454. *
  455. * FUNCTION: acpi_db_display_calling_tree
  456. *
  457. * PARAMETERS: None
  458. *
  459. * RETURN: None
  460. *
  461. * DESCRIPTION: Display current calling tree of nested control methods
  462. *
  463. ******************************************************************************/
  464. void acpi_db_display_calling_tree(void)
  465. {
  466. struct acpi_walk_state *walk_state;
  467. struct acpi_namespace_node *node;
  468. walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
  469. if (!walk_state) {
  470. acpi_os_printf("There is no method currently executing\n");
  471. return;
  472. }
  473. node = walk_state->method_node;
  474. acpi_os_printf("Current Control Method Call Tree\n");
  475. while (walk_state) {
  476. node = walk_state->method_node;
  477. acpi_os_printf(" [%4.4s]\n", acpi_ut_get_node_name(node));
  478. walk_state = walk_state->next;
  479. }
  480. }
  481. /*******************************************************************************
  482. *
  483. * FUNCTION: acpi_db_display_object_type
  484. *
  485. * PARAMETERS: object_arg - User entered NS node handle
  486. *
  487. * RETURN: None
  488. *
  489. * DESCRIPTION: Display type of an arbitrary NS node
  490. *
  491. ******************************************************************************/
  492. void acpi_db_display_object_type(char *object_arg)
  493. {
  494. acpi_size arg;
  495. acpi_handle handle;
  496. struct acpi_device_info *info;
  497. acpi_status status;
  498. u32 i;
  499. arg = strtoul(object_arg, NULL, 16);
  500. handle = ACPI_TO_POINTER(arg);
  501. status = acpi_get_object_info(handle, &info);
  502. if (ACPI_FAILURE(status)) {
  503. acpi_os_printf("Could not get object info, %s\n",
  504. acpi_format_exception(status));
  505. return;
  506. }
  507. acpi_os_printf("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n",
  508. ACPI_FORMAT_UINT64(info->address),
  509. info->current_status, info->flags);
  510. acpi_os_printf("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",
  511. info->highest_dstates[0], info->highest_dstates[1],
  512. info->highest_dstates[2], info->highest_dstates[3]);
  513. acpi_os_printf("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",
  514. info->lowest_dstates[0], info->lowest_dstates[1],
  515. info->lowest_dstates[2], info->lowest_dstates[3],
  516. info->lowest_dstates[4]);
  517. if (info->valid & ACPI_VALID_HID) {
  518. acpi_os_printf("HID: %s\n", info->hardware_id.string);
  519. }
  520. if (info->valid & ACPI_VALID_UID) {
  521. acpi_os_printf("UID: %s\n", info->unique_id.string);
  522. }
  523. if (info->valid & ACPI_VALID_CID) {
  524. for (i = 0; i < info->compatible_id_list.count; i++) {
  525. acpi_os_printf("CID %u: %s\n", i,
  526. info->compatible_id_list.ids[i].string);
  527. }
  528. }
  529. ACPI_FREE(info);
  530. }
  531. /*******************************************************************************
  532. *
  533. * FUNCTION: acpi_db_display_result_object
  534. *
  535. * PARAMETERS: obj_desc - Object to be displayed
  536. * walk_state - Current walk state
  537. *
  538. * RETURN: None
  539. *
  540. * DESCRIPTION: Display the result of an AML opcode
  541. *
  542. * Note: Curently only displays the result object if we are single stepping.
  543. * However, this output may be useful in other contexts and could be enabled
  544. * to do so if needed.
  545. *
  546. ******************************************************************************/
  547. void
  548. acpi_db_display_result_object(union acpi_operand_object *obj_desc,
  549. struct acpi_walk_state *walk_state)
  550. {
  551. #ifndef ACPI_APPLICATION
  552. if (acpi_gbl_db_thread_id != acpi_os_get_thread_id()) {
  553. return;
  554. }
  555. #endif
  556. /* Only display if single stepping */
  557. if (!acpi_gbl_cm_single_step) {
  558. return;
  559. }
  560. acpi_os_printf("ResultObj: ");
  561. acpi_db_display_internal_object(obj_desc, walk_state);
  562. acpi_os_printf("\n");
  563. }
  564. /*******************************************************************************
  565. *
  566. * FUNCTION: acpi_db_display_argument_object
  567. *
  568. * PARAMETERS: obj_desc - Object to be displayed
  569. * walk_state - Current walk state
  570. *
  571. * RETURN: None
  572. *
  573. * DESCRIPTION: Display the result of an AML opcode
  574. *
  575. ******************************************************************************/
  576. void
  577. acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
  578. struct acpi_walk_state *walk_state)
  579. {
  580. #ifndef ACPI_APPLICATION
  581. if (acpi_gbl_db_thread_id != acpi_os_get_thread_id()) {
  582. return;
  583. }
  584. #endif
  585. if (!acpi_gbl_cm_single_step) {
  586. return;
  587. }
  588. acpi_os_printf("ArgObj: ");
  589. acpi_db_display_internal_object(obj_desc, walk_state);
  590. }
  591. #if (!ACPI_REDUCED_HARDWARE)
  592. /*******************************************************************************
  593. *
  594. * FUNCTION: acpi_db_display_gpes
  595. *
  596. * PARAMETERS: None
  597. *
  598. * RETURN: None
  599. *
  600. * DESCRIPTION: Display the current GPE structures
  601. *
  602. ******************************************************************************/
  603. void acpi_db_display_gpes(void)
  604. {
  605. struct acpi_gpe_block_info *gpe_block;
  606. struct acpi_gpe_xrupt_info *gpe_xrupt_info;
  607. struct acpi_gpe_event_info *gpe_event_info;
  608. struct acpi_gpe_register_info *gpe_register_info;
  609. char *gpe_type;
  610. struct acpi_gpe_notify_info *notify;
  611. u32 gpe_index;
  612. u32 block = 0;
  613. u32 i;
  614. u32 j;
  615. u32 count;
  616. char buffer[80];
  617. struct acpi_buffer ret_buf;
  618. acpi_status status;
  619. ret_buf.length = sizeof(buffer);
  620. ret_buf.pointer = buffer;
  621. block = 0;
  622. /* Walk the GPE lists */
  623. gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
  624. while (gpe_xrupt_info) {
  625. gpe_block = gpe_xrupt_info->gpe_block_list_head;
  626. while (gpe_block) {
  627. status = acpi_get_name(gpe_block->node,
  628. ACPI_FULL_PATHNAME_NO_TRAILING,
  629. &ret_buf);
  630. if (ACPI_FAILURE(status)) {
  631. acpi_os_printf
  632. ("Could not convert name to pathname\n");
  633. }
  634. if (gpe_block->node == acpi_gbl_fadt_gpe_device) {
  635. gpe_type = "FADT-defined GPE block";
  636. } else {
  637. gpe_type = "GPE Block Device";
  638. }
  639. acpi_os_printf
  640. ("\nBlock %u - Info %p DeviceNode %p [%s] - %s\n",
  641. block, gpe_block, gpe_block->node, buffer,
  642. gpe_type);
  643. acpi_os_printf(" Registers: %u (%u GPEs)\n",
  644. gpe_block->register_count,
  645. gpe_block->gpe_count);
  646. acpi_os_printf
  647. (" GPE range: 0x%X to 0x%X on interrupt %u\n",
  648. gpe_block->block_base_number,
  649. gpe_block->block_base_number +
  650. (gpe_block->gpe_count - 1),
  651. gpe_xrupt_info->interrupt_number);
  652. acpi_os_printf
  653. (" RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n",
  654. gpe_block->register_info,
  655. ACPI_FORMAT_UINT64(gpe_block->register_info->
  656. status_address.address),
  657. ACPI_FORMAT_UINT64(gpe_block->register_info->
  658. enable_address.address));
  659. acpi_os_printf(" EventInfo: %p\n",
  660. gpe_block->event_info);
  661. /* Examine each GPE Register within the block */
  662. for (i = 0; i < gpe_block->register_count; i++) {
  663. gpe_register_info =
  664. &gpe_block->register_info[i];
  665. acpi_os_printf(" Reg %u: (GPE %.2X-%.2X) "
  666. "RunEnable %2.2X WakeEnable %2.2X"
  667. " Status %8.8X%8.8X Enable %8.8X%8.8X\n",
  668. i,
  669. gpe_register_info->
  670. base_gpe_number,
  671. gpe_register_info->
  672. base_gpe_number +
  673. (ACPI_GPE_REGISTER_WIDTH - 1),
  674. gpe_register_info->
  675. enable_for_run,
  676. gpe_register_info->
  677. enable_for_wake,
  678. ACPI_FORMAT_UINT64
  679. (gpe_register_info->
  680. status_address.address),
  681. ACPI_FORMAT_UINT64
  682. (gpe_register_info->
  683. enable_address.address));
  684. /* Now look at the individual GPEs in this byte register */
  685. for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
  686. gpe_index =
  687. (i * ACPI_GPE_REGISTER_WIDTH) + j;
  688. gpe_event_info =
  689. &gpe_block->event_info[gpe_index];
  690. if (ACPI_GPE_DISPATCH_TYPE
  691. (gpe_event_info->flags) ==
  692. ACPI_GPE_DISPATCH_NONE) {
  693. /* This GPE is not used (no method or handler), ignore it */
  694. continue;
  695. }
  696. acpi_os_printf
  697. (" GPE %.2X: %p RunRefs %2.2X Flags %2.2X (",
  698. gpe_block->block_base_number +
  699. gpe_index, gpe_event_info,
  700. gpe_event_info->runtime_count,
  701. gpe_event_info->flags);
  702. /* Decode the flags byte */
  703. if (gpe_event_info->
  704. flags & ACPI_GPE_LEVEL_TRIGGERED) {
  705. acpi_os_printf("Level, ");
  706. } else {
  707. acpi_os_printf("Edge, ");
  708. }
  709. if (gpe_event_info->
  710. flags & ACPI_GPE_CAN_WAKE) {
  711. acpi_os_printf("CanWake, ");
  712. } else {
  713. acpi_os_printf("RunOnly, ");
  714. }
  715. switch (ACPI_GPE_DISPATCH_TYPE
  716. (gpe_event_info->flags)) {
  717. case ACPI_GPE_DISPATCH_NONE:
  718. acpi_os_printf("NotUsed");
  719. break;
  720. case ACPI_GPE_DISPATCH_METHOD:
  721. acpi_os_printf("Method");
  722. break;
  723. case ACPI_GPE_DISPATCH_HANDLER:
  724. acpi_os_printf("Handler");
  725. break;
  726. case ACPI_GPE_DISPATCH_NOTIFY:
  727. count = 0;
  728. notify =
  729. gpe_event_info->dispatch.
  730. notify_list;
  731. while (notify) {
  732. count++;
  733. notify = notify->next;
  734. }
  735. acpi_os_printf
  736. ("Implicit Notify on %u devices",
  737. count);
  738. break;
  739. case ACPI_GPE_DISPATCH_RAW_HANDLER:
  740. acpi_os_printf("RawHandler");
  741. break;
  742. default:
  743. acpi_os_printf("UNKNOWN: %X",
  744. ACPI_GPE_DISPATCH_TYPE
  745. (gpe_event_info->
  746. flags));
  747. break;
  748. }
  749. acpi_os_printf(")\n");
  750. }
  751. }
  752. block++;
  753. gpe_block = gpe_block->next;
  754. }
  755. gpe_xrupt_info = gpe_xrupt_info->next;
  756. }
  757. }
  758. #endif /* !ACPI_REDUCED_HARDWARE */
  759. /*******************************************************************************
  760. *
  761. * FUNCTION: acpi_db_display_handlers
  762. *
  763. * PARAMETERS: None
  764. *
  765. * RETURN: None
  766. *
  767. * DESCRIPTION: Display the currently installed global handlers
  768. *
  769. ******************************************************************************/
  770. void acpi_db_display_handlers(void)
  771. {
  772. union acpi_operand_object *obj_desc;
  773. union acpi_operand_object *handler_obj;
  774. acpi_adr_space_type space_id;
  775. u32 i;
  776. /* Operation region handlers */
  777. acpi_os_printf("\nOperation Region Handlers at the namespace root:\n");
  778. obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node);
  779. if (obj_desc) {
  780. for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_space_id_list); i++) {
  781. space_id = acpi_gbl_space_id_list[i];
  782. acpi_os_printf(ACPI_PREDEFINED_PREFIX,
  783. acpi_ut_get_region_name((u8)space_id),
  784. space_id);
  785. handler_obj =
  786. acpi_ev_find_region_handler(space_id,
  787. obj_desc->common_notify.
  788. handler);
  789. if (handler_obj) {
  790. acpi_os_printf(ACPI_HANDLER_PRESENT_STRING,
  791. (handler_obj->address_space.
  792. handler_flags &
  793. ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
  794. ? "Default" : "User",
  795. handler_obj->address_space.
  796. handler);
  797. goto found_handler;
  798. }
  799. /* There is no handler for this space_id */
  800. acpi_os_printf("None\n");
  801. found_handler: ;
  802. }
  803. /* Find all handlers for user-defined space_IDs */
  804. handler_obj = obj_desc->common_notify.handler;
  805. while (handler_obj) {
  806. if (handler_obj->address_space.space_id >=
  807. ACPI_USER_REGION_BEGIN) {
  808. acpi_os_printf(ACPI_PREDEFINED_PREFIX,
  809. "User-defined ID",
  810. handler_obj->address_space.
  811. space_id);
  812. acpi_os_printf(ACPI_HANDLER_PRESENT_STRING,
  813. (handler_obj->address_space.
  814. handler_flags &
  815. ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
  816. ? "Default" : "User",
  817. handler_obj->address_space.
  818. handler);
  819. }
  820. handler_obj = handler_obj->address_space.next;
  821. }
  822. }
  823. #if (!ACPI_REDUCED_HARDWARE)
  824. /* Fixed event handlers */
  825. acpi_os_printf("\nFixed Event Handlers:\n");
  826. for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
  827. acpi_os_printf(ACPI_PREDEFINED_PREFIX,
  828. acpi_ut_get_event_name(i), i);
  829. if (acpi_gbl_fixed_event_handlers[i].handler) {
  830. acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, "User",
  831. acpi_gbl_fixed_event_handlers[i].
  832. handler);
  833. } else {
  834. acpi_os_printf(ACPI_HANDLER_NOT_PRESENT_STRING, "None");
  835. }
  836. }
  837. #endif /* !ACPI_REDUCED_HARDWARE */
  838. /* Miscellaneous global handlers */
  839. acpi_os_printf("\nMiscellaneous Global Handlers:\n");
  840. for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_handler_list); i++) {
  841. acpi_os_printf(ACPI_HANDLER_NAME_STRING,
  842. acpi_gbl_handler_list[i].name);
  843. if (acpi_gbl_handler_list[i].handler) {
  844. acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, "User",
  845. acpi_gbl_handler_list[i].handler);
  846. } else {
  847. acpi_os_printf(ACPI_HANDLER_NOT_PRESENT_STRING, "None");
  848. }
  849. }
  850. /* Other handlers that are installed throughout the namespace */
  851. acpi_os_printf("\nOperation Region Handlers for specific devices:\n");
  852. (void)acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
  853. ACPI_UINT32_MAX,
  854. acpi_db_display_non_root_handlers, NULL, NULL,
  855. NULL);
  856. }
  857. /*******************************************************************************
  858. *
  859. * FUNCTION: acpi_db_display_non_root_handlers
  860. *
  861. * PARAMETERS: acpi_walk_callback
  862. *
  863. * RETURN: Status
  864. *
  865. * DESCRIPTION: Display information about all handlers installed for a
  866. * device object.
  867. *
  868. ******************************************************************************/
  869. static acpi_status
  870. acpi_db_display_non_root_handlers(acpi_handle obj_handle,
  871. u32 nesting_level,
  872. void *context, void **return_value)
  873. {
  874. struct acpi_namespace_node *node =
  875. ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle);
  876. union acpi_operand_object *obj_desc;
  877. union acpi_operand_object *handler_obj;
  878. char *pathname;
  879. obj_desc = acpi_ns_get_attached_object(node);
  880. if (!obj_desc) {
  881. return (AE_OK);
  882. }
  883. pathname = acpi_ns_get_normalized_pathname(node, TRUE);
  884. if (!pathname) {
  885. return (AE_OK);
  886. }
  887. /* Display all handlers associated with this device */
  888. handler_obj = obj_desc->common_notify.handler;
  889. while (handler_obj) {
  890. acpi_os_printf(ACPI_PREDEFINED_PREFIX,
  891. acpi_ut_get_region_name((u8)handler_obj->
  892. address_space.space_id),
  893. handler_obj->address_space.space_id);
  894. acpi_os_printf(ACPI_HANDLER_PRESENT_STRING2,
  895. (handler_obj->address_space.handler_flags &
  896. ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default"
  897. : "User", handler_obj->address_space.handler);
  898. acpi_os_printf(" Device Name: %s (%p)\n", pathname, node);
  899. handler_obj = handler_obj->address_space.next;
  900. }
  901. ACPI_FREE(pathname);
  902. return (AE_OK);
  903. }