Home | History | Annotate | Line # | Download | only in disassembler
dmresrcl2.c revision 1.10.2.2
      1 /*******************************************************************************
      2  *
      3  * Module Name: dmresrcl2.c - "Large" Resource Descriptor disassembly (#2)
      4  *
      5  ******************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2020, Intel Corp.
      9  * All rights reserved.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     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.
     25  *
     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.
     29  *
     30  * NO WARRANTY
     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.
     42  */
     43 
     44 #include "acpi.h"
     45 #include "accommon.h"
     46 #include "acdisasm.h"
     47 
     48 #ifdef _KERNEL
     49 #define MpSaveGpioInfo(a, b, c, d, e)
     50 #define MpSaveSerialInfo(a, b, c)
     51 #endif
     52 
     53 #define _COMPONENT          ACPI_CA_DEBUGGER
     54         ACPI_MODULE_NAME    ("dbresrcl2")
     55 
     56 /* Local prototypes */
     57 
     58 static void
     59 AcpiDmI2cSerialBusDescriptor (
     60     ACPI_OP_WALK_INFO       *Info,
     61     AML_RESOURCE            *Resource,
     62     UINT32                  Length,
     63     UINT32                  Level);
     64 
     65 static void
     66 AcpiDmSpiSerialBusDescriptor (
     67     ACPI_OP_WALK_INFO       *Info,
     68     AML_RESOURCE            *Resource,
     69     UINT32                  Length,
     70     UINT32                  Level);
     71 
     72 static void
     73 AcpiDmUartSerialBusDescriptor (
     74     ACPI_OP_WALK_INFO       *Info,
     75     AML_RESOURCE            *Resource,
     76     UINT32                  Length,
     77     UINT32                  Level);
     78 
     79 static void
     80 AcpiDmGpioCommon (
     81     ACPI_OP_WALK_INFO       *Info,
     82     AML_RESOURCE            *Resource,
     83     UINT32                  Level);
     84 
     85 static void
     86 AcpiDmDumpRawDataBuffer (
     87     UINT8                   *Buffer,
     88     UINT32                  Length,
     89     UINT32                  Level);
     90 
     91 
     92 /* Dispatch table for the serial bus descriptors */
     93 
     94 static ACPI_RESOURCE_HANDLER        SerialBusResourceDispatch [] =
     95 {
     96     NULL,
     97     AcpiDmI2cSerialBusDescriptor,
     98     AcpiDmSpiSerialBusDescriptor,
     99     AcpiDmUartSerialBusDescriptor
    100 };
    101 
    102 
    103 /*******************************************************************************
    104  *
    105  * FUNCTION:    AcpiDmDumpRawDataBuffer
    106  *
    107  * PARAMETERS:  Buffer              - Pointer to the data bytes
    108  *              Length              - Length of the descriptor in bytes
    109  *              Level               - Current source code indentation level
    110  *
    111  * RETURN:      None
    112  *
    113  * DESCRIPTION: Dump a data buffer as a RawDataBuffer() object. Used for
    114  *              vendor data bytes.
    115  *
    116  ******************************************************************************/
    117 
    118 static void
    119 AcpiDmDumpRawDataBuffer (
    120     UINT8                   *Buffer,
    121     UINT32                  Length,
    122     UINT32                  Level)
    123 {
    124     UINT32                  Index;
    125     UINT32                  i;
    126     UINT32                  j;
    127 
    128 
    129     if (!Length)
    130     {
    131         return;
    132     }
    133 
    134     AcpiOsPrintf ("RawDataBuffer (0x%.2X)  // Vendor Data", Length);
    135 
    136     AcpiOsPrintf ("\n");
    137     AcpiDmIndent (Level + 1);
    138     AcpiOsPrintf ("{\n");
    139     AcpiDmIndent (Level + 2);
    140 
    141     for (i = 0; i < Length;)
    142     {
    143         for (j = 0; j < 8; j++)
    144         {
    145             Index = i + j;
    146             if (Index >= Length)
    147             {
    148                 goto Finish;
    149             }
    150 
    151             AcpiOsPrintf ("0x%2.2X", Buffer[Index]);
    152             if ((Index + 1) >= Length)
    153             {
    154                 goto Finish;
    155             }
    156 
    157             AcpiOsPrintf (", ");
    158         }
    159 
    160         AcpiOsPrintf ("\n");
    161         AcpiDmIndent (Level + 2);
    162 
    163         i += 8;
    164     }
    165 
    166 Finish:
    167     AcpiOsPrintf ("\n");
    168     AcpiDmIndent (Level + 1);
    169     AcpiOsPrintf ("}");
    170 }
    171 
    172 
    173 /*******************************************************************************
    174  *
    175  * FUNCTION:    AcpiDmGpioCommon
    176  *
    177  * PARAMETERS:  Info                - Extra resource info
    178  *              Resource            - Pointer to the resource descriptor
    179  *              Level               - Current source code indentation level
    180  *
    181  * RETURN:      None
    182  *
    183  * DESCRIPTION: Decode common parts of a GPIO Interrupt descriptor
    184  *
    185  ******************************************************************************/
    186 
    187 static void
    188 AcpiDmGpioCommon (
    189     ACPI_OP_WALK_INFO       *Info,
    190     AML_RESOURCE            *Resource,
    191     UINT32                  Level)
    192 {
    193     UINT16                  *PinList;
    194     UINT8                   *VendorData;
    195     char                    *DeviceName = NULL;
    196     UINT32                  PinCount;
    197     UINT32                  i;
    198 
    199 
    200     /* ResourceSource, ResourceSourceIndex, ResourceType */
    201 
    202     AcpiDmIndent (Level + 1);
    203     if (Resource->Gpio.ResSourceOffset)
    204     {
    205         DeviceName = ACPI_ADD_PTR (char,
    206             Resource, Resource->Gpio.ResSourceOffset);
    207         AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
    208     }
    209 
    210     AcpiOsPrintf (", ");
    211     AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.ResSourceIndex);
    212     AcpiOsPrintf ("%s, ",
    213         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.Flags)]);
    214 
    215     /* Insert a descriptor name */
    216 
    217     AcpiDmDescriptorName ();
    218     AcpiOsPrintf (",");
    219 
    220     /* Dump the vendor data */
    221 
    222     if (Resource->Gpio.VendorOffset)
    223     {
    224         AcpiOsPrintf ("\n");
    225         AcpiDmIndent (Level + 1);
    226         VendorData = ACPI_ADD_PTR (UINT8, Resource,
    227             Resource->Gpio.VendorOffset);
    228 
    229         AcpiDmDumpRawDataBuffer (VendorData,
    230             Resource->Gpio.VendorLength, Level);
    231     }
    232 
    233     AcpiOsPrintf (")\n");
    234 
    235     /* Dump the interrupt list */
    236 
    237     AcpiDmIndent (Level + 1);
    238     AcpiOsPrintf ("{   // Pin list\n");
    239 
    240     PinCount = ((UINT32) (Resource->Gpio.ResSourceOffset -
    241         Resource->Gpio.PinTableOffset)) /
    242         sizeof (UINT16);
    243 
    244     PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
    245         Resource->Gpio.PinTableOffset);
    246 
    247     for (i = 0; i < PinCount; i++)
    248     {
    249         AcpiDmIndent (Level + 2);
    250         AcpiOsPrintf ("0x%4.4X%s\n", PinList[i],
    251             ((i + 1) < PinCount) ? "," : "");
    252     }
    253 
    254     AcpiDmIndent (Level + 1);
    255     AcpiOsPrintf ("}\n");
    256 
    257     MpSaveGpioInfo (Info->MappingOp, Resource,
    258         PinCount, PinList, DeviceName);
    259 }
    260 
    261 
    262 /*******************************************************************************
    263  *
    264  * FUNCTION:    AcpiDmGpioIntDescriptor
    265  *
    266  * PARAMETERS:  Info                - Extra resource info
    267  *              Resource            - Pointer to the resource descriptor
    268  *              Length              - Length of the descriptor in bytes
    269  *              Level               - Current source code indentation level
    270  *
    271  * RETURN:      None
    272  *
    273  * DESCRIPTION: Decode a GPIO Interrupt descriptor
    274  *
    275  ******************************************************************************/
    276 
    277 static void
    278 AcpiDmGpioIntDescriptor (
    279     ACPI_OP_WALK_INFO       *Info,
    280     AML_RESOURCE            *Resource,
    281     UINT32                  Length,
    282     UINT32                  Level)
    283 {
    284 
    285     /* Dump the GpioInt-specific portion of the descriptor */
    286 
    287     /* EdgeLevel, ActiveLevel, Shared */
    288 
    289     AcpiDmIndent (Level);
    290     AcpiOsPrintf ("GpioInt (%s, %s, %s, ",
    291         AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.IntFlags)],
    292         AcpiGbl_LlDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 1)],
    293         AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
    294 
    295     /* PinConfig, DebounceTimeout */
    296 
    297     if (Resource->Gpio.PinConfig <= 3)
    298     {
    299         AcpiOsPrintf ("%s, ",
    300             AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]);
    301     }
    302     else
    303     {
    304         AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
    305     }
    306     AcpiOsPrintf ("0x%4.4X,\n", Resource->Gpio.DebounceTimeout);
    307 
    308     /* Dump the GpioInt/GpioIo common portion of the descriptor */
    309 
    310     AcpiDmGpioCommon (Info, Resource, Level);
    311 }
    312 
    313 
    314 /*******************************************************************************
    315  *
    316  * FUNCTION:    AcpiDmGpioIoDescriptor
    317  *
    318  * PARAMETERS:  Info                - Extra resource info
    319  *              Resource            - Pointer to the resource descriptor
    320  *              Length              - Length of the descriptor in bytes
    321  *              Level               - Current source code indentation level
    322  *
    323  * RETURN:      None
    324  *
    325  * DESCRIPTION: Decode a GPIO I/O descriptor
    326  *
    327  ******************************************************************************/
    328 
    329 static void
    330 AcpiDmGpioIoDescriptor (
    331     ACPI_OP_WALK_INFO       *Info,
    332     AML_RESOURCE            *Resource,
    333     UINT32                  Length,
    334     UINT32                  Level)
    335 {
    336 
    337     /* Dump the GpioIo-specific portion of the descriptor */
    338 
    339     /* Shared, PinConfig */
    340 
    341     AcpiDmIndent (Level);
    342     AcpiOsPrintf ("GpioIo (%s, ",
    343         AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
    344 
    345     if (Resource->Gpio.PinConfig <= 3)
    346     {
    347         AcpiOsPrintf ("%s, ",
    348             AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]);
    349     }
    350     else
    351     {
    352         AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
    353     }
    354 
    355     /* DebounceTimeout, DriveStrength, IoRestriction */
    356 
    357     AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DebounceTimeout);
    358     AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DriveStrength);
    359     AcpiOsPrintf ("%s,\n",
    360         AcpiGbl_IorDecode [ACPI_GET_2BIT_FLAG (Resource->Gpio.IntFlags)]);
    361 
    362     /* Dump the GpioInt/GpioIo common portion of the descriptor */
    363 
    364     AcpiDmGpioCommon (Info, Resource, Level);
    365 }
    366 
    367 
    368 /*******************************************************************************
    369  *
    370  * FUNCTION:    AcpiDmGpioDescriptor
    371  *
    372  * PARAMETERS:  Info                - Extra resource info
    373  *              Resource            - Pointer to the resource descriptor
    374  *              Length              - Length of the descriptor in bytes
    375  *              Level               - Current source code indentation level
    376  *
    377  * RETURN:      None
    378  *
    379  * DESCRIPTION: Decode a GpioInt/GpioIo GPIO Interrupt/IO descriptor
    380  *
    381  ******************************************************************************/
    382 
    383 void
    384 AcpiDmGpioDescriptor (
    385     ACPI_OP_WALK_INFO       *Info,
    386     AML_RESOURCE            *Resource,
    387     UINT32                  Length,
    388     UINT32                  Level)
    389 {
    390     UINT8                   ConnectionType;
    391 
    392 
    393     ConnectionType = Resource->Gpio.ConnectionType;
    394 
    395     switch (ConnectionType)
    396     {
    397     case AML_RESOURCE_GPIO_TYPE_INT:
    398 
    399         AcpiDmGpioIntDescriptor (Info, Resource, Length, Level);
    400         break;
    401 
    402     case AML_RESOURCE_GPIO_TYPE_IO:
    403 
    404         AcpiDmGpioIoDescriptor (Info, Resource, Length, Level);
    405         break;
    406 
    407     default:
    408 
    409         AcpiOsPrintf ("Unknown GPIO type\n");
    410         break;
    411     }
    412 }
    413 
    414 /*******************************************************************************
    415  *
    416  * FUNCTION:    AcpiDmPinFunctionDescriptor
    417  *
    418  * PARAMETERS:  Info                - Extra resource info
    419  *              Resource            - Pointer to the resource descriptor
    420  *              Length              - Length of the descriptor in bytes
    421  *              Level               - Current source code indentation level
    422  *
    423  * RETURN:      None
    424  *
    425  * DESCRIPTION: Decode a PinFunction descriptor
    426  *
    427  ******************************************************************************/
    428 
    429 void
    430 AcpiDmPinFunctionDescriptor (
    431     ACPI_OP_WALK_INFO       *Info,
    432     AML_RESOURCE            *Resource,
    433     UINT32                  Length,
    434     UINT32                  Level)
    435 {
    436     UINT16                  *PinList;
    437     UINT8                   *VendorData;
    438     char                    *DeviceName = NULL;
    439     UINT32                  PinCount;
    440     UINT32                  i;
    441 
    442     AcpiDmIndent (Level);
    443     AcpiOsPrintf ("PinFunction (%s, ",
    444         AcpiGbl_ShrDecode [ACPI_GET_1BIT_FLAG (Resource->PinFunction.Flags)]);
    445 
    446     if (Resource->PinFunction.PinConfig <= 3)
    447     {
    448         AcpiOsPrintf ("%s, ",
    449             AcpiGbl_PpcDecode[Resource->PinFunction.PinConfig]);
    450     }
    451     else
    452     {
    453         AcpiOsPrintf ("0x%2.2X, ", Resource->PinFunction.PinConfig);
    454     }
    455 
    456     /* FunctionNumber */
    457 
    458     AcpiOsPrintf ("0x%4.4X, ", Resource->PinFunction.FunctionNumber);
    459 
    460     if (Resource->PinFunction.ResSourceOffset)
    461     {
    462         DeviceName = ACPI_ADD_PTR (char,
    463             Resource, Resource->PinFunction.ResSourceOffset),
    464         AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
    465     }
    466 
    467     AcpiOsPrintf (", ");
    468     AcpiOsPrintf ("0x%2.2X,\n", Resource->PinFunction.ResSourceIndex);
    469 
    470     AcpiDmIndent (Level + 1);
    471 
    472     /* Always ResourceConsumer */
    473     AcpiOsPrintf ("%s, ", AcpiGbl_ConsumeDecode [ACPI_CONSUMER]);
    474 
    475     /* Insert a descriptor name */
    476 
    477     AcpiDmDescriptorName ();
    478 
    479     AcpiOsPrintf (",");
    480 
    481     /* Dump the vendor data */
    482 
    483     if (Resource->PinFunction.VendorLength)
    484     {
    485         AcpiOsPrintf ("\n");
    486         AcpiDmIndent (Level + 1);
    487         VendorData = ACPI_ADD_PTR (UINT8, Resource,
    488             Resource->PinFunction.VendorOffset);
    489 
    490         AcpiDmDumpRawDataBuffer (VendorData,
    491             Resource->PinFunction.VendorLength, Level);
    492     }
    493 
    494     AcpiOsPrintf (")\n");
    495 
    496     AcpiDmIndent (Level + 1);
    497 
    498     /* Dump the interrupt list */
    499 
    500     AcpiOsPrintf ("{   // Pin list\n");
    501 
    502     PinCount = ((UINT32) (Resource->PinFunction.ResSourceOffset -
    503         Resource->PinFunction.PinTableOffset)) /
    504         sizeof (UINT16);
    505 
    506     PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
    507         Resource->PinFunction.PinTableOffset);
    508 
    509     for (i = 0; i < PinCount; i++)
    510     {
    511         AcpiDmIndent (Level + 2);
    512         AcpiOsPrintf ("0x%4.4X%s\n", PinList[i],
    513             ((i + 1) < PinCount) ? "," : "");
    514     }
    515 
    516     AcpiDmIndent (Level + 1);
    517     AcpiOsPrintf ("}\n");
    518 }
    519 
    520 
    521 /*******************************************************************************
    522  *
    523  * FUNCTION:    AcpiDmDumpSerialBusVendorData
    524  *
    525  * PARAMETERS:  Resource            - Pointer to the resource descriptor
    526  *
    527  * RETURN:      None
    528  *
    529  * DESCRIPTION: Dump optional serial bus vendor data
    530  *
    531  ******************************************************************************/
    532 
    533 static void
    534 AcpiDmDumpSerialBusVendorData (
    535     AML_RESOURCE            *Resource,
    536     UINT32                  Level)
    537 {
    538     UINT8                   *VendorData;
    539     UINT32                  VendorLength;
    540 
    541 
    542     /* Get the (optional) vendor data and length */
    543 
    544     switch (Resource->CommonSerialBus.Type)
    545     {
    546     case AML_RESOURCE_I2C_SERIALBUSTYPE:
    547 
    548         VendorLength = Resource->CommonSerialBus.TypeDataLength -
    549             AML_RESOURCE_I2C_MIN_DATA_LEN;
    550 
    551         VendorData = ACPI_ADD_PTR (UINT8, Resource,
    552             sizeof (AML_RESOURCE_I2C_SERIALBUS));
    553         break;
    554 
    555     case AML_RESOURCE_SPI_SERIALBUSTYPE:
    556 
    557         VendorLength = Resource->CommonSerialBus.TypeDataLength -
    558             AML_RESOURCE_SPI_MIN_DATA_LEN;
    559 
    560         VendorData = ACPI_ADD_PTR (UINT8, Resource,
    561             sizeof (AML_RESOURCE_SPI_SERIALBUS));
    562         break;
    563 
    564     case AML_RESOURCE_UART_SERIALBUSTYPE:
    565 
    566         VendorLength = Resource->CommonSerialBus.TypeDataLength -
    567             AML_RESOURCE_UART_MIN_DATA_LEN;
    568 
    569         VendorData = ACPI_ADD_PTR (UINT8, Resource,
    570             sizeof (AML_RESOURCE_UART_SERIALBUS));
    571         break;
    572 
    573     default:
    574 
    575         return;
    576     }
    577 
    578     /* Dump the vendor bytes as a RawDataBuffer object */
    579 
    580     AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level);
    581 }
    582 
    583 
    584 /*******************************************************************************
    585  *
    586  * FUNCTION:    AcpiDmI2cSerialBusDescriptor
    587  *
    588  * PARAMETERS:  Info                - Extra resource info
    589  *              Resource            - Pointer to the resource descriptor
    590  *              Length              - Length of the descriptor in bytes
    591  *              Level               - Current source code indentation level
    592  *
    593  * RETURN:      None
    594  *
    595  * DESCRIPTION: Decode a I2C serial bus descriptor
    596  *
    597  ******************************************************************************/
    598 
    599 static void
    600 AcpiDmI2cSerialBusDescriptor (
    601     ACPI_OP_WALK_INFO       *Info,
    602     AML_RESOURCE            *Resource,
    603     UINT32                  Length,
    604     UINT32                  Level)
    605 {
    606     UINT32                  ResourceSourceOffset;
    607     char                    *DeviceName;
    608 
    609 
    610     /* SlaveAddress, SlaveMode, ConnectionSpeed, AddressingMode */
    611 
    612     AcpiDmIndent (Level);
    613     AcpiOsPrintf ("I2cSerialBusV2 (0x%4.4X, %s, 0x%8.8X,\n",
    614         Resource->I2cSerialBus.SlaveAddress,
    615         AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.Flags)],
    616         Resource->I2cSerialBus.ConnectionSpeed);
    617 
    618     AcpiDmIndent (Level + 1);
    619     AcpiOsPrintf ("%s, ",
    620         AcpiGbl_AmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.TypeSpecificFlags)]);
    621 
    622     /* ResourceSource is a required field */
    623 
    624     ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
    625         Resource->CommonSerialBus.TypeDataLength;
    626 
    627     DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
    628     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
    629 
    630     /* ResourceSourceIndex, ResourceUsage */
    631 
    632     AcpiOsPrintf (",\n");
    633     AcpiDmIndent (Level + 1);
    634     AcpiOsPrintf ("0x%2.2X, ", Resource->I2cSerialBus.ResSourceIndex);
    635 
    636     AcpiOsPrintf ("%s, ",
    637         AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->I2cSerialBus.Flags, 1)]);
    638 
    639     /* Insert a descriptor name */
    640 
    641     AcpiDmDescriptorName ();
    642 
    643     /* Share */
    644 
    645     AcpiOsPrintf (", %s,\n",
    646         AcpiGbl_ShrDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->I2cSerialBus.Flags, 2)]);
    647 
    648     /* Dump the vendor data */
    649 
    650     AcpiDmIndent (Level + 1);
    651     AcpiDmDumpSerialBusVendorData (Resource, Level);
    652     AcpiOsPrintf (")\n");
    653 
    654     MpSaveSerialInfo (Info->MappingOp, Resource, DeviceName);
    655 }
    656 
    657 
    658 /*******************************************************************************
    659  *
    660  * FUNCTION:    AcpiDmSpiSerialBusDescriptor
    661  *
    662  * PARAMETERS:  Info                - Extra resource info
    663  *              Resource            - Pointer to the resource descriptor
    664  *              Length              - Length of the descriptor in bytes
    665  *              Level               - Current source code indentation level
    666  *
    667  * RETURN:      None
    668  *
    669  * DESCRIPTION: Decode a SPI serial bus descriptor
    670  *
    671  ******************************************************************************/
    672 
    673 static void
    674 AcpiDmSpiSerialBusDescriptor (
    675     ACPI_OP_WALK_INFO       *Info,
    676     AML_RESOURCE            *Resource,
    677     UINT32                  Length,
    678     UINT32                  Level)
    679 {
    680     UINT32                  ResourceSourceOffset;
    681     char                    *DeviceName;
    682 
    683 
    684     /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */
    685 
    686     AcpiDmIndent (Level);
    687     AcpiOsPrintf ("SpiSerialBusV2 (0x%4.4X, %s, %s, 0x%2.2X,\n",
    688         Resource->SpiSerialBus.DeviceSelection,
    689         AcpiGbl_DpDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags, 1)],
    690         AcpiGbl_WmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags)],
    691         Resource->SpiSerialBus.DataBitLength);
    692 
    693     /* SlaveMode, ConnectionSpeed, ClockPolarity, ClockPhase */
    694 
    695     AcpiDmIndent (Level + 1);
    696     AcpiOsPrintf ("%s, 0x%8.8X, %s,\n",
    697         AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.Flags)],
    698         Resource->SpiSerialBus.ConnectionSpeed,
    699         AcpiGbl_CpoDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.ClockPolarity)]);
    700 
    701     AcpiDmIndent (Level + 1);
    702     AcpiOsPrintf ("%s, ",
    703         AcpiGbl_CphDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.ClockPhase)]);
    704 
    705     /* ResourceSource is a required field */
    706 
    707     ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
    708         Resource->CommonSerialBus.TypeDataLength;
    709 
    710     DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
    711     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
    712 
    713     /* ResourceSourceIndex, ResourceUsage */
    714 
    715     AcpiOsPrintf (",\n");
    716     AcpiDmIndent (Level + 1);
    717     AcpiOsPrintf ("0x%2.2X, ", Resource->SpiSerialBus.ResSourceIndex);
    718 
    719     AcpiOsPrintf ("%s, ",
    720         AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.Flags, 1)]);
    721 
    722     /* Insert a descriptor name */
    723 
    724     AcpiDmDescriptorName ();
    725 
    726     /* Share */
    727 
    728     AcpiOsPrintf (", %s,\n",
    729         AcpiGbl_ShrDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.Flags, 2)]);
    730 
    731     /* Dump the vendor data */
    732 
    733     AcpiDmIndent (Level + 1);
    734     AcpiDmDumpSerialBusVendorData (Resource, Level);
    735     AcpiOsPrintf (")\n");
    736 
    737     MpSaveSerialInfo (Info->MappingOp, Resource, DeviceName);
    738 }
    739 
    740 
    741 /*******************************************************************************
    742  *
    743  * FUNCTION:    AcpiDmUartSerialBusDescriptor
    744  *
    745  * PARAMETERS:  Info                - Extra resource info
    746  *              Resource            - Pointer to the resource descriptor
    747  *              Length              - Length of the descriptor in bytes
    748  *              Level               - Current source code indentation level
    749  *
    750  * RETURN:      None
    751  *
    752  * DESCRIPTION: Decode a UART serial bus descriptor
    753  *
    754  ******************************************************************************/
    755 
    756 static void
    757 AcpiDmUartSerialBusDescriptor (
    758     ACPI_OP_WALK_INFO       *Info,
    759     AML_RESOURCE            *Resource,
    760     UINT32                  Length,
    761     UINT32                  Level)
    762 {
    763     UINT32                  ResourceSourceOffset;
    764     char                    *DeviceName;
    765 
    766 
    767     /* ConnectionSpeed, BitsPerByte, StopBits */
    768 
    769     AcpiDmIndent (Level);
    770     AcpiOsPrintf ("UartSerialBusV2 (0x%8.8X, %s, %s,\n",
    771         Resource->UartSerialBus.DefaultBaudRate,
    772         AcpiGbl_BpbDecode [ACPI_EXTRACT_3BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 4)],
    773         AcpiGbl_SbDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 2)]);
    774 
    775     /* LinesInUse, IsBigEndian, Parity, FlowControl */
    776 
    777     AcpiDmIndent (Level + 1);
    778     AcpiOsPrintf ("0x%2.2X, %s, %s, %s,\n",
    779         Resource->UartSerialBus.LinesEnabled,
    780         AcpiGbl_EdDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 7)],
    781         AcpiGbl_PtDecode [ACPI_GET_3BIT_FLAG (Resource->UartSerialBus.Parity)],
    782         AcpiGbl_FcDecode [ACPI_GET_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags)]);
    783 
    784     /* ReceiveBufferSize, TransmitBufferSize */
    785 
    786     AcpiDmIndent (Level + 1);
    787     AcpiOsPrintf ("0x%4.4X, 0x%4.4X, ",
    788         Resource->UartSerialBus.RxFifoSize,
    789         Resource->UartSerialBus.TxFifoSize);
    790 
    791     /* ResourceSource is a required field */
    792 
    793     ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
    794         Resource->CommonSerialBus.TypeDataLength;
    795 
    796     DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
    797     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
    798 
    799     /* ResourceSourceIndex, ResourceUsage */
    800 
    801     AcpiOsPrintf (",\n");
    802     AcpiDmIndent (Level + 1);
    803     AcpiOsPrintf ("0x%2.2X, ", Resource->UartSerialBus.ResSourceIndex);
    804 
    805     AcpiOsPrintf ("%s, ",
    806         AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->UartSerialBus.Flags, 1)]);
    807 
    808     /* Insert a descriptor name */
    809 
    810     AcpiDmDescriptorName ();
    811 
    812     /* Share */
    813 
    814     AcpiOsPrintf (", %s,\n",
    815         AcpiGbl_ShrDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->UartSerialBus.Flags, 2)]);
    816 
    817     /* Dump the vendor data */
    818 
    819     AcpiDmIndent (Level + 1);
    820     AcpiDmDumpSerialBusVendorData (Resource, Level);
    821     AcpiOsPrintf (")\n");
    822 
    823     MpSaveSerialInfo (Info->MappingOp, Resource, DeviceName);
    824 }
    825 
    826 
    827 /*******************************************************************************
    828  *
    829  * FUNCTION:    AcpiDmSerialBusDescriptor
    830  *
    831  * PARAMETERS:  Info                - Extra resource info
    832  *              Resource            - Pointer to the resource descriptor
    833  *              Length              - Length of the descriptor in bytes
    834  *              Level               - Current source code indentation level
    835  *
    836  * RETURN:      None
    837  *
    838  * DESCRIPTION: Decode a I2C/SPI/UART serial bus descriptor
    839  *
    840  ******************************************************************************/
    841 
    842 void
    843 AcpiDmSerialBusDescriptor (
    844     ACPI_OP_WALK_INFO       *Info,
    845     AML_RESOURCE            *Resource,
    846     UINT32                  Length,
    847     UINT32                  Level)
    848 {
    849 
    850     SerialBusResourceDispatch [Resource->CommonSerialBus.Type] (
    851         Info, Resource, Length, Level);
    852 }
    853 
    854 /*******************************************************************************
    855  *
    856  * FUNCTION:    AcpiDmPinConfig
    857  *
    858  * PARAMETERS:  PinConfigType       - Pin configuration type
    859  *              PinConfigValue      - Pin configuration value
    860  *
    861  * RETURN:      None
    862  *
    863  * DESCRIPTION: Pretty prints PinConfig type and value.
    864  *
    865  ******************************************************************************/
    866 
    867 static void
    868 AcpiDmPinConfig(
    869     UINT8                   PinConfigType,
    870     UINT32                  PinConfigValue)
    871 {
    872     if (PinConfigType <= 13)
    873     {
    874         AcpiOsPrintf ("0x%2.2X /* %s */, ", PinConfigType,
    875             AcpiGbl_PtypDecode[PinConfigType]);
    876     }
    877     else
    878     {
    879         AcpiOsPrintf ("0x%2.2X, /* Vendor Defined */ ", PinConfigType);
    880     }
    881 
    882     /* PinConfigValue */
    883 
    884     AcpiOsPrintf ("0x%4.4X,\n", PinConfigValue);
    885 }
    886 
    887 /*******************************************************************************
    888  *
    889  * FUNCTION:    AcpiDmPinConfigDescriptor
    890  *
    891  * PARAMETERS:  Info                - Extra resource info
    892  *              Resource            - Pointer to the resource descriptor
    893  *              Length              - Length of the descriptor in bytes
    894  *              Level               - Current source code indentation level
    895  *
    896  * RETURN:      None
    897  *
    898  * DESCRIPTION: Decode a PinConfig descriptor
    899  *
    900  ******************************************************************************/
    901 
    902 void
    903 AcpiDmPinConfigDescriptor (
    904     ACPI_OP_WALK_INFO       *Info,
    905     AML_RESOURCE            *Resource,
    906     UINT32                  Length,
    907     UINT32                  Level)
    908 {
    909     UINT16                  *PinList;
    910     UINT8                   *VendorData;
    911     char                    *DeviceName = NULL;
    912     UINT32                  PinCount;
    913     UINT32                  i;
    914 
    915     AcpiDmIndent (Level);
    916     AcpiOsPrintf ("PinConfig (%s, ",
    917         AcpiGbl_ShrDecode [ACPI_GET_1BIT_FLAG (Resource->PinConfig.Flags)]);
    918 
    919     AcpiDmPinConfig (Resource->PinConfig.PinConfigType,
    920         Resource->PinConfig.PinConfigValue);
    921 
    922     AcpiDmIndent (Level + 1);
    923 
    924     if (Resource->PinConfig.ResSourceOffset)
    925     {
    926         DeviceName = ACPI_ADD_PTR (char,
    927             Resource, Resource->PinConfig.ResSourceOffset),
    928         AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
    929     }
    930 
    931     AcpiOsPrintf (", ");
    932     AcpiOsPrintf ("0x%2.2X, ", Resource->PinConfig.ResSourceIndex);
    933 
    934     AcpiOsPrintf ("%s, ",
    935         AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->PinConfig.Flags, 1)]);
    936 
    937     /* Insert a descriptor name */
    938 
    939     AcpiDmDescriptorName ();
    940 
    941     AcpiOsPrintf (",");
    942 
    943     /* Dump the vendor data */
    944 
    945     if (Resource->PinConfig.VendorLength)
    946     {
    947         AcpiOsPrintf ("\n");
    948         AcpiDmIndent (Level + 1);
    949         VendorData = ACPI_ADD_PTR (UINT8, Resource,
    950             Resource->PinConfig.VendorOffset);
    951 
    952         AcpiDmDumpRawDataBuffer (VendorData,
    953             Resource->PinConfig.VendorLength, Level);
    954     }
    955 
    956     AcpiOsPrintf (")\n");
    957 
    958     AcpiDmIndent (Level + 1);
    959 
    960     /* Dump the interrupt list */
    961 
    962     AcpiOsPrintf ("{   // Pin list\n");
    963 
    964     PinCount = ((UINT32) (Resource->PinConfig.ResSourceOffset -
    965         Resource->PinConfig.PinTableOffset)) /
    966         sizeof (UINT16);
    967 
    968     PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
    969         Resource->PinConfig.PinTableOffset);
    970 
    971     for (i = 0; i < PinCount; i++)
    972     {
    973         AcpiDmIndent (Level + 2);
    974         AcpiOsPrintf ("0x%4.4X%s\n", PinList[i],
    975             ((i + 1) < PinCount) ? "," : "");
    976     }
    977 
    978     AcpiDmIndent (Level + 1);
    979     AcpiOsPrintf ("}\n");
    980 }
    981 
    982 /*******************************************************************************
    983  *
    984  * FUNCTION:    AcpiDmPinGroupDescriptor
    985  *
    986  * PARAMETERS:  Info                - Extra resource info
    987  *              Resource            - Pointer to the resource descriptor
    988  *              Length              - Length of the descriptor in bytes
    989  *              Level               - Current source code indentation level
    990  *
    991  * RETURN:      None
    992  *
    993  * DESCRIPTION: Decode a PinGroup descriptor
    994  *
    995  ******************************************************************************/
    996 
    997 void
    998 AcpiDmPinGroupDescriptor (
    999     ACPI_OP_WALK_INFO       *Info,
   1000     AML_RESOURCE            *Resource,
   1001     UINT32                  Length,
   1002     UINT32                  Level)
   1003 {
   1004     char                    *Label;
   1005     UINT16                  *PinList;
   1006     UINT8                   *VendorData;
   1007     UINT32                  PinCount;
   1008     UINT32                  i;
   1009 
   1010     AcpiDmIndent (Level);
   1011     /* Always producer */
   1012     AcpiOsPrintf ("PinGroup (");
   1013 
   1014     Label = ACPI_ADD_PTR (char,
   1015         Resource, Resource->PinGroup.LabelOffset),
   1016     AcpiUtPrintString (Label, ACPI_UINT16_MAX);
   1017 
   1018     AcpiOsPrintf (", ");
   1019 
   1020     AcpiOsPrintf ("%s, ",
   1021         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Resource->PinGroup.Flags)]);
   1022 
   1023     /* Insert a descriptor name */
   1024 
   1025     AcpiDmDescriptorName ();
   1026 
   1027     AcpiOsPrintf (",");
   1028 
   1029     /* Dump the vendor data */
   1030 
   1031     if (Resource->PinGroup.VendorLength)
   1032     {
   1033         AcpiOsPrintf ("\n");
   1034         AcpiDmIndent (Level + 1);
   1035         VendorData = ACPI_ADD_PTR (UINT8, Resource,
   1036             Resource->PinGroup.VendorOffset);
   1037 
   1038         AcpiDmDumpRawDataBuffer (VendorData,
   1039             Resource->PinGroup.VendorLength, Level);
   1040     }
   1041 
   1042     AcpiOsPrintf (")\n");
   1043 
   1044     AcpiDmIndent (Level + 1);
   1045 
   1046     /* Dump the interrupt list */
   1047 
   1048     AcpiOsPrintf ("{   // Pin list\n");
   1049 
   1050     PinCount = (Resource->PinGroup.LabelOffset -
   1051         Resource->PinGroup.PinTableOffset) / sizeof (UINT16);
   1052 
   1053     PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
   1054         Resource->PinGroup.PinTableOffset);
   1055 
   1056     for (i = 0; i < PinCount; i++)
   1057     {
   1058         AcpiDmIndent (Level + 2);
   1059         AcpiOsPrintf ("0x%4.4X%s\n", PinList[i],
   1060             ((i + 1) < PinCount) ? "," : "");
   1061     }
   1062 
   1063     AcpiDmIndent (Level + 1);
   1064     AcpiOsPrintf ("}\n");
   1065 }
   1066 
   1067 /*******************************************************************************
   1068  *
   1069  * FUNCTION:    AcpiDmPinGroupFunctionDescriptor
   1070  *
   1071  * PARAMETERS:  Info                - Extra resource info
   1072  *              Resource            - Pointer to the resource descriptor
   1073  *              Length              - Length of the descriptor in bytes
   1074  *              Level               - Current source code indentation level
   1075  *
   1076  * RETURN:      None
   1077  *
   1078  * DESCRIPTION: Decode a PinGroupFunction descriptor
   1079  *
   1080  ******************************************************************************/
   1081 
   1082 void
   1083 AcpiDmPinGroupFunctionDescriptor (
   1084     ACPI_OP_WALK_INFO       *Info,
   1085     AML_RESOURCE            *Resource,
   1086     UINT32                  Length,
   1087     UINT32                  Level)
   1088 {
   1089     UINT8                   *VendorData;
   1090     char                    *DeviceName = NULL;
   1091     char                    *Label = NULL;
   1092 
   1093     AcpiDmIndent (Level);
   1094     AcpiOsPrintf ("PinGroupFunction (%s, ",
   1095         AcpiGbl_ShrDecode [ACPI_GET_1BIT_FLAG (Resource->PinGroupFunction.Flags)]);
   1096 
   1097     /* FunctionNumber */
   1098 
   1099     AcpiOsPrintf ("0x%4.4X, ", Resource->PinGroupFunction.FunctionNumber);
   1100 
   1101     DeviceName = ACPI_ADD_PTR (char,
   1102         Resource, Resource->PinGroupFunction.ResSourceOffset),
   1103     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
   1104 
   1105     AcpiOsPrintf (", ");
   1106     AcpiOsPrintf ("0x%2.2X,\n", Resource->PinGroupFunction.ResSourceIndex);
   1107 
   1108     AcpiDmIndent (Level + 1);
   1109 
   1110     Label = ACPI_ADD_PTR (char, Resource,
   1111         Resource->PinGroupFunction.ResSourceLabelOffset);
   1112     AcpiUtPrintString (Label, ACPI_UINT16_MAX);
   1113 
   1114     AcpiOsPrintf (", ");
   1115 
   1116     AcpiOsPrintf ("%s, ",
   1117         AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->PinGroupFunction.Flags, 1)]);
   1118 
   1119     /* Insert a descriptor name */
   1120 
   1121     AcpiDmDescriptorName ();
   1122 
   1123     AcpiOsPrintf (",");
   1124 
   1125     /* Dump the vendor data */
   1126 
   1127     if (Resource->PinGroupFunction.VendorLength)
   1128     {
   1129         AcpiOsPrintf ("\n");
   1130         AcpiDmIndent (Level + 1);
   1131         VendorData = ACPI_ADD_PTR (UINT8, Resource,
   1132             Resource->PinGroupFunction.VendorOffset);
   1133 
   1134         AcpiDmDumpRawDataBuffer (VendorData,
   1135             Resource->PinGroupFunction.VendorLength, Level);
   1136     }
   1137 
   1138     AcpiOsPrintf (")\n");
   1139 }
   1140 
   1141 /*******************************************************************************
   1142  *
   1143  * FUNCTION:    AcpiDmPinGroupConfigDescriptor
   1144  *
   1145  * PARAMETERS:  Info                - Extra resource info
   1146  *              Resource            - Pointer to the resource descriptor
   1147  *              Length              - Length of the descriptor in bytes
   1148  *              Level               - Current source code indentation level
   1149  *
   1150  * RETURN:      None
   1151  *
   1152  * DESCRIPTION: Decode a PinGroupConfig descriptor
   1153  *
   1154  ******************************************************************************/
   1155 
   1156 void
   1157 AcpiDmPinGroupConfigDescriptor (
   1158     ACPI_OP_WALK_INFO       *Info,
   1159     AML_RESOURCE            *Resource,
   1160     UINT32                  Length,
   1161     UINT32                  Level)
   1162 {
   1163     UINT8                   *VendorData;
   1164     char                    *DeviceName = NULL;
   1165     char                    *Label = NULL;
   1166 
   1167     AcpiDmIndent (Level);
   1168     AcpiOsPrintf ("PinGroupConfig (%s, ",
   1169         AcpiGbl_ShrDecode [ACPI_GET_1BIT_FLAG (Resource->PinGroupConfig.Flags)]);
   1170 
   1171     AcpiDmPinConfig(Resource->PinGroupConfig.PinConfigType,
   1172         Resource->PinGroupConfig.PinConfigValue);
   1173 
   1174     AcpiDmIndent (Level + 1);
   1175 
   1176     DeviceName = ACPI_ADD_PTR (char,
   1177         Resource, Resource->PinGroupConfig.ResSourceOffset),
   1178     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
   1179 
   1180     AcpiOsPrintf (", ");
   1181     AcpiOsPrintf ("0x%2.2X, ", Resource->PinGroupConfig.ResSourceIndex);
   1182 
   1183     Label = ACPI_ADD_PTR (char, Resource,
   1184         Resource->PinGroupConfig.ResSourceLabelOffset);
   1185     AcpiUtPrintString (Label, ACPI_UINT16_MAX);
   1186 
   1187     AcpiOsPrintf (", ");
   1188 
   1189     AcpiOsPrintf ("%s, ",
   1190         AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->PinGroupConfig.Flags, 1)]);
   1191 
   1192     /* Insert a descriptor name */
   1193 
   1194     AcpiDmDescriptorName ();
   1195 
   1196     AcpiOsPrintf (",");
   1197 
   1198     /* Dump the vendor data */
   1199 
   1200     if (Resource->PinGroupConfig.VendorLength)
   1201     {
   1202         AcpiOsPrintf ("\n");
   1203         AcpiDmIndent (Level + 1);
   1204         VendorData = ACPI_ADD_PTR (UINT8, Resource,
   1205             Resource->PinGroupConfig.VendorOffset);
   1206 
   1207         AcpiDmDumpRawDataBuffer (VendorData,
   1208             Resource->PinGroupConfig.VendorLength, Level);
   1209     }
   1210 
   1211     AcpiOsPrintf (")\n");
   1212 }
   1213