Back to home page

LXR

 
 

    


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

0001 /******************************************************************************
0002  *
0003  * Module Name: exoparg2 - AML execution - opcodes with 2 arguments
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 "acinterp.h"
0156 #include "acevents.h"
0157 #include "amlcode.h"
0158 
0159 
0160 #define _COMPONENT          ACPI_EXECUTER
0161         ACPI_MODULE_NAME    ("exoparg2")
0162 
0163 
0164 /*!
0165  * Naming convention for AML interpreter execution routines.
0166  *
0167  * The routines that begin execution of AML opcodes are named with a common
0168  * convention based upon the number of arguments, the number of target operands,
0169  * and whether or not a value is returned:
0170  *
0171  *      AcpiExOpcode_xA_yT_zR
0172  *
0173  * Where:
0174  *
0175  * xA - ARGUMENTS:    The number of arguments (input operands) that are
0176  *                    required for this opcode type (1 through 6 args).
0177  * yT - TARGETS:      The number of targets (output operands) that are required
0178  *                    for this opcode type (0, 1, or 2 targets).
0179  * zR - RETURN VALUE: Indicates whether this opcode type returns a value
0180  *                    as the function return (0 or 1).
0181  *
0182  * The AcpiExOpcode* functions are called via the Dispatcher component with
0183  * fully resolved operands.
0184 !*/
0185 
0186 
0187 /*******************************************************************************
0188  *
0189  * FUNCTION:    AcpiExOpcode_2A_0T_0R
0190  *
0191  * PARAMETERS:  WalkState           - Current walk state
0192  *
0193  * RETURN:      Status
0194  *
0195  * DESCRIPTION: Execute opcode with two arguments, no target, and no return
0196  *              value.
0197  *
0198  * ALLOCATION:  Deletes both operands
0199  *
0200  ******************************************************************************/
0201 
0202 ACPI_STATUS
0203 AcpiExOpcode_2A_0T_0R (
0204     ACPI_WALK_STATE         *WalkState)
0205 {
0206     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
0207     ACPI_NAMESPACE_NODE     *Node;
0208     UINT32                  Value;
0209     ACPI_STATUS             Status = AE_OK;
0210 
0211 
0212     ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_0R,
0213             AcpiPsGetOpcodeName (WalkState->Opcode));
0214 
0215 
0216     /* Examine the opcode */
0217 
0218     switch (WalkState->Opcode)
0219     {
0220     case AML_NOTIFY_OP:         /* Notify (NotifyObject, NotifyValue) */
0221 
0222         /* The first operand is a namespace node */
0223 
0224         Node = (ACPI_NAMESPACE_NODE *) Operand[0];
0225 
0226         /* Second value is the notify value */
0227 
0228         Value = (UINT32) Operand[1]->Integer.Value;
0229 
0230         /* Are notifies allowed on this object? */
0231 
0232         if (!AcpiEvIsNotifyObject (Node))
0233         {
0234             ACPI_ERROR ((AE_INFO,
0235                 "Unexpected notify object type [%s]",
0236                 AcpiUtGetTypeName (Node->Type)));
0237 
0238             Status = AE_AML_OPERAND_TYPE;
0239             break;
0240         }
0241 
0242         /*
0243          * Dispatch the notify to the appropriate handler
0244          * NOTE: the request is queued for execution after this method
0245          * completes. The notify handlers are NOT invoked synchronously
0246          * from this thread -- because handlers may in turn run other
0247          * control methods.
0248          */
0249         Status = AcpiEvQueueNotifyRequest (Node, Value);
0250         break;
0251 
0252     default:
0253 
0254         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
0255             WalkState->Opcode));
0256         Status = AE_AML_BAD_OPCODE;
0257     }
0258 
0259     return_ACPI_STATUS (Status);
0260 }
0261 
0262 
0263 /*******************************************************************************
0264  *
0265  * FUNCTION:    AcpiExOpcode_2A_2T_1R
0266  *
0267  * PARAMETERS:  WalkState           - Current walk state
0268  *
0269  * RETURN:      Status
0270  *
0271  * DESCRIPTION: Execute a dyadic operator (2 operands) with 2 output targets
0272  *              and one implicit return value.
0273  *
0274  ******************************************************************************/
0275 
0276 ACPI_STATUS
0277 AcpiExOpcode_2A_2T_1R (
0278     ACPI_WALK_STATE         *WalkState)
0279 {
0280     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
0281     ACPI_OPERAND_OBJECT     *ReturnDesc1 = NULL;
0282     ACPI_OPERAND_OBJECT     *ReturnDesc2 = NULL;
0283     ACPI_STATUS             Status;
0284 
0285 
0286     ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_2T_1R,
0287         AcpiPsGetOpcodeName (WalkState->Opcode));
0288 
0289 
0290     /* Execute the opcode */
0291 
0292     switch (WalkState->Opcode)
0293     {
0294     case AML_DIVIDE_OP:
0295 
0296         /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */
0297 
0298         ReturnDesc1 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
0299         if (!ReturnDesc1)
0300         {
0301             Status = AE_NO_MEMORY;
0302             goto Cleanup;
0303         }
0304 
0305         ReturnDesc2 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
0306         if (!ReturnDesc2)
0307         {
0308             Status = AE_NO_MEMORY;
0309             goto Cleanup;
0310         }
0311 
0312         /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */
0313 
0314         Status = AcpiUtDivide (
0315             Operand[0]->Integer.Value,
0316             Operand[1]->Integer.Value,
0317             &ReturnDesc1->Integer.Value,
0318             &ReturnDesc2->Integer.Value);
0319         if (ACPI_FAILURE (Status))
0320         {
0321             goto Cleanup;
0322         }
0323         break;
0324 
0325     default:
0326 
0327         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
0328             WalkState->Opcode));
0329 
0330         Status = AE_AML_BAD_OPCODE;
0331         goto Cleanup;
0332     }
0333 
0334     /* Store the results to the target reference operands */
0335 
0336     Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState);
0337     if (ACPI_FAILURE (Status))
0338     {
0339         goto Cleanup;
0340     }
0341 
0342     Status = AcpiExStore (ReturnDesc1, Operand[3], WalkState);
0343     if (ACPI_FAILURE (Status))
0344     {
0345         goto Cleanup;
0346     }
0347 
0348 Cleanup:
0349     /*
0350      * Since the remainder is not returned indirectly, remove a reference to
0351      * it. Only the quotient is returned indirectly.
0352      */
0353     AcpiUtRemoveReference (ReturnDesc2);
0354 
0355     if (ACPI_FAILURE (Status))
0356     {
0357         /* Delete the return object */
0358 
0359         AcpiUtRemoveReference (ReturnDesc1);
0360     }
0361 
0362     /* Save return object (the remainder) on success */
0363 
0364     else
0365     {
0366         WalkState->ResultObj = ReturnDesc1;
0367     }
0368 
0369     return_ACPI_STATUS (Status);
0370 }
0371 
0372 
0373 /*******************************************************************************
0374  *
0375  * FUNCTION:    AcpiExOpcode_2A_1T_1R
0376  *
0377  * PARAMETERS:  WalkState           - Current walk state
0378  *
0379  * RETURN:      Status
0380  *
0381  * DESCRIPTION: Execute opcode with two arguments, one target, and a return
0382  *              value.
0383  *
0384  ******************************************************************************/
0385 
0386 ACPI_STATUS
0387 AcpiExOpcode_2A_1T_1R (
0388     ACPI_WALK_STATE         *WalkState)
0389 {
0390     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
0391     ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
0392     UINT64                  Index;
0393     ACPI_STATUS             Status = AE_OK;
0394     ACPI_SIZE               Length = 0;
0395 
0396 
0397     ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R,
0398         AcpiPsGetOpcodeName (WalkState->Opcode));
0399 
0400 
0401     /* Execute the opcode */
0402 
0403     if (WalkState->OpInfo->Flags & AML_MATH)
0404     {
0405         /* All simple math opcodes (add, etc.) */
0406 
0407         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
0408         if (!ReturnDesc)
0409         {
0410             Status = AE_NO_MEMORY;
0411             goto Cleanup;
0412         }
0413 
0414         ReturnDesc->Integer.Value = AcpiExDoMathOp (
0415             WalkState->Opcode,
0416             Operand[0]->Integer.Value,
0417             Operand[1]->Integer.Value);
0418         goto StoreResultToTarget;
0419     }
0420 
0421     switch (WalkState->Opcode)
0422     {
0423     case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */
0424 
0425         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
0426         if (!ReturnDesc)
0427         {
0428             Status = AE_NO_MEMORY;
0429             goto Cleanup;
0430         }
0431 
0432         /* ReturnDesc will contain the remainder */
0433 
0434         Status = AcpiUtDivide (
0435             Operand[0]->Integer.Value,
0436             Operand[1]->Integer.Value,
0437             NULL,
0438             &ReturnDesc->Integer.Value);
0439         break;
0440 
0441     case AML_CONCATENATE_OP: /* Concatenate (Data1, Data2, Result) */
0442 
0443         Status = AcpiExDoConcatenate (
0444             Operand[0], Operand[1], &ReturnDesc, WalkState);
0445         break;
0446 
0447     case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */
0448         /*
0449          * Input object is guaranteed to be a buffer at this point (it may have
0450          * been converted.)  Copy the raw buffer data to a new object of
0451          * type String.
0452          */
0453 
0454         /*
0455          * Get the length of the new string. It is the smallest of:
0456          * 1) Length of the input buffer
0457          * 2) Max length as specified in the ToString operator
0458          * 3) Length of input buffer up to a zero byte (null terminator)
0459          *
0460          * NOTE: A length of zero is ok, and will create a zero-length, null
0461          *       terminated string.
0462          */
0463         while ((Length < Operand[0]->Buffer.Length) &&  /* Length of input buffer */
0464                (Length < Operand[1]->Integer.Value) &&  /* Length operand */
0465                (Operand[0]->Buffer.Pointer[Length]))    /* Null terminator */
0466         {
0467             Length++;
0468         }
0469 
0470         /* Allocate a new string object */
0471 
0472         ReturnDesc = AcpiUtCreateStringObject (Length);
0473         if (!ReturnDesc)
0474         {
0475             Status = AE_NO_MEMORY;
0476             goto Cleanup;
0477         }
0478 
0479         /*
0480          * Copy the raw buffer data with no transform.
0481          * (NULL terminated already)
0482          */
0483         memcpy (ReturnDesc->String.Pointer,
0484             Operand[0]->Buffer.Pointer, Length);
0485         break;
0486 
0487     case AML_CONCATENATE_TEMPLATE_OP:
0488 
0489         /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */
0490 
0491         Status = AcpiExConcatTemplate (
0492             Operand[0], Operand[1], &ReturnDesc, WalkState);
0493         break;
0494 
0495     case AML_INDEX_OP:              /* Index (Source Index Result) */
0496 
0497         /* Create the internal return object */
0498 
0499         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
0500         if (!ReturnDesc)
0501         {
0502             Status = AE_NO_MEMORY;
0503             goto Cleanup;
0504         }
0505 
0506         /* Initialize the Index reference object */
0507 
0508         Index = Operand[1]->Integer.Value;
0509         ReturnDesc->Reference.Value = (UINT32) Index;
0510         ReturnDesc->Reference.Class = ACPI_REFCLASS_INDEX;
0511 
0512         /*
0513          * At this point, the Source operand is a String, Buffer, or Package.
0514          * Verify that the index is within range.
0515          */
0516         switch ((Operand[0])->Common.Type)
0517         {
0518         case ACPI_TYPE_STRING:
0519 
0520             if (Index >= Operand[0]->String.Length)
0521             {
0522                 Length = Operand[0]->String.Length;
0523                 Status = AE_AML_STRING_LIMIT;
0524             }
0525 
0526             ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
0527             ReturnDesc->Reference.IndexPointer =
0528                 &(Operand[0]->Buffer.Pointer [Index]);
0529             break;
0530 
0531         case ACPI_TYPE_BUFFER:
0532 
0533             if (Index >= Operand[0]->Buffer.Length)
0534             {
0535                 Length = Operand[0]->Buffer.Length;
0536                 Status = AE_AML_BUFFER_LIMIT;
0537             }
0538 
0539             ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
0540             ReturnDesc->Reference.IndexPointer =
0541                 &(Operand[0]->Buffer.Pointer [Index]);
0542             break;
0543 
0544         case ACPI_TYPE_PACKAGE:
0545 
0546             if (Index >= Operand[0]->Package.Count)
0547             {
0548                 Length = Operand[0]->Package.Count;
0549                 Status = AE_AML_PACKAGE_LIMIT;
0550             }
0551 
0552             ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE;
0553             ReturnDesc->Reference.Where =
0554                 &Operand[0]->Package.Elements [Index];
0555             break;
0556 
0557         default:
0558 
0559             ACPI_ERROR ((AE_INFO,
0560                 "Invalid object type: %X", (Operand[0])->Common.Type));
0561             Status = AE_AML_INTERNAL;
0562             goto Cleanup;
0563         }
0564 
0565         /* Failure means that the Index was beyond the end of the object */
0566 
0567         if (ACPI_FAILURE (Status))
0568         {
0569             ACPI_BIOS_EXCEPTION ((AE_INFO, Status,
0570                 "Index (0x%X%8.8X) is beyond end of object (length 0x%X)",
0571                 ACPI_FORMAT_UINT64 (Index), (UINT32) Length));
0572             goto Cleanup;
0573         }
0574 
0575         /*
0576          * Save the target object and add a reference to it for the life
0577          * of the index
0578          */
0579         ReturnDesc->Reference.Object = Operand[0];
0580         AcpiUtAddReference (Operand[0]);
0581 
0582         /* Store the reference to the Target */
0583 
0584         Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
0585 
0586         /* Return the reference */
0587 
0588         WalkState->ResultObj = ReturnDesc;
0589         goto Cleanup;
0590 
0591     default:
0592 
0593         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
0594             WalkState->Opcode));
0595         Status = AE_AML_BAD_OPCODE;
0596         break;
0597     }
0598 
0599 
0600 StoreResultToTarget:
0601 
0602     if (ACPI_SUCCESS (Status))
0603     {
0604         /*
0605          * Store the result of the operation (which is now in ReturnDesc) into
0606          * the Target descriptor.
0607          */
0608         Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
0609         if (ACPI_FAILURE (Status))
0610         {
0611             goto Cleanup;
0612         }
0613 
0614         if (!WalkState->ResultObj)
0615         {
0616             WalkState->ResultObj = ReturnDesc;
0617         }
0618     }
0619 
0620 
0621 Cleanup:
0622 
0623     /* Delete return object on error */
0624 
0625     if (ACPI_FAILURE (Status))
0626     {
0627         AcpiUtRemoveReference (ReturnDesc);
0628         WalkState->ResultObj = NULL;
0629     }
0630 
0631     return_ACPI_STATUS (Status);
0632 }
0633 
0634 
0635 /*******************************************************************************
0636  *
0637  * FUNCTION:    AcpiExOpcode_2A_0T_1R
0638  *
0639  * PARAMETERS:  WalkState           - Current walk state
0640  *
0641  * RETURN:      Status
0642  *
0643  * DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value
0644  *
0645  ******************************************************************************/
0646 
0647 ACPI_STATUS
0648 AcpiExOpcode_2A_0T_1R (
0649     ACPI_WALK_STATE         *WalkState)
0650 {
0651     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
0652     ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
0653     ACPI_STATUS             Status = AE_OK;
0654     BOOLEAN                 LogicalResult = FALSE;
0655 
0656 
0657     ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R,
0658         AcpiPsGetOpcodeName (WalkState->Opcode));
0659 
0660 
0661     /* Create the internal return object */
0662 
0663     ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
0664     if (!ReturnDesc)
0665     {
0666         Status = AE_NO_MEMORY;
0667         goto Cleanup;
0668     }
0669 
0670     /* Execute the Opcode */
0671 
0672     if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC)
0673     {
0674         /* LogicalOp  (Operand0, Operand1) */
0675 
0676         Status = AcpiExDoLogicalNumericOp (WalkState->Opcode,
0677             Operand[0]->Integer.Value, Operand[1]->Integer.Value,
0678             &LogicalResult);
0679         goto StoreLogicalResult;
0680     }
0681     else if (WalkState->OpInfo->Flags & AML_LOGICAL)
0682     {
0683         /* LogicalOp  (Operand0, Operand1) */
0684 
0685         Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0],
0686             Operand[1], &LogicalResult);
0687         goto StoreLogicalResult;
0688     }
0689 
0690     switch (WalkState->Opcode)
0691     {
0692     case AML_ACQUIRE_OP:            /* Acquire (MutexObject, Timeout) */
0693 
0694         Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState);
0695         if (Status == AE_TIME)
0696         {
0697             LogicalResult = TRUE;       /* TRUE = Acquire timed out */
0698             Status = AE_OK;
0699         }
0700         break;
0701 
0702 
0703     case AML_WAIT_OP:               /* Wait (EventObject, Timeout) */
0704 
0705         Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]);
0706         if (Status == AE_TIME)
0707         {
0708             LogicalResult = TRUE;       /* TRUE, Wait timed out */
0709             Status = AE_OK;
0710         }
0711         break;
0712 
0713     default:
0714 
0715         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
0716             WalkState->Opcode));
0717 
0718         Status = AE_AML_BAD_OPCODE;
0719         goto Cleanup;
0720     }
0721 
0722 
0723 StoreLogicalResult:
0724     /*
0725      * Set return value to according to LogicalResult. logical TRUE (all ones)
0726      * Default is FALSE (zero)
0727      */
0728     if (LogicalResult)
0729     {
0730         ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
0731     }
0732 
0733 Cleanup:
0734 
0735     /* Delete return object on error */
0736 
0737     if (ACPI_FAILURE (Status))
0738     {
0739         AcpiUtRemoveReference (ReturnDesc);
0740     }
0741 
0742     /* Save return object on success */
0743 
0744     else
0745     {
0746         WalkState->ResultObj = ReturnDesc;
0747     }
0748 
0749     return_ACPI_STATUS (Status);
0750 }