1 /*******************************************************************************
3 * Module Name: rsdump - Functions to display the resource structures.
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2014, 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.
46 #include <contrib/dev/acpica/include/acpi.h>
47 #include <contrib/dev/acpica/include/accommon.h>
48 #include <contrib/dev/acpica/include/acresrc.h>
50 #define _COMPONENT ACPI_RESOURCES
51 ACPI_MODULE_NAME ("rsdump")
54 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DISASSEMBLER) || 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: AcpiRsDumpDescriptor
125 * PARAMETERS: Resource - Buffer containing the resource
126 * Table - Table entry to decode the resource
130 * DESCRIPTION: Dump a resource descriptor based on a dump table entry.
132 ******************************************************************************/
135 AcpiRsDumpDescriptor (
137 ACPI_RSDUMP_INFO *Table)
139 UINT8 *Target = NULL;
140 UINT8 *PreviousTarget;
145 /* First table entry must contain the table length (# of table entries) */
147 Count = Table->Offset;
151 PreviousTarget = Target;
152 Target = ACPI_ADD_PTR (UINT8, Resource, Table->Offset);
155 switch (Table->Opcode)
159 * Optional resource title
163 AcpiOsPrintf ("%s Resource\n", Name);
169 case ACPI_RSD_LITERAL:
171 AcpiRsOutString (Name, ACPI_CAST_PTR (char, Table->Pointer));
174 case ACPI_RSD_STRING:
176 AcpiRsOutString (Name, ACPI_CAST_PTR (char, Target));
179 /* Data items, 8/16/32/64 bit */
185 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
186 Table->Pointer [*Target]));
190 AcpiRsOutInteger8 (Name, ACPI_GET8 (Target));
194 case ACPI_RSD_UINT16:
196 AcpiRsOutInteger16 (Name, ACPI_GET16 (Target));
199 case ACPI_RSD_UINT32:
201 AcpiRsOutInteger32 (Name, ACPI_GET32 (Target));
204 case ACPI_RSD_UINT64:
206 AcpiRsOutInteger64 (Name, ACPI_GET64 (Target));
209 /* Flags: 1-bit and 2-bit flags supported */
211 case ACPI_RSD_1BITFLAG:
213 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
214 Table->Pointer [*Target & 0x01]));
217 case ACPI_RSD_2BITFLAG:
219 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
220 Table->Pointer [*Target & 0x03]));
223 case ACPI_RSD_3BITFLAG:
225 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
226 Table->Pointer [*Target & 0x07]));
229 case ACPI_RSD_SHORTLIST:
231 * Short byte list (single line output) for DMA and IRQ resources
232 * Note: The list length is obtained from the previous table entry
236 AcpiRsOutTitle (Name);
237 AcpiRsDumpShortByteList (*PreviousTarget, Target);
241 case ACPI_RSD_SHORTLISTX:
243 * Short byte list (single line output) for GPIO vendor data
244 * Note: The list length is obtained from the previous table entry
248 AcpiRsOutTitle (Name);
249 AcpiRsDumpShortByteList (*PreviousTarget,
250 *(ACPI_CAST_INDIRECT_PTR (UINT8, Target)));
254 case ACPI_RSD_LONGLIST:
256 * Long byte list for Vendor resource data
257 * Note: The list length is obtained from the previous table entry
261 AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget), Target);
265 case ACPI_RSD_DWORDLIST:
267 * Dword list for Extended Interrupt resources
268 * Note: The list length is obtained from the previous table entry
272 AcpiRsDumpDwordList (*PreviousTarget,
273 ACPI_CAST_PTR (UINT32, Target));
277 case ACPI_RSD_WORDLIST:
279 * Word list for GPIO Pin Table
280 * Note: The list length is obtained from the previous table entry
284 AcpiRsDumpWordList (*PreviousTarget,
285 *(ACPI_CAST_INDIRECT_PTR (UINT16, Target)));
289 case ACPI_RSD_ADDRESS:
291 * Common flags for all Address resources
293 AcpiRsDumpAddressCommon (ACPI_CAST_PTR (ACPI_RESOURCE_DATA, Target));
296 case ACPI_RSD_SOURCE:
298 * Optional ResourceSource for Address resources
300 AcpiRsDumpResourceSource (ACPI_CAST_PTR (ACPI_RESOURCE_SOURCE, Target));
305 AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
316 /*******************************************************************************
318 * FUNCTION: AcpiRsDumpResourceSource
320 * PARAMETERS: ResourceSource - Pointer to a Resource Source struct
324 * DESCRIPTION: Common routine for dumping the optional ResourceSource and the
325 * corresponding ResourceSourceIndex.
327 ******************************************************************************/
330 AcpiRsDumpResourceSource (
331 ACPI_RESOURCE_SOURCE *ResourceSource)
333 ACPI_FUNCTION_ENTRY ();
336 if (ResourceSource->Index == 0xFF)
341 AcpiRsOutInteger8 ("Resource Source Index",
342 ResourceSource->Index);
344 AcpiRsOutString ("Resource Source",
345 ResourceSource->StringPtr ?
346 ResourceSource->StringPtr : "[Not Specified]");
350 /*******************************************************************************
352 * FUNCTION: AcpiRsDumpAddressCommon
354 * PARAMETERS: Resource - Pointer to an internal resource descriptor
358 * DESCRIPTION: Dump the fields that are common to all Address resource
361 ******************************************************************************/
364 AcpiRsDumpAddressCommon (
365 ACPI_RESOURCE_DATA *Resource)
367 ACPI_FUNCTION_ENTRY ();
370 /* Decode the type-specific flags */
372 switch (Resource->Address.ResourceType)
374 case ACPI_MEMORY_RANGE:
376 AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags);
381 AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags);
384 case ACPI_BUS_NUMBER_RANGE:
386 AcpiRsOutString ("Resource Type", "Bus Number Range");
391 AcpiRsOutInteger8 ("Resource Type",
392 (UINT8) Resource->Address.ResourceType);
396 /* Decode the general flags */
398 AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags);
402 /*******************************************************************************
404 * FUNCTION: AcpiRsDumpResourceList
406 * PARAMETERS: ResourceList - Pointer to a resource descriptor list
410 * DESCRIPTION: Dispatches the structure to the correct dump routine.
412 ******************************************************************************/
415 AcpiRsDumpResourceList (
416 ACPI_RESOURCE *ResourceList)
422 ACPI_FUNCTION_ENTRY ();
425 /* Check if debug output enabled */
427 if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_RESOURCES, _COMPONENT))
432 /* Walk list and dump all resource descriptors (END_TAG terminates) */
436 AcpiOsPrintf ("\n[%02X] ", Count);
439 /* Validate Type before dispatch */
441 Type = ResourceList->Type;
442 if (Type > ACPI_RESOURCE_TYPE_MAX)
445 "Invalid descriptor type (%X) in resource list\n",
450 /* Sanity check the length. It must not be zero, or we loop forever */
452 if (!ResourceList->Length)
455 "Invalid zero length descriptor in resource list\n");
459 /* Dump the resource descriptor */
461 if (Type == ACPI_RESOURCE_TYPE_SERIAL_BUS)
463 AcpiRsDumpDescriptor (&ResourceList->Data,
464 AcpiGbl_DumpSerialBusDispatch[ResourceList->Data.CommonSerialBus.Type]);
468 AcpiRsDumpDescriptor (&ResourceList->Data,
469 AcpiGbl_DumpResourceDispatch[Type]);
472 /* Point to the next resource structure */
474 ResourceList = ACPI_NEXT_RESOURCE (ResourceList);
476 /* Exit when END_TAG descriptor is reached */
478 } while (Type != ACPI_RESOURCE_TYPE_END_TAG);
482 /*******************************************************************************
484 * FUNCTION: AcpiRsDumpIrqList
486 * PARAMETERS: RouteTable - Pointer to the routing table to dump.
490 * DESCRIPTION: Print IRQ routing table
492 ******************************************************************************/
498 ACPI_PCI_ROUTING_TABLE *PrtElement;
502 ACPI_FUNCTION_ENTRY ();
505 /* Check if debug output enabled */
507 if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_RESOURCES, _COMPONENT))
512 PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable);
514 /* Dump all table elements, Exit on zero length element */
516 for (Count = 0; PrtElement->Length; Count++)
518 AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count);
519 AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt);
521 PrtElement = ACPI_ADD_PTR (ACPI_PCI_ROUTING_TABLE,
522 PrtElement, PrtElement->Length);
527 /*******************************************************************************
529 * FUNCTION: AcpiRsOut*
531 * PARAMETERS: Title - Name of the resource field
532 * Value - Value of the resource field
536 * DESCRIPTION: Miscellaneous helper functions to consistently format the
537 * output of the resource dump routines
539 ******************************************************************************/
546 AcpiOsPrintf ("%27s : %s", Title, Value);
549 AcpiOsPrintf ("[NULL NAMESTRING]");
559 AcpiOsPrintf ("%27s : %2.2X\n", Title, Value);
567 AcpiOsPrintf ("%27s : %4.4X\n", Title, Value);
575 AcpiOsPrintf ("%27s : %8.8X\n", Title, Value);
583 AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title,
584 ACPI_FORMAT_UINT64 (Value));
591 AcpiOsPrintf ("%27s : ", Title);
595 /*******************************************************************************
597 * FUNCTION: AcpiRsDump*List
599 * PARAMETERS: Length - Number of elements in the list
600 * Data - Start of the list
604 * DESCRIPTION: Miscellaneous functions to dump lists of raw data
606 ******************************************************************************/
616 for (i = 0; i < Length; i++)
618 AcpiOsPrintf ("%25s%2.2X : %2.2X\n",
624 AcpiRsDumpShortByteList (
631 for (i = 0; i < Length; i++)
633 AcpiOsPrintf ("%X ", Data[i]);
639 AcpiRsDumpDwordList (
646 for (i = 0; i < Length; i++)
648 AcpiOsPrintf ("%25s%2.2X : %8.8X\n",
649 "Dword", i, Data[i]);
661 for (i = 0; i < Length; i++)
663 AcpiOsPrintf ("%25s%2.2X : %4.4X\n",