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