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