1 /*******************************************************************************
3 * Module Name: rsdump - AML debugger support for resource structures.
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2016, 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.
48 #define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rsdump")
52 * All functions in this module are used by the AML Debugger only
55 /* Local prototypes */
102 AcpiRsDumpShortByteList (
107 AcpiRsDumpResourceSource (
108 ACPI_RESOURCE_SOURCE
*ResourceSource
);
111 AcpiRsDumpAddressCommon (
112 ACPI_RESOURCE_DATA
*Resource
);
115 AcpiRsDumpDescriptor (
117 ACPI_RSDUMP_INFO
*Table
);
120 /*******************************************************************************
122 * FUNCTION: AcpiRsDumpResourceList
124 * PARAMETERS: ResourceList - Pointer to a resource descriptor list
128 * DESCRIPTION: Dispatches the structure to the correct dump routine.
130 ******************************************************************************/
133 AcpiRsDumpResourceList (
134 ACPI_RESOURCE
*ResourceList
)
140 ACPI_FUNCTION_ENTRY ();
143 /* Check if debug output enabled */
145 if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_RESOURCES
, _COMPONENT
))
150 /* Walk list and dump all resource descriptors (END_TAG terminates) */
154 AcpiOsPrintf ("\n[%02X] ", Count
);
157 /* Validate Type before dispatch */
159 Type
= ResourceList
->Type
;
160 if (Type
> ACPI_RESOURCE_TYPE_MAX
)
163 "Invalid descriptor type (%X) in resource list\n",
168 /* Sanity check the length. It must not be zero, or we loop forever */
170 if (!ResourceList
->Length
)
173 "Invalid zero length descriptor in resource list\n");
177 /* Dump the resource descriptor */
179 if (Type
== ACPI_RESOURCE_TYPE_SERIAL_BUS
)
181 AcpiRsDumpDescriptor (&ResourceList
->Data
,
182 AcpiGbl_DumpSerialBusDispatch
[
183 ResourceList
->Data
.CommonSerialBus
.Type
]);
187 AcpiRsDumpDescriptor (&ResourceList
->Data
,
188 AcpiGbl_DumpResourceDispatch
[Type
]);
191 /* Point to the next resource structure */
193 ResourceList
= ACPI_NEXT_RESOURCE (ResourceList
);
195 /* Exit when END_TAG descriptor is reached */
197 } while (Type
!= ACPI_RESOURCE_TYPE_END_TAG
);
201 /*******************************************************************************
203 * FUNCTION: AcpiRsDumpIrqList
205 * PARAMETERS: RouteTable - Pointer to the routing table to dump.
209 * DESCRIPTION: Print IRQ routing table
211 ******************************************************************************/
217 ACPI_PCI_ROUTING_TABLE
*PrtElement
;
221 ACPI_FUNCTION_ENTRY ();
224 /* Check if debug output enabled */
226 if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_RESOURCES
, _COMPONENT
))
231 PrtElement
= ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE
, RouteTable
);
233 /* Dump all table elements, Exit on zero length element */
235 for (Count
= 0; PrtElement
->Length
; Count
++)
237 AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count
);
238 AcpiRsDumpDescriptor (PrtElement
, AcpiRsDumpPrt
);
240 PrtElement
= ACPI_ADD_PTR (ACPI_PCI_ROUTING_TABLE
,
241 PrtElement
, PrtElement
->Length
);
246 /*******************************************************************************
248 * FUNCTION: AcpiRsDumpDescriptor
250 * PARAMETERS: Resource - Buffer containing the resource
251 * Table - Table entry to decode the resource
255 * DESCRIPTION: Dump a resource descriptor based on a dump table entry.
257 ******************************************************************************/
260 AcpiRsDumpDescriptor (
262 ACPI_RSDUMP_INFO
*Table
)
264 UINT8
*Target
= NULL
;
265 UINT8
*PreviousTarget
;
270 /* First table entry must contain the table length (# of table entries) */
272 Count
= Table
->Offset
;
276 PreviousTarget
= Target
;
277 Target
= ACPI_ADD_PTR (UINT8
, Resource
, Table
->Offset
);
280 switch (Table
->Opcode
)
284 * Optional resource title
288 AcpiOsPrintf ("%s Resource\n", Name
);
294 case ACPI_RSD_LITERAL
:
296 AcpiRsOutString (Name
, ACPI_CAST_PTR (char, Table
->Pointer
));
299 case ACPI_RSD_STRING
:
301 AcpiRsOutString (Name
, ACPI_CAST_PTR (char, Target
));
304 /* Data items, 8/16/32/64 bit */
310 AcpiRsOutString (Name
, ACPI_CAST_PTR (char,
311 Table
->Pointer
[*Target
]));
315 AcpiRsOutInteger8 (Name
, ACPI_GET8 (Target
));
319 case ACPI_RSD_UINT16
:
321 AcpiRsOutInteger16 (Name
, ACPI_GET16 (Target
));
324 case ACPI_RSD_UINT32
:
326 AcpiRsOutInteger32 (Name
, ACPI_GET32 (Target
));
329 case ACPI_RSD_UINT64
:
331 AcpiRsOutInteger64 (Name
, ACPI_GET64 (Target
));
334 /* Flags: 1-bit and 2-bit flags supported */
336 case ACPI_RSD_1BITFLAG
:
338 AcpiRsOutString (Name
, ACPI_CAST_PTR (char,
339 Table
->Pointer
[*Target
& 0x01]));
342 case ACPI_RSD_2BITFLAG
:
344 AcpiRsOutString (Name
, ACPI_CAST_PTR (char,
345 Table
->Pointer
[*Target
& 0x03]));
348 case ACPI_RSD_3BITFLAG
:
350 AcpiRsOutString (Name
, ACPI_CAST_PTR (char,
351 Table
->Pointer
[*Target
& 0x07]));
354 case ACPI_RSD_SHORTLIST
:
356 * Short byte list (single line output) for DMA and IRQ resources
357 * Note: The list length is obtained from the previous table entry
361 AcpiRsOutTitle (Name
);
362 AcpiRsDumpShortByteList (*PreviousTarget
, Target
);
366 case ACPI_RSD_SHORTLISTX
:
368 * Short byte list (single line output) for GPIO vendor data
369 * Note: The list length is obtained from the previous table entry
373 AcpiRsOutTitle (Name
);
374 AcpiRsDumpShortByteList (*PreviousTarget
,
375 *(ACPI_CAST_INDIRECT_PTR (UINT8
, Target
)));
379 case ACPI_RSD_LONGLIST
:
381 * Long byte list for Vendor resource data
382 * Note: The list length is obtained from the previous table entry
386 AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget
), Target
);
390 case ACPI_RSD_DWORDLIST
:
392 * Dword list for Extended Interrupt resources
393 * Note: The list length is obtained from the previous table entry
397 AcpiRsDumpDwordList (*PreviousTarget
,
398 ACPI_CAST_PTR (UINT32
, Target
));
402 case ACPI_RSD_WORDLIST
:
404 * Word list for GPIO Pin Table
405 * Note: The list length is obtained from the previous table entry
409 AcpiRsDumpWordList (*PreviousTarget
,
410 *(ACPI_CAST_INDIRECT_PTR (UINT16
, Target
)));
414 case ACPI_RSD_ADDRESS
:
416 * Common flags for all Address resources
418 AcpiRsDumpAddressCommon (ACPI_CAST_PTR (
419 ACPI_RESOURCE_DATA
, Target
));
422 case ACPI_RSD_SOURCE
:
424 * Optional ResourceSource for Address resources
426 AcpiRsDumpResourceSource (ACPI_CAST_PTR (
427 ACPI_RESOURCE_SOURCE
, Target
));
432 AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
443 /*******************************************************************************
445 * FUNCTION: AcpiRsDumpResourceSource
447 * PARAMETERS: ResourceSource - Pointer to a Resource Source struct
451 * DESCRIPTION: Common routine for dumping the optional ResourceSource and the
452 * corresponding ResourceSourceIndex.
454 ******************************************************************************/
457 AcpiRsDumpResourceSource (
458 ACPI_RESOURCE_SOURCE
*ResourceSource
)
460 ACPI_FUNCTION_ENTRY ();
463 if (ResourceSource
->Index
== 0xFF)
468 AcpiRsOutInteger8 ("Resource Source Index",
469 ResourceSource
->Index
);
471 AcpiRsOutString ("Resource Source",
472 ResourceSource
->StringPtr
?
473 ResourceSource
->StringPtr
: "[Not Specified]");
477 /*******************************************************************************
479 * FUNCTION: AcpiRsDumpAddressCommon
481 * PARAMETERS: Resource - Pointer to an internal resource descriptor
485 * DESCRIPTION: Dump the fields that are common to all Address resource
488 ******************************************************************************/
491 AcpiRsDumpAddressCommon (
492 ACPI_RESOURCE_DATA
*Resource
)
494 ACPI_FUNCTION_ENTRY ();
497 /* Decode the type-specific flags */
499 switch (Resource
->Address
.ResourceType
)
501 case ACPI_MEMORY_RANGE
:
503 AcpiRsDumpDescriptor (Resource
, AcpiRsDumpMemoryFlags
);
508 AcpiRsDumpDescriptor (Resource
, AcpiRsDumpIoFlags
);
511 case ACPI_BUS_NUMBER_RANGE
:
513 AcpiRsOutString ("Resource Type", "Bus Number Range");
518 AcpiRsOutInteger8 ("Resource Type",
519 (UINT8
) Resource
->Address
.ResourceType
);
523 /* Decode the general flags */
525 AcpiRsDumpDescriptor (Resource
, AcpiRsDumpGeneralFlags
);
529 /*******************************************************************************
531 * FUNCTION: AcpiRsOut*
533 * PARAMETERS: Title - Name of the resource field
534 * Value - Value of the resource field
538 * DESCRIPTION: Miscellaneous helper functions to consistently format the
539 * output of the resource dump routines
541 ******************************************************************************/
549 AcpiOsPrintf ("%27s : %s", Title
, Value
);
552 AcpiOsPrintf ("[NULL NAMESTRING]");
562 AcpiOsPrintf ("%27s : %2.2X\n", Title
, Value
);
571 AcpiOsPrintf ("%27s : %4.4X\n", Title
, Value
);
580 AcpiOsPrintf ("%27s : %8.8X\n", Title
, Value
);
589 AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title
,
590 ACPI_FORMAT_UINT64 (Value
));
598 AcpiOsPrintf ("%27s : ", Title
);
602 /*******************************************************************************
604 * FUNCTION: AcpiRsDump*List
606 * PARAMETERS: Length - Number of elements in the list
607 * Data - Start of the list
611 * DESCRIPTION: Miscellaneous functions to dump lists of raw data
613 ******************************************************************************/
623 for (i
= 0; i
< Length
; i
++)
625 AcpiOsPrintf ("%25s%2.2X : %2.2X\n", "Byte", i
, Data
[i
]);
630 AcpiRsDumpShortByteList (
637 for (i
= 0; i
< Length
; i
++)
639 AcpiOsPrintf ("%X ", Data
[i
]);
646 AcpiRsDumpDwordList (
653 for (i
= 0; i
< Length
; i
++)
655 AcpiOsPrintf ("%25s%2.2X : %8.8X\n", "Dword", i
, Data
[i
]);
667 for (i
= 0; i
< Length
; i
++)
669 AcpiOsPrintf ("%25s%2.2X : %4.4X\n", "Word", i
, Data
[i
]);