Path: blob/main/sys/contrib/dev/acpica/components/resources/rsutils.c
48406 views
/*******************************************************************************1*2* Module Name: rsutils - Utilities for the resource manager3*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/acnamesp.h>154#include <contrib/dev/acpica/include/acresrc.h>155156157#define _COMPONENT ACPI_RESOURCES158ACPI_MODULE_NAME ("rsutils")159160161/*******************************************************************************162*163* FUNCTION: AcpiRsDecodeBitmask164*165* PARAMETERS: Mask - Bitmask to decode166* List - Where the converted list is returned167*168* RETURN: Count of bits set (length of list)169*170* DESCRIPTION: Convert a bit mask into a list of values171*172******************************************************************************/173174UINT8175AcpiRsDecodeBitmask (176UINT16 Mask,177UINT8 *List)178{179UINT8 i;180UINT8 BitCount;181182183ACPI_FUNCTION_ENTRY ();184185186/* Decode the mask bits */187188for (i = 0, BitCount = 0; Mask; i++)189{190if (Mask & 0x0001)191{192List[BitCount] = i;193BitCount++;194}195196Mask >>= 1;197}198199return (BitCount);200}201202203/*******************************************************************************204*205* FUNCTION: AcpiRsEncodeBitmask206*207* PARAMETERS: List - List of values to encode208* Count - Length of list209*210* RETURN: Encoded bitmask211*212* DESCRIPTION: Convert a list of values to an encoded bitmask213*214******************************************************************************/215216UINT16217AcpiRsEncodeBitmask (218UINT8 *List,219UINT8 Count)220{221UINT32 i;222UINT16 Mask;223224225ACPI_FUNCTION_ENTRY ();226227228/* Encode the list into a single bitmask */229230for (i = 0, Mask = 0; i < Count; i++)231{232Mask |= (0x1 << List[i]);233}234235return (Mask);236}237238239/*******************************************************************************240*241* FUNCTION: AcpiRsMoveData242*243* PARAMETERS: Destination - Pointer to the destination descriptor244* Source - Pointer to the source descriptor245* ItemCount - How many items to move246* MoveType - Byte width247*248* RETURN: None249*250* DESCRIPTION: Move multiple data items from one descriptor to another. Handles251* alignment issues and endian issues if necessary, as configured252* via the ACPI_MOVE_* macros. (This is why a memcpy is not used)253*254******************************************************************************/255256void257AcpiRsMoveData (258void *Destination,259void *Source,260UINT16 ItemCount,261UINT8 MoveType)262{263UINT32 i;264265266ACPI_FUNCTION_ENTRY ();267268269/* One move per item */270271for (i = 0; i < ItemCount; i++)272{273switch (MoveType)274{275/*276* For the 8-bit case, we can perform the move all at once277* since there are no alignment or endian issues278*/279case ACPI_RSC_MOVE8:280case ACPI_RSC_MOVE_GPIO_RES:281case ACPI_RSC_MOVE_SERIAL_VEN:282case ACPI_RSC_MOVE_SERIAL_RES:283284memcpy (Destination, Source, ItemCount);285return;286287/*288* 16-, 32-, and 64-bit cases must use the move macros that perform289* endian conversion and/or accommodate hardware that cannot perform290* misaligned memory transfers291*/292case ACPI_RSC_MOVE16:293case ACPI_RSC_MOVE_GPIO_PIN:294295ACPI_MOVE_16_TO_16 (296&ACPI_CAST_PTR (UINT16, Destination)[i],297&ACPI_CAST_PTR (UINT16, Source)[i]);298break;299300case ACPI_RSC_MOVE32:301302ACPI_MOVE_32_TO_32 (303&ACPI_CAST_PTR (UINT32, Destination)[i],304&ACPI_CAST_PTR (UINT32, Source)[i]);305break;306307case ACPI_RSC_MOVE64:308309ACPI_MOVE_64_TO_64 (310&ACPI_CAST_PTR (UINT64, Destination)[i],311&ACPI_CAST_PTR (UINT64, Source)[i]);312break;313314default:315316return;317}318}319}320321322/*******************************************************************************323*324* FUNCTION: AcpiRsSetResourceLength325*326* PARAMETERS: TotalLength - Length of the AML descriptor, including327* the header and length fields.328* Aml - Pointer to the raw AML descriptor329*330* RETURN: None331*332* DESCRIPTION: Set the ResourceLength field of an AML333* resource descriptor, both Large and Small descriptors are334* supported automatically. Note: Descriptor Type field must335* be valid.336*337******************************************************************************/338339void340AcpiRsSetResourceLength (341ACPI_RSDESC_SIZE TotalLength,342AML_RESOURCE *Aml)343{344ACPI_RS_LENGTH ResourceLength;345346347ACPI_FUNCTION_ENTRY ();348349350/* Length is the total descriptor length minus the header length */351352ResourceLength = (ACPI_RS_LENGTH)353(TotalLength - AcpiUtGetResourceHeaderLength (Aml));354355/* Length is stored differently for large and small descriptors */356357if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE)358{359/* Large descriptor -- bytes 1-2 contain the 16-bit length */360361ACPI_MOVE_16_TO_16 (362&Aml->LargeHeader.ResourceLength, &ResourceLength);363}364else365{366/*367* Small descriptor -- bits 2:0 of byte 0 contain the length368* Clear any existing length, preserving descriptor type bits369*/370Aml->SmallHeader.DescriptorType = (UINT8)371((Aml->SmallHeader.DescriptorType &372~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)373| ResourceLength);374}375}376377378/*******************************************************************************379*380* FUNCTION: AcpiRsSetResourceHeader381*382* PARAMETERS: DescriptorType - Byte to be inserted as the type383* TotalLength - Length of the AML descriptor, including384* the header and length fields.385* Aml - Pointer to the raw AML descriptor386*387* RETURN: None388*389* DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML390* resource descriptor, both Large and Small descriptors are391* supported automatically392*393******************************************************************************/394395void396AcpiRsSetResourceHeader (397UINT8 DescriptorType,398ACPI_RSDESC_SIZE TotalLength,399AML_RESOURCE *Aml)400{401ACPI_FUNCTION_ENTRY ();402403404/* Set the Resource Type */405406Aml->SmallHeader.DescriptorType = DescriptorType;407408/* Set the Resource Length */409410AcpiRsSetResourceLength (TotalLength, Aml);411}412413414/*******************************************************************************415*416* FUNCTION: AcpiRsStrcpy417*418* PARAMETERS: Destination - Pointer to the destination string419* Source - Pointer to the source string420*421* RETURN: String length, including NULL terminator422*423* DESCRIPTION: Local string copy that returns the string length, saving a424* strcpy followed by a strlen.425*426******************************************************************************/427428static UINT16429AcpiRsStrcpy (430char *Destination,431char *Source)432{433UINT16 i;434435436ACPI_FUNCTION_ENTRY ();437438439for (i = 0; Source[i]; i++)440{441Destination[i] = Source[i];442}443444Destination[i] = 0;445446/* Return string length including the NULL terminator */447448return ((UINT16) (i + 1));449}450451452/*******************************************************************************453*454* FUNCTION: AcpiRsGetResourceSource455*456* PARAMETERS: ResourceLength - Length field of the descriptor457* MinimumLength - Minimum length of the descriptor (minus458* any optional fields)459* ResourceSource - Where the ResourceSource is returned460* Aml - Pointer to the raw AML descriptor461* StringPtr - (optional) where to store the actual462* ResourceSource string463*464* RETURN: Length of the string plus NULL terminator, rounded up to native465* word boundary466*467* DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor468* to an internal resource descriptor469*470******************************************************************************/471472ACPI_RS_LENGTH473AcpiRsGetResourceSource (474ACPI_RS_LENGTH ResourceLength,475ACPI_RS_LENGTH MinimumLength,476ACPI_RESOURCE_SOURCE *ResourceSource,477AML_RESOURCE *Aml,478char *StringPtr)479{480ACPI_RSDESC_SIZE TotalLength;481UINT8 *AmlResourceSource;482483484ACPI_FUNCTION_ENTRY ();485486487TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);488AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);489490/*491* ResourceSource is present if the length of the descriptor is longer492* than the minimum length.493*494* Note: Some resource descriptors will have an additional null, so495* we add 1 to the minimum length.496*/497if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1))498{499/* Get the ResourceSourceIndex */500501ResourceSource->Index = AmlResourceSource[0];502503ResourceSource->StringPtr = StringPtr;504if (!StringPtr)505{506/*507* String destination pointer is not specified; Set the String508* pointer to the end of the current ResourceSource structure.509*/510ResourceSource->StringPtr = ACPI_ADD_PTR (511char, ResourceSource, sizeof (ACPI_RESOURCE_SOURCE));512}513514/*515* In order for the Resource length to be a multiple of the native516* word, calculate the length of the string (+1 for NULL terminator)517* and expand to the next word multiple.518*519* Zero the entire area of the buffer.520*/521TotalLength = (UINT32) strlen (522ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;523524TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);525526memset (ResourceSource->StringPtr, 0, TotalLength);527528/* Copy the ResourceSource string to the destination */529530ResourceSource->StringLength = AcpiRsStrcpy (531ResourceSource->StringPtr,532ACPI_CAST_PTR (char, &AmlResourceSource[1]));533534return ((ACPI_RS_LENGTH) TotalLength);535}536537/* ResourceSource is not present */538539ResourceSource->Index = 0;540ResourceSource->StringLength = 0;541ResourceSource->StringPtr = NULL;542return (0);543}544545546/*******************************************************************************547*548* FUNCTION: AcpiRsSetResourceSource549*550* PARAMETERS: Aml - Pointer to the raw AML descriptor551* MinimumLength - Minimum length of the descriptor (minus552* any optional fields)553* ResourceSource - Internal ResourceSource554555*556* RETURN: Total length of the AML descriptor557*558* DESCRIPTION: Convert an optional ResourceSource from internal format to a559* raw AML resource descriptor560*561******************************************************************************/562563ACPI_RSDESC_SIZE564AcpiRsSetResourceSource (565AML_RESOURCE *Aml,566ACPI_RS_LENGTH MinimumLength,567ACPI_RESOURCE_SOURCE *ResourceSource)568{569UINT8 *AmlResourceSource;570ACPI_RSDESC_SIZE DescriptorLength;571572573ACPI_FUNCTION_ENTRY ();574575576DescriptorLength = MinimumLength;577578/* Non-zero string length indicates presence of a ResourceSource */579580if (ResourceSource->StringLength)581{582/* Point to the end of the AML descriptor */583584AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);585586/* Copy the ResourceSourceIndex */587588AmlResourceSource[0] = (UINT8) ResourceSource->Index;589590/* Copy the ResourceSource string */591592strcpy (ACPI_CAST_PTR (char, &AmlResourceSource[1]),593ResourceSource->StringPtr);594595/*596* Add the length of the string (+ 1 for null terminator) to the597* final descriptor length598*/599DescriptorLength += ((ACPI_RSDESC_SIZE)600ResourceSource->StringLength + 1);601}602603/* Return the new total length of the AML descriptor */604605return (DescriptorLength);606}607608609/*******************************************************************************610*611* FUNCTION: AcpiRsGetPrtMethodData612*613* PARAMETERS: Node - Device node614* RetBuffer - Pointer to a buffer structure for the615* results616*617* RETURN: Status618*619* DESCRIPTION: This function is called to get the _PRT value of an object620* contained in an object specified by the handle passed in621*622* If the function fails an appropriate status will be returned623* and the contents of the callers buffer is undefined.624*625******************************************************************************/626627ACPI_STATUS628AcpiRsGetPrtMethodData (629ACPI_NAMESPACE_NODE *Node,630ACPI_BUFFER *RetBuffer)631{632ACPI_OPERAND_OBJECT *ObjDesc;633ACPI_STATUS Status;634635636ACPI_FUNCTION_TRACE (RsGetPrtMethodData);637638639/* Parameters guaranteed valid by caller */640641/* Execute the method, no parameters */642643Status = AcpiUtEvaluateObject (644Node, METHOD_NAME__PRT, ACPI_BTYPE_PACKAGE, &ObjDesc);645if (ACPI_FAILURE (Status))646{647return_ACPI_STATUS (Status);648}649650/*651* Create a resource linked list from the byte stream buffer that comes652* back from the _CRS method execution.653*/654Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);655656/* On exit, we must delete the object returned by EvaluateObject */657658AcpiUtRemoveReference (ObjDesc);659return_ACPI_STATUS (Status);660}661662663/*******************************************************************************664*665* FUNCTION: AcpiRsGetCrsMethodData666*667* PARAMETERS: Node - Device node668* RetBuffer - Pointer to a buffer structure for the669* results670*671* RETURN: Status672*673* DESCRIPTION: This function is called to get the _CRS value of an object674* contained in an object specified by the handle passed in675*676* If the function fails an appropriate status will be returned677* and the contents of the callers buffer is undefined.678*679******************************************************************************/680681ACPI_STATUS682AcpiRsGetCrsMethodData (683ACPI_NAMESPACE_NODE *Node,684ACPI_BUFFER *RetBuffer)685{686ACPI_OPERAND_OBJECT *ObjDesc;687ACPI_STATUS Status;688689690ACPI_FUNCTION_TRACE (RsGetCrsMethodData);691692693/* Parameters guaranteed valid by caller */694695/* Execute the method, no parameters */696697Status = AcpiUtEvaluateObject (698Node, METHOD_NAME__CRS, ACPI_BTYPE_BUFFER, &ObjDesc);699if (ACPI_FAILURE (Status))700{701return_ACPI_STATUS (Status);702}703704/*705* Make the call to create a resource linked list from the706* byte stream buffer that comes back from the _CRS method707* execution.708*/709Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);710711/* On exit, we must delete the object returned by evaluateObject */712713AcpiUtRemoveReference (ObjDesc);714return_ACPI_STATUS (Status);715}716717718/*******************************************************************************719*720* FUNCTION: AcpiRsGetPrsMethodData721*722* PARAMETERS: Node - Device node723* RetBuffer - Pointer to a buffer structure for the724* results725*726* RETURN: Status727*728* DESCRIPTION: This function is called to get the _PRS value of an object729* contained in an object specified by the handle passed in730*731* If the function fails an appropriate status will be returned732* and the contents of the callers buffer is undefined.733*734******************************************************************************/735736ACPI_STATUS737AcpiRsGetPrsMethodData (738ACPI_NAMESPACE_NODE *Node,739ACPI_BUFFER *RetBuffer)740{741ACPI_OPERAND_OBJECT *ObjDesc;742ACPI_STATUS Status;743744745ACPI_FUNCTION_TRACE (RsGetPrsMethodData);746747748/* Parameters guaranteed valid by caller */749750/* Execute the method, no parameters */751752Status = AcpiUtEvaluateObject (753Node, METHOD_NAME__PRS, ACPI_BTYPE_BUFFER, &ObjDesc);754if (ACPI_FAILURE (Status))755{756return_ACPI_STATUS (Status);757}758759/*760* Make the call to create a resource linked list from the761* byte stream buffer that comes back from the _CRS method762* execution.763*/764Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);765766/* On exit, we must delete the object returned by evaluateObject */767768AcpiUtRemoveReference (ObjDesc);769return_ACPI_STATUS (Status);770}771772773/*******************************************************************************774*775* FUNCTION: AcpiRsGetAeiMethodData776*777* PARAMETERS: Node - Device node778* RetBuffer - Pointer to a buffer structure for the779* results780*781* RETURN: Status782*783* DESCRIPTION: This function is called to get the _AEI value of an object784* contained in an object specified by the handle passed in785*786* If the function fails an appropriate status will be returned787* and the contents of the callers buffer is undefined.788*789******************************************************************************/790791ACPI_STATUS792AcpiRsGetAeiMethodData (793ACPI_NAMESPACE_NODE *Node,794ACPI_BUFFER *RetBuffer)795{796ACPI_OPERAND_OBJECT *ObjDesc;797ACPI_STATUS Status;798799800ACPI_FUNCTION_TRACE (RsGetAeiMethodData);801802803/* Parameters guaranteed valid by caller */804805/* Execute the method, no parameters */806807Status = AcpiUtEvaluateObject (808Node, METHOD_NAME__AEI, ACPI_BTYPE_BUFFER, &ObjDesc);809if (ACPI_FAILURE (Status))810{811return_ACPI_STATUS (Status);812}813814/*815* Make the call to create a resource linked list from the816* byte stream buffer that comes back from the _CRS method817* execution.818*/819Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);820821/* On exit, we must delete the object returned by evaluateObject */822823AcpiUtRemoveReference (ObjDesc);824return_ACPI_STATUS (Status);825}826827828/*******************************************************************************829*830* FUNCTION: AcpiRsGetMethodData831*832* PARAMETERS: Handle - Handle to the containing object833* Path - Path to method, relative to Handle834* RetBuffer - Pointer to a buffer structure for the835* results836*837* RETURN: Status838*839* DESCRIPTION: This function is called to get the _CRS or _PRS value of an840* object contained in an object specified by the handle passed in841*842* If the function fails an appropriate status will be returned843* and the contents of the callers buffer is undefined.844*845******************************************************************************/846847ACPI_STATUS848AcpiRsGetMethodData (849ACPI_HANDLE Handle,850const char *Path,851ACPI_BUFFER *RetBuffer)852{853ACPI_OPERAND_OBJECT *ObjDesc;854ACPI_STATUS Status;855856857ACPI_FUNCTION_TRACE (RsGetMethodData);858859860/* Parameters guaranteed valid by caller */861862/* Execute the method, no parameters */863864Status = AcpiUtEvaluateObject (865ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle),866Path, ACPI_BTYPE_BUFFER, &ObjDesc);867if (ACPI_FAILURE (Status))868{869return_ACPI_STATUS (Status);870}871872/*873* Make the call to create a resource linked list from the874* byte stream buffer that comes back from the method875* execution.876*/877Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);878879/* On exit, we must delete the object returned by EvaluateObject */880881AcpiUtRemoveReference (ObjDesc);882return_ACPI_STATUS (Status);883}884885886/*******************************************************************************887*888* FUNCTION: AcpiRsSetSrsMethodData889*890* PARAMETERS: Node - Device node891* InBuffer - Pointer to a buffer structure of the892* parameter893*894* RETURN: Status895*896* DESCRIPTION: This function is called to set the _SRS of an object contained897* in an object specified by the handle passed in898*899* If the function fails an appropriate status will be returned900* and the contents of the callers buffer is undefined.901*902* Note: Parameters guaranteed valid by caller903*904******************************************************************************/905906ACPI_STATUS907AcpiRsSetSrsMethodData (908ACPI_NAMESPACE_NODE *Node,909ACPI_BUFFER *InBuffer)910{911ACPI_EVALUATE_INFO *Info;912ACPI_OPERAND_OBJECT *Args[2];913ACPI_STATUS Status;914ACPI_BUFFER Buffer;915916917ACPI_FUNCTION_TRACE (RsSetSrsMethodData);918919920/* Allocate and initialize the evaluation information block */921922Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));923if (!Info)924{925return_ACPI_STATUS (AE_NO_MEMORY);926}927928Info->PrefixNode = Node;929Info->RelativePathname = METHOD_NAME__SRS;930Info->Parameters = Args;931Info->Flags = ACPI_IGNORE_RETURN_VALUE;932933/*934* The InBuffer parameter will point to a linked list of935* resource parameters. It needs to be formatted into a936* byte stream to be sent in as an input parameter to _SRS937*938* Convert the linked list into a byte stream939*/940Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;941Status = AcpiRsCreateAmlResources (InBuffer, &Buffer);942if (ACPI_FAILURE (Status))943{944goto Cleanup;945}946947/* Create and initialize the method parameter object */948949Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);950if (!Args[0])951{952/*953* Must free the buffer allocated above (otherwise it is freed954* later)955*/956ACPI_FREE (Buffer.Pointer);957Status = AE_NO_MEMORY;958goto Cleanup;959}960961Args[0]->Buffer.Length = (UINT32) Buffer.Length;962Args[0]->Buffer.Pointer = Buffer.Pointer;963Args[0]->Common.Flags = AOPOBJ_DATA_VALID;964Args[1] = NULL;965966/* Execute the method, no return value is expected */967968Status = AcpiNsEvaluate (Info);969970/* Clean up and return the status from AcpiNsEvaluate */971972AcpiUtRemoveReference (Args[0]);973974Cleanup:975ACPI_FREE (Info);976return_ACPI_STATUS (Status);977}978979980