1 /*******************************************************************************
3 * Module Name: rsdump - AML debugger support for resource structures.
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2017, 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
, Table
->Pointer
[*Target
]);
314 AcpiRsOutInteger8 (Name
, ACPI_GET8 (Target
));
318 case ACPI_RSD_UINT16
:
320 AcpiRsOutInteger16 (Name
, ACPI_GET16 (Target
));
323 case ACPI_RSD_UINT32
:
325 AcpiRsOutInteger32 (Name
, ACPI_GET32 (Target
));
328 case ACPI_RSD_UINT64
:
330 AcpiRsOutInteger64 (Name
, ACPI_GET64 (Target
));
333 /* Flags: 1-bit and 2-bit flags supported */
335 case ACPI_RSD_1BITFLAG
:
337 AcpiRsOutString (Name
, Table
->Pointer
[*Target
& 0x01]);
340 case ACPI_RSD_2BITFLAG
:
342 AcpiRsOutString (Name
, Table
->Pointer
[*Target
& 0x03]);
345 case ACPI_RSD_3BITFLAG
:
347 AcpiRsOutString (Name
, Table
->Pointer
[*Target
& 0x07]);
350 case ACPI_RSD_SHORTLIST
:
352 * Short byte list (single line output) for DMA and IRQ resources
353 * Note: The list length is obtained from the previous table entry
357 AcpiRsOutTitle (Name
);
358 AcpiRsDumpShortByteList (*PreviousTarget
, Target
);
362 case ACPI_RSD_SHORTLISTX
:
364 * Short byte list (single line output) for GPIO vendor data
365 * Note: The list length is obtained from the previous table entry
369 AcpiRsOutTitle (Name
);
370 AcpiRsDumpShortByteList (*PreviousTarget
,
371 *(ACPI_CAST_INDIRECT_PTR (UINT8
, Target
)));
375 case ACPI_RSD_LONGLIST
:
377 * Long byte list for Vendor resource data
378 * Note: The list length is obtained from the previous table entry
382 AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget
), Target
);
386 case ACPI_RSD_DWORDLIST
:
388 * Dword list for Extended Interrupt resources
389 * Note: The list length is obtained from the previous table entry
393 AcpiRsDumpDwordList (*PreviousTarget
,
394 ACPI_CAST_PTR (UINT32
, Target
));
398 case ACPI_RSD_WORDLIST
:
400 * Word list for GPIO Pin Table
401 * Note: The list length is obtained from the previous table entry
405 AcpiRsDumpWordList (*PreviousTarget
,
406 *(ACPI_CAST_INDIRECT_PTR (UINT16
, Target
)));
410 case ACPI_RSD_ADDRESS
:
412 * Common flags for all Address resources
414 AcpiRsDumpAddressCommon (ACPI_CAST_PTR (
415 ACPI_RESOURCE_DATA
, Target
));
418 case ACPI_RSD_SOURCE
:
420 * Optional ResourceSource for Address resources
422 AcpiRsDumpResourceSource (ACPI_CAST_PTR (
423 ACPI_RESOURCE_SOURCE
, Target
));
428 AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
439 /*******************************************************************************
441 * FUNCTION: AcpiRsDumpResourceSource
443 * PARAMETERS: ResourceSource - Pointer to a Resource Source struct
447 * DESCRIPTION: Common routine for dumping the optional ResourceSource and the
448 * corresponding ResourceSourceIndex.
450 ******************************************************************************/
453 AcpiRsDumpResourceSource (
454 ACPI_RESOURCE_SOURCE
*ResourceSource
)
456 ACPI_FUNCTION_ENTRY ();
459 if (ResourceSource
->Index
== 0xFF)
464 AcpiRsOutInteger8 ("Resource Source Index",
465 ResourceSource
->Index
);
467 AcpiRsOutString ("Resource Source",
468 ResourceSource
->StringPtr
?
469 ResourceSource
->StringPtr
: "[Not Specified]");
473 /*******************************************************************************
475 * FUNCTION: AcpiRsDumpAddressCommon
477 * PARAMETERS: Resource - Pointer to an internal resource descriptor
481 * DESCRIPTION: Dump the fields that are common to all Address resource
484 ******************************************************************************/
487 AcpiRsDumpAddressCommon (
488 ACPI_RESOURCE_DATA
*Resource
)
490 ACPI_FUNCTION_ENTRY ();
493 /* Decode the type-specific flags */
495 switch (Resource
->Address
.ResourceType
)
497 case ACPI_MEMORY_RANGE
:
499 AcpiRsDumpDescriptor (Resource
, AcpiRsDumpMemoryFlags
);
504 AcpiRsDumpDescriptor (Resource
, AcpiRsDumpIoFlags
);
507 case ACPI_BUS_NUMBER_RANGE
:
509 AcpiRsOutString ("Resource Type", "Bus Number Range");
514 AcpiRsOutInteger8 ("Resource Type",
515 (UINT8
) Resource
->Address
.ResourceType
);
519 /* Decode the general flags */
521 AcpiRsDumpDescriptor (Resource
, AcpiRsDumpGeneralFlags
);
525 /*******************************************************************************
527 * FUNCTION: AcpiRsOut*
529 * PARAMETERS: Title - Name of the resource field
530 * Value - Value of the resource field
534 * DESCRIPTION: Miscellaneous helper functions to consistently format the
535 * output of the resource dump routines
537 ******************************************************************************/
545 AcpiOsPrintf ("%27s : %s", Title
, Value
);
548 AcpiOsPrintf ("[NULL NAMESTRING]");
558 AcpiOsPrintf ("%27s : %2.2X\n", Title
, Value
);
567 AcpiOsPrintf ("%27s : %4.4X\n", Title
, Value
);
576 AcpiOsPrintf ("%27s : %8.8X\n", Title
, Value
);
585 AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title
,
586 ACPI_FORMAT_UINT64 (Value
));
594 AcpiOsPrintf ("%27s : ", Title
);
598 /*******************************************************************************
600 * FUNCTION: AcpiRsDump*List
602 * PARAMETERS: Length - Number of elements in the list
603 * Data - Start of the list
607 * DESCRIPTION: Miscellaneous functions to dump lists of raw data
609 ******************************************************************************/
619 for (i
= 0; i
< Length
; i
++)
621 AcpiOsPrintf ("%25s%2.2X : %2.2X\n", "Byte", i
, Data
[i
]);
626 AcpiRsDumpShortByteList (
633 for (i
= 0; i
< Length
; i
++)
635 AcpiOsPrintf ("%X ", Data
[i
]);
642 AcpiRsDumpDwordList (
649 for (i
= 0; i
< Length
; i
++)
651 AcpiOsPrintf ("%25s%2.2X : %8.8X\n", "Dword", i
, Data
[i
]);
663 for (i
= 0; i
< Length
; i
++)
665 AcpiOsPrintf ("%25s%2.2X : %4.4X\n", "Word", i
, Data
[i
]);