xref: /onnv-gate/usr/src/uts/intel/io/acpica/resources/rsmisc.c (revision 9980:13d7f3eec672)
13446Smrj /*******************************************************************************
23446Smrj  *
33446Smrj  * Module Name: rsmisc - Miscellaneous resource descriptors
43446Smrj  *
53446Smrj  ******************************************************************************/
63446Smrj 
73446Smrj /******************************************************************************
83446Smrj  *
93446Smrj  * 1. Copyright Notice
103446Smrj  *
11*9980SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
123446Smrj  * All rights reserved.
133446Smrj  *
143446Smrj  * 2. License
153446Smrj  *
163446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
173446Smrj  * rights.  You may have additional license terms from the party that provided
183446Smrj  * you this software, covering your right to use that party's intellectual
193446Smrj  * property rights.
203446Smrj  *
213446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
223446Smrj  * copy of the source code appearing in this file ("Covered Code") an
233446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
243446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
253446Smrj  * make derivatives, distribute, use and display any portion of the Covered
263446Smrj  * Code in any form, with the right to sublicense such rights; and
273446Smrj  *
283446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
293446Smrj  * license (with the right to sublicense), under only those claims of Intel
303446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
313446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
323446Smrj  * solely to the minimum extent necessary to exercise the above copyright
333446Smrj  * license, and in no event shall the patent license extend to any additions
343446Smrj  * to or modifications of the Original Intel Code.  No other license or right
353446Smrj  * is granted directly or by implication, estoppel or otherwise;
363446Smrj  *
373446Smrj  * The above copyright and patent license is granted only if the following
383446Smrj  * conditions are met:
393446Smrj  *
403446Smrj  * 3. Conditions
413446Smrj  *
423446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
433446Smrj  * Redistribution of source code of any substantial portion of the Covered
443446Smrj  * Code or modification with rights to further distribute source must include
453446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
463446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
473446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
483446Smrj  * contain a file documenting the changes Licensee made to create that Covered
493446Smrj  * Code and the date of any change.  Licensee must include in that file the
503446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
513446Smrj  * must include a prominent statement that the modification is derived,
523446Smrj  * directly or indirectly, from Original Intel Code.
533446Smrj  *
543446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
553446Smrj  * Redistribution of source code of any substantial portion of the Covered
563446Smrj  * Code or modification without rights to further distribute source must
573446Smrj  * include the following Disclaimer and Export Compliance provision in the
583446Smrj  * documentation and/or other materials provided with distribution.  In
593446Smrj  * addition, Licensee may not authorize further sublicense of source of any
603446Smrj  * portion of the Covered Code, and must include terms to the effect that the
613446Smrj  * license from Licensee to its licensee is limited to the intellectual
623446Smrj  * property embodied in the software Licensee provides to its licensee, and
633446Smrj  * not to intellectual property embodied in modifications its licensee may
643446Smrj  * make.
653446Smrj  *
663446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
673446Smrj  * substantial portion of the Covered Code or modification must reproduce the
683446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
693446Smrj  * provision in the documentation and/or other materials provided with the
703446Smrj  * distribution.
713446Smrj  *
723446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
733446Smrj  * Intel Code.
743446Smrj  *
753446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
763446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
773446Smrj  * other dealings in products derived from or relating to the Covered Code
783446Smrj  * without prior written authorization from Intel.
793446Smrj  *
803446Smrj  * 4. Disclaimer and Export Compliance
813446Smrj  *
823446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
833446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
843446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
853446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
863446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
873446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
883446Smrj  * PARTICULAR PURPOSE.
893446Smrj  *
903446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
913446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
923446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
933446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
943446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
953446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
963446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
973446Smrj  * LIMITED REMEDY.
983446Smrj  *
993446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1003446Smrj  * software or system incorporating such software without first obtaining any
1013446Smrj  * required license or other approval from the U. S. Department of Commerce or
1023446Smrj  * any other agency or department of the United States Government.  In the
1033446Smrj  * event Licensee exports any such software from the United States or
1043446Smrj  * re-exports any such software from a foreign destination, Licensee shall
1053446Smrj  * ensure that the distribution and export/re-export of the software is in
1063446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
1073446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1083446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
1093446Smrj  * software, or service, directly or indirectly, to any country for which the
1103446Smrj  * United States government or any agency thereof requires an export license,
1113446Smrj  * other governmental approval, or letter of assurance, without first obtaining
1123446Smrj  * such license, approval or letter.
1133446Smrj  *
1143446Smrj  *****************************************************************************/
1153446Smrj 
1163446Smrj #define __RSMISC_C__
1173446Smrj 
1183446Smrj #include "acpi.h"
119*9980SDana.Myers@Sun.COM #include "accommon.h"
1203446Smrj #include "acresrc.h"
1213446Smrj 
1223446Smrj #define _COMPONENT          ACPI_RESOURCES
1233446Smrj         ACPI_MODULE_NAME    ("rsmisc")
1243446Smrj 
1253446Smrj 
1263446Smrj #define INIT_RESOURCE_TYPE(i)       i->ResourceOffset
1273446Smrj #define INIT_RESOURCE_LENGTH(i)     i->AmlOffset
1283446Smrj #define INIT_TABLE_LENGTH(i)        i->Value
1293446Smrj 
1303446Smrj #define COMPARE_OPCODE(i)           i->ResourceOffset
1313446Smrj #define COMPARE_TARGET(i)           i->AmlOffset
1323446Smrj #define COMPARE_VALUE(i)            i->Value
1333446Smrj 
1343446Smrj 
1353446Smrj /*******************************************************************************
1363446Smrj  *
1373446Smrj  * FUNCTION:    AcpiRsConvertAmlToResource
1383446Smrj  *
1393446Smrj  * PARAMETERS:  Resource            - Pointer to the resource descriptor
1403446Smrj  *              Aml                 - Where the AML descriptor is returned
1413446Smrj  *              Info                - Pointer to appropriate conversion table
1423446Smrj  *
1433446Smrj  * RETURN:      Status
1443446Smrj  *
1453446Smrj  * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
1463446Smrj  *              internal resource descriptor
1473446Smrj  *
1483446Smrj  ******************************************************************************/
1493446Smrj 
1503446Smrj ACPI_STATUS
AcpiRsConvertAmlToResource(ACPI_RESOURCE * Resource,AML_RESOURCE * Aml,ACPI_RSCONVERT_INFO * Info)1513446Smrj AcpiRsConvertAmlToResource (
1523446Smrj     ACPI_RESOURCE           *Resource,
1533446Smrj     AML_RESOURCE            *Aml,
1543446Smrj     ACPI_RSCONVERT_INFO     *Info)
1553446Smrj {
1563446Smrj     ACPI_RS_LENGTH          AmlResourceLength;
1573446Smrj     void                    *Source;
1583446Smrj     void                    *Destination;
1593446Smrj     char                    *Target;
1603446Smrj     UINT8                   Count;
1613446Smrj     UINT8                   FlagsMode = FALSE;
1623446Smrj     UINT16                  ItemCount = 0;
1633446Smrj     UINT16                  Temp16 = 0;
1643446Smrj 
1653446Smrj 
1663446Smrj     ACPI_FUNCTION_TRACE (RsConvertAmlToResource);
1673446Smrj 
1683446Smrj 
1697851SDana.Myers@Sun.COM     if (((ACPI_SIZE) Resource) & 0x3)
1703446Smrj     {
1713446Smrj         /* Each internal resource struct is expected to be 32-bit aligned */
1723446Smrj 
1733446Smrj         ACPI_WARNING ((AE_INFO,
1743446Smrj             "Misaligned resource pointer (get): %p Type %2.2X Len %X",
1753446Smrj             Resource, Resource->Type, Resource->Length));
1763446Smrj     }
1773446Smrj 
1783446Smrj     /* Extract the resource Length field (does not include header length) */
1793446Smrj 
1803446Smrj     AmlResourceLength = AcpiUtGetResourceLength (Aml);
1813446Smrj 
1823446Smrj     /*
1833446Smrj      * First table entry must be ACPI_RSC_INITxxx and must contain the
1843446Smrj      * table length (# of table entries)
1853446Smrj      */
1863446Smrj     Count = INIT_TABLE_LENGTH (Info);
1873446Smrj 
1883446Smrj     while (Count)
1893446Smrj     {
1903446Smrj         /*
1913446Smrj          * Source is the external AML byte stream buffer,
1923446Smrj          * destination is the internal resource descriptor
1933446Smrj          */
1943446Smrj         Source      = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
1953446Smrj         Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
1963446Smrj 
1973446Smrj         switch (Info->Opcode)
1983446Smrj         {
1993446Smrj         case ACPI_RSC_INITGET:
2003446Smrj             /*
2013446Smrj              * Get the resource type and the initial (minimum) length
2023446Smrj              */
2033446Smrj             ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info));
2043446Smrj             Resource->Type = INIT_RESOURCE_TYPE (Info);
2053446Smrj             Resource->Length = INIT_RESOURCE_LENGTH (Info);
2063446Smrj             break;
2073446Smrj 
2083446Smrj 
2093446Smrj         case ACPI_RSC_INITSET:
2103446Smrj             break;
2113446Smrj 
2123446Smrj 
2133446Smrj         case ACPI_RSC_FLAGINIT:
2143446Smrj 
2153446Smrj             FlagsMode = TRUE;
2163446Smrj             break;
2173446Smrj 
2183446Smrj 
2193446Smrj         case ACPI_RSC_1BITFLAG:
2203446Smrj             /*
2213446Smrj              * Mask and shift the flag bit
2223446Smrj              */
2233446Smrj             ACPI_SET8 (Destination) = (UINT8)
2243446Smrj                 ((ACPI_GET8 (Source) >> Info->Value) & 0x01);
2253446Smrj             break;
2263446Smrj 
2273446Smrj 
2283446Smrj         case ACPI_RSC_2BITFLAG:
2293446Smrj             /*
2303446Smrj              * Mask and shift the flag bits
2313446Smrj              */
2323446Smrj             ACPI_SET8 (Destination) = (UINT8)
2333446Smrj                 ((ACPI_GET8 (Source) >> Info->Value) & 0x03);
2343446Smrj             break;
2353446Smrj 
2363446Smrj 
2373446Smrj         case ACPI_RSC_COUNT:
2383446Smrj 
2393446Smrj             ItemCount = ACPI_GET8 (Source);
2403446Smrj             ACPI_SET8 (Destination) = (UINT8) ItemCount;
2413446Smrj 
2423446Smrj             Resource->Length = Resource->Length +
2433446Smrj                 (Info->Value * (ItemCount - 1));
2443446Smrj             break;
2453446Smrj 
2463446Smrj 
2473446Smrj         case ACPI_RSC_COUNT16:
2483446Smrj 
2493446Smrj             ItemCount = AmlResourceLength;
2503446Smrj             ACPI_SET16 (Destination) = ItemCount;
2513446Smrj 
2523446Smrj             Resource->Length = Resource->Length +
2533446Smrj                 (Info->Value * (ItemCount - 1));
2543446Smrj             break;
2553446Smrj 
2563446Smrj 
2573446Smrj         case ACPI_RSC_LENGTH:
2583446Smrj 
2593446Smrj             Resource->Length = Resource->Length + Info->Value;
2603446Smrj             break;
2613446Smrj 
2623446Smrj 
2633446Smrj         case ACPI_RSC_MOVE8:
2643446Smrj         case ACPI_RSC_MOVE16:
2653446Smrj         case ACPI_RSC_MOVE32:
2663446Smrj         case ACPI_RSC_MOVE64:
2673446Smrj             /*
2683446Smrj              * Raw data move. Use the Info value field unless ItemCount has
2693446Smrj              * been previously initialized via a COUNT opcode
2703446Smrj              */
2713446Smrj             if (Info->Value)
2723446Smrj             {
2733446Smrj                 ItemCount = Info->Value;
2743446Smrj             }
2753446Smrj             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
2763446Smrj             break;
2773446Smrj 
2783446Smrj 
2793446Smrj         case ACPI_RSC_SET8:
2803446Smrj 
2813446Smrj             ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value);
2823446Smrj             break;
2833446Smrj 
2843446Smrj 
2853446Smrj         case ACPI_RSC_DATA8:
2863446Smrj 
2873446Smrj             Target = ACPI_ADD_PTR (char, Resource, Info->Value);
2883446Smrj             ACPI_MEMCPY (Destination, Source,  ACPI_GET16 (Target));
2893446Smrj             break;
2903446Smrj 
2913446Smrj 
2923446Smrj         case ACPI_RSC_ADDRESS:
2933446Smrj             /*
2943446Smrj              * Common handler for address descriptor flags
2953446Smrj              */
2963446Smrj             if (!AcpiRsGetAddressCommon (Resource, Aml))
2973446Smrj             {
2983446Smrj                 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
2993446Smrj             }
3003446Smrj             break;
3013446Smrj 
3023446Smrj 
3033446Smrj         case ACPI_RSC_SOURCE:
3043446Smrj             /*
3053446Smrj              * Optional ResourceSource (Index and String)
3063446Smrj              */
3073446Smrj             Resource->Length +=
3083446Smrj                 AcpiRsGetResourceSource (AmlResourceLength, Info->Value,
3093446Smrj                     Destination, Aml, NULL);
3103446Smrj             break;
3113446Smrj 
3123446Smrj 
3133446Smrj         case ACPI_RSC_SOURCEX:
3143446Smrj             /*
3153446Smrj              * Optional ResourceSource (Index and String). This is the more
3163446Smrj              * complicated case used by the Interrupt() macro
3173446Smrj              */
3183446Smrj             Target = ACPI_ADD_PTR (char, Resource, Info->AmlOffset + (ItemCount * 4));
3193446Smrj 
3203446Smrj             Resource->Length +=
3213446Smrj                 AcpiRsGetResourceSource (AmlResourceLength,
3223446Smrj                     (ACPI_RS_LENGTH) (((ItemCount - 1) * sizeof (UINT32)) + Info->Value),
3233446Smrj                     Destination, Aml, Target);
3243446Smrj             break;
3253446Smrj 
3263446Smrj 
3273446Smrj         case ACPI_RSC_BITMASK:
3283446Smrj             /*
3293446Smrj              * 8-bit encoded bitmask (DMA macro)
3303446Smrj              */
3313446Smrj             ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination);
3323446Smrj             if (ItemCount)
3333446Smrj             {
3343446Smrj                 Resource->Length += (ItemCount - 1);
3353446Smrj             }
3363446Smrj 
3373446Smrj             Target = ACPI_ADD_PTR (char, Resource, Info->Value);
3383446Smrj             ACPI_SET8 (Target) = (UINT8) ItemCount;
3393446Smrj             break;
3403446Smrj 
3413446Smrj 
3423446Smrj         case ACPI_RSC_BITMASK16:
3433446Smrj             /*
3443446Smrj              * 16-bit encoded bitmask (IRQ macro)
3453446Smrj              */
3463446Smrj             ACPI_MOVE_16_TO_16 (&Temp16, Source);
3473446Smrj 
3483446Smrj             ItemCount = AcpiRsDecodeBitmask (Temp16, Destination);
3493446Smrj             if (ItemCount)
3503446Smrj             {
3513446Smrj                 Resource->Length += (ItemCount - 1);
3523446Smrj             }
3533446Smrj 
3543446Smrj             Target = ACPI_ADD_PTR (char, Resource, Info->Value);
3553446Smrj             ACPI_SET8 (Target) = (UINT8) ItemCount;
3563446Smrj             break;
3573446Smrj 
3583446Smrj 
3593446Smrj         case ACPI_RSC_EXIT_NE:
3603446Smrj             /*
3613446Smrj              * Control - Exit conversion if not equal
3623446Smrj              */
3633446Smrj             switch (Info->ResourceOffset)
3643446Smrj             {
3653446Smrj             case ACPI_RSC_COMPARE_AML_LENGTH:
3663446Smrj                 if (AmlResourceLength != Info->Value)
3673446Smrj                 {
3683446Smrj                     goto Exit;
3693446Smrj                 }
3703446Smrj                 break;
3713446Smrj 
3723446Smrj             case ACPI_RSC_COMPARE_VALUE:
3733446Smrj                 if (ACPI_GET8 (Source) != Info->Value)
3743446Smrj                 {
3753446Smrj                     goto Exit;
3763446Smrj                 }
3773446Smrj                 break;
3783446Smrj 
3793446Smrj             default:
3803446Smrj 
3813446Smrj                 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
3823446Smrj                 return_ACPI_STATUS (AE_BAD_PARAMETER);
3833446Smrj             }
3843446Smrj             break;
3853446Smrj 
3863446Smrj 
3873446Smrj         default:
3883446Smrj 
3893446Smrj             ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
3903446Smrj             return_ACPI_STATUS (AE_BAD_PARAMETER);
3913446Smrj         }
3923446Smrj 
3933446Smrj         Count--;
3943446Smrj         Info++;
3953446Smrj     }
3963446Smrj 
3973446Smrj Exit:
3983446Smrj     if (!FlagsMode)
3993446Smrj     {
4003446Smrj         /* Round the resource struct length up to the next boundary (32 or 64) */
4013446Smrj 
4023446Smrj         Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length);
4033446Smrj     }
4043446Smrj     return_ACPI_STATUS (AE_OK);
4053446Smrj }
4063446Smrj 
4073446Smrj 
4083446Smrj /*******************************************************************************
4093446Smrj  *
4103446Smrj  * FUNCTION:    AcpiRsConvertResourceToAml
4113446Smrj  *
4123446Smrj  * PARAMETERS:  Resource            - Pointer to the resource descriptor
4133446Smrj  *              Aml                 - Where the AML descriptor is returned
4143446Smrj  *              Info                - Pointer to appropriate conversion table
4153446Smrj  *
4163446Smrj  * RETURN:      Status
4173446Smrj  *
4183446Smrj  * DESCRIPTION: Convert an internal resource descriptor to the corresponding
4193446Smrj  *              external AML resource descriptor.
4203446Smrj  *
4213446Smrj  ******************************************************************************/
4223446Smrj 
4233446Smrj ACPI_STATUS
AcpiRsConvertResourceToAml(ACPI_RESOURCE * Resource,AML_RESOURCE * Aml,ACPI_RSCONVERT_INFO * Info)4243446Smrj AcpiRsConvertResourceToAml (
4253446Smrj     ACPI_RESOURCE           *Resource,
4263446Smrj     AML_RESOURCE            *Aml,
4273446Smrj     ACPI_RSCONVERT_INFO     *Info)
4283446Smrj {
4293446Smrj     void                    *Source = NULL;
4303446Smrj     void                    *Destination;
4313446Smrj     ACPI_RSDESC_SIZE        AmlLength = 0;
4323446Smrj     UINT8                   Count;
4333446Smrj     UINT16                  Temp16 = 0;
4343446Smrj     UINT16                  ItemCount = 0;
4353446Smrj 
4363446Smrj 
4373446Smrj     ACPI_FUNCTION_TRACE (RsConvertResourceToAml);
4383446Smrj 
4393446Smrj 
4403446Smrj     /*
4413446Smrj      * First table entry must be ACPI_RSC_INITxxx and must contain the
4423446Smrj      * table length (# of table entries)
4433446Smrj      */
4443446Smrj     Count = INIT_TABLE_LENGTH (Info);
4453446Smrj 
4463446Smrj     while (Count)
4473446Smrj     {
4483446Smrj         /*
4493446Smrj          * Source is the internal resource descriptor,
4503446Smrj          * destination is the external AML byte stream buffer
4513446Smrj          */
4523446Smrj         Source      = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
4533446Smrj         Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
4543446Smrj 
4553446Smrj         switch (Info->Opcode)
4563446Smrj         {
4573446Smrj         case ACPI_RSC_INITSET:
4583446Smrj 
4593446Smrj             ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info));
4603446Smrj             AmlLength = INIT_RESOURCE_LENGTH (Info);
4613446Smrj             AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml);
4623446Smrj             break;
4633446Smrj 
4643446Smrj 
4653446Smrj         case ACPI_RSC_INITGET:
4663446Smrj             break;
4673446Smrj 
4683446Smrj 
4693446Smrj         case ACPI_RSC_FLAGINIT:
4703446Smrj             /*
4713446Smrj              * Clear the flag byte
4723446Smrj              */
4733446Smrj             ACPI_SET8 (Destination) = 0;
4743446Smrj             break;
4753446Smrj 
4763446Smrj 
4773446Smrj         case ACPI_RSC_1BITFLAG:
4783446Smrj             /*
4793446Smrj              * Mask and shift the flag bit
4803446Smrj              */
4813446Smrj             ACPI_SET8 (Destination) |= (UINT8)
4823446Smrj                 ((ACPI_GET8 (Source) & 0x01) << Info->Value);
4833446Smrj             break;
4843446Smrj 
4853446Smrj 
4863446Smrj         case ACPI_RSC_2BITFLAG:
4873446Smrj             /*
4883446Smrj              * Mask and shift the flag bits
4893446Smrj              */
4903446Smrj             ACPI_SET8 (Destination) |= (UINT8)
4913446Smrj                 ((ACPI_GET8 (Source) & 0x03) << Info->Value);
4923446Smrj             break;
4933446Smrj 
4943446Smrj 
4953446Smrj         case ACPI_RSC_COUNT:
4963446Smrj 
4973446Smrj             ItemCount = ACPI_GET8 (Source);
4983446Smrj             ACPI_SET8 (Destination) = (UINT8) ItemCount;
4993446Smrj 
5003446Smrj             AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1)));
5013446Smrj             break;
5023446Smrj 
5033446Smrj 
5043446Smrj         case ACPI_RSC_COUNT16:
5053446Smrj 
5063446Smrj             ItemCount = ACPI_GET16 (Source);
5073446Smrj             AmlLength = (UINT16) (AmlLength + ItemCount);
5083446Smrj             AcpiRsSetResourceLength (AmlLength, Aml);
5093446Smrj             break;
5103446Smrj 
5113446Smrj 
5123446Smrj         case ACPI_RSC_LENGTH:
5133446Smrj 
5143446Smrj             AcpiRsSetResourceLength (Info->Value, Aml);
5153446Smrj             break;
5163446Smrj 
5173446Smrj 
5183446Smrj         case ACPI_RSC_MOVE8:
5193446Smrj         case ACPI_RSC_MOVE16:
5203446Smrj         case ACPI_RSC_MOVE32:
5213446Smrj         case ACPI_RSC_MOVE64:
5223446Smrj 
5233446Smrj             if (Info->Value)
5243446Smrj             {
5253446Smrj                 ItemCount = Info->Value;
5263446Smrj             }
5273446Smrj             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
5283446Smrj             break;
5293446Smrj 
5303446Smrj 
5313446Smrj         case ACPI_RSC_ADDRESS:
5323446Smrj 
5333446Smrj             /* Set the Resource Type, General Flags, and Type-Specific Flags */
5343446Smrj 
5353446Smrj             AcpiRsSetAddressCommon (Aml, Resource);
5363446Smrj             break;
5373446Smrj 
5383446Smrj 
5393446Smrj         case ACPI_RSC_SOURCEX:
5403446Smrj             /*
5413446Smrj              * Optional ResourceSource (Index and String)
5423446Smrj              */
5433446Smrj             AmlLength = AcpiRsSetResourceSource (
5443446Smrj                             Aml, (ACPI_RS_LENGTH) AmlLength, Source);
5453446Smrj             AcpiRsSetResourceLength (AmlLength, Aml);
5463446Smrj             break;
5473446Smrj 
5483446Smrj 
5493446Smrj         case ACPI_RSC_SOURCE:
5503446Smrj             /*
5513446Smrj              * Optional ResourceSource (Index and String). This is the more
5523446Smrj              * complicated case used by the Interrupt() macro
5533446Smrj              */
5543446Smrj             AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source);
5553446Smrj             AcpiRsSetResourceLength (AmlLength, Aml);
5563446Smrj             break;
5573446Smrj 
5583446Smrj 
5593446Smrj         case ACPI_RSC_BITMASK:
5603446Smrj             /*
5613446Smrj              * 8-bit encoded bitmask (DMA macro)
5623446Smrj              */
5633446Smrj             ACPI_SET8 (Destination) = (UINT8)
5643446Smrj                 AcpiRsEncodeBitmask (Source,
5653446Smrj                     *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
5663446Smrj             break;
5673446Smrj 
5683446Smrj 
5693446Smrj         case ACPI_RSC_BITMASK16:
5703446Smrj             /*
5713446Smrj              * 16-bit encoded bitmask (IRQ macro)
5723446Smrj              */
5733446Smrj             Temp16 = AcpiRsEncodeBitmask (Source,
5743446Smrj                         *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
5753446Smrj             ACPI_MOVE_16_TO_16 (Destination, &Temp16);
5763446Smrj             break;
5773446Smrj 
5783446Smrj 
5793446Smrj         case ACPI_RSC_EXIT_LE:
5803446Smrj             /*
5813446Smrj              * Control - Exit conversion if less than or equal
5823446Smrj              */
5833446Smrj             if (ItemCount <= Info->Value)
5843446Smrj             {
5853446Smrj                 goto Exit;
5863446Smrj             }
5873446Smrj             break;
5883446Smrj 
5893446Smrj 
5903446Smrj         case ACPI_RSC_EXIT_NE:
5913446Smrj             /*
5923446Smrj              * Control - Exit conversion if not equal
5933446Smrj              */
5943446Smrj             switch (COMPARE_OPCODE (Info))
5953446Smrj             {
5963446Smrj             case ACPI_RSC_COMPARE_VALUE:
5973446Smrj 
5983446Smrj                 if (*ACPI_ADD_PTR (UINT8, Resource,
5993446Smrj                         COMPARE_TARGET (Info)) != COMPARE_VALUE (Info))
6003446Smrj                 {
6013446Smrj                     goto Exit;
6023446Smrj                 }
6033446Smrj                 break;
6043446Smrj 
6053446Smrj             default:
6063446Smrj 
6073446Smrj                 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
6083446Smrj                 return_ACPI_STATUS (AE_BAD_PARAMETER);
6093446Smrj             }
6103446Smrj             break;
6113446Smrj 
6123446Smrj 
6137851SDana.Myers@Sun.COM         case ACPI_RSC_EXIT_EQ:
6147851SDana.Myers@Sun.COM             /*
6157851SDana.Myers@Sun.COM              * Control - Exit conversion if equal
6167851SDana.Myers@Sun.COM              */
6177851SDana.Myers@Sun.COM             if (*ACPI_ADD_PTR (UINT8, Resource,
6187851SDana.Myers@Sun.COM                     COMPARE_TARGET (Info)) == COMPARE_VALUE (Info))
6197851SDana.Myers@Sun.COM             {
6207851SDana.Myers@Sun.COM                 goto Exit;
6217851SDana.Myers@Sun.COM             }
6227851SDana.Myers@Sun.COM             break;
6237851SDana.Myers@Sun.COM 
6247851SDana.Myers@Sun.COM 
6253446Smrj         default:
6263446Smrj 
6273446Smrj             ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
6283446Smrj             return_ACPI_STATUS (AE_BAD_PARAMETER);
6293446Smrj         }
6303446Smrj 
6313446Smrj         Count--;
6323446Smrj         Info++;
6333446Smrj     }
6343446Smrj 
6353446Smrj Exit:
6363446Smrj     return_ACPI_STATUS (AE_OK);
6373446Smrj }
6383446Smrj 
6393446Smrj 
6403446Smrj #if 0
6413446Smrj /* Previous resource validations */
6423446Smrj 
6433446Smrj     if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION)
6443446Smrj     {
6453446Smrj         return_ACPI_STATUS (AE_SUPPORT);
6463446Smrj     }
6473446Smrj 
6483446Smrj     if (Resource->Data.StartDpf.PerformanceRobustness >= 3)
6493446Smrj     {
6503446Smrj         return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
6513446Smrj     }
6523446Smrj 
6533446Smrj     if (((Aml->Irq.Flags & 0x09) == 0x00) ||
6543446Smrj         ((Aml->Irq.Flags & 0x09) == 0x09))
6553446Smrj     {
6563446Smrj         /*
6573446Smrj          * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive]
6583446Smrj          * polarity/trigger interrupts are allowed (ACPI spec, section
6593446Smrj          * "IRQ Format"), so 0x00 and 0x09 are illegal.
6603446Smrj          */
6613446Smrj         ACPI_ERROR ((AE_INFO,
6623446Smrj             "Invalid interrupt polarity/trigger in resource list, %X",
6633446Smrj             Aml->Irq.Flags));
6643446Smrj         return_ACPI_STATUS (AE_BAD_DATA);
6653446Smrj     }
6663446Smrj 
6673446Smrj     Resource->Data.ExtendedIrq.InterruptCount = Temp8;
6683446Smrj     if (Temp8 < 1)
6693446Smrj     {
6703446Smrj         /* Must have at least one IRQ */
6713446Smrj 
6723446Smrj         return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
6733446Smrj     }
6743446Smrj 
6753446Smrj     if (Resource->Data.Dma.Transfer == 0x03)
6763446Smrj     {
6773446Smrj         ACPI_ERROR ((AE_INFO,
6783446Smrj             "Invalid DMA.Transfer preference (3)"));
6793446Smrj         return_ACPI_STATUS (AE_BAD_DATA);
6803446Smrj     }
6813446Smrj #endif
6823446Smrj 
6833446Smrj 
684