Path: blob/main/sys/contrib/dev/acpica/components/resources/rsmisc.c
48406 views
/*******************************************************************************1*2* Module Name: rsmisc - Miscellaneous resource descriptors3*4******************************************************************************/56/******************************************************************************7*8* 1. Copyright Notice9*10* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.11* All rights reserved.12*13* 2. License14*15* 2.1. This is your license from Intel Corp. under its intellectual property16* rights. You may have additional license terms from the party that provided17* you this software, covering your right to use that party's intellectual18* property rights.19*20* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a21* copy of the source code appearing in this file ("Covered Code") an22* irrevocable, perpetual, worldwide license under Intel's copyrights in the23* base code distributed originally by Intel ("Original Intel Code") to copy,24* make derivatives, distribute, use and display any portion of the Covered25* Code in any form, with the right to sublicense such rights; and26*27* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent28* license (with the right to sublicense), under only those claims of Intel29* patents that are infringed by the Original Intel Code, to make, use, sell,30* offer to sell, and import the Covered Code and derivative works thereof31* solely to the minimum extent necessary to exercise the above copyright32* license, and in no event shall the patent license extend to any additions33* to or modifications of the Original Intel Code. No other license or right34* is granted directly or by implication, estoppel or otherwise;35*36* The above copyright and patent license is granted only if the following37* conditions are met:38*39* 3. Conditions40*41* 3.1. Redistribution of Source with Rights to Further Distribute Source.42* Redistribution of source code of any substantial portion of the Covered43* Code or modification with rights to further distribute source must include44* the above Copyright Notice, the above License, this list of Conditions,45* and the following Disclaimer and Export Compliance provision. In addition,46* Licensee must cause all Covered Code to which Licensee contributes to47* contain a file documenting the changes Licensee made to create that Covered48* Code and the date of any change. Licensee must include in that file the49* documentation of any changes made by any predecessor Licensee. Licensee50* must include a prominent statement that the modification is derived,51* directly or indirectly, from Original Intel Code.52*53* 3.2. Redistribution of Source with no Rights to Further Distribute Source.54* Redistribution of source code of any substantial portion of the Covered55* Code or modification without rights to further distribute source must56* include the following Disclaimer and Export Compliance provision in the57* documentation and/or other materials provided with distribution. In58* addition, Licensee may not authorize further sublicense of source of any59* portion of the Covered Code, and must include terms to the effect that the60* license from Licensee to its licensee is limited to the intellectual61* property embodied in the software Licensee provides to its licensee, and62* not to intellectual property embodied in modifications its licensee may63* make.64*65* 3.3. Redistribution of Executable. Redistribution in executable form of any66* substantial portion of the Covered Code or modification must reproduce the67* above Copyright Notice, and the following Disclaimer and Export Compliance68* provision in the documentation and/or other materials provided with the69* distribution.70*71* 3.4. Intel retains all right, title, and interest in and to the Original72* Intel Code.73*74* 3.5. Neither the name Intel nor any other trademark owned or controlled by75* Intel shall be used in advertising or otherwise to promote the sale, use or76* other dealings in products derived from or relating to the Covered Code77* without prior written authorization from Intel.78*79* 4. Disclaimer and Export Compliance80*81* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED82* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE83* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,84* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY85* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY86* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A87* PARTICULAR PURPOSE.88*89* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES90* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR91* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,92* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY93* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL94* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS95* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY96* LIMITED REMEDY.97*98* 4.3. Licensee shall not export, either directly or indirectly, any of this99* software or system incorporating such software without first obtaining any100* required license or other approval from the U. S. Department of Commerce or101* any other agency or department of the United States Government. In the102* event Licensee exports any such software from the United States or103* re-exports any such software from a foreign destination, Licensee shall104* ensure that the distribution and export/re-export of the software is in105* compliance with all laws, regulations, orders, or other restrictions of the106* U.S. Export Administration Regulations. Licensee agrees that neither it nor107* any of its subsidiaries will export/re-export any technical data, process,108* software, or service, directly or indirectly, to any country for which the109* United States government or any agency thereof requires an export license,110* other governmental approval, or letter of assurance, without first obtaining111* such license, approval or letter.112*113*****************************************************************************114*115* Alternatively, you may choose to be licensed under the terms of the116* following license:117*118* Redistribution and use in source and binary forms, with or without119* modification, are permitted provided that the following conditions120* are met:121* 1. Redistributions of source code must retain the above copyright122* notice, this list of conditions, and the following disclaimer,123* without modification.124* 2. Redistributions in binary form must reproduce at minimum a disclaimer125* substantially similar to the "NO WARRANTY" disclaimer below126* ("Disclaimer") and any redistribution must be conditioned upon127* including a substantially similar Disclaimer requirement for further128* binary redistribution.129* 3. Neither the names of the above-listed copyright holders nor the names130* of any contributors may be used to endorse or promote products derived131* from this software without specific prior written permission.132*133* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS134* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT135* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR136* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT137* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,138* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT139* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,140* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY141* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT142* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE143* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.144*145* Alternatively, you may choose to be licensed under the terms of the146* GNU General Public License ("GPL") version 2 as published by the Free147* Software Foundation.148*149*****************************************************************************/150151#include <contrib/dev/acpica/include/acpi.h>152#include <contrib/dev/acpica/include/accommon.h>153#include <contrib/dev/acpica/include/acresrc.h>154155#define _COMPONENT ACPI_RESOURCES156ACPI_MODULE_NAME ("rsmisc")157158159#define INIT_RESOURCE_TYPE(i) i->ResourceOffset160#define INIT_RESOURCE_LENGTH(i) i->AmlOffset161#define INIT_TABLE_LENGTH(i) i->Value162163#define COMPARE_OPCODE(i) i->ResourceOffset164#define COMPARE_TARGET(i) i->AmlOffset165#define COMPARE_VALUE(i) i->Value166167168/*******************************************************************************169*170* FUNCTION: AcpiRsConvertAmlToResource171*172* PARAMETERS: Resource - Pointer to the resource descriptor173* Aml - Where the AML descriptor is returned174* Info - Pointer to appropriate conversion table175*176* RETURN: Status177*178* DESCRIPTION: Convert an external AML resource descriptor to the corresponding179* internal resource descriptor180*181******************************************************************************/182183ACPI_STATUS184AcpiRsConvertAmlToResource (185ACPI_RESOURCE *Resource,186AML_RESOURCE *Aml,187ACPI_RSCONVERT_INFO *Info)188{189ACPI_RS_LENGTH AmlResourceLength;190void *Source;191void *Destination;192char *Target;193UINT8 Count;194UINT8 FlagsMode = FALSE;195UINT16 ItemCount = 0;196UINT16 Temp16 = 0;197198199ACPI_FUNCTION_TRACE (RsConvertAmlToResource);200201202if (!Info)203{204return_ACPI_STATUS (AE_BAD_PARAMETER);205}206207if (((ACPI_SIZE) Resource) & 0x3)208{209/* Each internal resource struct is expected to be 32-bit aligned */210211ACPI_WARNING ((AE_INFO,212"Misaligned resource pointer (get): %p Type 0x%2.2X Length %u",213Resource, Resource->Type, Resource->Length));214}215216/* Extract the resource Length field (does not include header length) */217218AmlResourceLength = AcpiUtGetResourceLength (Aml);219220/*221* First table entry must be ACPI_RSC_INITxxx and must contain the222* table length (# of table entries)223*/224Count = INIT_TABLE_LENGTH (Info);225while (Count)226{227Target = NULL;228229/*230* Source is the external AML byte stream buffer,231* destination is the internal resource descriptor232*/233Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);234Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);235236switch (Info->Opcode)237{238case ACPI_RSC_INITGET:239/*240* Get the resource type and the initial (minimum) length241*/242memset (Resource, 0, INIT_RESOURCE_LENGTH (Info));243Resource->Type = INIT_RESOURCE_TYPE (Info);244Resource->Length = INIT_RESOURCE_LENGTH (Info);245break;246247case ACPI_RSC_INITSET:248break;249250case ACPI_RSC_FLAGINIT:251252FlagsMode = TRUE;253break;254255case ACPI_RSC_1BITFLAG:256/*257* Mask and shift the flag bit258*/259ACPI_SET8 (Destination,260((ACPI_GET8 (Source) >> Info->Value) & 0x01));261break;262263case ACPI_RSC_2BITFLAG:264/*265* Mask and shift the flag bits266*/267ACPI_SET8 (Destination,268((ACPI_GET8 (Source) >> Info->Value) & 0x03));269break;270271case ACPI_RSC_3BITFLAG:272/*273* Mask and shift the flag bits274*/275ACPI_SET8 (Destination,276((ACPI_GET8 (Source) >> Info->Value) & 0x07));277break;278279case ACPI_RSC_6BITFLAG:280/*281* Mask and shift the flag bits282*/283ACPI_SET8 (Destination,284((ACPI_GET8 (Source) >> Info->Value) & 0x3F));285break;286287case ACPI_RSC_COUNT:288289ItemCount = ACPI_GET8 (Source);290ACPI_SET8 (Destination, ItemCount);291292Resource->Length = Resource->Length +293(Info->Value * (ItemCount - 1));294break;295296case ACPI_RSC_COUNT16:297298ItemCount = AmlResourceLength;299ACPI_SET16 (Destination, ItemCount);300301Resource->Length = Resource->Length +302(Info->Value * (ItemCount - 1));303break;304305case ACPI_RSC_COUNT_GPIO_PIN:306307Target = ACPI_ADD_PTR (void, Aml, Info->Value);308ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);309310Resource->Length = Resource->Length + ItemCount;311ItemCount = ItemCount / 2;312ACPI_SET16 (Destination, ItemCount);313break;314315case ACPI_RSC_COUNT_GPIO_VEN:316317ItemCount = ACPI_GET8 (Source);318ACPI_SET8 (Destination, ItemCount);319320Resource->Length = Resource->Length + (Info->Value * ItemCount);321break;322323case ACPI_RSC_COUNT_GPIO_RES:324/*325* Vendor data is optional (length/offset may both be zero)326* Examine vendor data length field first327*/328Target = ACPI_ADD_PTR (void, Aml, (Info->Value + 2));329if (ACPI_GET16 (Target))330{331/* Use vendor offset to get resource source length */332333Target = ACPI_ADD_PTR (void, Aml, Info->Value);334ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);335}336else337{338/* No vendor data to worry about */339340ItemCount = Aml->LargeHeader.ResourceLength +341sizeof (AML_RESOURCE_LARGE_HEADER) -342ACPI_GET16 (Source);343}344345Resource->Length = Resource->Length + ItemCount;346ACPI_SET16 (Destination, ItemCount);347break;348349case ACPI_RSC_COUNT_SERIAL_VEN:350351ACPI_MOVE_16_TO_16(&Temp16, Source);352ItemCount = Temp16 - Info->Value;353354Resource->Length = Resource->Length + ItemCount;355ACPI_SET16 (Destination, ItemCount);356break;357358case ACPI_RSC_COUNT_SERIAL_RES:359360ACPI_MOVE_16_TO_16(&Temp16, Source);361ItemCount = (AmlResourceLength +362sizeof (AML_RESOURCE_LARGE_HEADER)) -363Temp16 - Info->Value;364365Resource->Length = Resource->Length + ItemCount;366ACPI_SET16 (Destination, ItemCount);367break;368369case ACPI_RSC_LENGTH:370371Resource->Length = Resource->Length + Info->Value;372break;373374case ACPI_RSC_MOVE8:375case ACPI_RSC_MOVE16:376case ACPI_RSC_MOVE32:377case ACPI_RSC_MOVE64:378/*379* Raw data move. Use the Info value field unless ItemCount has380* been previously initialized via a COUNT opcode381*/382if (Info->Value)383{384ItemCount = Info->Value;385}386AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);387break;388389case ACPI_RSC_MOVE_GPIO_PIN:390391/* Generate and set the PIN data pointer */392393Target = (char *) ACPI_ADD_PTR (void, Resource,394(Resource->Length - ItemCount * 2));395*(UINT16 **) Destination = ACPI_CAST_PTR (UINT16, Target);396397/* Copy the PIN data */398399Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source));400AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);401break;402403case ACPI_RSC_MOVE_GPIO_RES:404405/* Generate and set the ResourceSource string pointer */406407Target = (char *) ACPI_ADD_PTR (void, Resource,408(Resource->Length - ItemCount));409*(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);410411/* Copy the ResourceSource string */412413Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source));414AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);415break;416417case ACPI_RSC_MOVE_SERIAL_VEN:418419/* Generate and set the Vendor Data pointer */420421Target = (char *) ACPI_ADD_PTR (void, Resource,422(Resource->Length - ItemCount));423*(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);424425/* Copy the Vendor Data */426427Source = ACPI_ADD_PTR (void, Aml, Info->Value);428AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);429break;430431case ACPI_RSC_MOVE_SERIAL_RES:432433/* Generate and set the ResourceSource string pointer */434435Target = (char *) ACPI_ADD_PTR (void, Resource,436(Resource->Length - ItemCount));437*(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);438439/* Copy the ResourceSource string */440441ACPI_MOVE_16_TO_16 (&Temp16, Source);442Source = ACPI_ADD_PTR (443void, Aml, (Temp16 + Info->Value));444AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);445break;446447case ACPI_RSC_SET8:448449memset (Destination, Info->AmlOffset, Info->Value);450break;451452case ACPI_RSC_DATA8:453454Target = ACPI_ADD_PTR (char, Resource, Info->Value);455memcpy (Destination, Source, ACPI_GET16 (Target));456break;457458case ACPI_RSC_ADDRESS:459/*460* Common handler for address descriptor flags461*/462if (!AcpiRsGetAddressCommon (Resource, Aml))463{464return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);465}466break;467468case ACPI_RSC_SOURCE:469/*470* Optional ResourceSource (Index and String)471*/472Resource->Length +=473AcpiRsGetResourceSource (AmlResourceLength, Info->Value,474Destination, Aml, NULL);475break;476477case ACPI_RSC_SOURCEX:478/*479* Optional ResourceSource (Index and String). This is the more480* complicated case used by the Interrupt() macro481*/482Target = ACPI_ADD_PTR (char, Resource,483Info->AmlOffset + (ItemCount * 4));484485Resource->Length +=486AcpiRsGetResourceSource (AmlResourceLength, (ACPI_RS_LENGTH)487(((ItemCount - 1) * sizeof (UINT32)) + Info->Value),488Destination, Aml, Target);489break;490491case ACPI_RSC_BITMASK:492/*493* 8-bit encoded bitmask (DMA macro)494*/495ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination);496if (ItemCount)497{498Resource->Length += (ItemCount - 1);499}500501Target = ACPI_ADD_PTR (char, Resource, Info->Value);502ACPI_SET8 (Target, ItemCount);503break;504505case ACPI_RSC_BITMASK16:506/*507* 16-bit encoded bitmask (IRQ macro)508*/509ACPI_MOVE_16_TO_16 (&Temp16, Source);510511ItemCount = AcpiRsDecodeBitmask (Temp16, Destination);512if (ItemCount)513{514Resource->Length += (ItemCount - 1);515}516517Target = ACPI_ADD_PTR (char, Resource, Info->Value);518ACPI_SET8 (Target, ItemCount);519break;520521case ACPI_RSC_EXIT_NE:522/*523* Control - Exit conversion if not equal524*/525switch (Info->ResourceOffset)526{527case ACPI_RSC_COMPARE_AML_LENGTH:528529if (AmlResourceLength != Info->Value)530{531goto Exit;532}533break;534535case ACPI_RSC_COMPARE_VALUE:536537if (ACPI_GET8 (Source) != Info->Value)538{539goto Exit;540}541break;542543default:544545ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));546return_ACPI_STATUS (AE_BAD_PARAMETER);547}548break;549550default:551552ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));553return_ACPI_STATUS (AE_BAD_PARAMETER);554}555556Count--;557Info++;558}559560Exit:561if (!FlagsMode)562{563/* Round the resource struct length up to the next boundary (32 or 64) */564565Resource->Length = (UINT32)566ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length);567}568return_ACPI_STATUS (AE_OK);569}570571572/*******************************************************************************573*574* FUNCTION: AcpiRsConvertResourceToAml575*576* PARAMETERS: Resource - Pointer to the resource descriptor577* Aml - Where the AML descriptor is returned578* Info - Pointer to appropriate conversion table579*580* RETURN: Status581*582* DESCRIPTION: Convert an internal resource descriptor to the corresponding583* external AML resource descriptor.584*585******************************************************************************/586587ACPI_STATUS588AcpiRsConvertResourceToAml (589ACPI_RESOURCE *Resource,590AML_RESOURCE *Aml,591ACPI_RSCONVERT_INFO *Info)592{593void *Source = NULL;594void *Destination;595char *Target;596ACPI_RSDESC_SIZE AmlLength = 0;597UINT8 Count;598UINT16 Temp16 = 0;599UINT16 ItemCount = 0;600601602ACPI_FUNCTION_TRACE (RsConvertResourceToAml);603604605if (!Info)606{607return_ACPI_STATUS (AE_BAD_PARAMETER);608}609610/*611* First table entry must be ACPI_RSC_INITxxx and must contain the612* table length (# of table entries)613*/614Count = INIT_TABLE_LENGTH (Info);615616while (Count)617{618/*619* Source is the internal resource descriptor,620* destination is the external AML byte stream buffer621*/622Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);623Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);624625switch (Info->Opcode)626{627case ACPI_RSC_INITSET:628629memset (Aml, 0, INIT_RESOURCE_LENGTH (Info));630AmlLength = INIT_RESOURCE_LENGTH (Info);631AcpiRsSetResourceHeader (632INIT_RESOURCE_TYPE (Info), AmlLength, Aml);633break;634635case ACPI_RSC_INITGET:636break;637638case ACPI_RSC_FLAGINIT:639/*640* Clear the flag byte641*/642ACPI_SET8 (Destination, 0);643break;644645case ACPI_RSC_1BITFLAG:646/*647* Mask and shift the flag bit648*/649ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)650((ACPI_GET8 (Source) & 0x01) << Info->Value));651break;652653case ACPI_RSC_2BITFLAG:654/*655* Mask and shift the flag bits656*/657ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)658((ACPI_GET8 (Source) & 0x03) << Info->Value));659break;660661case ACPI_RSC_3BITFLAG:662/*663* Mask and shift the flag bits664*/665ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)666((ACPI_GET8 (Source) & 0x07) << Info->Value));667break;668669case ACPI_RSC_6BITFLAG:670/*671* Mask and shift the flag bits672*/673ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)674((ACPI_GET8 (Source) & 0x3F) << Info->Value));675break;676677case ACPI_RSC_COUNT:678679ItemCount = ACPI_GET8 (Source);680ACPI_SET8 (Destination, ItemCount);681682AmlLength = (UINT16)683(AmlLength + (Info->Value * (ItemCount - 1)));684break;685686case ACPI_RSC_COUNT16:687688ItemCount = ACPI_GET16 (Source);689AmlLength = (UINT16) (AmlLength + ItemCount);690AcpiRsSetResourceLength (AmlLength, Aml);691break;692693case ACPI_RSC_COUNT_GPIO_PIN:694695ItemCount = ACPI_GET16 (Source);696ACPI_SET16 (Destination, AmlLength);697698AmlLength = (UINT16) (AmlLength + ItemCount * 2);699Target = ACPI_ADD_PTR (void, Aml, Info->Value);700ACPI_SET16 (Target, AmlLength);701AcpiRsSetResourceLength (AmlLength, Aml);702break;703704case ACPI_RSC_COUNT_GPIO_VEN:705706ItemCount = ACPI_GET16 (Source);707ACPI_SET16 (Destination, ItemCount);708709AmlLength = (UINT16) (710AmlLength + (Info->Value * ItemCount));711AcpiRsSetResourceLength (AmlLength, Aml);712break;713714case ACPI_RSC_COUNT_GPIO_RES:715716/* Set resource source string length */717718ItemCount = ACPI_GET16 (Source);719ACPI_SET16 (Destination, AmlLength);720721/* Compute offset for the Vendor Data */722723AmlLength = (UINT16) (AmlLength + ItemCount);724Target = ACPI_ADD_PTR (void, Aml, Info->Value);725726/* Set vendor offset only if there is vendor data */727728ACPI_SET16 (Target, AmlLength);729730AcpiRsSetResourceLength (AmlLength, Aml);731break;732733case ACPI_RSC_COUNT_SERIAL_VEN:734735ItemCount = ACPI_GET16 (Source);736ACPI_SET16 (Destination, ItemCount + Info->Value);737AmlLength = (UINT16) (AmlLength + ItemCount);738AcpiRsSetResourceLength (AmlLength, Aml);739break;740741case ACPI_RSC_COUNT_SERIAL_RES:742743ItemCount = ACPI_GET16 (Source);744AmlLength = (UINT16) (AmlLength + ItemCount);745AcpiRsSetResourceLength (AmlLength, Aml);746break;747748case ACPI_RSC_LENGTH:749750AcpiRsSetResourceLength (Info->Value, Aml);751break;752753case ACPI_RSC_MOVE8:754case ACPI_RSC_MOVE16:755case ACPI_RSC_MOVE32:756case ACPI_RSC_MOVE64:757758if (Info->Value)759{760ItemCount = Info->Value;761}762AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);763break;764765case ACPI_RSC_MOVE_GPIO_PIN:766767Destination = (char *) ACPI_ADD_PTR (void, Aml,768ACPI_GET16 (Destination));769Source = * (UINT16 **) Source;770AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);771break;772773case ACPI_RSC_MOVE_GPIO_RES:774775/* Used for both ResourceSource string and VendorData */776777Destination = (char *) ACPI_ADD_PTR (void, Aml,778ACPI_GET16 (Destination));779Source = * (UINT8 **) Source;780AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);781break;782783case ACPI_RSC_MOVE_SERIAL_VEN:784785Destination = (char *) ACPI_ADD_PTR (void, Aml,786(AmlLength - ItemCount));787Source = * (UINT8 **) Source;788AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);789break;790791case ACPI_RSC_MOVE_SERIAL_RES:792793Destination = (char *) ACPI_ADD_PTR (void, Aml,794(AmlLength - ItemCount));795Source = * (UINT8 **) Source;796AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);797break;798799case ACPI_RSC_ADDRESS:800801/* Set the Resource Type, General Flags, and Type-Specific Flags */802803AcpiRsSetAddressCommon (Aml, Resource);804break;805806case ACPI_RSC_SOURCEX:807/*808* Optional ResourceSource (Index and String)809*/810AmlLength = AcpiRsSetResourceSource (811Aml, (ACPI_RS_LENGTH) AmlLength, Source);812AcpiRsSetResourceLength (AmlLength, Aml);813break;814815case ACPI_RSC_SOURCE:816/*817* Optional ResourceSource (Index and String). This is the more818* complicated case used by the Interrupt() macro819*/820AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source);821AcpiRsSetResourceLength (AmlLength, Aml);822break;823824case ACPI_RSC_BITMASK:825/*826* 8-bit encoded bitmask (DMA macro)827*/828ACPI_SET8 (Destination,829AcpiRsEncodeBitmask (Source,830*ACPI_ADD_PTR (UINT8, Resource, Info->Value)));831break;832833case ACPI_RSC_BITMASK16:834/*835* 16-bit encoded bitmask (IRQ macro)836*/837Temp16 = AcpiRsEncodeBitmask (838Source, *ACPI_ADD_PTR (UINT8, Resource, Info->Value));839ACPI_MOVE_16_TO_16 (Destination, &Temp16);840break;841842case ACPI_RSC_EXIT_LE:843/*844* Control - Exit conversion if less than or equal845*/846if (ItemCount <= Info->Value)847{848goto Exit;849}850break;851852case ACPI_RSC_EXIT_NE:853/*854* Control - Exit conversion if not equal855*/856switch (COMPARE_OPCODE (Info))857{858case ACPI_RSC_COMPARE_VALUE:859860if (*ACPI_ADD_PTR (UINT8, Resource,861COMPARE_TARGET (Info)) != COMPARE_VALUE (Info))862{863goto Exit;864}865break;866867default:868869ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));870return_ACPI_STATUS (AE_BAD_PARAMETER);871}872break;873874case ACPI_RSC_EXIT_EQ:875/*876* Control - Exit conversion if equal877*/878if (*ACPI_ADD_PTR (UINT8, Resource,879COMPARE_TARGET (Info)) == COMPARE_VALUE (Info))880{881goto Exit;882}883break;884885default:886887ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));888return_ACPI_STATUS (AE_BAD_PARAMETER);889}890891Count--;892Info++;893}894895Exit:896return_ACPI_STATUS (AE_OK);897}898899900#if 0901/* Previous resource validations */902903if (Aml->ExtAddress64.RevisionID !=904AML_RESOURCE_EXTENDED_ADDRESS_REVISION)905{906return_ACPI_STATUS (AE_SUPPORT);907}908909if (Resource->Data.StartDpf.PerformanceRobustness >= 3)910{911return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);912}913914if (((Aml->Irq.Flags & 0x09) == 0x00) ||915((Aml->Irq.Flags & 0x09) == 0x09))916{917/*918* Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive]919* polarity/trigger interrupts are allowed (ACPI spec, section920* "IRQ Format"), so 0x00 and 0x09 are illegal.921*/922ACPI_ERROR ((AE_INFO,923"Invalid interrupt polarity/trigger in resource list, 0x%X",924Aml->Irq.Flags));925return_ACPI_STATUS (AE_BAD_DATA);926}927928Resource->Data.ExtendedIrq.InterruptCount = Temp8;929if (Temp8 < 1)930{931/* Must have at least one IRQ */932933return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);934}935936if (Resource->Data.Dma.Transfer == 0x03)937{938ACPI_ERROR ((AE_INFO,939"Invalid DMA.Transfer preference (3)"));940return_ACPI_STATUS (AE_BAD_DATA);941}942#endif943944945