These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / acpi / acpica / dbdisply.c
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
54 ACPI_MODULE_NAME("dbdisply")
55
56 /* Local prototypes */
57 static void acpi_db_dump_parser_descriptor(union acpi_parse_object *op);
58
59 static void *acpi_db_get_pointer(void *target);
60
61 static acpi_status
62 acpi_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
78 static 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
95 typedef struct acpi_handler_info {
96         void *handler;
97         char *name;
98
99 } acpi_handler_info;
100
101 static 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
121 static 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
143 static 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
174 void 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
303 dump_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
356 void 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
458 void 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
483 void 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
508 void 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
565 void 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
599 void 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
677 void
678 acpi_db_display_result_object(union acpi_operand_object *obj_desc,
679                               struct acpi_walk_state *walk_state)
680 {
681
682         /* Only display if single stepping */
683
684         if (!acpi_gbl_cm_single_step) {
685                 return;
686         }
687
688         acpi_os_printf("ResultObj: ");
689         acpi_db_display_internal_object(obj_desc, walk_state);
690         acpi_os_printf("\n");
691 }
692
693 /*******************************************************************************
694  *
695  * FUNCTION:    acpi_db_display_argument_object
696  *
697  * PARAMETERS:  obj_desc        - Object to be displayed
698  *              walk_state      - Current walk state
699  *
700  * RETURN:      None
701  *
702  * DESCRIPTION: Display the result of an AML opcode
703  *
704  ******************************************************************************/
705
706 void
707 acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
708                                 struct acpi_walk_state *walk_state)
709 {
710
711         if (!acpi_gbl_cm_single_step) {
712                 return;
713         }
714
715         acpi_os_printf("ArgObj:  ");
716         acpi_db_display_internal_object(obj_desc, walk_state);
717 }
718
719 #if (!ACPI_REDUCED_HARDWARE)
720 /*******************************************************************************
721  *
722  * FUNCTION:    acpi_db_display_gpes
723  *
724  * PARAMETERS:  None
725  *
726  * RETURN:      None
727  *
728  * DESCRIPTION: Display the current GPE structures
729  *
730  ******************************************************************************/
731
732 void acpi_db_display_gpes(void)
733 {
734         struct acpi_gpe_block_info *gpe_block;
735         struct acpi_gpe_xrupt_info *gpe_xrupt_info;
736         struct acpi_gpe_event_info *gpe_event_info;
737         struct acpi_gpe_register_info *gpe_register_info;
738         char *gpe_type;
739         struct acpi_gpe_notify_info *notify;
740         u32 gpe_index;
741         u32 block = 0;
742         u32 i;
743         u32 j;
744         u32 count;
745         char buffer[80];
746         struct acpi_buffer ret_buf;
747         acpi_status status;
748
749         ret_buf.length = sizeof(buffer);
750         ret_buf.pointer = buffer;
751
752         block = 0;
753
754         /* Walk the GPE lists */
755
756         gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
757         while (gpe_xrupt_info) {
758                 gpe_block = gpe_xrupt_info->gpe_block_list_head;
759                 while (gpe_block) {
760                         status = acpi_get_name(gpe_block->node,
761                                                ACPI_FULL_PATHNAME_NO_TRAILING,
762                                                &ret_buf);
763                         if (ACPI_FAILURE(status)) {
764                                 acpi_os_printf
765                                     ("Could not convert name to pathname\n");
766                         }
767
768                         if (gpe_block->node == acpi_gbl_fadt_gpe_device) {
769                                 gpe_type = "FADT-defined GPE block";
770                         } else {
771                                 gpe_type = "GPE Block Device";
772                         }
773
774                         acpi_os_printf
775                             ("\nBlock %u - Info %p  DeviceNode %p [%s] - %s\n",
776                              block, gpe_block, gpe_block->node, buffer,
777                              gpe_type);
778
779                         acpi_os_printf("    Registers:    %u (%u GPEs)\n",
780                                        gpe_block->register_count,
781                                        gpe_block->gpe_count);
782
783                         acpi_os_printf
784                             ("    GPE range:    0x%X to 0x%X on interrupt %u\n",
785                              gpe_block->block_base_number,
786                              gpe_block->block_base_number +
787                              (gpe_block->gpe_count - 1),
788                              gpe_xrupt_info->interrupt_number);
789
790                         acpi_os_printf
791                             ("    RegisterInfo: %p  Status %8.8X%8.8X Enable %8.8X%8.8X\n",
792                              gpe_block->register_info,
793                              ACPI_FORMAT_UINT64(gpe_block->register_info->
794                                                 status_address.address),
795                              ACPI_FORMAT_UINT64(gpe_block->register_info->
796                                                 enable_address.address));
797
798                         acpi_os_printf("  EventInfo:    %p\n",
799                                        gpe_block->event_info);
800
801                         /* Examine each GPE Register within the block */
802
803                         for (i = 0; i < gpe_block->register_count; i++) {
804                                 gpe_register_info =
805                                     &gpe_block->register_info[i];
806
807                                 acpi_os_printf("    Reg %u: (GPE %.2X-%.2X)  "
808                                                "RunEnable %2.2X WakeEnable %2.2X"
809                                                " Status %8.8X%8.8X Enable %8.8X%8.8X\n",
810                                                i,
811                                                gpe_register_info->
812                                                base_gpe_number,
813                                                gpe_register_info->
814                                                base_gpe_number +
815                                                (ACPI_GPE_REGISTER_WIDTH - 1),
816                                                gpe_register_info->
817                                                enable_for_run,
818                                                gpe_register_info->
819                                                enable_for_wake,
820                                                ACPI_FORMAT_UINT64
821                                                (gpe_register_info->
822                                                 status_address.address),
823                                                ACPI_FORMAT_UINT64
824                                                (gpe_register_info->
825                                                 enable_address.address));
826
827                                 /* Now look at the individual GPEs in this byte register */
828
829                                 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
830                                         gpe_index =
831                                             (i * ACPI_GPE_REGISTER_WIDTH) + j;
832                                         gpe_event_info =
833                                             &gpe_block->event_info[gpe_index];
834
835                                         if (ACPI_GPE_DISPATCH_TYPE
836                                             (gpe_event_info->flags) ==
837                                             ACPI_GPE_DISPATCH_NONE) {
838
839                                                 /* This GPE is not used (no method or handler), ignore it */
840
841                                                 continue;
842                                         }
843
844                                         acpi_os_printf
845                                             ("        GPE %.2X: %p  RunRefs %2.2X Flags %2.2X (",
846                                              gpe_block->block_base_number +
847                                              gpe_index, gpe_event_info,
848                                              gpe_event_info->runtime_count,
849                                              gpe_event_info->flags);
850
851                                         /* Decode the flags byte */
852
853                                         if (gpe_event_info->
854                                             flags & ACPI_GPE_LEVEL_TRIGGERED) {
855                                                 acpi_os_printf("Level, ");
856                                         } else {
857                                                 acpi_os_printf("Edge, ");
858                                         }
859
860                                         if (gpe_event_info->
861                                             flags & ACPI_GPE_CAN_WAKE) {
862                                                 acpi_os_printf("CanWake, ");
863                                         } else {
864                                                 acpi_os_printf("RunOnly, ");
865                                         }
866
867                                         switch (ACPI_GPE_DISPATCH_TYPE
868                                                 (gpe_event_info->flags)) {
869                                         case ACPI_GPE_DISPATCH_NONE:
870
871                                                 acpi_os_printf("NotUsed");
872                                                 break;
873
874                                         case ACPI_GPE_DISPATCH_METHOD:
875
876                                                 acpi_os_printf("Method");
877                                                 break;
878
879                                         case ACPI_GPE_DISPATCH_HANDLER:
880
881                                                 acpi_os_printf("Handler");
882                                                 break;
883
884                                         case ACPI_GPE_DISPATCH_NOTIFY:
885
886                                                 count = 0;
887                                                 notify =
888                                                     gpe_event_info->dispatch.
889                                                     notify_list;
890                                                 while (notify) {
891                                                         count++;
892                                                         notify = notify->next;
893                                                 }
894
895                                                 acpi_os_printf
896                                                     ("Implicit Notify on %u devices",
897                                                      count);
898                                                 break;
899
900                                         case ACPI_GPE_DISPATCH_RAW_HANDLER:
901
902                                                 acpi_os_printf("RawHandler");
903                                                 break;
904
905                                         default:
906
907                                                 acpi_os_printf("UNKNOWN: %X",
908                                                                ACPI_GPE_DISPATCH_TYPE
909                                                                (gpe_event_info->
910                                                                 flags));
911                                                 break;
912                                         }
913
914                                         acpi_os_printf(")\n");
915                                 }
916                         }
917
918                         block++;
919                         gpe_block = gpe_block->next;
920                 }
921
922                 gpe_xrupt_info = gpe_xrupt_info->next;
923         }
924 }
925 #endif                          /* !ACPI_REDUCED_HARDWARE */
926
927 /*******************************************************************************
928  *
929  * FUNCTION:    acpi_db_display_handlers
930  *
931  * PARAMETERS:  None
932  *
933  * RETURN:      None
934  *
935  * DESCRIPTION: Display the currently installed global handlers
936  *
937  ******************************************************************************/
938
939 void acpi_db_display_handlers(void)
940 {
941         union acpi_operand_object *obj_desc;
942         union acpi_operand_object *handler_obj;
943         acpi_adr_space_type space_id;
944         u32 i;
945
946         /* Operation region handlers */
947
948         acpi_os_printf("\nOperation Region Handlers at the namespace root:\n");
949
950         obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node);
951         if (obj_desc) {
952                 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_space_id_list); i++) {
953                         space_id = acpi_gbl_space_id_list[i];
954                         handler_obj = obj_desc->device.handler;
955
956                         acpi_os_printf(ACPI_PREDEFINED_PREFIX,
957                                        acpi_ut_get_region_name((u8)space_id),
958                                        space_id);
959
960                         while (handler_obj) {
961                                 if (acpi_gbl_space_id_list[i] ==
962                                     handler_obj->address_space.space_id) {
963                                         acpi_os_printf
964                                             (ACPI_HANDLER_PRESENT_STRING,
965                                              (handler_obj->address_space.
966                                               handler_flags &
967                                               ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
968                                              ? "Default" : "User",
969                                              handler_obj->address_space.
970                                              handler);
971
972                                         goto found_handler;
973                                 }
974
975                                 handler_obj = handler_obj->address_space.next;
976                         }
977
978                         /* There is no handler for this space_id */
979
980                         acpi_os_printf("None\n");
981
982 found_handler:          ;
983                 }
984
985                 /* Find all handlers for user-defined space_IDs */
986
987                 handler_obj = obj_desc->device.handler;
988                 while (handler_obj) {
989                         if (handler_obj->address_space.space_id >=
990                             ACPI_USER_REGION_BEGIN) {
991                                 acpi_os_printf(ACPI_PREDEFINED_PREFIX,
992                                                "User-defined ID",
993                                                handler_obj->address_space.
994                                                space_id);
995                                 acpi_os_printf(ACPI_HANDLER_PRESENT_STRING,
996                                                (handler_obj->address_space.
997                                                 handler_flags &
998                                                 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
999                                                ? "Default" : "User",
1000                                                handler_obj->address_space.
1001                                                handler);
1002                         }
1003
1004                         handler_obj = handler_obj->address_space.next;
1005                 }
1006         }
1007 #if (!ACPI_REDUCED_HARDWARE)
1008
1009         /* Fixed event handlers */
1010
1011         acpi_os_printf("\nFixed Event Handlers:\n");
1012
1013         for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
1014                 acpi_os_printf(ACPI_PREDEFINED_PREFIX,
1015                                acpi_ut_get_event_name(i), i);
1016                 if (acpi_gbl_fixed_event_handlers[i].handler) {
1017                         acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, "User",
1018                                        acpi_gbl_fixed_event_handlers[i].
1019                                        handler);
1020                 } else {
1021                         acpi_os_printf(ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1022                 }
1023         }
1024
1025 #endif                          /* !ACPI_REDUCED_HARDWARE */
1026
1027         /* Miscellaneous global handlers */
1028
1029         acpi_os_printf("\nMiscellaneous Global Handlers:\n");
1030
1031         for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_handler_list); i++) {
1032                 acpi_os_printf(ACPI_HANDLER_NAME_STRING,
1033                                acpi_gbl_handler_list[i].name);
1034
1035                 if (acpi_gbl_handler_list[i].handler) {
1036                         acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, "User",
1037                                        acpi_gbl_handler_list[i].handler);
1038                 } else {
1039                         acpi_os_printf(ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1040                 }
1041         }
1042
1043         /* Other handlers that are installed throughout the namespace */
1044
1045         acpi_os_printf("\nOperation Region Handlers for specific devices:\n");
1046
1047         (void)acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1048                                   ACPI_UINT32_MAX,
1049                                   acpi_db_display_non_root_handlers, NULL, NULL,
1050                                   NULL);
1051 }
1052
1053 /*******************************************************************************
1054  *
1055  * FUNCTION:    acpi_db_display_non_root_handlers
1056  *
1057  * PARAMETERS:  acpi_walk_callback
1058  *
1059  * RETURN:      Status
1060  *
1061  * DESCRIPTION: Display information about all handlers installed for a
1062  *              device object.
1063  *
1064  ******************************************************************************/
1065
1066 static acpi_status
1067 acpi_db_display_non_root_handlers(acpi_handle obj_handle,
1068                                   u32 nesting_level,
1069                                   void *context, void **return_value)
1070 {
1071         struct acpi_namespace_node *node =
1072             ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle);
1073         union acpi_operand_object *obj_desc;
1074         union acpi_operand_object *handler_obj;
1075         char *pathname;
1076
1077         obj_desc = acpi_ns_get_attached_object(node);
1078         if (!obj_desc) {
1079                 return (AE_OK);
1080         }
1081
1082         pathname = acpi_ns_get_external_pathname(node);
1083         if (!pathname) {
1084                 return (AE_OK);
1085         }
1086
1087         /* Display all handlers associated with this device */
1088
1089         handler_obj = obj_desc->device.handler;
1090         while (handler_obj) {
1091                 acpi_os_printf(ACPI_PREDEFINED_PREFIX,
1092                                acpi_ut_get_region_name((u8)handler_obj->
1093                                                        address_space.space_id),
1094                                handler_obj->address_space.space_id);
1095
1096                 acpi_os_printf(ACPI_HANDLER_PRESENT_STRING2,
1097                                (handler_obj->address_space.handler_flags &
1098                                 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default"
1099                                : "User", handler_obj->address_space.handler);
1100
1101                 acpi_os_printf(" Device Name: %s (%p)\n", pathname, node);
1102
1103                 handler_obj = handler_obj->address_space.next;
1104         }
1105
1106         ACPI_FREE(pathname);
1107         return (AE_OK);
1108 }