Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:02

0001 /******************************************************************************
0002  *
0003  * Module Name: dsopcode - Dispatcher support for regions and fields
0004  *
0005  *****************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights. You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025  * make derivatives, distribute, use and display any portion of the Covered
0026  * Code in any form, with the right to sublicense such rights; and
0027  *
0028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0029  * license (with the right to sublicense), under only those claims of Intel
0030  * patents that are infringed by the Original Intel Code, to make, use, sell,
0031  * offer to sell, and import the Covered Code and derivative works thereof
0032  * solely to the minimum extent necessary to exercise the above copyright
0033  * license, and in no event shall the patent license extend to any additions
0034  * to or modifications of the Original Intel Code. No other license or right
0035  * is granted directly or by implication, estoppel or otherwise;
0036  *
0037  * The above copyright and patent license is granted only if the following
0038  * conditions are met:
0039  *
0040  * 3. Conditions
0041  *
0042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0043  * Redistribution of source code of any substantial portion of the Covered
0044  * Code or modification with rights to further distribute source must include
0045  * the above Copyright Notice, the above License, this list of Conditions,
0046  * and the following Disclaimer and Export Compliance provision. In addition,
0047  * Licensee must cause all Covered Code to which Licensee contributes to
0048  * contain a file documenting the changes Licensee made to create that Covered
0049  * Code and the date of any change. Licensee must include in that file the
0050  * documentation of any changes made by any predecessor Licensee. Licensee
0051  * must include a prominent statement that the modification is derived,
0052  * directly or indirectly, from Original Intel Code.
0053  *
0054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0055  * Redistribution of source code of any substantial portion of the Covered
0056  * Code or modification without rights to further distribute source must
0057  * include the following Disclaimer and Export Compliance provision in the
0058  * documentation and/or other materials provided with distribution. In
0059  * addition, Licensee may not authorize further sublicense of source of any
0060  * portion of the Covered Code, and must include terms to the effect that the
0061  * license from Licensee to its licensee is limited to the intellectual
0062  * property embodied in the software Licensee provides to its licensee, and
0063  * not to intellectual property embodied in modifications its licensee may
0064  * make.
0065  *
0066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0067  * substantial portion of the Covered Code or modification must reproduce the
0068  * above Copyright Notice, and the following Disclaimer and Export Compliance
0069  * provision in the documentation and/or other materials provided with the
0070  * distribution.
0071  *
0072  * 3.4. Intel retains all right, title, and interest in and to the Original
0073  * Intel Code.
0074  *
0075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0076  * Intel shall be used in advertising or otherwise to promote the sale, use or
0077  * other dealings in products derived from or relating to the Covered Code
0078  * without prior written authorization from Intel.
0079  *
0080  * 4. Disclaimer and Export Compliance
0081  *
0082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0083  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
0085  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
0086  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
0087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0088  * PARTICULAR PURPOSE.
0089  *
0090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
0096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0097  * LIMITED REMEDY.
0098  *
0099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0100  * software or system incorporating such software without first obtaining any
0101  * required license or other approval from the U. S. Department of Commerce or
0102  * any other agency or department of the United States Government. In the
0103  * event Licensee exports any such software from the United States or
0104  * re-exports any such software from a foreign destination, Licensee shall
0105  * ensure that the distribution and export/re-export of the software is in
0106  * compliance with all laws, regulations, orders, or other restrictions of the
0107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0108  * any of its subsidiaries will export/re-export any technical data, process,
0109  * software, or service, directly or indirectly, to any country for which the
0110  * United States government or any agency thereof requires an export license,
0111  * other governmental approval, or letter of assurance, without first obtaining
0112  * such license, approval or letter.
0113  *
0114  *****************************************************************************
0115  *
0116  * Alternatively, you may choose to be licensed under the terms of the
0117  * following license:
0118  *
0119  * Redistribution and use in source and binary forms, with or without
0120  * modification, are permitted provided that the following conditions
0121  * are met:
0122  * 1. Redistributions of source code must retain the above copyright
0123  *    notice, this list of conditions, and the following disclaimer,
0124  *    without modification.
0125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0126  *    substantially similar to the "NO WARRANTY" disclaimer below
0127  *    ("Disclaimer") and any redistribution must be conditioned upon
0128  *    including a substantially similar Disclaimer requirement for further
0129  *    binary redistribution.
0130  * 3. Neither the names of the above-listed copyright holders nor the names
0131  *    of any contributors may be used to endorse or promote products derived
0132  *    from this software without specific prior written permission.
0133  *
0134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0145  *
0146  * Alternatively, you may choose to be licensed under the terms of the
0147  * GNU General Public License ("GPL") version 2 as published by the Free
0148  * Software Foundation.
0149  *
0150  *****************************************************************************/
0151 
0152 #include "acpi.h"
0153 #include "accommon.h"
0154 #include "acparser.h"
0155 #include "amlcode.h"
0156 #include "acdispat.h"
0157 #include "acinterp.h"
0158 #include "acnamesp.h"
0159 #include "acevents.h"
0160 #include "actables.h"
0161 
0162 #define _COMPONENT          ACPI_DISPATCHER
0163         ACPI_MODULE_NAME    ("dsopcode")
0164 
0165 /* Local prototypes */
0166 
0167 static ACPI_STATUS
0168 AcpiDsInitBufferField (
0169     UINT16                  AmlOpcode,
0170     ACPI_OPERAND_OBJECT     *ObjDesc,
0171     ACPI_OPERAND_OBJECT     *BufferDesc,
0172     ACPI_OPERAND_OBJECT     *OffsetDesc,
0173     ACPI_OPERAND_OBJECT     *LengthDesc,
0174     ACPI_OPERAND_OBJECT     *ResultDesc);
0175 
0176 
0177 /*******************************************************************************
0178  *
0179  * FUNCTION:    AcpiDsInitializeRegion
0180  *
0181  * PARAMETERS:  ObjHandle       - Region namespace node
0182  *
0183  * RETURN:      Status
0184  *
0185  * DESCRIPTION: Front end to EvInitializeRegion
0186  *
0187  ******************************************************************************/
0188 
0189 ACPI_STATUS
0190 AcpiDsInitializeRegion (
0191     ACPI_HANDLE             ObjHandle)
0192 {
0193     ACPI_OPERAND_OBJECT     *ObjDesc;
0194     ACPI_STATUS             Status;
0195 
0196 
0197     ObjDesc = AcpiNsGetAttachedObject (ObjHandle);
0198 
0199     /* Namespace is NOT locked */
0200 
0201     Status = AcpiEvInitializeRegion (ObjDesc);
0202     return (Status);
0203 }
0204 
0205 
0206 /*******************************************************************************
0207  *
0208  * FUNCTION:    AcpiDsInitBufferField
0209  *
0210  * PARAMETERS:  AmlOpcode       - CreateXxxField
0211  *              ObjDesc         - BufferField object
0212  *              BufferDesc      - Host Buffer
0213  *              OffsetDesc      - Offset into buffer
0214  *              LengthDesc      - Length of field (CREATE_FIELD_OP only)
0215  *              ResultDesc      - Where to store the result
0216  *
0217  * RETURN:      Status
0218  *
0219  * DESCRIPTION: Perform actual initialization of a buffer field
0220  *
0221  ******************************************************************************/
0222 
0223 static ACPI_STATUS
0224 AcpiDsInitBufferField (
0225     UINT16                  AmlOpcode,
0226     ACPI_OPERAND_OBJECT     *ObjDesc,
0227     ACPI_OPERAND_OBJECT     *BufferDesc,
0228     ACPI_OPERAND_OBJECT     *OffsetDesc,
0229     ACPI_OPERAND_OBJECT     *LengthDesc,
0230     ACPI_OPERAND_OBJECT     *ResultDesc)
0231 {
0232     UINT32                  Offset;
0233     UINT32                  BitOffset;
0234     UINT32                  BitCount;
0235     UINT8                   FieldFlags;
0236     ACPI_STATUS             Status;
0237 
0238 
0239     ACPI_FUNCTION_TRACE_PTR (DsInitBufferField, ObjDesc);
0240 
0241 
0242     /* Host object must be a Buffer */
0243 
0244     if (BufferDesc->Common.Type != ACPI_TYPE_BUFFER)
0245     {
0246         ACPI_ERROR ((AE_INFO,
0247             "Target of Create Field is not a Buffer object - %s",
0248             AcpiUtGetObjectTypeName (BufferDesc)));
0249 
0250         Status = AE_AML_OPERAND_TYPE;
0251         goto Cleanup;
0252     }
0253 
0254     /*
0255      * The last parameter to all of these opcodes (ResultDesc) started
0256      * out as a NameString, and should therefore now be a NS node
0257      * after resolution in AcpiExResolveOperands().
0258      */
0259     if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED)
0260     {
0261         ACPI_ERROR ((AE_INFO,
0262             "(%s) destination not a NS Node [%s]",
0263             AcpiPsGetOpcodeName (AmlOpcode),
0264             AcpiUtGetDescriptorName (ResultDesc)));
0265 
0266         Status = AE_AML_OPERAND_TYPE;
0267         goto Cleanup;
0268     }
0269 
0270     Offset = (UINT32) OffsetDesc->Integer.Value;
0271 
0272     /*
0273      * Setup the Bit offsets and counts, according to the opcode
0274      */
0275     switch (AmlOpcode)
0276     {
0277     case AML_CREATE_FIELD_OP:
0278 
0279         /* Offset is in bits, count is in bits */
0280 
0281         FieldFlags = AML_FIELD_ACCESS_BYTE;
0282         BitOffset  = Offset;
0283         BitCount   = (UINT32) LengthDesc->Integer.Value;
0284 
0285         /* Must have a valid (>0) bit count */
0286 
0287         if (BitCount == 0)
0288         {
0289             ACPI_BIOS_ERROR ((AE_INFO,
0290                 "Attempt to CreateField of length zero"));
0291             Status = AE_AML_OPERAND_VALUE;
0292             goto Cleanup;
0293         }
0294         break;
0295 
0296     case AML_CREATE_BIT_FIELD_OP:
0297 
0298         /* Offset is in bits, Field is one bit */
0299 
0300         BitOffset  = Offset;
0301         BitCount   = 1;
0302         FieldFlags = AML_FIELD_ACCESS_BYTE;
0303         break;
0304 
0305     case AML_CREATE_BYTE_FIELD_OP:
0306 
0307         /* Offset is in bytes, field is one byte */
0308 
0309         BitOffset  = 8 * Offset;
0310         BitCount   = 8;
0311         FieldFlags = AML_FIELD_ACCESS_BYTE;
0312         break;
0313 
0314     case AML_CREATE_WORD_FIELD_OP:
0315 
0316         /* Offset is in bytes, field is one word */
0317 
0318         BitOffset  = 8 * Offset;
0319         BitCount   = 16;
0320         FieldFlags = AML_FIELD_ACCESS_WORD;
0321         break;
0322 
0323     case AML_CREATE_DWORD_FIELD_OP:
0324 
0325         /* Offset is in bytes, field is one dword */
0326 
0327         BitOffset  = 8 * Offset;
0328         BitCount   = 32;
0329         FieldFlags = AML_FIELD_ACCESS_DWORD;
0330         break;
0331 
0332     case AML_CREATE_QWORD_FIELD_OP:
0333 
0334         /* Offset is in bytes, field is one qword */
0335 
0336         BitOffset  = 8 * Offset;
0337         BitCount   = 64;
0338         FieldFlags = AML_FIELD_ACCESS_QWORD;
0339         break;
0340 
0341     default:
0342 
0343         ACPI_ERROR ((AE_INFO,
0344             "Unknown field creation opcode 0x%02X",
0345             AmlOpcode));
0346         Status = AE_AML_BAD_OPCODE;
0347         goto Cleanup;
0348     }
0349 
0350     /* Entire field must fit within the current length of the buffer */
0351 
0352     if ((BitOffset + BitCount) >
0353         (8 * (UINT32) BufferDesc->Buffer.Length))
0354     {
0355         Status = AE_AML_BUFFER_LIMIT;
0356         ACPI_BIOS_EXCEPTION ((AE_INFO, Status,
0357             "Field [%4.4s] at bit offset/length %u/%u "
0358             "exceeds size of target Buffer (%u bits)",
0359             AcpiUtGetNodeName (ResultDesc), BitOffset, BitCount,
0360             8 * (UINT32) BufferDesc->Buffer.Length));
0361         goto Cleanup;
0362     }
0363 
0364     /*
0365      * Initialize areas of the field object that are common to all fields
0366      * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK),
0367      * UPDATE_RULE = 0 (UPDATE_PRESERVE)
0368      */
0369     Status = AcpiExPrepCommonFieldObject (
0370         ObjDesc, FieldFlags, 0, BitOffset, BitCount);
0371     if (ACPI_FAILURE (Status))
0372     {
0373         goto Cleanup;
0374     }
0375 
0376     ObjDesc->BufferField.BufferObj = BufferDesc;
0377     ObjDesc->BufferField.IsCreateField = AmlOpcode == AML_CREATE_FIELD_OP;
0378 
0379     /* Reference count for BufferDesc inherits ObjDesc count */
0380 
0381     BufferDesc->Common.ReferenceCount = (UINT16)
0382         (BufferDesc->Common.ReferenceCount + ObjDesc->Common.ReferenceCount);
0383 
0384 
0385 Cleanup:
0386 
0387     /* Always delete the operands */
0388 
0389     AcpiUtRemoveReference (OffsetDesc);
0390     AcpiUtRemoveReference (BufferDesc);
0391 
0392     if (AmlOpcode == AML_CREATE_FIELD_OP)
0393     {
0394         AcpiUtRemoveReference (LengthDesc);
0395     }
0396 
0397     /* On failure, delete the result descriptor */
0398 
0399     if (ACPI_FAILURE (Status))
0400     {
0401         AcpiUtRemoveReference (ResultDesc);     /* Result descriptor */
0402     }
0403     else
0404     {
0405         /* Now the address and length are valid for this BufferField */
0406 
0407         ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID;
0408     }
0409 
0410     return_ACPI_STATUS (Status);
0411 }
0412 
0413 
0414 /*******************************************************************************
0415  *
0416  * FUNCTION:    AcpiDsEvalBufferFieldOperands
0417  *
0418  * PARAMETERS:  WalkState       - Current walk
0419  *              Op              - A valid BufferField Op object
0420  *
0421  * RETURN:      Status
0422  *
0423  * DESCRIPTION: Get BufferField Buffer and Index
0424  *              Called from AcpiDsExecEndOp during BufferField parse tree walk
0425  *
0426  ******************************************************************************/
0427 
0428 ACPI_STATUS
0429 AcpiDsEvalBufferFieldOperands (
0430     ACPI_WALK_STATE         *WalkState,
0431     ACPI_PARSE_OBJECT       *Op)
0432 {
0433     ACPI_STATUS             Status;
0434     ACPI_OPERAND_OBJECT     *ObjDesc;
0435     ACPI_NAMESPACE_NODE     *Node;
0436     ACPI_PARSE_OBJECT       *NextOp;
0437 
0438 
0439     ACPI_FUNCTION_TRACE_PTR (DsEvalBufferFieldOperands, Op);
0440 
0441 
0442     /*
0443      * This is where we evaluate the address and length fields of the
0444      * CreateXxxField declaration
0445      */
0446     Node =  Op->Common.Node;
0447 
0448     /* NextOp points to the op that holds the Buffer */
0449 
0450     NextOp = Op->Common.Value.Arg;
0451 
0452     /* Evaluate/create the address and length operands */
0453 
0454     Status = AcpiDsCreateOperands (WalkState, NextOp);
0455     if (ACPI_FAILURE (Status))
0456     {
0457         return_ACPI_STATUS (Status);
0458     }
0459 
0460     ObjDesc = AcpiNsGetAttachedObject (Node);
0461     if (!ObjDesc)
0462     {
0463         return_ACPI_STATUS (AE_NOT_EXIST);
0464     }
0465 
0466     /* Resolve the operands */
0467 
0468     Status = AcpiExResolveOperands (
0469         Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);
0470     if (ACPI_FAILURE (Status))
0471     {
0472         ACPI_ERROR ((AE_INFO, "(%s) bad operand(s), status 0x%X",
0473             AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status));
0474 
0475         return_ACPI_STATUS (Status);
0476     }
0477 
0478     /* Initialize the Buffer Field */
0479 
0480     if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
0481     {
0482         /* NOTE: Slightly different operands for this opcode */
0483 
0484         Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
0485             WalkState->Operands[0], WalkState->Operands[1],
0486             WalkState->Operands[2], WalkState->Operands[3]);
0487     }
0488     else
0489     {
0490         /* All other, CreateXxxField opcodes */
0491 
0492         Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
0493             WalkState->Operands[0], WalkState->Operands[1],
0494             NULL, WalkState->Operands[2]);
0495     }
0496 
0497     return_ACPI_STATUS (Status);
0498 }
0499 
0500 
0501 /*******************************************************************************
0502  *
0503  * FUNCTION:    AcpiDsEvalRegionOperands
0504  *
0505  * PARAMETERS:  WalkState       - Current walk
0506  *              Op              - A valid region Op object
0507  *
0508  * RETURN:      Status
0509  *
0510  * DESCRIPTION: Get region address and length
0511  *              Called from AcpiDsExecEndOp during OpRegion parse tree walk
0512  *
0513  ******************************************************************************/
0514 
0515 ACPI_STATUS
0516 AcpiDsEvalRegionOperands (
0517     ACPI_WALK_STATE         *WalkState,
0518     ACPI_PARSE_OBJECT       *Op)
0519 {
0520     ACPI_STATUS             Status;
0521     ACPI_OPERAND_OBJECT     *ObjDesc;
0522     ACPI_OPERAND_OBJECT     *OperandDesc;
0523     ACPI_NAMESPACE_NODE     *Node;
0524     ACPI_PARSE_OBJECT       *NextOp;
0525     ACPI_ADR_SPACE_TYPE     SpaceId;
0526 
0527 
0528     ACPI_FUNCTION_TRACE_PTR (DsEvalRegionOperands, Op);
0529 
0530 
0531     /*
0532      * This is where we evaluate the address and length fields of the
0533      * OpRegion declaration
0534      */
0535     Node = Op->Common.Node;
0536 
0537     /* NextOp points to the op that holds the SpaceID */
0538 
0539     NextOp = Op->Common.Value.Arg;
0540     SpaceId = (ACPI_ADR_SPACE_TYPE) NextOp->Common.Value.Integer;
0541 
0542     /* NextOp points to address op */
0543 
0544     NextOp = NextOp->Common.Next;
0545 
0546     /* Evaluate/create the address and length operands */
0547 
0548     Status = AcpiDsCreateOperands (WalkState, NextOp);
0549     if (ACPI_FAILURE (Status))
0550     {
0551         return_ACPI_STATUS (Status);
0552     }
0553 
0554     /* Resolve the length and address operands to numbers */
0555 
0556     Status = AcpiExResolveOperands (
0557         Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);
0558     if (ACPI_FAILURE (Status))
0559     {
0560         return_ACPI_STATUS (Status);
0561     }
0562 
0563     ObjDesc = AcpiNsGetAttachedObject (Node);
0564     if (!ObjDesc)
0565     {
0566         return_ACPI_STATUS (AE_NOT_EXIST);
0567     }
0568 
0569     /*
0570      * Get the length operand and save it
0571      * (at Top of stack)
0572      */
0573     OperandDesc = WalkState->Operands[WalkState->NumOperands - 1];
0574 
0575     ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value;
0576     AcpiUtRemoveReference (OperandDesc);
0577 
0578     /* A zero-length operation region is unusable. Just warn */
0579 
0580     if (!ObjDesc->Region.Length && (SpaceId < ACPI_NUM_PREDEFINED_REGIONS))
0581     {
0582         ACPI_WARNING ((AE_INFO,
0583             "Operation Region [%4.4s] has zero length (SpaceId %X)",
0584             Node->Name.Ascii, SpaceId));
0585     }
0586 
0587     /*
0588      * Get the address and save it
0589      * (at top of stack - 1)
0590      */
0591     OperandDesc = WalkState->Operands[WalkState->NumOperands - 2];
0592 
0593     ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS)
0594         OperandDesc->Integer.Value;
0595     AcpiUtRemoveReference (OperandDesc);
0596 
0597     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
0598         ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
0599         ObjDesc->Region.Length));
0600 
0601     Status = AcpiUtAddAddressRange (ObjDesc->Region.SpaceId,
0602         ObjDesc->Region.Address, ObjDesc->Region.Length, Node);
0603 
0604     /* Now the address and length are valid for this opregion */
0605 
0606     ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID;
0607     return_ACPI_STATUS (Status);
0608 }
0609 
0610 
0611 /*******************************************************************************
0612  *
0613  * FUNCTION:    AcpiDsEvalTableRegionOperands
0614  *
0615  * PARAMETERS:  WalkState       - Current walk
0616  *              Op              - A valid region Op object
0617  *
0618  * RETURN:      Status
0619  *
0620  * DESCRIPTION: Get region address and length.
0621  *              Called from AcpiDsExecEndOp during DataTableRegion parse
0622  *              tree walk.
0623  *
0624  ******************************************************************************/
0625 
0626 ACPI_STATUS
0627 AcpiDsEvalTableRegionOperands (
0628     ACPI_WALK_STATE         *WalkState,
0629     ACPI_PARSE_OBJECT       *Op)
0630 {
0631     ACPI_STATUS             Status;
0632     ACPI_OPERAND_OBJECT     *ObjDesc;
0633     ACPI_OPERAND_OBJECT     **Operand;
0634     ACPI_NAMESPACE_NODE     *Node;
0635     ACPI_PARSE_OBJECT       *NextOp;
0636     ACPI_TABLE_HEADER       *Table;
0637     UINT32                  TableIndex;
0638 
0639 
0640     ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op);
0641 
0642 
0643     /*
0644      * This is where we evaluate the Signature string, OemId string,
0645      * and OemTableId string of the Data Table Region declaration
0646      */
0647     Node =  Op->Common.Node;
0648 
0649     /* NextOp points to Signature string op */
0650 
0651     NextOp = Op->Common.Value.Arg;
0652 
0653     /*
0654      * Evaluate/create the Signature string, OemId string,
0655      * and OemTableId string operands
0656      */
0657     Status = AcpiDsCreateOperands (WalkState, NextOp);
0658     if (ACPI_FAILURE (Status))
0659     {
0660         return_ACPI_STATUS (Status);
0661     }
0662 
0663     Operand = &WalkState->Operands[0];
0664 
0665     /*
0666      * Resolve the Signature string, OemId string,
0667      * and OemTableId string operands
0668      */
0669     Status = AcpiExResolveOperands (
0670         Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);
0671     if (ACPI_FAILURE (Status))
0672     {
0673         goto Cleanup;
0674     }
0675 
0676     /* Find the ACPI table */
0677 
0678     Status = AcpiTbFindTable (
0679         Operand[0]->String.Pointer,
0680         Operand[1]->String.Pointer,
0681         Operand[2]->String.Pointer, &TableIndex);
0682     if (ACPI_FAILURE (Status))
0683     {
0684         if (Status == AE_NOT_FOUND)
0685         {
0686             ACPI_ERROR ((AE_INFO,
0687                 "ACPI Table [%4.4s] OEM:(%s, %s) not found in RSDT/XSDT",
0688                 Operand[0]->String.Pointer,
0689                 Operand[1]->String.Pointer,
0690                 Operand[2]->String.Pointer));
0691         }
0692         goto Cleanup;
0693     }
0694 
0695     Status = AcpiGetTableByIndex (TableIndex, &Table);
0696     if (ACPI_FAILURE (Status))
0697     {
0698         goto Cleanup;
0699     }
0700 
0701     ObjDesc = AcpiNsGetAttachedObject (Node);
0702     if (!ObjDesc)
0703     {
0704         Status = AE_NOT_EXIST;
0705         goto Cleanup;
0706     }
0707 
0708     ObjDesc->Region.Address = ACPI_PTR_TO_PHYSADDR (Table);
0709     ObjDesc->Region.Length = Table->Length;
0710     ObjDesc->Region.Pointer = Table;
0711 
0712     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
0713         ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
0714         ObjDesc->Region.Length));
0715 
0716     /* Now the address and length are valid for this opregion */
0717 
0718     ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID;
0719 
0720 Cleanup:
0721     AcpiUtRemoveReference (Operand[0]);
0722     AcpiUtRemoveReference (Operand[1]);
0723     AcpiUtRemoveReference (Operand[2]);
0724 
0725     return_ACPI_STATUS (Status);
0726 }
0727 
0728 
0729 /*******************************************************************************
0730  *
0731  * FUNCTION:    AcpiDsEvalDataObjectOperands
0732  *
0733  * PARAMETERS:  WalkState       - Current walk
0734  *              Op              - A valid DataObject Op object
0735  *              ObjDesc         - DataObject
0736  *
0737  * RETURN:      Status
0738  *
0739  * DESCRIPTION: Get the operands and complete the following data object types:
0740  *              Buffer, Package.
0741  *
0742  ******************************************************************************/
0743 
0744 ACPI_STATUS
0745 AcpiDsEvalDataObjectOperands (
0746     ACPI_WALK_STATE         *WalkState,
0747     ACPI_PARSE_OBJECT       *Op,
0748     ACPI_OPERAND_OBJECT     *ObjDesc)
0749 {
0750     ACPI_STATUS             Status;
0751     ACPI_OPERAND_OBJECT     *ArgDesc;
0752     UINT32                  Length;
0753 
0754 
0755     ACPI_FUNCTION_TRACE (DsEvalDataObjectOperands);
0756 
0757 
0758     /* The first operand (for all of these data objects) is the length */
0759 
0760     /*
0761      * Set proper index into operand stack for AcpiDsObjStackPush
0762      * invoked inside AcpiDsCreateOperand.
0763      */
0764     WalkState->OperandIndex = WalkState->NumOperands;
0765 
0766     /* Ignore if child is not valid */
0767 
0768     if (!Op->Common.Value.Arg)
0769     {
0770         ACPI_ERROR ((AE_INFO,
0771             "Missing child while evaluating opcode %4.4X, Op %p",
0772             Op->Common.AmlOpcode, Op));
0773         return_ACPI_STATUS (AE_OK);
0774     }
0775 
0776     Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1);
0777     if (ACPI_FAILURE (Status))
0778     {
0779         return_ACPI_STATUS (Status);
0780     }
0781 
0782     Status = AcpiExResolveOperands (WalkState->Opcode,
0783         &(WalkState->Operands [WalkState->NumOperands -1]),
0784         WalkState);
0785     if (ACPI_FAILURE (Status))
0786     {
0787         return_ACPI_STATUS (Status);
0788     }
0789 
0790     /* Extract length operand */
0791 
0792     ArgDesc = WalkState->Operands [WalkState->NumOperands - 1];
0793     Length = (UINT32) ArgDesc->Integer.Value;
0794 
0795     /* Cleanup for length operand */
0796 
0797     Status = AcpiDsObjStackPop (1, WalkState);
0798     if (ACPI_FAILURE (Status))
0799     {
0800         return_ACPI_STATUS (Status);
0801     }
0802 
0803     AcpiUtRemoveReference (ArgDesc);
0804 
0805     /*
0806      * Create the actual data object
0807      */
0808     switch (Op->Common.AmlOpcode)
0809     {
0810     case AML_BUFFER_OP:
0811 
0812         Status = AcpiDsBuildInternalBufferObj (
0813             WalkState, Op, Length, &ObjDesc);
0814         break;
0815 
0816     case AML_PACKAGE_OP:
0817     case AML_VARIABLE_PACKAGE_OP:
0818 
0819         Status = AcpiDsBuildInternalPackageObj (
0820             WalkState, Op, Length, &ObjDesc);
0821         break;
0822 
0823     default:
0824 
0825         return_ACPI_STATUS (AE_AML_BAD_OPCODE);
0826     }
0827 
0828     if (ACPI_SUCCESS (Status))
0829     {
0830         /*
0831          * Return the object in the WalkState, unless the parent is a package -
0832          * in this case, the return object will be stored in the parse tree
0833          * for the package.
0834          */
0835         if ((!Op->Common.Parent) ||
0836             ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) &&
0837              (Op->Common.Parent->Common.AmlOpcode != AML_VARIABLE_PACKAGE_OP) &&
0838              (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP)))
0839         {
0840             WalkState->ResultObj = ObjDesc;
0841         }
0842     }
0843 
0844     return_ACPI_STATUS (Status);
0845 }
0846 
0847 
0848 /*******************************************************************************
0849  *
0850  * FUNCTION:    AcpiDsEvalBankFieldOperands
0851  *
0852  * PARAMETERS:  WalkState       - Current walk
0853  *              Op              - A valid BankField Op object
0854  *
0855  * RETURN:      Status
0856  *
0857  * DESCRIPTION: Get BankField BankValue
0858  *              Called from AcpiDsExecEndOp during BankField parse tree walk
0859  *
0860  ******************************************************************************/
0861 
0862 ACPI_STATUS
0863 AcpiDsEvalBankFieldOperands (
0864     ACPI_WALK_STATE         *WalkState,
0865     ACPI_PARSE_OBJECT       *Op)
0866 {
0867     ACPI_STATUS             Status;
0868     ACPI_OPERAND_OBJECT     *ObjDesc;
0869     ACPI_OPERAND_OBJECT     *OperandDesc;
0870     ACPI_NAMESPACE_NODE     *Node;
0871     ACPI_PARSE_OBJECT       *NextOp;
0872     ACPI_PARSE_OBJECT       *Arg;
0873 
0874 
0875     ACPI_FUNCTION_TRACE_PTR (DsEvalBankFieldOperands, Op);
0876 
0877 
0878     /*
0879      * This is where we evaluate the BankValue field of the
0880      * BankField declaration
0881      */
0882 
0883     /* NextOp points to the op that holds the Region */
0884 
0885     NextOp = Op->Common.Value.Arg;
0886 
0887     /* NextOp points to the op that holds the Bank Register */
0888 
0889     NextOp = NextOp->Common.Next;
0890 
0891     /* NextOp points to the op that holds the Bank Value */
0892 
0893     NextOp = NextOp->Common.Next;
0894 
0895     /*
0896      * Set proper index into operand stack for AcpiDsObjStackPush
0897      * invoked inside AcpiDsCreateOperand.
0898      *
0899      * We use WalkState->Operands[0] to store the evaluated BankValue
0900      */
0901     WalkState->OperandIndex = 0;
0902 
0903     Status = AcpiDsCreateOperand (WalkState, NextOp, 0);
0904     if (ACPI_FAILURE (Status))
0905     {
0906         return_ACPI_STATUS (Status);
0907     }
0908 
0909     Status = AcpiExResolveToValue (&WalkState->Operands[0], WalkState);
0910     if (ACPI_FAILURE (Status))
0911     {
0912         return_ACPI_STATUS (Status);
0913     }
0914 
0915     ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS,
0916         AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 1);
0917     /*
0918      * Get the BankValue operand and save it
0919      * (at Top of stack)
0920      */
0921     OperandDesc = WalkState->Operands[0];
0922 
0923     /* Arg points to the start Bank Field */
0924 
0925     Arg = AcpiPsGetArg (Op, 4);
0926     while (Arg)
0927     {
0928         /* Ignore OFFSET and ACCESSAS terms here */
0929 
0930         if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
0931         {
0932             Node = Arg->Common.Node;
0933 
0934             ObjDesc = AcpiNsGetAttachedObject (Node);
0935             if (!ObjDesc)
0936             {
0937                 return_ACPI_STATUS (AE_NOT_EXIST);
0938             }
0939 
0940             ObjDesc->BankField.Value = (UINT32) OperandDesc->Integer.Value;
0941         }
0942 
0943         /* Move to next field in the list */
0944 
0945         Arg = Arg->Common.Next;
0946     }
0947 
0948     AcpiUtRemoveReference (OperandDesc);
0949     return_ACPI_STATUS (Status);
0950 }