]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/acpi/acpica/dbdisply.c
f10c158424f3a4d222f62dee4dede465ef81a9d1
[karo-tx-linux.git] / drivers / acpi / acpica / dbdisply.c
1 /*******************************************************************************
2  *
3  * Module Name: dbdisply - debug display commands
4  *
5  ******************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2016, 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 "acevents.h"
52 #include "acdebug.h"
53
54 #define _COMPONENT          ACPI_CA_DEBUGGER
55 ACPI_MODULE_NAME("dbdisply")
56
57 /* Local prototypes */
58 static void acpi_db_dump_parser_descriptor(union acpi_parse_object *op);
59
60 static void *acpi_db_get_pointer(void *target);
61
62 static acpi_status
63 acpi_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
79 static 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
96 typedef struct acpi_handler_info {
97         void *handler;
98         char *name;
99
100 } acpi_handler_info;
101
102 static 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
122 static 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
144 static 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
175 void 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
304 dump_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
357 void 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
459 void 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
484 void 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
509 void 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
566 void 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  *
592  * PARAMETERS:  object_arg      - User entered NS node handle
593  *
594  * RETURN:      None
595  *
596  * DESCRIPTION: Display type of an arbitrary NS node
597  *
598  ******************************************************************************/
599
600 void acpi_db_display_object_type(char *object_arg)
601 {
602         acpi_handle handle;
603         struct acpi_device_info *info;
604         acpi_status status;
605         u32 i;
606
607         handle = ACPI_TO_POINTER(strtoul(object_arg, NULL, 16));
608
609         status = acpi_get_object_info(handle, &info);
610         if (ACPI_FAILURE(status)) {
611                 acpi_os_printf("Could not get object info, %s\n",
612                                acpi_format_exception(status));
613                 return;
614         }
615
616         acpi_os_printf("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n",
617                        ACPI_FORMAT_UINT64(info->address),
618                        info->current_status, info->flags);
619
620         acpi_os_printf("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",
621                        info->highest_dstates[0], info->highest_dstates[1],
622                        info->highest_dstates[2], info->highest_dstates[3]);
623
624         acpi_os_printf("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",
625                        info->lowest_dstates[0], info->lowest_dstates[1],
626                        info->lowest_dstates[2], info->lowest_dstates[3],
627                        info->lowest_dstates[4]);
628
629         if (info->valid & ACPI_VALID_HID) {
630                 acpi_os_printf("HID: %s\n", info->hardware_id.string);
631         }
632
633         if (info->valid & ACPI_VALID_UID) {
634                 acpi_os_printf("UID: %s\n", info->unique_id.string);
635         }
636
637         if (info->valid & ACPI_VALID_CID) {
638                 for (i = 0; i < info->compatible_id_list.count; i++) {
639                         acpi_os_printf("CID %u: %s\n", i,
640                                        info->compatible_id_list.ids[i].string);
641                 }
642         }
643
644         ACPI_FREE(info);
645 }
646
647 /*******************************************************************************
648  *
649  * FUNCTION:    acpi_db_display_result_object
650  *
651  * PARAMETERS:  obj_desc        - Object to be displayed
652  *              walk_state      - Current walk state
653  *
654  * RETURN:      None
655  *
656  * DESCRIPTION: Display the result of an AML opcode
657  *
658  * Note: Curently only displays the result object if we are single stepping.
659  * However, this output may be useful in other contexts and could be enabled
660  * to do so if needed.
661  *
662  ******************************************************************************/
663
664 void
665 acpi_db_display_result_object(union acpi_operand_object *obj_desc,
666                               struct acpi_walk_state *walk_state)
667 {
668
669 #ifndef ACPI_APPLICATION
670         if (acpi_gbl_db_thread_id != acpi_os_get_thread_id()) {
671                 return;
672         }
673 #endif
674
675         /* Only display if single stepping */
676
677         if (!acpi_gbl_cm_single_step) {
678                 return;
679         }
680
681         acpi_os_printf("ResultObj: ");
682         acpi_db_display_internal_object(obj_desc, walk_state);
683         acpi_os_printf("\n");
684 }
685
686 /*******************************************************************************
687  *
688  * FUNCTION:    acpi_db_display_argument_object
689  *
690  * PARAMETERS:  obj_desc        - Object to be displayed
691  *              walk_state      - Current walk state
692  *
693  * RETURN:      None
694  *
695  * DESCRIPTION: Display the result of an AML opcode
696  *
697  ******************************************************************************/
698
699 void
700 acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
701                                 struct acpi_walk_state *walk_state)
702 {
703
704 #ifndef ACPI_APPLICATION
705         if (acpi_gbl_db_thread_id != acpi_os_get_thread_id()) {
706                 return;
707         }
708 #endif
709
710         if (!acpi_gbl_cm_single_step) {
711                 return;
712         }
713
714         acpi_os_printf("ArgObj:  ");
715         acpi_db_display_internal_object(obj_desc, walk_state);
716 }
717
718 #if (!ACPI_REDUCED_HARDWARE)
719 /*******************************************************************************
720  *
721  * FUNCTION:    acpi_db_display_gpes
722  *
723  * PARAMETERS:  None
724  *
725  * RETURN:      None
726  *
727  * DESCRIPTION: Display the current GPE structures
728  *
729  ******************************************************************************/
730
731 void acpi_db_display_gpes(void)
732 {
733         struct acpi_gpe_block_info *gpe_block;
734         struct acpi_gpe_xrupt_info *gpe_xrupt_info;
735         struct acpi_gpe_event_info *gpe_event_info;
736         struct acpi_gpe_register_info *gpe_register_info;
737         char *gpe_type;
738         struct acpi_gpe_notify_info *notify;
739         u32 gpe_index;
740         u32 block = 0;
741         u32 i;
742         u32 j;
743         u32 count;
744         char buffer[80];
745         struct acpi_buffer ret_buf;
746         acpi_status status;
747
748         ret_buf.length = sizeof(buffer);
749         ret_buf.pointer = buffer;
750
751         block = 0;
752
753         /* Walk the GPE lists */
754
755         gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
756         while (gpe_xrupt_info) {
757                 gpe_block = gpe_xrupt_info->gpe_block_list_head;
758                 while (gpe_block) {
759                         status = acpi_get_name(gpe_block->node,
760                                                ACPI_FULL_PATHNAME_NO_TRAILING,
761                                                &ret_buf);
762                         if (ACPI_FAILURE(status)) {
763                                 acpi_os_printf
764                                     ("Could not convert name to pathname\n");
765                         }
766
767                         if (gpe_block->node == acpi_gbl_fadt_gpe_device) {
768                                 gpe_type = "FADT-defined GPE block";
769                         } else {
770                                 gpe_type = "GPE Block Device";
771                         }
772
773                         acpi_os_printf
774                             ("\nBlock %u - Info %p  DeviceNode %p [%s] - %s\n",
775                              block, gpe_block, gpe_block->node, buffer,
776                              gpe_type);
777
778                         acpi_os_printf("    Registers:    %u (%u GPEs)\n",
779                                        gpe_block->register_count,
780                                        gpe_block->gpe_count);
781
782                         acpi_os_printf
783                             ("    GPE range:    0x%X to 0x%X on interrupt %u\n",
784                              gpe_block->block_base_number,
785                              gpe_block->block_base_number +
786                              (gpe_block->gpe_count - 1),
787                              gpe_xrupt_info->interrupt_number);
788
789                         acpi_os_printf
790                             ("    RegisterInfo: %p  Status %8.8X%8.8X Enable %8.8X%8.8X\n",
791                              gpe_block->register_info,
792                              ACPI_FORMAT_UINT64(gpe_block->register_info->
793                                                 status_address.address),
794                              ACPI_FORMAT_UINT64(gpe_block->register_info->
795                                                 enable_address.address));
796
797                         acpi_os_printf("  EventInfo:    %p\n",
798                                        gpe_block->event_info);
799
800                         /* Examine each GPE Register within the block */
801
802                         for (i = 0; i < gpe_block->register_count; i++) {
803                                 gpe_register_info =
804                                     &gpe_block->register_info[i];
805
806                                 acpi_os_printf("    Reg %u: (GPE %.2X-%.2X)  "
807                                                "RunEnable %2.2X WakeEnable %2.2X"
808                                                " Status %8.8X%8.8X Enable %8.8X%8.8X\n",
809                                                i,
810                                                gpe_register_info->
811                                                base_gpe_number,
812                                                gpe_register_info->
813                                                base_gpe_number +
814                                                (ACPI_GPE_REGISTER_WIDTH - 1),
815                                                gpe_register_info->
816                                                enable_for_run,
817                                                gpe_register_info->
818                                                enable_for_wake,
819                                                ACPI_FORMAT_UINT64
820                                                (gpe_register_info->
821                                                 status_address.address),
822                                                ACPI_FORMAT_UINT64
823                                                (gpe_register_info->
824                                                 enable_address.address));
825
826                                 /* Now look at the individual GPEs in this byte register */
827
828                                 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
829                                         gpe_index =
830                                             (i * ACPI_GPE_REGISTER_WIDTH) + j;
831                                         gpe_event_info =
832                                             &gpe_block->event_info[gpe_index];
833
834                                         if (ACPI_GPE_DISPATCH_TYPE
835                                             (gpe_event_info->flags) ==
836                                             ACPI_GPE_DISPATCH_NONE) {
837
838                                                 /* This GPE is not used (no method or handler), ignore it */
839
840                                                 continue;
841                                         }
842
843                                         acpi_os_printf
844                                             ("        GPE %.2X: %p  RunRefs %2.2X Flags %2.2X (",
845                                              gpe_block->block_base_number +
846                                              gpe_index, gpe_event_info,
847                                              gpe_event_info->runtime_count,
848                                              gpe_event_info->flags);
849
850                                         /* Decode the flags byte */
851
852                                         if (gpe_event_info->
853                                             flags & ACPI_GPE_LEVEL_TRIGGERED) {
854                                                 acpi_os_printf("Level, ");
855                                         } else {
856                                                 acpi_os_printf("Edge, ");
857                                         }
858
859                                         if (gpe_event_info->
860                                             flags & ACPI_GPE_CAN_WAKE) {
861                                                 acpi_os_printf("CanWake, ");
862                                         } else {
863                                                 acpi_os_printf("RunOnly, ");
864                                         }
865
866                                         switch (ACPI_GPE_DISPATCH_TYPE
867                                                 (gpe_event_info->flags)) {
868                                         case ACPI_GPE_DISPATCH_NONE:
869
870                                                 acpi_os_printf("NotUsed");
871                                                 break;
872
873                                         case ACPI_GPE_DISPATCH_METHOD:
874
875                                                 acpi_os_printf("Method");
876                                                 break;
877
878                                         case ACPI_GPE_DISPATCH_HANDLER:
879
880                                                 acpi_os_printf("Handler");
881                                                 break;
882
883                                         case ACPI_GPE_DISPATCH_NOTIFY:
884
885                                                 count = 0;
886                                                 notify =
887                                                     gpe_event_info->dispatch.
888                                                     notify_list;
889                                                 while (notify) {
890                                                         count++;
891                                                         notify = notify->next;
892                                                 }
893
894                                                 acpi_os_printf
895                                                     ("Implicit Notify on %u devices",
896                                                      count);
897                                                 break;
898
899                                         case ACPI_GPE_DISPATCH_RAW_HANDLER:
900
901                                                 acpi_os_printf("RawHandler");
902                                                 break;
903
904                                         default:
905
906                                                 acpi_os_printf("UNKNOWN: %X",
907                                                                ACPI_GPE_DISPATCH_TYPE
908                                                                (gpe_event_info->
909                                                                 flags));
910                                                 break;
911                                         }
912
913                                         acpi_os_printf(")\n");
914                                 }
915                         }
916
917                         block++;
918                         gpe_block = gpe_block->next;
919                 }
920
921                 gpe_xrupt_info = gpe_xrupt_info->next;
922         }
923 }
924 #endif                          /* !ACPI_REDUCED_HARDWARE */
925
926 /*******************************************************************************
927  *
928  * FUNCTION:    acpi_db_display_handlers
929  *
930  * PARAMETERS:  None
931  *
932  * RETURN:      None
933  *
934  * DESCRIPTION: Display the currently installed global handlers
935  *
936  ******************************************************************************/
937
938 void acpi_db_display_handlers(void)
939 {
940         union acpi_operand_object *obj_desc;
941         union acpi_operand_object *handler_obj;
942         acpi_adr_space_type space_id;
943         u32 i;
944
945         /* Operation region handlers */
946
947         acpi_os_printf("\nOperation Region Handlers at the namespace root:\n");
948
949         obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node);
950         if (obj_desc) {
951                 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_space_id_list); i++) {
952                         space_id = acpi_gbl_space_id_list[i];
953
954                         acpi_os_printf(ACPI_PREDEFINED_PREFIX,
955                                        acpi_ut_get_region_name((u8)space_id),
956                                        space_id);
957
958                         handler_obj =
959                             acpi_ev_find_region_handler(space_id,
960                                                         obj_desc->common_notify.
961                                                         handler);
962                         if (handler_obj) {
963                                 acpi_os_printf(ACPI_HANDLER_PRESENT_STRING,
964                                                (handler_obj->address_space.
965                                                 handler_flags &
966                                                 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
967                                                ? "Default" : "User",
968                                                handler_obj->address_space.
969                                                handler);
970
971                                 goto found_handler;
972                         }
973
974                         /* There is no handler for this space_id */
975
976                         acpi_os_printf("None\n");
977
978 found_handler:          ;
979                 }
980
981                 /* Find all handlers for user-defined space_IDs */
982
983                 handler_obj = obj_desc->common_notify.handler;
984                 while (handler_obj) {
985                         if (handler_obj->address_space.space_id >=
986                             ACPI_USER_REGION_BEGIN) {
987                                 acpi_os_printf(ACPI_PREDEFINED_PREFIX,
988                                                "User-defined ID",
989                                                handler_obj->address_space.
990                                                space_id);
991                                 acpi_os_printf(ACPI_HANDLER_PRESENT_STRING,
992                                                (handler_obj->address_space.
993                                                 handler_flags &
994                                                 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
995                                                ? "Default" : "User",
996                                                handler_obj->address_space.
997                                                handler);
998                         }
999
1000                         handler_obj = handler_obj->address_space.next;
1001                 }
1002         }
1003 #if (!ACPI_REDUCED_HARDWARE)
1004
1005         /* Fixed event handlers */
1006
1007         acpi_os_printf("\nFixed Event Handlers:\n");
1008
1009         for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
1010                 acpi_os_printf(ACPI_PREDEFINED_PREFIX,
1011                                acpi_ut_get_event_name(i), i);
1012                 if (acpi_gbl_fixed_event_handlers[i].handler) {
1013                         acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, "User",
1014                                        acpi_gbl_fixed_event_handlers[i].
1015                                        handler);
1016                 } else {
1017                         acpi_os_printf(ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1018                 }
1019         }
1020
1021 #endif                          /* !ACPI_REDUCED_HARDWARE */
1022
1023         /* Miscellaneous global handlers */
1024
1025         acpi_os_printf("\nMiscellaneous Global Handlers:\n");
1026
1027         for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_handler_list); i++) {
1028                 acpi_os_printf(ACPI_HANDLER_NAME_STRING,
1029                                acpi_gbl_handler_list[i].name);
1030
1031                 if (acpi_gbl_handler_list[i].handler) {
1032                         acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, "User",
1033                                        acpi_gbl_handler_list[i].handler);
1034                 } else {
1035                         acpi_os_printf(ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1036                 }
1037         }
1038
1039         /* Other handlers that are installed throughout the namespace */
1040
1041         acpi_os_printf("\nOperation Region Handlers for specific devices:\n");
1042
1043         (void)acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1044                                   ACPI_UINT32_MAX,
1045                                   acpi_db_display_non_root_handlers, NULL, NULL,
1046                                   NULL);
1047 }
1048
1049 /*******************************************************************************
1050  *
1051  * FUNCTION:    acpi_db_display_non_root_handlers
1052  *
1053  * PARAMETERS:  acpi_walk_callback
1054  *
1055  * RETURN:      Status
1056  *
1057  * DESCRIPTION: Display information about all handlers installed for a
1058  *              device object.
1059  *
1060  ******************************************************************************/
1061
1062 static acpi_status
1063 acpi_db_display_non_root_handlers(acpi_handle obj_handle,
1064                                   u32 nesting_level,
1065                                   void *context, void **return_value)
1066 {
1067         struct acpi_namespace_node *node =
1068             ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle);
1069         union acpi_operand_object *obj_desc;
1070         union acpi_operand_object *handler_obj;
1071         char *pathname;
1072
1073         obj_desc = acpi_ns_get_attached_object(node);
1074         if (!obj_desc) {
1075                 return (AE_OK);
1076         }
1077
1078         pathname = acpi_ns_get_normalized_pathname(node, TRUE);
1079         if (!pathname) {
1080                 return (AE_OK);
1081         }
1082
1083         /* Display all handlers associated with this device */
1084
1085         handler_obj = obj_desc->common_notify.handler;
1086         while (handler_obj) {
1087                 acpi_os_printf(ACPI_PREDEFINED_PREFIX,
1088                                acpi_ut_get_region_name((u8)handler_obj->
1089                                                        address_space.space_id),
1090                                handler_obj->address_space.space_id);
1091
1092                 acpi_os_printf(ACPI_HANDLER_PRESENT_STRING2,
1093                                (handler_obj->address_space.handler_flags &
1094                                 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default"
1095                                : "User", handler_obj->address_space.handler);
1096
1097                 acpi_os_printf(" Device Name: %s (%p)\n", pathname, node);
1098
1099                 handler_obj = handler_obj->address_space.next;
1100         }
1101
1102         ACPI_FREE(pathname);
1103         return (AE_OK);
1104 }