Path: blob/main/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c
48521 views
/******************************************************************************1*2* Module Name: dsopcode - Dispatcher support for regions and fields3*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/acparser.h>154#include <contrib/dev/acpica/include/amlcode.h>155#include <contrib/dev/acpica/include/acdispat.h>156#include <contrib/dev/acpica/include/acinterp.h>157#include <contrib/dev/acpica/include/acnamesp.h>158#include <contrib/dev/acpica/include/acevents.h>159#include <contrib/dev/acpica/include/actables.h>160161#define _COMPONENT ACPI_DISPATCHER162ACPI_MODULE_NAME ("dsopcode")163164/* Local prototypes */165166static ACPI_STATUS167AcpiDsInitBufferField (168UINT16 AmlOpcode,169ACPI_OPERAND_OBJECT *ObjDesc,170ACPI_OPERAND_OBJECT *BufferDesc,171ACPI_OPERAND_OBJECT *OffsetDesc,172ACPI_OPERAND_OBJECT *LengthDesc,173ACPI_OPERAND_OBJECT *ResultDesc);174175176/*******************************************************************************177*178* FUNCTION: AcpiDsInitializeRegion179*180* PARAMETERS: ObjHandle - Region namespace node181*182* RETURN: Status183*184* DESCRIPTION: Front end to EvInitializeRegion185*186******************************************************************************/187188ACPI_STATUS189AcpiDsInitializeRegion (190ACPI_HANDLE ObjHandle)191{192ACPI_OPERAND_OBJECT *ObjDesc;193ACPI_STATUS Status;194195196ObjDesc = AcpiNsGetAttachedObject (ObjHandle);197198/* Namespace is NOT locked */199200Status = AcpiEvInitializeRegion (ObjDesc);201return (Status);202}203204205/*******************************************************************************206*207* FUNCTION: AcpiDsInitBufferField208*209* PARAMETERS: AmlOpcode - CreateXxxField210* ObjDesc - BufferField object211* BufferDesc - Host Buffer212* OffsetDesc - Offset into buffer213* LengthDesc - Length of field (CREATE_FIELD_OP only)214* ResultDesc - Where to store the result215*216* RETURN: Status217*218* DESCRIPTION: Perform actual initialization of a buffer field219*220******************************************************************************/221222static ACPI_STATUS223AcpiDsInitBufferField (224UINT16 AmlOpcode,225ACPI_OPERAND_OBJECT *ObjDesc,226ACPI_OPERAND_OBJECT *BufferDesc,227ACPI_OPERAND_OBJECT *OffsetDesc,228ACPI_OPERAND_OBJECT *LengthDesc,229ACPI_OPERAND_OBJECT *ResultDesc)230{231UINT32 Offset;232UINT32 BitOffset;233UINT32 BitCount;234UINT8 FieldFlags;235ACPI_STATUS Status;236237238ACPI_FUNCTION_TRACE_PTR (DsInitBufferField, ObjDesc);239240241/* Host object must be a Buffer */242243if (BufferDesc->Common.Type != ACPI_TYPE_BUFFER)244{245ACPI_ERROR ((AE_INFO,246"Target of Create Field is not a Buffer object - %s",247AcpiUtGetObjectTypeName (BufferDesc)));248249Status = AE_AML_OPERAND_TYPE;250goto Cleanup;251}252253/*254* The last parameter to all of these opcodes (ResultDesc) started255* out as a NameString, and should therefore now be a NS node256* after resolution in AcpiExResolveOperands().257*/258if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED)259{260ACPI_ERROR ((AE_INFO,261"(%s) destination not a NS Node [%s]",262AcpiPsGetOpcodeName (AmlOpcode),263AcpiUtGetDescriptorName (ResultDesc)));264265Status = AE_AML_OPERAND_TYPE;266goto Cleanup;267}268269Offset = (UINT32) OffsetDesc->Integer.Value;270271/*272* Setup the Bit offsets and counts, according to the opcode273*/274switch (AmlOpcode)275{276case AML_CREATE_FIELD_OP:277278/* Offset is in bits, count is in bits */279280FieldFlags = AML_FIELD_ACCESS_BYTE;281BitOffset = Offset;282BitCount = (UINT32) LengthDesc->Integer.Value;283284/* Must have a valid (>0) bit count */285286if (BitCount == 0)287{288ACPI_BIOS_ERROR ((AE_INFO,289"Attempt to CreateField of length zero"));290Status = AE_AML_OPERAND_VALUE;291goto Cleanup;292}293break;294295case AML_CREATE_BIT_FIELD_OP:296297/* Offset is in bits, Field is one bit */298299BitOffset = Offset;300BitCount = 1;301FieldFlags = AML_FIELD_ACCESS_BYTE;302break;303304case AML_CREATE_BYTE_FIELD_OP:305306/* Offset is in bytes, field is one byte */307308BitOffset = 8 * Offset;309BitCount = 8;310FieldFlags = AML_FIELD_ACCESS_BYTE;311break;312313case AML_CREATE_WORD_FIELD_OP:314315/* Offset is in bytes, field is one word */316317BitOffset = 8 * Offset;318BitCount = 16;319FieldFlags = AML_FIELD_ACCESS_WORD;320break;321322case AML_CREATE_DWORD_FIELD_OP:323324/* Offset is in bytes, field is one dword */325326BitOffset = 8 * Offset;327BitCount = 32;328FieldFlags = AML_FIELD_ACCESS_DWORD;329break;330331case AML_CREATE_QWORD_FIELD_OP:332333/* Offset is in bytes, field is one qword */334335BitOffset = 8 * Offset;336BitCount = 64;337FieldFlags = AML_FIELD_ACCESS_QWORD;338break;339340default:341342ACPI_ERROR ((AE_INFO,343"Unknown field creation opcode 0x%02X",344AmlOpcode));345Status = AE_AML_BAD_OPCODE;346goto Cleanup;347}348349/* Entire field must fit within the current length of the buffer */350351if ((BitOffset + BitCount) >352(8 * (UINT32) BufferDesc->Buffer.Length))353{354Status = AE_AML_BUFFER_LIMIT;355ACPI_BIOS_EXCEPTION ((AE_INFO, Status,356"Field [%4.4s] at bit offset/length %u/%u "357"exceeds size of target Buffer (%u bits)",358AcpiUtGetNodeName (ResultDesc), BitOffset, BitCount,3598 * (UINT32) BufferDesc->Buffer.Length));360goto Cleanup;361}362363/*364* Initialize areas of the field object that are common to all fields365* For FieldFlags, use LOCK_RULE = 0 (NO_LOCK),366* UPDATE_RULE = 0 (UPDATE_PRESERVE)367*/368Status = AcpiExPrepCommonFieldObject (369ObjDesc, FieldFlags, 0, BitOffset, BitCount);370if (ACPI_FAILURE (Status))371{372goto Cleanup;373}374375ObjDesc->BufferField.BufferObj = BufferDesc;376ObjDesc->BufferField.IsCreateField = AmlOpcode == AML_CREATE_FIELD_OP;377378/* Reference count for BufferDesc inherits ObjDesc count */379380BufferDesc->Common.ReferenceCount = (UINT16)381(BufferDesc->Common.ReferenceCount + ObjDesc->Common.ReferenceCount);382383384Cleanup:385386/* Always delete the operands */387388AcpiUtRemoveReference (OffsetDesc);389AcpiUtRemoveReference (BufferDesc);390391if (AmlOpcode == AML_CREATE_FIELD_OP)392{393AcpiUtRemoveReference (LengthDesc);394}395396/* On failure, delete the result descriptor */397398if (ACPI_FAILURE (Status))399{400AcpiUtRemoveReference (ResultDesc); /* Result descriptor */401}402else403{404/* Now the address and length are valid for this BufferField */405406ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID;407}408409return_ACPI_STATUS (Status);410}411412413/*******************************************************************************414*415* FUNCTION: AcpiDsEvalBufferFieldOperands416*417* PARAMETERS: WalkState - Current walk418* Op - A valid BufferField Op object419*420* RETURN: Status421*422* DESCRIPTION: Get BufferField Buffer and Index423* Called from AcpiDsExecEndOp during BufferField parse tree walk424*425******************************************************************************/426427ACPI_STATUS428AcpiDsEvalBufferFieldOperands (429ACPI_WALK_STATE *WalkState,430ACPI_PARSE_OBJECT *Op)431{432ACPI_STATUS Status;433ACPI_OPERAND_OBJECT *ObjDesc;434ACPI_NAMESPACE_NODE *Node;435ACPI_PARSE_OBJECT *NextOp;436437438ACPI_FUNCTION_TRACE_PTR (DsEvalBufferFieldOperands, Op);439440441/*442* This is where we evaluate the address and length fields of the443* CreateXxxField declaration444*/445Node = Op->Common.Node;446447/* NextOp points to the op that holds the Buffer */448449NextOp = Op->Common.Value.Arg;450451/* Evaluate/create the address and length operands */452453Status = AcpiDsCreateOperands (WalkState, NextOp);454if (ACPI_FAILURE (Status))455{456return_ACPI_STATUS (Status);457}458459ObjDesc = AcpiNsGetAttachedObject (Node);460if (!ObjDesc)461{462return_ACPI_STATUS (AE_NOT_EXIST);463}464465/* Resolve the operands */466467Status = AcpiExResolveOperands (468Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);469if (ACPI_FAILURE (Status))470{471ACPI_ERROR ((AE_INFO, "(%s) bad operand(s), status 0x%X",472AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status));473474return_ACPI_STATUS (Status);475}476477/* Initialize the Buffer Field */478479if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)480{481/* NOTE: Slightly different operands for this opcode */482483Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,484WalkState->Operands[0], WalkState->Operands[1],485WalkState->Operands[2], WalkState->Operands[3]);486}487else488{489/* All other, CreateXxxField opcodes */490491Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,492WalkState->Operands[0], WalkState->Operands[1],493NULL, WalkState->Operands[2]);494}495496return_ACPI_STATUS (Status);497}498499500/*******************************************************************************501*502* FUNCTION: AcpiDsEvalRegionOperands503*504* PARAMETERS: WalkState - Current walk505* Op - A valid region Op object506*507* RETURN: Status508*509* DESCRIPTION: Get region address and length510* Called from AcpiDsExecEndOp during OpRegion parse tree walk511*512******************************************************************************/513514ACPI_STATUS515AcpiDsEvalRegionOperands (516ACPI_WALK_STATE *WalkState,517ACPI_PARSE_OBJECT *Op)518{519ACPI_STATUS Status;520ACPI_OPERAND_OBJECT *ObjDesc;521ACPI_OPERAND_OBJECT *OperandDesc;522ACPI_NAMESPACE_NODE *Node;523ACPI_PARSE_OBJECT *NextOp;524ACPI_ADR_SPACE_TYPE SpaceId;525526527ACPI_FUNCTION_TRACE_PTR (DsEvalRegionOperands, Op);528529530/*531* This is where we evaluate the address and length fields of the532* OpRegion declaration533*/534Node = Op->Common.Node;535536/* NextOp points to the op that holds the SpaceID */537538NextOp = Op->Common.Value.Arg;539SpaceId = (ACPI_ADR_SPACE_TYPE) NextOp->Common.Value.Integer;540541/* NextOp points to address op */542543NextOp = NextOp->Common.Next;544545/* Evaluate/create the address and length operands */546547Status = AcpiDsCreateOperands (WalkState, NextOp);548if (ACPI_FAILURE (Status))549{550return_ACPI_STATUS (Status);551}552553/* Resolve the length and address operands to numbers */554555Status = AcpiExResolveOperands (556Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);557if (ACPI_FAILURE (Status))558{559return_ACPI_STATUS (Status);560}561562ObjDesc = AcpiNsGetAttachedObject (Node);563if (!ObjDesc)564{565return_ACPI_STATUS (AE_NOT_EXIST);566}567568/*569* Get the length operand and save it570* (at Top of stack)571*/572OperandDesc = WalkState->Operands[WalkState->NumOperands - 1];573574ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value;575AcpiUtRemoveReference (OperandDesc);576577/* A zero-length operation region is unusable. Just warn */578579if (!ObjDesc->Region.Length && (SpaceId < ACPI_NUM_PREDEFINED_REGIONS))580{581ACPI_WARNING ((AE_INFO,582"Operation Region [%4.4s] has zero length (SpaceId %X)",583Node->Name.Ascii, SpaceId));584}585586/*587* Get the address and save it588* (at top of stack - 1)589*/590OperandDesc = WalkState->Operands[WalkState->NumOperands - 2];591592ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS)593OperandDesc->Integer.Value;594AcpiUtRemoveReference (OperandDesc);595596ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",597ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),598ObjDesc->Region.Length));599600Status = AcpiUtAddAddressRange (ObjDesc->Region.SpaceId,601ObjDesc->Region.Address, ObjDesc->Region.Length, Node);602603/* Now the address and length are valid for this opregion */604605ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID;606return_ACPI_STATUS (Status);607}608609610/*******************************************************************************611*612* FUNCTION: AcpiDsEvalTableRegionOperands613*614* PARAMETERS: WalkState - Current walk615* Op - A valid region Op object616*617* RETURN: Status618*619* DESCRIPTION: Get region address and length.620* Called from AcpiDsExecEndOp during DataTableRegion parse621* tree walk.622*623******************************************************************************/624625ACPI_STATUS626AcpiDsEvalTableRegionOperands (627ACPI_WALK_STATE *WalkState,628ACPI_PARSE_OBJECT *Op)629{630ACPI_STATUS Status;631ACPI_OPERAND_OBJECT *ObjDesc;632ACPI_OPERAND_OBJECT **Operand;633ACPI_NAMESPACE_NODE *Node;634ACPI_PARSE_OBJECT *NextOp;635ACPI_TABLE_HEADER *Table;636UINT32 TableIndex;637638639ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op);640641642/*643* This is where we evaluate the Signature string, OemId string,644* and OemTableId string of the Data Table Region declaration645*/646Node = Op->Common.Node;647648/* NextOp points to Signature string op */649650NextOp = Op->Common.Value.Arg;651652/*653* Evaluate/create the Signature string, OemId string,654* and OemTableId string operands655*/656Status = AcpiDsCreateOperands (WalkState, NextOp);657if (ACPI_FAILURE (Status))658{659return_ACPI_STATUS (Status);660}661662Operand = &WalkState->Operands[0];663664/*665* Resolve the Signature string, OemId string,666* and OemTableId string operands667*/668Status = AcpiExResolveOperands (669Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);670if (ACPI_FAILURE (Status))671{672goto Cleanup;673}674675/* Find the ACPI table */676677Status = AcpiTbFindTable (678Operand[0]->String.Pointer,679Operand[1]->String.Pointer,680Operand[2]->String.Pointer, &TableIndex);681if (ACPI_FAILURE (Status))682{683if (Status == AE_NOT_FOUND)684{685ACPI_ERROR ((AE_INFO,686"ACPI Table [%4.4s] OEM:(%s, %s) not found in RSDT/XSDT",687Operand[0]->String.Pointer,688Operand[1]->String.Pointer,689Operand[2]->String.Pointer));690}691goto Cleanup;692}693694Status = AcpiGetTableByIndex (TableIndex, &Table);695if (ACPI_FAILURE (Status))696{697goto Cleanup;698}699700ObjDesc = AcpiNsGetAttachedObject (Node);701if (!ObjDesc)702{703Status = AE_NOT_EXIST;704goto Cleanup;705}706707ObjDesc->Region.Address = ACPI_PTR_TO_PHYSADDR (Table);708ObjDesc->Region.Length = Table->Length;709ObjDesc->Region.Pointer = Table;710711ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",712ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),713ObjDesc->Region.Length));714715/* Now the address and length are valid for this opregion */716717ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID;718719Cleanup:720AcpiUtRemoveReference (Operand[0]);721AcpiUtRemoveReference (Operand[1]);722AcpiUtRemoveReference (Operand[2]);723724return_ACPI_STATUS (Status);725}726727728/*******************************************************************************729*730* FUNCTION: AcpiDsEvalDataObjectOperands731*732* PARAMETERS: WalkState - Current walk733* Op - A valid DataObject Op object734* ObjDesc - DataObject735*736* RETURN: Status737*738* DESCRIPTION: Get the operands and complete the following data object types:739* Buffer, Package.740*741******************************************************************************/742743ACPI_STATUS744AcpiDsEvalDataObjectOperands (745ACPI_WALK_STATE *WalkState,746ACPI_PARSE_OBJECT *Op,747ACPI_OPERAND_OBJECT *ObjDesc)748{749ACPI_STATUS Status;750ACPI_OPERAND_OBJECT *ArgDesc;751UINT32 Length;752753754ACPI_FUNCTION_TRACE (DsEvalDataObjectOperands);755756757/* The first operand (for all of these data objects) is the length */758759/*760* Set proper index into operand stack for AcpiDsObjStackPush761* invoked inside AcpiDsCreateOperand.762*/763WalkState->OperandIndex = WalkState->NumOperands;764765/* Ignore if child is not valid */766767if (!Op->Common.Value.Arg)768{769ACPI_ERROR ((AE_INFO,770"Missing child while evaluating opcode %4.4X, Op %p",771Op->Common.AmlOpcode, Op));772return_ACPI_STATUS (AE_OK);773}774775Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1);776if (ACPI_FAILURE (Status))777{778return_ACPI_STATUS (Status);779}780781Status = AcpiExResolveOperands (WalkState->Opcode,782&(WalkState->Operands [WalkState->NumOperands -1]),783WalkState);784if (ACPI_FAILURE (Status))785{786return_ACPI_STATUS (Status);787}788789/* Extract length operand */790791ArgDesc = WalkState->Operands [WalkState->NumOperands - 1];792Length = (UINT32) ArgDesc->Integer.Value;793794/* Cleanup for length operand */795796Status = AcpiDsObjStackPop (1, WalkState);797if (ACPI_FAILURE (Status))798{799return_ACPI_STATUS (Status);800}801802AcpiUtRemoveReference (ArgDesc);803804/*805* Create the actual data object806*/807switch (Op->Common.AmlOpcode)808{809case AML_BUFFER_OP:810811Status = AcpiDsBuildInternalBufferObj (812WalkState, Op, Length, &ObjDesc);813break;814815case AML_PACKAGE_OP:816case AML_VARIABLE_PACKAGE_OP:817818Status = AcpiDsBuildInternalPackageObj (819WalkState, Op, Length, &ObjDesc);820break;821822default:823824return_ACPI_STATUS (AE_AML_BAD_OPCODE);825}826827if (ACPI_SUCCESS (Status))828{829/*830* Return the object in the WalkState, unless the parent is a package -831* in this case, the return object will be stored in the parse tree832* for the package.833*/834if ((!Op->Common.Parent) ||835((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) &&836(Op->Common.Parent->Common.AmlOpcode != AML_VARIABLE_PACKAGE_OP) &&837(Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP)))838{839WalkState->ResultObj = ObjDesc;840}841}842843return_ACPI_STATUS (Status);844}845846847/*******************************************************************************848*849* FUNCTION: AcpiDsEvalBankFieldOperands850*851* PARAMETERS: WalkState - Current walk852* Op - A valid BankField Op object853*854* RETURN: Status855*856* DESCRIPTION: Get BankField BankValue857* Called from AcpiDsExecEndOp during BankField parse tree walk858*859******************************************************************************/860861ACPI_STATUS862AcpiDsEvalBankFieldOperands (863ACPI_WALK_STATE *WalkState,864ACPI_PARSE_OBJECT *Op)865{866ACPI_STATUS Status;867ACPI_OPERAND_OBJECT *ObjDesc;868ACPI_OPERAND_OBJECT *OperandDesc;869ACPI_NAMESPACE_NODE *Node;870ACPI_PARSE_OBJECT *NextOp;871ACPI_PARSE_OBJECT *Arg;872873874ACPI_FUNCTION_TRACE_PTR (DsEvalBankFieldOperands, Op);875876877/*878* This is where we evaluate the BankValue field of the879* BankField declaration880*/881882/* NextOp points to the op that holds the Region */883884NextOp = Op->Common.Value.Arg;885886/* NextOp points to the op that holds the Bank Register */887888NextOp = NextOp->Common.Next;889890/* NextOp points to the op that holds the Bank Value */891892NextOp = NextOp->Common.Next;893894/*895* Set proper index into operand stack for AcpiDsObjStackPush896* invoked inside AcpiDsCreateOperand.897*898* We use WalkState->Operands[0] to store the evaluated BankValue899*/900WalkState->OperandIndex = 0;901902Status = AcpiDsCreateOperand (WalkState, NextOp, 0);903if (ACPI_FAILURE (Status))904{905return_ACPI_STATUS (Status);906}907908Status = AcpiExResolveToValue (&WalkState->Operands[0], WalkState);909if (ACPI_FAILURE (Status))910{911return_ACPI_STATUS (Status);912}913914ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS,915AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 1);916/*917* Get the BankValue operand and save it918* (at Top of stack)919*/920OperandDesc = WalkState->Operands[0];921922/* Arg points to the start Bank Field */923924Arg = AcpiPsGetArg (Op, 4);925while (Arg)926{927/* Ignore OFFSET and ACCESSAS terms here */928929if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)930{931Node = Arg->Common.Node;932933ObjDesc = AcpiNsGetAttachedObject (Node);934if (!ObjDesc)935{936return_ACPI_STATUS (AE_NOT_EXIST);937}938939ObjDesc->BankField.Value = (UINT32) OperandDesc->Integer.Value;940}941942/* Move to next field in the list */943944Arg = Arg->Common.Next;945}946947AcpiUtRemoveReference (OperandDesc);948return_ACPI_STATUS (Status);949}950951952