1 /*******************************************************************************
3 * Module Name: rsdump - AML debugger support for resource structures.
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2015, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
44 #include <acpi/acpi.h>
48 #define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME("rsdump")
52 * All functions in this module are used by the AML Debugger only
54 #if defined(ACPI_DEBUGGER)
55 /* Local prototypes */
56 static void acpi_rs_out_string(char *title
, char *value
);
58 static void acpi_rs_out_integer8(char *title
, u8 value
);
60 static void acpi_rs_out_integer16(char *title
, u16 value
);
62 static void acpi_rs_out_integer32(char *title
, u32 value
);
64 static void acpi_rs_out_integer64(char *title
, u64 value
);
66 static void acpi_rs_out_title(char *title
);
68 static void acpi_rs_dump_byte_list(u16 length
, u8
*data
);
70 static void acpi_rs_dump_word_list(u16 length
, u16
*data
);
72 static void acpi_rs_dump_dword_list(u8 length
, u32
*data
);
74 static void acpi_rs_dump_short_byte_list(u8 length
, u8
*data
);
77 acpi_rs_dump_resource_source(struct acpi_resource_source
*resource_source
);
79 static void acpi_rs_dump_address_common(union acpi_resource_data
*resource
);
82 acpi_rs_dump_descriptor(void *resource
, struct acpi_rsdump_info
*table
);
84 /*******************************************************************************
86 * FUNCTION: acpi_rs_dump_resource_list
88 * PARAMETERS: resource_list - Pointer to a resource descriptor list
92 * DESCRIPTION: Dispatches the structure to the correct dump routine.
94 ******************************************************************************/
96 void acpi_rs_dump_resource_list(struct acpi_resource
*resource_list
)
101 ACPI_FUNCTION_ENTRY();
103 /* Check if debug output enabled */
105 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES
, _COMPONENT
)) {
109 /* Walk list and dump all resource descriptors (END_TAG terminates) */
112 acpi_os_printf("\n[%02X] ", count
);
115 /* Validate Type before dispatch */
117 type
= resource_list
->type
;
118 if (type
> ACPI_RESOURCE_TYPE_MAX
) {
120 ("Invalid descriptor type (%X) in resource list\n",
121 resource_list
->type
);
125 /* Sanity check the length. It must not be zero, or we loop forever */
127 if (!resource_list
->length
) {
129 ("Invalid zero length descriptor in resource list\n");
133 /* Dump the resource descriptor */
135 if (type
== ACPI_RESOURCE_TYPE_SERIAL_BUS
) {
136 acpi_rs_dump_descriptor(&resource_list
->data
,
137 acpi_gbl_dump_serial_bus_dispatch
138 [resource_list
->data
.
139 common_serial_bus
.type
]);
141 acpi_rs_dump_descriptor(&resource_list
->data
,
142 acpi_gbl_dump_resource_dispatch
146 /* Point to the next resource structure */
148 resource_list
= ACPI_NEXT_RESOURCE(resource_list
);
150 /* Exit when END_TAG descriptor is reached */
152 } while (type
!= ACPI_RESOURCE_TYPE_END_TAG
);
155 /*******************************************************************************
157 * FUNCTION: acpi_rs_dump_irq_list
159 * PARAMETERS: route_table - Pointer to the routing table to dump.
163 * DESCRIPTION: Print IRQ routing table
165 ******************************************************************************/
167 void acpi_rs_dump_irq_list(u8
*route_table
)
169 struct acpi_pci_routing_table
*prt_element
;
172 ACPI_FUNCTION_ENTRY();
174 /* Check if debug output enabled */
176 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES
, _COMPONENT
)) {
180 prt_element
= ACPI_CAST_PTR(struct acpi_pci_routing_table
, route_table
);
182 /* Dump all table elements, Exit on zero length element */
184 for (count
= 0; prt_element
->length
; count
++) {
185 acpi_os_printf("\n[%02X] PCI IRQ Routing Table Package\n",
187 acpi_rs_dump_descriptor(prt_element
, acpi_rs_dump_prt
);
189 prt_element
= ACPI_ADD_PTR(struct acpi_pci_routing_table
,
190 prt_element
, prt_element
->length
);
194 /*******************************************************************************
196 * FUNCTION: acpi_rs_dump_descriptor
198 * PARAMETERS: resource - Buffer containing the resource
199 * table - Table entry to decode the resource
203 * DESCRIPTION: Dump a resource descriptor based on a dump table entry.
205 ******************************************************************************/
208 acpi_rs_dump_descriptor(void *resource
, struct acpi_rsdump_info
*table
)
215 /* First table entry must contain the table length (# of table entries) */
217 count
= table
->offset
;
220 previous_target
= target
;
221 target
= ACPI_ADD_PTR(u8
, resource
, table
->offset
);
224 switch (table
->opcode
) {
227 * Optional resource title
230 acpi_os_printf("%s Resource\n", name
);
236 case ACPI_RSD_LITERAL
:
238 acpi_rs_out_string(name
,
239 ACPI_CAST_PTR(char, table
->pointer
));
242 case ACPI_RSD_STRING
:
244 acpi_rs_out_string(name
, ACPI_CAST_PTR(char, target
));
247 /* Data items, 8/16/32/64 bit */
251 if (table
->pointer
) {
252 acpi_rs_out_string(name
, ACPI_CAST_PTR(char,
257 acpi_rs_out_integer8(name
, ACPI_GET8(target
));
261 case ACPI_RSD_UINT16
:
263 acpi_rs_out_integer16(name
, ACPI_GET16(target
));
266 case ACPI_RSD_UINT32
:
268 acpi_rs_out_integer32(name
, ACPI_GET32(target
));
271 case ACPI_RSD_UINT64
:
273 acpi_rs_out_integer64(name
, ACPI_GET64(target
));
276 /* Flags: 1-bit and 2-bit flags supported */
278 case ACPI_RSD_1BITFLAG
:
280 acpi_rs_out_string(name
, ACPI_CAST_PTR(char,
286 case ACPI_RSD_2BITFLAG
:
288 acpi_rs_out_string(name
, ACPI_CAST_PTR(char,
294 case ACPI_RSD_3BITFLAG
:
296 acpi_rs_out_string(name
, ACPI_CAST_PTR(char,
302 case ACPI_RSD_SHORTLIST
:
304 * Short byte list (single line output) for DMA and IRQ resources
305 * Note: The list length is obtained from the previous table entry
307 if (previous_target
) {
308 acpi_rs_out_title(name
);
309 acpi_rs_dump_short_byte_list(*previous_target
,
314 case ACPI_RSD_SHORTLISTX
:
316 * Short byte list (single line output) for GPIO vendor data
317 * Note: The list length is obtained from the previous table entry
319 if (previous_target
) {
320 acpi_rs_out_title(name
);
321 acpi_rs_dump_short_byte_list(*previous_target
,
323 (ACPI_CAST_INDIRECT_PTR
328 case ACPI_RSD_LONGLIST
:
330 * Long byte list for Vendor resource data
331 * Note: The list length is obtained from the previous table entry
333 if (previous_target
) {
334 acpi_rs_dump_byte_list(ACPI_GET16
340 case ACPI_RSD_DWORDLIST
:
342 * Dword list for Extended Interrupt resources
343 * Note: The list length is obtained from the previous table entry
345 if (previous_target
) {
346 acpi_rs_dump_dword_list(*previous_target
,
352 case ACPI_RSD_WORDLIST
:
354 * Word list for GPIO Pin Table
355 * Note: The list length is obtained from the previous table entry
357 if (previous_target
) {
358 acpi_rs_dump_word_list(*previous_target
,
359 *(ACPI_CAST_INDIRECT_PTR
364 case ACPI_RSD_ADDRESS
:
366 * Common flags for all Address resources
368 acpi_rs_dump_address_common(ACPI_CAST_PTR
369 (union acpi_resource_data
,
373 case ACPI_RSD_SOURCE
:
375 * Optional resource_source for Address resources
377 acpi_rs_dump_resource_source(ACPI_CAST_PTR
379 acpi_resource_source
,
385 acpi_os_printf("**** Invalid table opcode [%X] ****\n",
395 /*******************************************************************************
397 * FUNCTION: acpi_rs_dump_resource_source
399 * PARAMETERS: resource_source - Pointer to a Resource Source struct
403 * DESCRIPTION: Common routine for dumping the optional resource_source and the
404 * corresponding resource_source_index.
406 ******************************************************************************/
409 acpi_rs_dump_resource_source(struct acpi_resource_source
*resource_source
)
411 ACPI_FUNCTION_ENTRY();
413 if (resource_source
->index
== 0xFF) {
417 acpi_rs_out_integer8("Resource Source Index", resource_source
->index
);
419 acpi_rs_out_string("Resource Source",
420 resource_source
->string_ptr
?
421 resource_source
->string_ptr
: "[Not Specified]");
424 /*******************************************************************************
426 * FUNCTION: acpi_rs_dump_address_common
428 * PARAMETERS: resource - Pointer to an internal resource descriptor
432 * DESCRIPTION: Dump the fields that are common to all Address resource
435 ******************************************************************************/
437 static void acpi_rs_dump_address_common(union acpi_resource_data
*resource
)
439 ACPI_FUNCTION_ENTRY();
441 /* Decode the type-specific flags */
443 switch (resource
->address
.resource_type
) {
444 case ACPI_MEMORY_RANGE
:
446 acpi_rs_dump_descriptor(resource
, acpi_rs_dump_memory_flags
);
451 acpi_rs_dump_descriptor(resource
, acpi_rs_dump_io_flags
);
454 case ACPI_BUS_NUMBER_RANGE
:
456 acpi_rs_out_string("Resource Type", "Bus Number Range");
461 acpi_rs_out_integer8("Resource Type",
462 (u8
) resource
->address
.resource_type
);
466 /* Decode the general flags */
468 acpi_rs_dump_descriptor(resource
, acpi_rs_dump_general_flags
);
471 /*******************************************************************************
473 * FUNCTION: acpi_rs_out*
475 * PARAMETERS: title - Name of the resource field
476 * value - Value of the resource field
480 * DESCRIPTION: Miscellaneous helper functions to consistently format the
481 * output of the resource dump routines
483 ******************************************************************************/
485 static void acpi_rs_out_string(char *title
, char *value
)
487 acpi_os_printf("%27s : %s", title
, value
);
489 acpi_os_printf("[NULL NAMESTRING]");
491 acpi_os_printf("\n");
494 static void acpi_rs_out_integer8(char *title
, u8 value
)
496 acpi_os_printf("%27s : %2.2X\n", title
, value
);
499 static void acpi_rs_out_integer16(char *title
, u16 value
)
501 acpi_os_printf("%27s : %4.4X\n", title
, value
);
504 static void acpi_rs_out_integer32(char *title
, u32 value
)
506 acpi_os_printf("%27s : %8.8X\n", title
, value
);
509 static void acpi_rs_out_integer64(char *title
, u64 value
)
511 acpi_os_printf("%27s : %8.8X%8.8X\n", title
, ACPI_FORMAT_UINT64(value
));
514 static void acpi_rs_out_title(char *title
)
516 acpi_os_printf("%27s : ", title
);
519 /*******************************************************************************
521 * FUNCTION: acpi_rs_dump*List
523 * PARAMETERS: length - Number of elements in the list
524 * data - Start of the list
528 * DESCRIPTION: Miscellaneous functions to dump lists of raw data
530 ******************************************************************************/
532 static void acpi_rs_dump_byte_list(u16 length
, u8
* data
)
536 for (i
= 0; i
< length
; i
++) {
537 acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i
, data
[i
]);
541 static void acpi_rs_dump_short_byte_list(u8 length
, u8
* data
)
545 for (i
= 0; i
< length
; i
++) {
546 acpi_os_printf("%X ", data
[i
]);
548 acpi_os_printf("\n");
551 static void acpi_rs_dump_dword_list(u8 length
, u32
* data
)
555 for (i
= 0; i
< length
; i
++) {
556 acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i
, data
[i
]);
560 static void acpi_rs_dump_word_list(u16 length
, u16
*data
)
564 for (i
= 0; i
< length
; i
++) {
565 acpi_os_printf("%25s%2.2X : %4.4X\n", "Word", i
, data
[i
]);