dbdisply.c 29 KB

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