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 <contrib/dev/acpica/include/acpi.h>
45 #include <contrib/dev/acpica/include/accommon.h>
46 #include <contrib/dev/acpica/include/acresrc.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)
56 /* Local prototypes */
103 AcpiRsDumpShortByteList (
108 AcpiRsDumpResourceSource (
109 ACPI_RESOURCE_SOURCE *ResourceSource);
112 AcpiRsDumpAddressCommon (
113 ACPI_RESOURCE_DATA *Resource);
116 AcpiRsDumpDescriptor (
118 ACPI_RSDUMP_INFO *Table);
121 /*******************************************************************************
123 * FUNCTION: AcpiRsDumpResourceList
125 * PARAMETERS: ResourceList - Pointer to a resource descriptor list
129 * DESCRIPTION: Dispatches the structure to the correct dump routine.
131 ******************************************************************************/
134 AcpiRsDumpResourceList (
135 ACPI_RESOURCE *ResourceList)
141 ACPI_FUNCTION_ENTRY ();
144 /* Check if debug output enabled */
146 if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_RESOURCES, _COMPONENT))
151 /* Walk list and dump all resource descriptors (END_TAG terminates) */
155 AcpiOsPrintf ("\n[%02X] ", Count);
158 /* Validate Type before dispatch */
160 Type = ResourceList->Type;
161 if (Type > ACPI_RESOURCE_TYPE_MAX)
164 "Invalid descriptor type (%X) in resource list\n",
169 /* Sanity check the length. It must not be zero, or we loop forever */
171 if (!ResourceList->Length)
174 "Invalid zero length descriptor in resource list\n");
178 /* Dump the resource descriptor */
180 if (Type == ACPI_RESOURCE_TYPE_SERIAL_BUS)
182 AcpiRsDumpDescriptor (&ResourceList->Data,
183 AcpiGbl_DumpSerialBusDispatch[
184 ResourceList->Data.CommonSerialBus.Type]);
188 AcpiRsDumpDescriptor (&ResourceList->Data,
189 AcpiGbl_DumpResourceDispatch[Type]);
192 /* Point to the next resource structure */
194 ResourceList = ACPI_NEXT_RESOURCE (ResourceList);
196 /* Exit when END_TAG descriptor is reached */
198 } while (Type != ACPI_RESOURCE_TYPE_END_TAG);
202 /*******************************************************************************
204 * FUNCTION: AcpiRsDumpIrqList
206 * PARAMETERS: RouteTable - Pointer to the routing table to dump.
210 * DESCRIPTION: Print IRQ routing table
212 ******************************************************************************/
218 ACPI_PCI_ROUTING_TABLE *PrtElement;
222 ACPI_FUNCTION_ENTRY ();
225 /* Check if debug output enabled */
227 if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_RESOURCES, _COMPONENT))
232 PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable);
234 /* Dump all table elements, Exit on zero length element */
236 for (Count = 0; PrtElement->Length; Count++)
238 AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count);
239 AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt);
241 PrtElement = ACPI_ADD_PTR (ACPI_PCI_ROUTING_TABLE,
242 PrtElement, PrtElement->Length);
247 /*******************************************************************************
249 * FUNCTION: AcpiRsDumpDescriptor
251 * PARAMETERS: Resource - Buffer containing the resource
252 * Table - Table entry to decode the resource
256 * DESCRIPTION: Dump a resource descriptor based on a dump table entry.
258 ******************************************************************************/
261 AcpiRsDumpDescriptor (
263 ACPI_RSDUMP_INFO *Table)
265 UINT8 *Target = NULL;
266 UINT8 *PreviousTarget;
271 /* First table entry must contain the table length (# of table entries) */
273 Count = Table->Offset;
277 PreviousTarget = Target;
278 Target = ACPI_ADD_PTR (UINT8, Resource, Table->Offset);
281 switch (Table->Opcode)
285 * Optional resource title
289 AcpiOsPrintf ("%s Resource\n", Name);
295 case ACPI_RSD_LITERAL:
297 AcpiRsOutString (Name, ACPI_CAST_PTR (char, Table->Pointer));
300 case ACPI_RSD_STRING:
302 AcpiRsOutString (Name, ACPI_CAST_PTR (char, Target));
305 /* Data items, 8/16/32/64 bit */
311 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
312 Table->Pointer [*Target]));
316 AcpiRsOutInteger8 (Name, ACPI_GET8 (Target));
320 case ACPI_RSD_UINT16:
322 AcpiRsOutInteger16 (Name, ACPI_GET16 (Target));
325 case ACPI_RSD_UINT32:
327 AcpiRsOutInteger32 (Name, ACPI_GET32 (Target));
330 case ACPI_RSD_UINT64:
332 AcpiRsOutInteger64 (Name, ACPI_GET64 (Target));
335 /* Flags: 1-bit and 2-bit flags supported */
337 case ACPI_RSD_1BITFLAG:
339 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
340 Table->Pointer [*Target & 0x01]));
343 case ACPI_RSD_2BITFLAG:
345 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
346 Table->Pointer [*Target & 0x03]));
349 case ACPI_RSD_3BITFLAG:
351 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
352 Table->Pointer [*Target & 0x07]));
355 case ACPI_RSD_SHORTLIST:
357 * Short byte list (single line output) for DMA and IRQ resources
358 * Note: The list length is obtained from the previous table entry
362 AcpiRsOutTitle (Name);
363 AcpiRsDumpShortByteList (*PreviousTarget, Target);
367 case ACPI_RSD_SHORTLISTX:
369 * Short byte list (single line output) for GPIO vendor data
370 * Note: The list length is obtained from the previous table entry
374 AcpiRsOutTitle (Name);
375 AcpiRsDumpShortByteList (*PreviousTarget,
376 *(ACPI_CAST_INDIRECT_PTR (UINT8, Target)));
380 case ACPI_RSD_LONGLIST:
382 * Long byte list for Vendor resource data
383 * Note: The list length is obtained from the previous table entry
387 AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget), Target);
391 case ACPI_RSD_DWORDLIST:
393 * Dword list for Extended Interrupt resources
394 * Note: The list length is obtained from the previous table entry
398 AcpiRsDumpDwordList (*PreviousTarget,
399 ACPI_CAST_PTR (UINT32, Target));
403 case ACPI_RSD_WORDLIST:
405 * Word list for GPIO Pin Table
406 * Note: The list length is obtained from the previous table entry
410 AcpiRsDumpWordList (*PreviousTarget,
411 *(ACPI_CAST_INDIRECT_PTR (UINT16, Target)));
415 case ACPI_RSD_ADDRESS:
417 * Common flags for all Address resources
419 AcpiRsDumpAddressCommon (ACPI_CAST_PTR (
420 ACPI_RESOURCE_DATA, Target));
423 case ACPI_RSD_SOURCE:
425 * Optional ResourceSource for Address resources
427 AcpiRsDumpResourceSource (ACPI_CAST_PTR (
428 ACPI_RESOURCE_SOURCE, Target));
433 AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
444 /*******************************************************************************
446 * FUNCTION: AcpiRsDumpResourceSource
448 * PARAMETERS: ResourceSource - Pointer to a Resource Source struct
452 * DESCRIPTION: Common routine for dumping the optional ResourceSource and the
453 * corresponding ResourceSourceIndex.
455 ******************************************************************************/
458 AcpiRsDumpResourceSource (
459 ACPI_RESOURCE_SOURCE *ResourceSource)
461 ACPI_FUNCTION_ENTRY ();
464 if (ResourceSource->Index == 0xFF)
469 AcpiRsOutInteger8 ("Resource Source Index",
470 ResourceSource->Index);
472 AcpiRsOutString ("Resource Source",
473 ResourceSource->StringPtr ?
474 ResourceSource->StringPtr : "[Not Specified]");
478 /*******************************************************************************
480 * FUNCTION: AcpiRsDumpAddressCommon
482 * PARAMETERS: Resource - Pointer to an internal resource descriptor
486 * DESCRIPTION: Dump the fields that are common to all Address resource
489 ******************************************************************************/
492 AcpiRsDumpAddressCommon (
493 ACPI_RESOURCE_DATA *Resource)
495 ACPI_FUNCTION_ENTRY ();
498 /* Decode the type-specific flags */
500 switch (Resource->Address.ResourceType)
502 case ACPI_MEMORY_RANGE:
504 AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags);
509 AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags);
512 case ACPI_BUS_NUMBER_RANGE:
514 AcpiRsOutString ("Resource Type", "Bus Number Range");
519 AcpiRsOutInteger8 ("Resource Type",
520 (UINT8) Resource->Address.ResourceType);
524 /* Decode the general flags */
526 AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags);
530 /*******************************************************************************
532 * FUNCTION: AcpiRsOut*
534 * PARAMETERS: Title - Name of the resource field
535 * Value - Value of the resource field
539 * DESCRIPTION: Miscellaneous helper functions to consistently format the
540 * output of the resource dump routines
542 ******************************************************************************/
549 AcpiOsPrintf ("%27s : %s", Title, Value);
552 AcpiOsPrintf ("[NULL NAMESTRING]");
562 AcpiOsPrintf ("%27s : %2.2X\n", Title, Value);
570 AcpiOsPrintf ("%27s : %4.4X\n", Title, Value);
578 AcpiOsPrintf ("%27s : %8.8X\n", Title, Value);
586 AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title,
587 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",
627 AcpiRsDumpShortByteList (
634 for (i = 0; i < Length; i++)
636 AcpiOsPrintf ("%X ", Data[i]);
642 AcpiRsDumpDwordList (
649 for (i = 0; i < Length; i++)
651 AcpiOsPrintf ("%25s%2.2X : %8.8X\n",
652 "Dword", i, Data[i]);
664 for (i = 0; i < Length; i++)
666 AcpiOsPrintf ("%25s%2.2X : %4.4X\n",