blob: 502bb587f1128a8a2e37194aed9e581be29f3f99 [file] [log] [blame]
Lv Zheng99575102015-10-19 10:25:20 +08001/*******************************************************************************
2 *
3 * Module Name: dbdisply - debug display commands
4 *
5 ******************************************************************************/
6
7/*
Bob Moorec8100dc2016-01-15 08:17:03 +08008 * Copyright (C) 2000 - 2016, Intel Corp.
Lv Zheng99575102015-10-19 10:25:20 +08009 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "amlcode.h"
47#include "acdispat.h"
48#include "acnamesp.h"
49#include "acparser.h"
50#include "acinterp.h"
Lv Zhengf31a99ce2015-12-29 14:02:00 +080051#include "acevents.h"
Lv Zheng99575102015-10-19 10:25:20 +080052#include "acdebug.h"
53
54#define _COMPONENT ACPI_CA_DEBUGGER
55ACPI_MODULE_NAME("dbdisply")
56
57/* Local prototypes */
58static void acpi_db_dump_parser_descriptor(union acpi_parse_object *op);
59
60static void *acpi_db_get_pointer(void *target);
61
62static acpi_status
63acpi_db_display_non_root_handlers(acpi_handle obj_handle,
64 u32 nesting_level,
65 void *context, void **return_value);
66
67/*
68 * System handler information.
69 * Used for Handlers command, in acpi_db_display_handlers.
70 */
71#define ACPI_PREDEFINED_PREFIX "%25s (%.2X) : "
72#define ACPI_HANDLER_NAME_STRING "%30s : "
73#define ACPI_HANDLER_PRESENT_STRING "%-9s (%p)\n"
74#define ACPI_HANDLER_PRESENT_STRING2 "%-9s (%p)"
75#define ACPI_HANDLER_NOT_PRESENT_STRING "%-9s\n"
76
77/* All predefined Address Space IDs */
78
79static acpi_adr_space_type acpi_gbl_space_id_list[] = {
80 ACPI_ADR_SPACE_SYSTEM_MEMORY,
81 ACPI_ADR_SPACE_SYSTEM_IO,
82 ACPI_ADR_SPACE_PCI_CONFIG,
83 ACPI_ADR_SPACE_EC,
84 ACPI_ADR_SPACE_SMBUS,
85 ACPI_ADR_SPACE_CMOS,
86 ACPI_ADR_SPACE_PCI_BAR_TARGET,
87 ACPI_ADR_SPACE_IPMI,
88 ACPI_ADR_SPACE_GPIO,
89 ACPI_ADR_SPACE_GSBUS,
90 ACPI_ADR_SPACE_DATA_TABLE,
91 ACPI_ADR_SPACE_FIXED_HARDWARE
92};
93
94/* Global handler information */
95
96typedef struct acpi_handler_info {
97 void *handler;
98 char *name;
99
100} acpi_handler_info;
101
102static struct acpi_handler_info acpi_gbl_handler_list[] = {
103 {&acpi_gbl_global_notify[0].handler, "System Notifications"},
104 {&acpi_gbl_global_notify[1].handler, "Device Notifications"},
105 {&acpi_gbl_table_handler, "ACPI Table Events"},
106 {&acpi_gbl_exception_handler, "Control Method Exceptions"},
107 {&acpi_gbl_interface_handler, "OSI Invocations"}
108};
109
110/*******************************************************************************
111 *
112 * FUNCTION: acpi_db_get_pointer
113 *
114 * PARAMETERS: target - Pointer to string to be converted
115 *
116 * RETURN: Converted pointer
117 *
118 * DESCRIPTION: Convert an ascii pointer value to a real value
119 *
120 ******************************************************************************/
121
122static void *acpi_db_get_pointer(void *target)
123{
124 void *obj_ptr;
125 acpi_size address;
126
127 address = strtoul(target, NULL, 16);
128 obj_ptr = ACPI_TO_POINTER(address);
129 return (obj_ptr);
130}
131
132/*******************************************************************************
133 *
134 * FUNCTION: acpi_db_dump_parser_descriptor
135 *
136 * PARAMETERS: op - A parser Op descriptor
137 *
138 * RETURN: None
139 *
140 * DESCRIPTION: Display a formatted parser object
141 *
142 ******************************************************************************/
143
144static void acpi_db_dump_parser_descriptor(union acpi_parse_object *op)
145{
146 const struct acpi_opcode_info *info;
147
148 info = acpi_ps_get_opcode_info(op->common.aml_opcode);
149
150 acpi_os_printf("Parser Op Descriptor:\n");
151 acpi_os_printf("%20.20s : %4.4X\n", "Opcode", op->common.aml_opcode);
152
153 ACPI_DEBUG_ONLY_MEMBERS(acpi_os_printf("%20.20s : %s\n", "Opcode Name",
154 info->name));
155
156 acpi_os_printf("%20.20s : %p\n", "Value/ArgList", op->common.value.arg);
157 acpi_os_printf("%20.20s : %p\n", "Parent", op->common.parent);
158 acpi_os_printf("%20.20s : %p\n", "NextOp", op->common.next);
159}
160
161/*******************************************************************************
162 *
163 * FUNCTION: acpi_db_decode_and_display_object
164 *
165 * PARAMETERS: target - String with object to be displayed. Names
166 * and hex pointers are supported.
167 * output_type - Byte, Word, Dword, or Qword (B|W|D|Q)
168 *
169 * RETURN: None
170 *
171 * DESCRIPTION: Display a formatted ACPI object
172 *
173 ******************************************************************************/
174
175void acpi_db_decode_and_display_object(char *target, char *output_type)
176{
177 void *obj_ptr;
178 struct acpi_namespace_node *node;
179 union acpi_operand_object *obj_desc;
180 u32 display = DB_BYTE_DISPLAY;
181 char buffer[80];
182 struct acpi_buffer ret_buf;
183 acpi_status status;
184 u32 size;
185
186 if (!target) {
187 return;
188 }
189
190 /* Decode the output type */
191
192 if (output_type) {
193 acpi_ut_strupr(output_type);
194 if (output_type[0] == 'W') {
195 display = DB_WORD_DISPLAY;
196 } else if (output_type[0] == 'D') {
197 display = DB_DWORD_DISPLAY;
198 } else if (output_type[0] == 'Q') {
199 display = DB_QWORD_DISPLAY;
200 }
201 }
202
203 ret_buf.length = sizeof(buffer);
204 ret_buf.pointer = buffer;
205
206 /* Differentiate between a number and a name */
207
208 if ((target[0] >= 0x30) && (target[0] <= 0x39)) {
209 obj_ptr = acpi_db_get_pointer(target);
210 if (!acpi_os_readable(obj_ptr, 16)) {
211 acpi_os_printf
212 ("Address %p is invalid in this address space\n",
213 obj_ptr);
214 return;
215 }
216
217 /* Decode the object type */
218
219 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_ptr)) {
220 case ACPI_DESC_TYPE_NAMED:
221
222 /* This is a namespace Node */
223
224 if (!acpi_os_readable
225 (obj_ptr, sizeof(struct acpi_namespace_node))) {
226 acpi_os_printf
227 ("Cannot read entire Named object at address %p\n",
228 obj_ptr);
229 return;
230 }
231
232 node = obj_ptr;
233 goto dump_node;
234
235 case ACPI_DESC_TYPE_OPERAND:
236
237 /* This is a ACPI OPERAND OBJECT */
238
239 if (!acpi_os_readable
240 (obj_ptr, sizeof(union acpi_operand_object))) {
241 acpi_os_printf
242 ("Cannot read entire ACPI object at address %p\n",
243 obj_ptr);
244 return;
245 }
246
247 acpi_ut_debug_dump_buffer(obj_ptr,
248 sizeof(union
249 acpi_operand_object),
250 display, ACPI_UINT32_MAX);
251 acpi_ex_dump_object_descriptor(obj_ptr, 1);
252 break;
253
254 case ACPI_DESC_TYPE_PARSER:
255
256 /* This is a Parser Op object */
257
258 if (!acpi_os_readable
259 (obj_ptr, sizeof(union acpi_parse_object))) {
260 acpi_os_printf
261 ("Cannot read entire Parser object at address %p\n",
262 obj_ptr);
263 return;
264 }
265
266 acpi_ut_debug_dump_buffer(obj_ptr,
267 sizeof(union
268 acpi_parse_object),
269 display, ACPI_UINT32_MAX);
270 acpi_db_dump_parser_descriptor((union acpi_parse_object
271 *)obj_ptr);
272 break;
273
274 default:
275
276 /* Is not a recognizeable object */
277
278 acpi_os_printf
279 ("Not a known ACPI internal object, descriptor type %2.2X\n",
280 ACPI_GET_DESCRIPTOR_TYPE(obj_ptr));
281
282 size = 16;
283 if (acpi_os_readable(obj_ptr, 64)) {
284 size = 64;
285 }
286
287 /* Just dump some memory */
288
289 acpi_ut_debug_dump_buffer(obj_ptr, size, display,
290 ACPI_UINT32_MAX);
291 break;
292 }
293
294 return;
295 }
296
297 /* The parameter is a name string that must be resolved to a Named obj */
298
299 node = acpi_db_local_ns_lookup(target);
300 if (!node) {
301 return;
302 }
303
304dump_node:
305 /* Now dump the NS node */
306
307 status = acpi_get_name(node, ACPI_FULL_PATHNAME_NO_TRAILING, &ret_buf);
308 if (ACPI_FAILURE(status)) {
309 acpi_os_printf("Could not convert name to pathname\n");
310 }
311
312 else {
313 acpi_os_printf("Object (%p) Pathname: %s\n",
314 node, (char *)ret_buf.pointer);
315 }
316
317 if (!acpi_os_readable(node, sizeof(struct acpi_namespace_node))) {
318 acpi_os_printf("Invalid Named object at address %p\n", node);
319 return;
320 }
321
322 acpi_ut_debug_dump_buffer((void *)node,
323 sizeof(struct acpi_namespace_node), display,
324 ACPI_UINT32_MAX);
325 acpi_ex_dump_namespace_node(node, 1);
326
327 obj_desc = acpi_ns_get_attached_object(node);
328 if (obj_desc) {
329 acpi_os_printf("\nAttached Object (%p):\n", obj_desc);
330 if (!acpi_os_readable
331 (obj_desc, sizeof(union acpi_operand_object))) {
332 acpi_os_printf
333 ("Invalid internal ACPI Object at address %p\n",
334 obj_desc);
335 return;
336 }
337
338 acpi_ut_debug_dump_buffer((void *)obj_desc,
339 sizeof(union acpi_operand_object),
340 display, ACPI_UINT32_MAX);
341 acpi_ex_dump_object_descriptor(obj_desc, 1);
342 }
343}
344
345/*******************************************************************************
346 *
347 * FUNCTION: acpi_db_display_method_info
348 *
349 * PARAMETERS: start_op - Root of the control method parse tree
350 *
351 * RETURN: None
352 *
353 * DESCRIPTION: Display information about the current method
354 *
355 ******************************************************************************/
356
357void acpi_db_display_method_info(union acpi_parse_object *start_op)
358{
359 struct acpi_walk_state *walk_state;
360 union acpi_operand_object *obj_desc;
361 struct acpi_namespace_node *node;
362 union acpi_parse_object *root_op;
363 union acpi_parse_object *op;
364 const struct acpi_opcode_info *op_info;
365 u32 num_ops = 0;
366 u32 num_operands = 0;
367 u32 num_operators = 0;
368 u32 num_remaining_ops = 0;
369 u32 num_remaining_operands = 0;
370 u32 num_remaining_operators = 0;
371 u8 count_remaining = FALSE;
372
373 walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
374 if (!walk_state) {
375 acpi_os_printf("There is no method currently executing\n");
376 return;
377 }
378
379 obj_desc = walk_state->method_desc;
380 node = walk_state->method_node;
381
382 acpi_os_printf("Currently executing control method is [%4.4s]\n",
383 acpi_ut_get_node_name(node));
384 acpi_os_printf("%X Arguments, SyncLevel = %X\n",
385 (u32)obj_desc->method.param_count,
386 (u32)obj_desc->method.sync_level);
387
388 root_op = start_op;
389 while (root_op->common.parent) {
390 root_op = root_op->common.parent;
391 }
392
393 op = root_op;
394
395 while (op) {
396 if (op == start_op) {
397 count_remaining = TRUE;
398 }
399
400 num_ops++;
401 if (count_remaining) {
402 num_remaining_ops++;
403 }
404
405 /* Decode the opcode */
406
407 op_info = acpi_ps_get_opcode_info(op->common.aml_opcode);
408 switch (op_info->class) {
409 case AML_CLASS_ARGUMENT:
410
411 if (count_remaining) {
412 num_remaining_operands++;
413 }
414
415 num_operands++;
416 break;
417
418 case AML_CLASS_UNKNOWN:
419
420 /* Bad opcode or ASCII character */
421
422 continue;
423
424 default:
425
426 if (count_remaining) {
427 num_remaining_operators++;
428 }
429
430 num_operators++;
431 break;
432 }
433
434 op = acpi_ps_get_depth_next(start_op, op);
435 }
436
437 acpi_os_printf
438 ("Method contains: %X AML Opcodes - %X Operators, %X Operands\n",
439 num_ops, num_operators, num_operands);
440
441 acpi_os_printf
442 ("Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n",
443 num_remaining_ops, num_remaining_operators,
444 num_remaining_operands);
445}
446
447/*******************************************************************************
448 *
449 * FUNCTION: acpi_db_display_locals
450 *
451 * PARAMETERS: None
452 *
453 * RETURN: None
454 *
455 * DESCRIPTION: Display all locals for the currently running control method
456 *
457 ******************************************************************************/
458
459void acpi_db_display_locals(void)
460{
461 struct acpi_walk_state *walk_state;
462
463 walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
464 if (!walk_state) {
465 acpi_os_printf("There is no method currently executing\n");
466 return;
467 }
468
469 acpi_db_decode_locals(walk_state);
470}
471
472/*******************************************************************************
473 *
474 * FUNCTION: acpi_db_display_arguments
475 *
476 * PARAMETERS: None
477 *
478 * RETURN: None
479 *
480 * DESCRIPTION: Display all arguments for the currently running control method
481 *
482 ******************************************************************************/
483
484void acpi_db_display_arguments(void)
485{
486 struct acpi_walk_state *walk_state;
487
488 walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
489 if (!walk_state) {
490 acpi_os_printf("There is no method currently executing\n");
491 return;
492 }
493
494 acpi_db_decode_arguments(walk_state);
495}
496
497/*******************************************************************************
498 *
499 * FUNCTION: acpi_db_display_results
500 *
501 * PARAMETERS: None
502 *
503 * RETURN: None
504 *
505 * DESCRIPTION: Display current contents of a method result stack
506 *
507 ******************************************************************************/
508
509void acpi_db_display_results(void)
510{
511 u32 i;
512 struct acpi_walk_state *walk_state;
513 union acpi_operand_object *obj_desc;
514 u32 result_count = 0;
515 struct acpi_namespace_node *node;
516 union acpi_generic_state *frame;
517 u32 index; /* Index onto current frame */
518
519 walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
520 if (!walk_state) {
521 acpi_os_printf("There is no method currently executing\n");
522 return;
523 }
524
525 obj_desc = walk_state->method_desc;
526 node = walk_state->method_node;
527
528 if (walk_state->results) {
529 result_count = walk_state->result_count;
530 }
531
532 acpi_os_printf("Method [%4.4s] has %X stacked result objects\n",
533 acpi_ut_get_node_name(node), result_count);
534
535 /* From the top element of result stack */
536
537 frame = walk_state->results;
538 index = (result_count - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
539
540 for (i = 0; i < result_count; i++) {
541 obj_desc = frame->results.obj_desc[index];
542 acpi_os_printf("Result%u: ", i);
543 acpi_db_display_internal_object(obj_desc, walk_state);
544
545 if (index == 0) {
546 frame = frame->results.next;
547 index = ACPI_RESULTS_FRAME_OBJ_NUM;
548 }
549
550 index--;
551 }
552}
553
554/*******************************************************************************
555 *
556 * FUNCTION: acpi_db_display_calling_tree
557 *
558 * PARAMETERS: None
559 *
560 * RETURN: None
561 *
562 * DESCRIPTION: Display current calling tree of nested control methods
563 *
564 ******************************************************************************/
565
566void acpi_db_display_calling_tree(void)
567{
568 struct acpi_walk_state *walk_state;
569 struct acpi_namespace_node *node;
570
571 walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
572 if (!walk_state) {
573 acpi_os_printf("There is no method currently executing\n");
574 return;
575 }
576
577 node = walk_state->method_node;
578 acpi_os_printf("Current Control Method Call Tree\n");
579
580 while (walk_state) {
581 node = walk_state->method_node;
582 acpi_os_printf(" [%4.4s]\n", acpi_ut_get_node_name(node));
583
584 walk_state = walk_state->next;
585 }
586}
587
588/*******************************************************************************
589 *
590 * FUNCTION: acpi_db_display_object_type
591 *
Bob Moore07cb3902015-12-29 13:55:47 +0800592 * PARAMETERS: object_arg - User entered NS node handle
Lv Zheng99575102015-10-19 10:25:20 +0800593 *
594 * RETURN: None
595 *
596 * DESCRIPTION: Display type of an arbitrary NS node
597 *
598 ******************************************************************************/
599
Bob Moore07cb3902015-12-29 13:55:47 +0800600void acpi_db_display_object_type(char *object_arg)
Lv Zheng99575102015-10-19 10:25:20 +0800601{
Lv Zhengc11e5dd2016-01-15 08:17:11 +0800602 acpi_size arg;
Bob Moore07cb3902015-12-29 13:55:47 +0800603 acpi_handle handle;
Lv Zheng99575102015-10-19 10:25:20 +0800604 struct acpi_device_info *info;
605 acpi_status status;
606 u32 i;
607
Lv Zhengc11e5dd2016-01-15 08:17:11 +0800608 arg = strtoul(object_arg, NULL, 16);
609 handle = ACPI_TO_POINTER(arg);
Lv Zheng99575102015-10-19 10:25:20 +0800610
Bob Moore07cb3902015-12-29 13:55:47 +0800611 status = acpi_get_object_info(handle, &info);
Lv Zheng99575102015-10-19 10:25:20 +0800612 if (ACPI_FAILURE(status)) {
613 acpi_os_printf("Could not get object info, %s\n",
614 acpi_format_exception(status));
615 return;
616 }
617
Bob Moore07cb3902015-12-29 13:55:47 +0800618 acpi_os_printf("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n",
619 ACPI_FORMAT_UINT64(info->address),
620 info->current_status, info->flags);
621
622 acpi_os_printf("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",
623 info->highest_dstates[0], info->highest_dstates[1],
624 info->highest_dstates[2], info->highest_dstates[3]);
625
626 acpi_os_printf("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",
627 info->lowest_dstates[0], info->lowest_dstates[1],
628 info->lowest_dstates[2], info->lowest_dstates[3],
629 info->lowest_dstates[4]);
Lv Zheng99575102015-10-19 10:25:20 +0800630
631 if (info->valid & ACPI_VALID_HID) {
632 acpi_os_printf("HID: %s\n", info->hardware_id.string);
633 }
634
635 if (info->valid & ACPI_VALID_UID) {
636 acpi_os_printf("UID: %s\n", info->unique_id.string);
637 }
638
Lv Zheng99575102015-10-19 10:25:20 +0800639 if (info->valid & ACPI_VALID_CID) {
640 for (i = 0; i < info->compatible_id_list.count; i++) {
641 acpi_os_printf("CID %u: %s\n", i,
642 info->compatible_id_list.ids[i].string);
643 }
644 }
645
646 ACPI_FREE(info);
647}
648
649/*******************************************************************************
650 *
651 * FUNCTION: acpi_db_display_result_object
652 *
653 * PARAMETERS: obj_desc - Object to be displayed
654 * walk_state - Current walk state
655 *
656 * RETURN: None
657 *
658 * DESCRIPTION: Display the result of an AML opcode
659 *
660 * Note: Curently only displays the result object if we are single stepping.
661 * However, this output may be useful in other contexts and could be enabled
662 * to do so if needed.
663 *
664 ******************************************************************************/
665
666void
667acpi_db_display_result_object(union acpi_operand_object *obj_desc,
668 struct acpi_walk_state *walk_state)
669{
670
Lv Zheng8a2a2502015-12-03 10:42:53 +0800671#ifndef ACPI_APPLICATION
672 if (acpi_gbl_db_thread_id != acpi_os_get_thread_id()) {
673 return;
674 }
675#endif
676
Lv Zheng99575102015-10-19 10:25:20 +0800677 /* Only display if single stepping */
678
679 if (!acpi_gbl_cm_single_step) {
680 return;
681 }
682
683 acpi_os_printf("ResultObj: ");
684 acpi_db_display_internal_object(obj_desc, walk_state);
685 acpi_os_printf("\n");
686}
687
688/*******************************************************************************
689 *
690 * FUNCTION: acpi_db_display_argument_object
691 *
692 * PARAMETERS: obj_desc - Object to be displayed
693 * walk_state - Current walk state
694 *
695 * RETURN: None
696 *
697 * DESCRIPTION: Display the result of an AML opcode
698 *
699 ******************************************************************************/
700
701void
702acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
703 struct acpi_walk_state *walk_state)
704{
705
Lv Zheng8a2a2502015-12-03 10:42:53 +0800706#ifndef ACPI_APPLICATION
707 if (acpi_gbl_db_thread_id != acpi_os_get_thread_id()) {
708 return;
709 }
710#endif
711
Lv Zheng99575102015-10-19 10:25:20 +0800712 if (!acpi_gbl_cm_single_step) {
713 return;
714 }
715
716 acpi_os_printf("ArgObj: ");
717 acpi_db_display_internal_object(obj_desc, walk_state);
718}
719
720#if (!ACPI_REDUCED_HARDWARE)
721/*******************************************************************************
722 *
723 * FUNCTION: acpi_db_display_gpes
724 *
725 * PARAMETERS: None
726 *
727 * RETURN: None
728 *
729 * DESCRIPTION: Display the current GPE structures
730 *
731 ******************************************************************************/
732
733void acpi_db_display_gpes(void)
734{
735 struct acpi_gpe_block_info *gpe_block;
736 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
737 struct acpi_gpe_event_info *gpe_event_info;
738 struct acpi_gpe_register_info *gpe_register_info;
739 char *gpe_type;
740 struct acpi_gpe_notify_info *notify;
741 u32 gpe_index;
742 u32 block = 0;
743 u32 i;
744 u32 j;
745 u32 count;
746 char buffer[80];
747 struct acpi_buffer ret_buf;
748 acpi_status status;
749
750 ret_buf.length = sizeof(buffer);
751 ret_buf.pointer = buffer;
752
753 block = 0;
754
755 /* Walk the GPE lists */
756
757 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
758 while (gpe_xrupt_info) {
759 gpe_block = gpe_xrupt_info->gpe_block_list_head;
760 while (gpe_block) {
761 status = acpi_get_name(gpe_block->node,
762 ACPI_FULL_PATHNAME_NO_TRAILING,
763 &ret_buf);
764 if (ACPI_FAILURE(status)) {
765 acpi_os_printf
766 ("Could not convert name to pathname\n");
767 }
768
769 if (gpe_block->node == acpi_gbl_fadt_gpe_device) {
770 gpe_type = "FADT-defined GPE block";
771 } else {
772 gpe_type = "GPE Block Device";
773 }
774
775 acpi_os_printf
776 ("\nBlock %u - Info %p DeviceNode %p [%s] - %s\n",
777 block, gpe_block, gpe_block->node, buffer,
778 gpe_type);
779
780 acpi_os_printf(" Registers: %u (%u GPEs)\n",
781 gpe_block->register_count,
782 gpe_block->gpe_count);
783
784 acpi_os_printf
785 (" GPE range: 0x%X to 0x%X on interrupt %u\n",
786 gpe_block->block_base_number,
787 gpe_block->block_base_number +
788 (gpe_block->gpe_count - 1),
789 gpe_xrupt_info->interrupt_number);
790
791 acpi_os_printf
792 (" RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n",
793 gpe_block->register_info,
794 ACPI_FORMAT_UINT64(gpe_block->register_info->
795 status_address.address),
796 ACPI_FORMAT_UINT64(gpe_block->register_info->
797 enable_address.address));
798
799 acpi_os_printf(" EventInfo: %p\n",
800 gpe_block->event_info);
801
802 /* Examine each GPE Register within the block */
803
804 for (i = 0; i < gpe_block->register_count; i++) {
805 gpe_register_info =
806 &gpe_block->register_info[i];
807
808 acpi_os_printf(" Reg %u: (GPE %.2X-%.2X) "
809 "RunEnable %2.2X WakeEnable %2.2X"
810 " Status %8.8X%8.8X Enable %8.8X%8.8X\n",
811 i,
812 gpe_register_info->
813 base_gpe_number,
814 gpe_register_info->
815 base_gpe_number +
816 (ACPI_GPE_REGISTER_WIDTH - 1),
817 gpe_register_info->
818 enable_for_run,
819 gpe_register_info->
820 enable_for_wake,
821 ACPI_FORMAT_UINT64
822 (gpe_register_info->
823 status_address.address),
824 ACPI_FORMAT_UINT64
825 (gpe_register_info->
826 enable_address.address));
827
828 /* Now look at the individual GPEs in this byte register */
829
830 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
831 gpe_index =
832 (i * ACPI_GPE_REGISTER_WIDTH) + j;
833 gpe_event_info =
834 &gpe_block->event_info[gpe_index];
835
836 if (ACPI_GPE_DISPATCH_TYPE
837 (gpe_event_info->flags) ==
838 ACPI_GPE_DISPATCH_NONE) {
839
840 /* This GPE is not used (no method or handler), ignore it */
841
842 continue;
843 }
844
845 acpi_os_printf
846 (" GPE %.2X: %p RunRefs %2.2X Flags %2.2X (",
847 gpe_block->block_base_number +
848 gpe_index, gpe_event_info,
849 gpe_event_info->runtime_count,
850 gpe_event_info->flags);
851
852 /* Decode the flags byte */
853
854 if (gpe_event_info->
855 flags & ACPI_GPE_LEVEL_TRIGGERED) {
856 acpi_os_printf("Level, ");
857 } else {
858 acpi_os_printf("Edge, ");
859 }
860
861 if (gpe_event_info->
862 flags & ACPI_GPE_CAN_WAKE) {
863 acpi_os_printf("CanWake, ");
864 } else {
865 acpi_os_printf("RunOnly, ");
866 }
867
868 switch (ACPI_GPE_DISPATCH_TYPE
869 (gpe_event_info->flags)) {
870 case ACPI_GPE_DISPATCH_NONE:
871
872 acpi_os_printf("NotUsed");
873 break;
874
875 case ACPI_GPE_DISPATCH_METHOD:
876
877 acpi_os_printf("Method");
878 break;
879
880 case ACPI_GPE_DISPATCH_HANDLER:
881
882 acpi_os_printf("Handler");
883 break;
884
885 case ACPI_GPE_DISPATCH_NOTIFY:
886
887 count = 0;
888 notify =
889 gpe_event_info->dispatch.
890 notify_list;
891 while (notify) {
892 count++;
893 notify = notify->next;
894 }
895
896 acpi_os_printf
897 ("Implicit Notify on %u devices",
898 count);
899 break;
900
901 case ACPI_GPE_DISPATCH_RAW_HANDLER:
902
903 acpi_os_printf("RawHandler");
904 break;
905
906 default:
907
908 acpi_os_printf("UNKNOWN: %X",
909 ACPI_GPE_DISPATCH_TYPE
910 (gpe_event_info->
911 flags));
912 break;
913 }
914
915 acpi_os_printf(")\n");
916 }
917 }
918
919 block++;
920 gpe_block = gpe_block->next;
921 }
922
923 gpe_xrupt_info = gpe_xrupt_info->next;
924 }
925}
926#endif /* !ACPI_REDUCED_HARDWARE */
927
928/*******************************************************************************
929 *
930 * FUNCTION: acpi_db_display_handlers
931 *
932 * PARAMETERS: None
933 *
934 * RETURN: None
935 *
936 * DESCRIPTION: Display the currently installed global handlers
937 *
938 ******************************************************************************/
939
940void acpi_db_display_handlers(void)
941{
942 union acpi_operand_object *obj_desc;
943 union acpi_operand_object *handler_obj;
944 acpi_adr_space_type space_id;
945 u32 i;
946
947 /* Operation region handlers */
948
949 acpi_os_printf("\nOperation Region Handlers at the namespace root:\n");
950
951 obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node);
952 if (obj_desc) {
953 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_space_id_list); i++) {
954 space_id = acpi_gbl_space_id_list[i];
Lv Zheng99575102015-10-19 10:25:20 +0800955
956 acpi_os_printf(ACPI_PREDEFINED_PREFIX,
957 acpi_ut_get_region_name((u8)space_id),
958 space_id);
959
Lv Zhengf31a99ce2015-12-29 14:02:00 +0800960 handler_obj =
961 acpi_ev_find_region_handler(space_id,
Lv Zhengaa6abd22015-12-29 14:02:08 +0800962 obj_desc->common_notify.
Lv Zhengf31a99ce2015-12-29 14:02:00 +0800963 handler);
964 if (handler_obj) {
965 acpi_os_printf(ACPI_HANDLER_PRESENT_STRING,
966 (handler_obj->address_space.
967 handler_flags &
968 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
969 ? "Default" : "User",
970 handler_obj->address_space.
971 handler);
Lv Zheng99575102015-10-19 10:25:20 +0800972
Lv Zhengf31a99ce2015-12-29 14:02:00 +0800973 goto found_handler;
Lv Zheng99575102015-10-19 10:25:20 +0800974 }
975
976 /* There is no handler for this space_id */
977
978 acpi_os_printf("None\n");
979
980found_handler: ;
981 }
982
983 /* Find all handlers for user-defined space_IDs */
984
Lv Zhengaa6abd22015-12-29 14:02:08 +0800985 handler_obj = obj_desc->common_notify.handler;
Lv Zheng99575102015-10-19 10:25:20 +0800986 while (handler_obj) {
987 if (handler_obj->address_space.space_id >=
988 ACPI_USER_REGION_BEGIN) {
989 acpi_os_printf(ACPI_PREDEFINED_PREFIX,
990 "User-defined ID",
991 handler_obj->address_space.
992 space_id);
993 acpi_os_printf(ACPI_HANDLER_PRESENT_STRING,
994 (handler_obj->address_space.
995 handler_flags &
996 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
997 ? "Default" : "User",
998 handler_obj->address_space.
999 handler);
1000 }
1001
1002 handler_obj = handler_obj->address_space.next;
1003 }
1004 }
1005#if (!ACPI_REDUCED_HARDWARE)
1006
1007 /* Fixed event handlers */
1008
1009 acpi_os_printf("\nFixed Event Handlers:\n");
1010
1011 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
1012 acpi_os_printf(ACPI_PREDEFINED_PREFIX,
1013 acpi_ut_get_event_name(i), i);
1014 if (acpi_gbl_fixed_event_handlers[i].handler) {
1015 acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, "User",
1016 acpi_gbl_fixed_event_handlers[i].
1017 handler);
1018 } else {
1019 acpi_os_printf(ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1020 }
1021 }
1022
1023#endif /* !ACPI_REDUCED_HARDWARE */
1024
1025 /* Miscellaneous global handlers */
1026
1027 acpi_os_printf("\nMiscellaneous Global Handlers:\n");
1028
1029 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_handler_list); i++) {
1030 acpi_os_printf(ACPI_HANDLER_NAME_STRING,
1031 acpi_gbl_handler_list[i].name);
1032
1033 if (acpi_gbl_handler_list[i].handler) {
1034 acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, "User",
1035 acpi_gbl_handler_list[i].handler);
1036 } else {
1037 acpi_os_printf(ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1038 }
1039 }
1040
1041 /* Other handlers that are installed throughout the namespace */
1042
1043 acpi_os_printf("\nOperation Region Handlers for specific devices:\n");
1044
1045 (void)acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1046 ACPI_UINT32_MAX,
1047 acpi_db_display_non_root_handlers, NULL, NULL,
1048 NULL);
1049}
1050
1051/*******************************************************************************
1052 *
1053 * FUNCTION: acpi_db_display_non_root_handlers
1054 *
1055 * PARAMETERS: acpi_walk_callback
1056 *
1057 * RETURN: Status
1058 *
1059 * DESCRIPTION: Display information about all handlers installed for a
1060 * device object.
1061 *
1062 ******************************************************************************/
1063
1064static acpi_status
1065acpi_db_display_non_root_handlers(acpi_handle obj_handle,
1066 u32 nesting_level,
1067 void *context, void **return_value)
1068{
1069 struct acpi_namespace_node *node =
1070 ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle);
1071 union acpi_operand_object *obj_desc;
1072 union acpi_operand_object *handler_obj;
1073 char *pathname;
1074
1075 obj_desc = acpi_ns_get_attached_object(node);
1076 if (!obj_desc) {
1077 return (AE_OK);
1078 }
1079
Lv Zheng0e166e42015-12-29 13:53:50 +08001080 pathname = acpi_ns_get_normalized_pathname(node, TRUE);
Lv Zheng99575102015-10-19 10:25:20 +08001081 if (!pathname) {
1082 return (AE_OK);
1083 }
1084
1085 /* Display all handlers associated with this device */
1086
Lv Zhengaa6abd22015-12-29 14:02:08 +08001087 handler_obj = obj_desc->common_notify.handler;
Lv Zheng99575102015-10-19 10:25:20 +08001088 while (handler_obj) {
1089 acpi_os_printf(ACPI_PREDEFINED_PREFIX,
1090 acpi_ut_get_region_name((u8)handler_obj->
1091 address_space.space_id),
1092 handler_obj->address_space.space_id);
1093
1094 acpi_os_printf(ACPI_HANDLER_PRESENT_STRING2,
1095 (handler_obj->address_space.handler_flags &
1096 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default"
1097 : "User", handler_obj->address_space.handler);
1098
1099 acpi_os_printf(" Device Name: %s (%p)\n", pathname, node);
1100
1101 handler_obj = handler_obj->address_space.next;
1102 }
1103
1104 ACPI_FREE(pathname);
1105 return (AE_OK);
1106}