1 /*******************************************************************************
3 * Module Name: rsdump - Functions to display the resource structures.
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2013, 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.
47 #include <contrib/dev/acpica/include/acpi.h>
48 #include <contrib/dev/acpica/include/accommon.h>
49 #include <contrib/dev/acpica/include/acresrc.h>
51 #define _COMPONENT ACPI_RESOURCES
52 ACPI_MODULE_NAME ("rsdump")
55 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
57 /* Local prototypes */
104 AcpiRsDumpShortByteList (
109 AcpiRsDumpResourceSource (
110 ACPI_RESOURCE_SOURCE *ResourceSource);
113 AcpiRsDumpAddressCommon (
114 ACPI_RESOURCE_DATA *Resource);
117 AcpiRsDumpDescriptor (
119 ACPI_RSDUMP_INFO *Table);
122 /*******************************************************************************
124 * FUNCTION: AcpiRsDumpDescriptor
126 * PARAMETERS: Resource - Buffer containing the resource
127 * Table - Table entry to decode the resource
131 * DESCRIPTION: Dump a resource descriptor based on a dump table entry.
133 ******************************************************************************/
136 AcpiRsDumpDescriptor (
138 ACPI_RSDUMP_INFO *Table)
140 UINT8 *Target = NULL;
141 UINT8 *PreviousTarget;
146 /* First table entry must contain the table length (# of table entries) */
148 Count = Table->Offset;
152 PreviousTarget = Target;
153 Target = ACPI_ADD_PTR (UINT8, Resource, Table->Offset);
156 switch (Table->Opcode)
160 * Optional resource title
164 AcpiOsPrintf ("%s Resource\n", Name);
170 case ACPI_RSD_LITERAL:
172 AcpiRsOutString (Name, ACPI_CAST_PTR (char, Table->Pointer));
175 case ACPI_RSD_STRING:
177 AcpiRsOutString (Name, ACPI_CAST_PTR (char, Target));
180 /* Data items, 8/16/32/64 bit */
186 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
187 Table->Pointer [*Target]));
191 AcpiRsOutInteger8 (Name, ACPI_GET8 (Target));
195 case ACPI_RSD_UINT16:
197 AcpiRsOutInteger16 (Name, ACPI_GET16 (Target));
200 case ACPI_RSD_UINT32:
202 AcpiRsOutInteger32 (Name, ACPI_GET32 (Target));
205 case ACPI_RSD_UINT64:
207 AcpiRsOutInteger64 (Name, ACPI_GET64 (Target));
210 /* Flags: 1-bit and 2-bit flags supported */
212 case ACPI_RSD_1BITFLAG:
214 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
215 Table->Pointer [*Target & 0x01]));
218 case ACPI_RSD_2BITFLAG:
220 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
221 Table->Pointer [*Target & 0x03]));
224 case ACPI_RSD_3BITFLAG:
226 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
227 Table->Pointer [*Target & 0x07]));
230 case ACPI_RSD_SHORTLIST:
232 * Short byte list (single line output) for DMA and IRQ resources
233 * Note: The list length is obtained from the previous table entry
237 AcpiRsOutTitle (Name);
238 AcpiRsDumpShortByteList (*PreviousTarget, Target);
242 case ACPI_RSD_SHORTLISTX:
244 * Short byte list (single line output) for GPIO vendor data
245 * Note: The list length is obtained from the previous table entry
249 AcpiRsOutTitle (Name);
250 AcpiRsDumpShortByteList (*PreviousTarget,
251 *(ACPI_CAST_INDIRECT_PTR (UINT8, Target)));
255 case ACPI_RSD_LONGLIST:
257 * Long byte list for Vendor resource data
258 * Note: The list length is obtained from the previous table entry
262 AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget), Target);
266 case ACPI_RSD_DWORDLIST:
268 * Dword list for Extended Interrupt resources
269 * Note: The list length is obtained from the previous table entry
273 AcpiRsDumpDwordList (*PreviousTarget,
274 ACPI_CAST_PTR (UINT32, Target));
278 case ACPI_RSD_WORDLIST:
280 * Word list for GPIO Pin Table
281 * Note: The list length is obtained from the previous table entry
285 AcpiRsDumpWordList (*PreviousTarget,
286 *(ACPI_CAST_INDIRECT_PTR (UINT16, Target)));
290 case ACPI_RSD_ADDRESS:
292 * Common flags for all Address resources
294 AcpiRsDumpAddressCommon (ACPI_CAST_PTR (ACPI_RESOURCE_DATA, Target));
297 case ACPI_RSD_SOURCE:
299 * Optional ResourceSource for Address resources
301 AcpiRsDumpResourceSource (ACPI_CAST_PTR (ACPI_RESOURCE_SOURCE, Target));
306 AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
317 /*******************************************************************************
319 * FUNCTION: AcpiRsDumpResourceSource
321 * PARAMETERS: ResourceSource - Pointer to a Resource Source struct
325 * DESCRIPTION: Common routine for dumping the optional ResourceSource and the
326 * corresponding ResourceSourceIndex.
328 ******************************************************************************/
331 AcpiRsDumpResourceSource (
332 ACPI_RESOURCE_SOURCE *ResourceSource)
334 ACPI_FUNCTION_ENTRY ();
337 if (ResourceSource->Index == 0xFF)
342 AcpiRsOutInteger8 ("Resource Source Index",
343 ResourceSource->Index);
345 AcpiRsOutString ("Resource Source",
346 ResourceSource->StringPtr ?
347 ResourceSource->StringPtr : "[Not Specified]");
351 /*******************************************************************************
353 * FUNCTION: AcpiRsDumpAddressCommon
355 * PARAMETERS: Resource - Pointer to an internal resource descriptor
359 * DESCRIPTION: Dump the fields that are common to all Address resource
362 ******************************************************************************/
365 AcpiRsDumpAddressCommon (
366 ACPI_RESOURCE_DATA *Resource)
368 ACPI_FUNCTION_ENTRY ();
371 /* Decode the type-specific flags */
373 switch (Resource->Address.ResourceType)
375 case ACPI_MEMORY_RANGE:
377 AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags);
382 AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags);
385 case ACPI_BUS_NUMBER_RANGE:
387 AcpiRsOutString ("Resource Type", "Bus Number Range");
392 AcpiRsOutInteger8 ("Resource Type",
393 (UINT8) Resource->Address.ResourceType);
397 /* Decode the general flags */
399 AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags);
403 /*******************************************************************************
405 * FUNCTION: AcpiRsDumpResourceList
407 * PARAMETERS: ResourceList - Pointer to a resource descriptor list
411 * DESCRIPTION: Dispatches the structure to the correct dump routine.
413 ******************************************************************************/
416 AcpiRsDumpResourceList (
417 ACPI_RESOURCE *ResourceList)
423 ACPI_FUNCTION_ENTRY ();
426 /* Check if debug output enabled */
428 if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_RESOURCES, _COMPONENT))
433 /* Walk list and dump all resource descriptors (END_TAG terminates) */
437 AcpiOsPrintf ("\n[%02X] ", Count);
440 /* Validate Type before dispatch */
442 Type = ResourceList->Type;
443 if (Type > ACPI_RESOURCE_TYPE_MAX)
446 "Invalid descriptor type (%X) in resource list\n",
451 /* Sanity check the length. It must not be zero, or we loop forever */
453 if (!ResourceList->Length)
456 "Invalid zero length descriptor in resource list\n");
460 /* Dump the resource descriptor */
462 if (Type == ACPI_RESOURCE_TYPE_SERIAL_BUS)
464 AcpiRsDumpDescriptor (&ResourceList->Data,
465 AcpiGbl_DumpSerialBusDispatch[ResourceList->Data.CommonSerialBus.Type]);
469 AcpiRsDumpDescriptor (&ResourceList->Data,
470 AcpiGbl_DumpResourceDispatch[Type]);
473 /* Point to the next resource structure */
475 ResourceList = ACPI_NEXT_RESOURCE (ResourceList);
477 /* Exit when END_TAG descriptor is reached */
479 } while (Type != ACPI_RESOURCE_TYPE_END_TAG);
483 /*******************************************************************************
485 * FUNCTION: AcpiRsDumpIrqList
487 * PARAMETERS: RouteTable - Pointer to the routing table to dump.
491 * DESCRIPTION: Print IRQ routing table
493 ******************************************************************************/
499 ACPI_PCI_ROUTING_TABLE *PrtElement;
503 ACPI_FUNCTION_ENTRY ();
506 /* Check if debug output enabled */
508 if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_RESOURCES, _COMPONENT))
513 PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable);
515 /* Dump all table elements, Exit on zero length element */
517 for (Count = 0; PrtElement->Length; Count++)
519 AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count);
520 AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt);
522 PrtElement = ACPI_ADD_PTR (ACPI_PCI_ROUTING_TABLE,
523 PrtElement, PrtElement->Length);
528 /*******************************************************************************
530 * FUNCTION: AcpiRsOut*
532 * PARAMETERS: Title - Name of the resource field
533 * Value - Value of the resource field
537 * DESCRIPTION: Miscellaneous helper functions to consistently format the
538 * output of the resource dump routines
540 ******************************************************************************/
547 AcpiOsPrintf ("%27s : %s", Title, Value);
550 AcpiOsPrintf ("[NULL NAMESTRING]");
560 AcpiOsPrintf ("%27s : %2.2X\n", Title, Value);
568 AcpiOsPrintf ("%27s : %4.4X\n", Title, Value);
576 AcpiOsPrintf ("%27s : %8.8X\n", Title, Value);
584 AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title,
585 ACPI_FORMAT_UINT64 (Value));
592 AcpiOsPrintf ("%27s : ", Title);
596 /*******************************************************************************
598 * FUNCTION: AcpiRsDump*List
600 * PARAMETERS: Length - Number of elements in the list
601 * Data - Start of the list
605 * DESCRIPTION: Miscellaneous functions to dump lists of raw data
607 ******************************************************************************/
617 for (i = 0; i < Length; i++)
619 AcpiOsPrintf ("%25s%2.2X : %2.2X\n",
625 AcpiRsDumpShortByteList (
632 for (i = 0; i < Length; i++)
634 AcpiOsPrintf ("%X ", Data[i]);
640 AcpiRsDumpDwordList (
647 for (i = 0; i < Length; i++)
649 AcpiOsPrintf ("%25s%2.2X : %8.8X\n",
650 "Dword", i, Data[i]);
662 for (i = 0; i < Length; i++)
664 AcpiOsPrintf ("%25s%2.2X : %4.4X\n",