Home | History | Annotate | Line # | Download | only in resources
rsmisc.c revision 1.1.1.15
      1 /*******************************************************************************
      2  *
      3  * Module Name: rsmisc - Miscellaneous resource descriptors
      4  *
      5  ******************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2023, 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 MERCHANTABILITY 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 "acresrc.h"
     47 
     48 #define _COMPONENT          ACPI_RESOURCES
     49         ACPI_MODULE_NAME    ("rsmisc")
     50 
     51 
     52 #define INIT_RESOURCE_TYPE(i)       i->ResourceOffset
     53 #define INIT_RESOURCE_LENGTH(i)     i->AmlOffset
     54 #define INIT_TABLE_LENGTH(i)        i->Value
     55 
     56 #define COMPARE_OPCODE(i)           i->ResourceOffset
     57 #define COMPARE_TARGET(i)           i->AmlOffset
     58 #define COMPARE_VALUE(i)            i->Value
     59 
     60 
     61 /*******************************************************************************
     62  *
     63  * FUNCTION:    AcpiRsConvertAmlToResource
     64  *
     65  * PARAMETERS:  Resource            - Pointer to the resource descriptor
     66  *              Aml                 - Where the AML descriptor is returned
     67  *              Info                - Pointer to appropriate conversion table
     68  *
     69  * RETURN:      Status
     70  *
     71  * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
     72  *              internal resource descriptor
     73  *
     74  ******************************************************************************/
     75 
     76 ACPI_STATUS
     77 AcpiRsConvertAmlToResource (
     78     ACPI_RESOURCE           *Resource,
     79     AML_RESOURCE            *Aml,
     80     ACPI_RSCONVERT_INFO     *Info)
     81 {
     82     ACPI_RS_LENGTH          AmlResourceLength;
     83     void                    *Source;
     84     void                    *Destination;
     85     char                    *Target;
     86     UINT8                   Count;
     87     UINT8                   FlagsMode = FALSE;
     88     UINT16                  ItemCount = 0;
     89     UINT16                  Temp16 = 0;
     90 
     91 
     92     ACPI_FUNCTION_TRACE (RsConvertAmlToResource);
     93 
     94 
     95     if (!Info)
     96     {
     97         return_ACPI_STATUS (AE_BAD_PARAMETER);
     98     }
     99 
    100     if (((ACPI_SIZE) Resource) & 0x3)
    101     {
    102         /* Each internal resource struct is expected to be 32-bit aligned */
    103 
    104         ACPI_WARNING ((AE_INFO,
    105             "Misaligned resource pointer (get): %p Type 0x%2.2X Length %u",
    106             Resource, Resource->Type, Resource->Length));
    107     }
    108 
    109     /* Extract the resource Length field (does not include header length) */
    110 
    111     AmlResourceLength = AcpiUtGetResourceLength (Aml);
    112 
    113     /*
    114      * First table entry must be ACPI_RSC_INITxxx and must contain the
    115      * table length (# of table entries)
    116      */
    117     Count = INIT_TABLE_LENGTH (Info);
    118     while (Count)
    119     {
    120         Target = NULL;
    121 
    122         /*
    123          * Source is the external AML byte stream buffer,
    124          * destination is the internal resource descriptor
    125          */
    126         Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
    127         Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
    128 
    129         switch (Info->Opcode)
    130         {
    131         case ACPI_RSC_INITGET:
    132             /*
    133              * Get the resource type and the initial (minimum) length
    134              */
    135             memset (Resource, 0, INIT_RESOURCE_LENGTH (Info));
    136             Resource->Type = INIT_RESOURCE_TYPE (Info);
    137             Resource->Length = INIT_RESOURCE_LENGTH (Info);
    138             break;
    139 
    140         case ACPI_RSC_INITSET:
    141             break;
    142 
    143         case ACPI_RSC_FLAGINIT:
    144 
    145             FlagsMode = TRUE;
    146             break;
    147 
    148         case ACPI_RSC_1BITFLAG:
    149             /*
    150              * Mask and shift the flag bit
    151              */
    152             ACPI_SET8 (Destination,
    153                 ((ACPI_GET8 (Source) >> Info->Value) & 0x01));
    154             break;
    155 
    156         case ACPI_RSC_2BITFLAG:
    157             /*
    158              * Mask and shift the flag bits
    159              */
    160             ACPI_SET8 (Destination,
    161                 ((ACPI_GET8 (Source) >> Info->Value) & 0x03));
    162             break;
    163 
    164         case ACPI_RSC_3BITFLAG:
    165             /*
    166              * Mask and shift the flag bits
    167              */
    168             ACPI_SET8 (Destination,
    169                 ((ACPI_GET8 (Source) >> Info->Value) & 0x07));
    170             break;
    171 
    172         case ACPI_RSC_6BITFLAG:
    173             /*
    174              * Mask and shift the flag bits
    175              */
    176             ACPI_SET8 (Destination,
    177                 ((ACPI_GET8 (Source) >> Info->Value) & 0x3F));
    178             break;
    179 
    180         case ACPI_RSC_COUNT:
    181 
    182             ItemCount = ACPI_GET8 (Source);
    183             ACPI_SET8 (Destination, ItemCount);
    184 
    185             Resource->Length = Resource->Length +
    186                 (Info->Value * (ItemCount - 1));
    187             break;
    188 
    189         case ACPI_RSC_COUNT16:
    190 
    191             ItemCount = AmlResourceLength;
    192             ACPI_SET16 (Destination, ItemCount);
    193 
    194             Resource->Length = Resource->Length +
    195                 (Info->Value * (ItemCount - 1));
    196             break;
    197 
    198         case ACPI_RSC_COUNT_GPIO_PIN:
    199 
    200             Target = ACPI_ADD_PTR (void, Aml, Info->Value);
    201             ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);
    202 
    203             Resource->Length = Resource->Length + ItemCount;
    204             ItemCount = ItemCount / 2;
    205             ACPI_SET16 (Destination, ItemCount);
    206             break;
    207 
    208         case ACPI_RSC_COUNT_GPIO_VEN:
    209 
    210             ItemCount = ACPI_GET8 (Source);
    211             ACPI_SET8 (Destination, ItemCount);
    212 
    213             Resource->Length = Resource->Length + (Info->Value * ItemCount);
    214             break;
    215 
    216         case ACPI_RSC_COUNT_GPIO_RES:
    217             /*
    218              * Vendor data is optional (length/offset may both be zero)
    219              * Examine vendor data length field first
    220              */
    221             Target = ACPI_ADD_PTR (void, Aml, (Info->Value + 2));
    222             if (ACPI_GET16 (Target))
    223             {
    224                 /* Use vendor offset to get resource source length */
    225 
    226                 Target = ACPI_ADD_PTR (void, Aml, Info->Value);
    227                 ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);
    228             }
    229             else
    230             {
    231                 /* No vendor data to worry about */
    232 
    233                 ItemCount = Aml->LargeHeader.ResourceLength +
    234                     sizeof (AML_RESOURCE_LARGE_HEADER) -
    235                     ACPI_GET16 (Source);
    236             }
    237 
    238             Resource->Length = Resource->Length + ItemCount;
    239             ACPI_SET16 (Destination, ItemCount);
    240             break;
    241 
    242         case ACPI_RSC_COUNT_SERIAL_VEN:
    243 
    244             ACPI_MOVE_16_TO_16(&Temp16, Source);
    245             ItemCount = Temp16 - Info->Value;
    246 
    247             Resource->Length = Resource->Length + ItemCount;
    248             ACPI_SET16 (Destination, ItemCount);
    249             break;
    250 
    251         case ACPI_RSC_COUNT_SERIAL_RES:
    252 
    253             ACPI_MOVE_16_TO_16(&Temp16, Source);
    254             ItemCount = (AmlResourceLength +
    255                 sizeof (AML_RESOURCE_LARGE_HEADER)) -
    256                 Temp16 - Info->Value;
    257 
    258             Resource->Length = Resource->Length + ItemCount;
    259             ACPI_SET16 (Destination, ItemCount);
    260             break;
    261 
    262         case ACPI_RSC_LENGTH:
    263 
    264             Resource->Length = Resource->Length + Info->Value;
    265             break;
    266 
    267         case ACPI_RSC_MOVE8:
    268         case ACPI_RSC_MOVE16:
    269         case ACPI_RSC_MOVE32:
    270         case ACPI_RSC_MOVE64:
    271             /*
    272              * Raw data move. Use the Info value field unless ItemCount has
    273              * been previously initialized via a COUNT opcode
    274              */
    275             if (Info->Value)
    276             {
    277                 ItemCount = Info->Value;
    278             }
    279             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
    280             break;
    281 
    282         case ACPI_RSC_MOVE_GPIO_PIN:
    283 
    284             /* Generate and set the PIN data pointer */
    285 
    286             Target = (char *) ACPI_ADD_PTR (void, Resource,
    287                 (Resource->Length - ItemCount * 2));
    288             *(UINT16 **) Destination = ACPI_CAST_PTR (UINT16, Target);
    289 
    290             /* Copy the PIN data */
    291 
    292             Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source));
    293             AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
    294             break;
    295 
    296         case ACPI_RSC_MOVE_GPIO_RES:
    297 
    298             /* Generate and set the ResourceSource string pointer */
    299 
    300             Target = (char *) ACPI_ADD_PTR (void, Resource,
    301                 (Resource->Length - ItemCount));
    302             *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
    303 
    304             /* Copy the ResourceSource string */
    305 
    306             Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source));
    307             AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
    308             break;
    309 
    310         case ACPI_RSC_MOVE_SERIAL_VEN:
    311 
    312             /* Generate and set the Vendor Data pointer */
    313 
    314             Target = (char *) ACPI_ADD_PTR (void, Resource,
    315                 (Resource->Length - ItemCount));
    316             *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
    317 
    318             /* Copy the Vendor Data */
    319 
    320             Source = ACPI_ADD_PTR (void, Aml, Info->Value);
    321             AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
    322             break;
    323 
    324         case ACPI_RSC_MOVE_SERIAL_RES:
    325 
    326             /* Generate and set the ResourceSource string pointer */
    327 
    328             Target = (char *) ACPI_ADD_PTR (void, Resource,
    329                 (Resource->Length - ItemCount));
    330             *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
    331 
    332             /* Copy the ResourceSource string */
    333 
    334             ACPI_MOVE_16_TO_16 (&Temp16, Source);
    335             Source = ACPI_ADD_PTR (
    336                 void, Aml, (Temp16 + Info->Value));
    337             AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
    338             break;
    339 
    340         case ACPI_RSC_SET8:
    341 
    342             memset (Destination, Info->AmlOffset, Info->Value);
    343             break;
    344 
    345         case ACPI_RSC_DATA8:
    346 
    347             Target = ACPI_ADD_PTR (char, Resource, Info->Value);
    348             memcpy (Destination, Source,  ACPI_GET16 (Target));
    349             break;
    350 
    351         case ACPI_RSC_ADDRESS:
    352             /*
    353              * Common handler for address descriptor flags
    354              */
    355             if (!AcpiRsGetAddressCommon (Resource, Aml))
    356             {
    357                 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
    358             }
    359             break;
    360 
    361         case ACPI_RSC_SOURCE:
    362             /*
    363              * Optional ResourceSource (Index and String)
    364              */
    365             Resource->Length +=
    366                 AcpiRsGetResourceSource (AmlResourceLength, Info->Value,
    367                     Destination, Aml, NULL);
    368             break;
    369 
    370         case ACPI_RSC_SOURCEX:
    371             /*
    372              * Optional ResourceSource (Index and String). This is the more
    373              * complicated case used by the Interrupt() macro
    374              */
    375             Target = ACPI_ADD_PTR (char, Resource,
    376                 Info->AmlOffset + (ItemCount * 4));
    377 
    378             Resource->Length +=
    379                 AcpiRsGetResourceSource (AmlResourceLength, (ACPI_RS_LENGTH)
    380                     (((ItemCount - 1) * sizeof (UINT32)) + Info->Value),
    381                     Destination, Aml, Target);
    382             break;
    383 
    384         case ACPI_RSC_BITMASK:
    385             /*
    386              * 8-bit encoded bitmask (DMA macro)
    387              */
    388             ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination);
    389             if (ItemCount)
    390             {
    391                 Resource->Length += (ItemCount - 1);
    392             }
    393 
    394             Target = ACPI_ADD_PTR (char, Resource, Info->Value);
    395             ACPI_SET8 (Target, ItemCount);
    396             break;
    397 
    398         case ACPI_RSC_BITMASK16:
    399             /*
    400              * 16-bit encoded bitmask (IRQ macro)
    401              */
    402             ACPI_MOVE_16_TO_16 (&Temp16, Source);
    403 
    404             ItemCount = AcpiRsDecodeBitmask (Temp16, Destination);
    405             if (ItemCount)
    406             {
    407                 Resource->Length += (ItemCount - 1);
    408             }
    409 
    410             Target = ACPI_ADD_PTR (char, Resource, Info->Value);
    411             ACPI_SET8 (Target, ItemCount);
    412             break;
    413 
    414         case ACPI_RSC_EXIT_NE:
    415             /*
    416              * Control - Exit conversion if not equal
    417              */
    418             switch (Info->ResourceOffset)
    419             {
    420             case ACPI_RSC_COMPARE_AML_LENGTH:
    421 
    422                 if (AmlResourceLength != Info->Value)
    423                 {
    424                     goto Exit;
    425                 }
    426                 break;
    427 
    428             case ACPI_RSC_COMPARE_VALUE:
    429 
    430                 if (ACPI_GET8 (Source) != Info->Value)
    431                 {
    432                     goto Exit;
    433                 }
    434                 break;
    435 
    436             default:
    437 
    438                 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
    439                 return_ACPI_STATUS (AE_BAD_PARAMETER);
    440             }
    441             break;
    442 
    443         default:
    444 
    445             ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
    446             return_ACPI_STATUS (AE_BAD_PARAMETER);
    447         }
    448 
    449         Count--;
    450         Info++;
    451     }
    452 
    453 Exit:
    454     if (!FlagsMode)
    455     {
    456         /* Round the resource struct length up to the next boundary (32 or 64) */
    457 
    458         Resource->Length = (UINT32)
    459             ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length);
    460     }
    461     return_ACPI_STATUS (AE_OK);
    462 }
    463 
    464 
    465 /*******************************************************************************
    466  *
    467  * FUNCTION:    AcpiRsConvertResourceToAml
    468  *
    469  * PARAMETERS:  Resource            - Pointer to the resource descriptor
    470  *              Aml                 - Where the AML descriptor is returned
    471  *              Info                - Pointer to appropriate conversion table
    472  *
    473  * RETURN:      Status
    474  *
    475  * DESCRIPTION: Convert an internal resource descriptor to the corresponding
    476  *              external AML resource descriptor.
    477  *
    478  ******************************************************************************/
    479 
    480 ACPI_STATUS
    481 AcpiRsConvertResourceToAml (
    482     ACPI_RESOURCE           *Resource,
    483     AML_RESOURCE            *Aml,
    484     ACPI_RSCONVERT_INFO     *Info)
    485 {
    486     void                    *Source = NULL;
    487     void                    *Destination;
    488     char                    *Target;
    489     ACPI_RSDESC_SIZE        AmlLength = 0;
    490     UINT8                   Count;
    491     UINT16                  Temp16 = 0;
    492     UINT16                  ItemCount = 0;
    493 
    494 
    495     ACPI_FUNCTION_TRACE (RsConvertResourceToAml);
    496 
    497 
    498     if (!Info)
    499     {
    500         return_ACPI_STATUS (AE_BAD_PARAMETER);
    501     }
    502 
    503     /*
    504      * First table entry must be ACPI_RSC_INITxxx and must contain the
    505      * table length (# of table entries)
    506      */
    507     Count = INIT_TABLE_LENGTH (Info);
    508 
    509     while (Count)
    510     {
    511         /*
    512          * Source is the internal resource descriptor,
    513          * destination is the external AML byte stream buffer
    514          */
    515         Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
    516         Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
    517 
    518         switch (Info->Opcode)
    519         {
    520         case ACPI_RSC_INITSET:
    521 
    522             memset (Aml, 0, INIT_RESOURCE_LENGTH (Info));
    523             AmlLength = INIT_RESOURCE_LENGTH (Info);
    524             AcpiRsSetResourceHeader (
    525                 INIT_RESOURCE_TYPE (Info), AmlLength, Aml);
    526             break;
    527 
    528         case ACPI_RSC_INITGET:
    529             break;
    530 
    531         case ACPI_RSC_FLAGINIT:
    532             /*
    533              * Clear the flag byte
    534              */
    535             ACPI_SET8 (Destination, 0);
    536             break;
    537 
    538         case ACPI_RSC_1BITFLAG:
    539             /*
    540              * Mask and shift the flag bit
    541              */
    542             ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)
    543                 ((ACPI_GET8 (Source) & 0x01) << Info->Value));
    544             break;
    545 
    546         case ACPI_RSC_2BITFLAG:
    547             /*
    548              * Mask and shift the flag bits
    549              */
    550             ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)
    551                 ((ACPI_GET8 (Source) & 0x03) << Info->Value));
    552             break;
    553 
    554         case ACPI_RSC_3BITFLAG:
    555             /*
    556              * Mask and shift the flag bits
    557              */
    558             ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)
    559                 ((ACPI_GET8 (Source) & 0x07) << Info->Value));
    560             break;
    561 
    562         case ACPI_RSC_6BITFLAG:
    563             /*
    564              * Mask and shift the flag bits
    565              */
    566             ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)
    567                 ((ACPI_GET8 (Source) & 0x3F) << Info->Value));
    568             break;
    569 
    570         case ACPI_RSC_COUNT:
    571 
    572             ItemCount = ACPI_GET8 (Source);
    573             ACPI_SET8 (Destination, ItemCount);
    574 
    575             AmlLength = (UINT16)
    576                 (AmlLength + (Info->Value * (ItemCount - 1)));
    577             break;
    578 
    579         case ACPI_RSC_COUNT16:
    580 
    581             ItemCount = ACPI_GET16 (Source);
    582             AmlLength = (UINT16) (AmlLength + ItemCount);
    583             AcpiRsSetResourceLength (AmlLength, Aml);
    584             break;
    585 
    586         case ACPI_RSC_COUNT_GPIO_PIN:
    587 
    588             ItemCount = ACPI_GET16 (Source);
    589             ACPI_SET16 (Destination, AmlLength);
    590 
    591             AmlLength = (UINT16) (AmlLength + ItemCount * 2);
    592             Target = ACPI_ADD_PTR (void, Aml, Info->Value);
    593             ACPI_SET16 (Target, AmlLength);
    594             AcpiRsSetResourceLength (AmlLength, Aml);
    595             break;
    596 
    597         case ACPI_RSC_COUNT_GPIO_VEN:
    598 
    599             ItemCount = ACPI_GET16 (Source);
    600             ACPI_SET16 (Destination, ItemCount);
    601 
    602             AmlLength = (UINT16) (
    603                 AmlLength + (Info->Value * ItemCount));
    604             AcpiRsSetResourceLength (AmlLength, Aml);
    605             break;
    606 
    607         case ACPI_RSC_COUNT_GPIO_RES:
    608 
    609             /* Set resource source string length */
    610 
    611             ItemCount = ACPI_GET16 (Source);
    612             ACPI_SET16 (Destination, AmlLength);
    613 
    614             /* Compute offset for the Vendor Data */
    615 
    616             AmlLength = (UINT16) (AmlLength + ItemCount);
    617             Target = ACPI_ADD_PTR (void, Aml, Info->Value);
    618 
    619             /* Set vendor offset only if there is vendor data */
    620 
    621             ACPI_SET16 (Target, AmlLength);
    622 
    623             AcpiRsSetResourceLength (AmlLength, Aml);
    624             break;
    625 
    626         case ACPI_RSC_COUNT_SERIAL_VEN:
    627 
    628             ItemCount = ACPI_GET16 (Source);
    629             ACPI_SET16 (Destination, ItemCount + Info->Value);
    630             AmlLength = (UINT16) (AmlLength + ItemCount);
    631             AcpiRsSetResourceLength (AmlLength, Aml);
    632             break;
    633 
    634         case ACPI_RSC_COUNT_SERIAL_RES:
    635 
    636             ItemCount = ACPI_GET16 (Source);
    637             AmlLength = (UINT16) (AmlLength + ItemCount);
    638             AcpiRsSetResourceLength (AmlLength, Aml);
    639             break;
    640 
    641         case ACPI_RSC_LENGTH:
    642 
    643             AcpiRsSetResourceLength (Info->Value, Aml);
    644             break;
    645 
    646         case ACPI_RSC_MOVE8:
    647         case ACPI_RSC_MOVE16:
    648         case ACPI_RSC_MOVE32:
    649         case ACPI_RSC_MOVE64:
    650 
    651             if (Info->Value)
    652             {
    653                 ItemCount = Info->Value;
    654             }
    655             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
    656             break;
    657 
    658         case ACPI_RSC_MOVE_GPIO_PIN:
    659 
    660             Destination = (char *) ACPI_ADD_PTR (void, Aml,
    661                 ACPI_GET16 (Destination));
    662             Source = * (UINT16 **) Source;
    663             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
    664             break;
    665 
    666         case ACPI_RSC_MOVE_GPIO_RES:
    667 
    668             /* Used for both ResourceSource string and VendorData */
    669 
    670             Destination = (char *) ACPI_ADD_PTR (void, Aml,
    671                 ACPI_GET16 (Destination));
    672             Source = * (UINT8 **) Source;
    673             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
    674             break;
    675 
    676         case ACPI_RSC_MOVE_SERIAL_VEN:
    677 
    678             Destination = (char *) ACPI_ADD_PTR (void, Aml,
    679                 (AmlLength - ItemCount));
    680             Source = * (UINT8 **) Source;
    681             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
    682             break;
    683 
    684         case ACPI_RSC_MOVE_SERIAL_RES:
    685 
    686             Destination = (char *) ACPI_ADD_PTR (void, Aml,
    687                 (AmlLength - ItemCount));
    688             Source = * (UINT8 **) Source;
    689             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
    690             break;
    691 
    692         case ACPI_RSC_ADDRESS:
    693 
    694             /* Set the Resource Type, General Flags, and Type-Specific Flags */
    695 
    696             AcpiRsSetAddressCommon (Aml, Resource);
    697             break;
    698 
    699         case ACPI_RSC_SOURCEX:
    700             /*
    701              * Optional ResourceSource (Index and String)
    702              */
    703             AmlLength = AcpiRsSetResourceSource (
    704                 Aml, (ACPI_RS_LENGTH) AmlLength, Source);
    705             AcpiRsSetResourceLength (AmlLength, Aml);
    706             break;
    707 
    708         case ACPI_RSC_SOURCE:
    709             /*
    710              * Optional ResourceSource (Index and String). This is the more
    711              * complicated case used by the Interrupt() macro
    712              */
    713             AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source);
    714             AcpiRsSetResourceLength (AmlLength, Aml);
    715             break;
    716 
    717         case ACPI_RSC_BITMASK:
    718             /*
    719              * 8-bit encoded bitmask (DMA macro)
    720              */
    721             ACPI_SET8 (Destination,
    722                 AcpiRsEncodeBitmask (Source,
    723                     *ACPI_ADD_PTR (UINT8, Resource, Info->Value)));
    724             break;
    725 
    726         case ACPI_RSC_BITMASK16:
    727             /*
    728              * 16-bit encoded bitmask (IRQ macro)
    729              */
    730             Temp16 = AcpiRsEncodeBitmask (
    731                 Source, *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
    732             ACPI_MOVE_16_TO_16 (Destination, &Temp16);
    733             break;
    734 
    735         case ACPI_RSC_EXIT_LE:
    736             /*
    737              * Control - Exit conversion if less than or equal
    738              */
    739             if (ItemCount <= Info->Value)
    740             {
    741                 goto Exit;
    742             }
    743             break;
    744 
    745         case ACPI_RSC_EXIT_NE:
    746             /*
    747              * Control - Exit conversion if not equal
    748              */
    749             switch (COMPARE_OPCODE (Info))
    750             {
    751             case ACPI_RSC_COMPARE_VALUE:
    752 
    753                 if (*ACPI_ADD_PTR (UINT8, Resource,
    754                     COMPARE_TARGET (Info)) != COMPARE_VALUE (Info))
    755                 {
    756                     goto Exit;
    757                 }
    758                 break;
    759 
    760             default:
    761 
    762                 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
    763                 return_ACPI_STATUS (AE_BAD_PARAMETER);
    764             }
    765             break;
    766 
    767         case ACPI_RSC_EXIT_EQ:
    768             /*
    769              * Control - Exit conversion if equal
    770              */
    771             if (*ACPI_ADD_PTR (UINT8, Resource,
    772                 COMPARE_TARGET (Info)) == COMPARE_VALUE (Info))
    773             {
    774                 goto Exit;
    775             }
    776             break;
    777 
    778         default:
    779 
    780             ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
    781             return_ACPI_STATUS (AE_BAD_PARAMETER);
    782         }
    783 
    784         Count--;
    785         Info++;
    786     }
    787 
    788 Exit:
    789     return_ACPI_STATUS (AE_OK);
    790 }
    791 
    792 
    793 #if 0
    794 /* Previous resource validations */
    795 
    796     if (Aml->ExtAddress64.RevisionID !=
    797         AML_RESOURCE_EXTENDED_ADDRESS_REVISION)
    798     {
    799         return_ACPI_STATUS (AE_SUPPORT);
    800     }
    801 
    802     if (Resource->Data.StartDpf.PerformanceRobustness >= 3)
    803     {
    804         return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
    805     }
    806 
    807     if (((Aml->Irq.Flags & 0x09) == 0x00) ||
    808         ((Aml->Irq.Flags & 0x09) == 0x09))
    809     {
    810         /*
    811          * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive]
    812          * polarity/trigger interrupts are allowed (ACPI spec, section
    813          * "IRQ Format"), so 0x00 and 0x09 are illegal.
    814          */
    815         ACPI_ERROR ((AE_INFO,
    816             "Invalid interrupt polarity/trigger in resource list, 0x%X",
    817             Aml->Irq.Flags));
    818         return_ACPI_STATUS (AE_BAD_DATA);
    819     }
    820 
    821     Resource->Data.ExtendedIrq.InterruptCount = Temp8;
    822     if (Temp8 < 1)
    823     {
    824         /* Must have at least one IRQ */
    825 
    826         return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
    827     }
    828 
    829     if (Resource->Data.Dma.Transfer == 0x03)
    830     {
    831         ACPI_ERROR ((AE_INFO,
    832             "Invalid DMA.Transfer preference (3)"));
    833         return_ACPI_STATUS (AE_BAD_DATA);
    834     }
    835 #endif
    836