xref: /freebsd/sys/contrib/dev/acpica/components/executer/exoparg2.c (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
1 /******************************************************************************
2  *
3  * Module Name: exoparg2 - AML execution - opcodes with 2 arguments
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government. In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************
115  *
116  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151 
152 #include <contrib/dev/acpica/include/acpi.h>
153 #include <contrib/dev/acpica/include/accommon.h>
154 #include <contrib/dev/acpica/include/acparser.h>
155 #include <contrib/dev/acpica/include/acinterp.h>
156 #include <contrib/dev/acpica/include/acevents.h>
157 #include <contrib/dev/acpica/include/amlcode.h>
158 
159 
160 #define _COMPONENT          ACPI_EXECUTER
161         ACPI_MODULE_NAME    ("exoparg2")
162 
163 
164 /*!
165  * Naming convention for AML interpreter execution routines.
166  *
167  * The routines that begin execution of AML opcodes are named with a common
168  * convention based upon the number of arguments, the number of target operands,
169  * and whether or not a value is returned:
170  *
171  *      AcpiExOpcode_xA_yT_zR
172  *
173  * Where:
174  *
175  * xA - ARGUMENTS:    The number of arguments (input operands) that are
176  *                    required for this opcode type (1 through 6 args).
177  * yT - TARGETS:      The number of targets (output operands) that are required
178  *                    for this opcode type (0, 1, or 2 targets).
179  * zR - RETURN VALUE: Indicates whether this opcode type returns a value
180  *                    as the function return (0 or 1).
181  *
182  * The AcpiExOpcode* functions are called via the Dispatcher component with
183  * fully resolved operands.
184 !*/
185 
186 
187 /*******************************************************************************
188  *
189  * FUNCTION:    AcpiExOpcode_2A_0T_0R
190  *
191  * PARAMETERS:  WalkState           - Current walk state
192  *
193  * RETURN:      Status
194  *
195  * DESCRIPTION: Execute opcode with two arguments, no target, and no return
196  *              value.
197  *
198  * ALLOCATION:  Deletes both operands
199  *
200  ******************************************************************************/
201 
202 ACPI_STATUS
203 AcpiExOpcode_2A_0T_0R (
204     ACPI_WALK_STATE         *WalkState)
205 {
206     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
207     ACPI_NAMESPACE_NODE     *Node;
208     UINT32                  Value;
209     ACPI_STATUS             Status = AE_OK;
210 
211 
212     ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_0R,
213             AcpiPsGetOpcodeName (WalkState->Opcode));
214 
215 
216     /* Examine the opcode */
217 
218     switch (WalkState->Opcode)
219     {
220     case AML_NOTIFY_OP:         /* Notify (NotifyObject, NotifyValue) */
221 
222         /* The first operand is a namespace node */
223 
224         Node = (ACPI_NAMESPACE_NODE *) Operand[0];
225 
226         /* Second value is the notify value */
227 
228         Value = (UINT32) Operand[1]->Integer.Value;
229 
230         /* Are notifies allowed on this object? */
231 
232         if (!AcpiEvIsNotifyObject (Node))
233         {
234             ACPI_ERROR ((AE_INFO,
235                 "Unexpected notify object type [%s]",
236                 AcpiUtGetTypeName (Node->Type)));
237 
238             Status = AE_AML_OPERAND_TYPE;
239             break;
240         }
241 
242         /*
243          * Dispatch the notify to the appropriate handler
244          * NOTE: the request is queued for execution after this method
245          * completes. The notify handlers are NOT invoked synchronously
246          * from this thread -- because handlers may in turn run other
247          * control methods.
248          */
249         Status = AcpiEvQueueNotifyRequest (Node, Value);
250         break;
251 
252     default:
253 
254         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
255             WalkState->Opcode));
256         Status = AE_AML_BAD_OPCODE;
257     }
258 
259     return_ACPI_STATUS (Status);
260 }
261 
262 
263 /*******************************************************************************
264  *
265  * FUNCTION:    AcpiExOpcode_2A_2T_1R
266  *
267  * PARAMETERS:  WalkState           - Current walk state
268  *
269  * RETURN:      Status
270  *
271  * DESCRIPTION: Execute a dyadic operator (2 operands) with 2 output targets
272  *              and one implicit return value.
273  *
274  ******************************************************************************/
275 
276 ACPI_STATUS
277 AcpiExOpcode_2A_2T_1R (
278     ACPI_WALK_STATE         *WalkState)
279 {
280     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
281     ACPI_OPERAND_OBJECT     *ReturnDesc1 = NULL;
282     ACPI_OPERAND_OBJECT     *ReturnDesc2 = NULL;
283     ACPI_STATUS             Status;
284 
285 
286     ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_2T_1R,
287         AcpiPsGetOpcodeName (WalkState->Opcode));
288 
289 
290     /* Execute the opcode */
291 
292     switch (WalkState->Opcode)
293     {
294     case AML_DIVIDE_OP:
295 
296         /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */
297 
298         ReturnDesc1 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
299         if (!ReturnDesc1)
300         {
301             Status = AE_NO_MEMORY;
302             goto Cleanup;
303         }
304 
305         ReturnDesc2 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
306         if (!ReturnDesc2)
307         {
308             Status = AE_NO_MEMORY;
309             goto Cleanup;
310         }
311 
312         /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */
313 
314         Status = AcpiUtDivide (
315             Operand[0]->Integer.Value,
316             Operand[1]->Integer.Value,
317             &ReturnDesc1->Integer.Value,
318             &ReturnDesc2->Integer.Value);
319         if (ACPI_FAILURE (Status))
320         {
321             goto Cleanup;
322         }
323         break;
324 
325     default:
326 
327         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
328             WalkState->Opcode));
329 
330         Status = AE_AML_BAD_OPCODE;
331         goto Cleanup;
332     }
333 
334     /* Store the results to the target reference operands */
335 
336     Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState);
337     if (ACPI_FAILURE (Status))
338     {
339         goto Cleanup;
340     }
341 
342     Status = AcpiExStore (ReturnDesc1, Operand[3], WalkState);
343     if (ACPI_FAILURE (Status))
344     {
345         goto Cleanup;
346     }
347 
348 Cleanup:
349     /*
350      * Since the remainder is not returned indirectly, remove a reference to
351      * it. Only the quotient is returned indirectly.
352      */
353     AcpiUtRemoveReference (ReturnDesc2);
354 
355     if (ACPI_FAILURE (Status))
356     {
357         /* Delete the return object */
358 
359         AcpiUtRemoveReference (ReturnDesc1);
360     }
361 
362     /* Save return object (the remainder) on success */
363 
364     else
365     {
366         WalkState->ResultObj = ReturnDesc1;
367     }
368 
369     return_ACPI_STATUS (Status);
370 }
371 
372 
373 /*******************************************************************************
374  *
375  * FUNCTION:    AcpiExOpcode_2A_1T_1R
376  *
377  * PARAMETERS:  WalkState           - Current walk state
378  *
379  * RETURN:      Status
380  *
381  * DESCRIPTION: Execute opcode with two arguments, one target, and a return
382  *              value.
383  *
384  ******************************************************************************/
385 
386 ACPI_STATUS
387 AcpiExOpcode_2A_1T_1R (
388     ACPI_WALK_STATE         *WalkState)
389 {
390     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
391     ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
392     UINT64                  Index;
393     ACPI_STATUS             Status = AE_OK;
394     ACPI_SIZE               Length = 0;
395 
396 
397     ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R,
398         AcpiPsGetOpcodeName (WalkState->Opcode));
399 
400 
401     /* Execute the opcode */
402 
403     if (WalkState->OpInfo->Flags & AML_MATH)
404     {
405         /* All simple math opcodes (add, etc.) */
406 
407         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
408         if (!ReturnDesc)
409         {
410             Status = AE_NO_MEMORY;
411             goto Cleanup;
412         }
413 
414         ReturnDesc->Integer.Value = AcpiExDoMathOp (
415             WalkState->Opcode,
416             Operand[0]->Integer.Value,
417             Operand[1]->Integer.Value);
418         goto StoreResultToTarget;
419     }
420 
421     switch (WalkState->Opcode)
422     {
423     case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */
424 
425         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
426         if (!ReturnDesc)
427         {
428             Status = AE_NO_MEMORY;
429             goto Cleanup;
430         }
431 
432         /* ReturnDesc will contain the remainder */
433 
434         Status = AcpiUtDivide (
435             Operand[0]->Integer.Value,
436             Operand[1]->Integer.Value,
437             NULL,
438             &ReturnDesc->Integer.Value);
439         break;
440 
441     case AML_CONCATENATE_OP: /* Concatenate (Data1, Data2, Result) */
442 
443         Status = AcpiExDoConcatenate (
444             Operand[0], Operand[1], &ReturnDesc, WalkState);
445         break;
446 
447     case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */
448         /*
449          * Input object is guaranteed to be a buffer at this point (it may have
450          * been converted.)  Copy the raw buffer data to a new object of
451          * type String.
452          */
453 
454         /*
455          * Get the length of the new string. It is the smallest of:
456          * 1) Length of the input buffer
457          * 2) Max length as specified in the ToString operator
458          * 3) Length of input buffer up to a zero byte (null terminator)
459          *
460          * NOTE: A length of zero is ok, and will create a zero-length, null
461          *       terminated string.
462          */
463         while ((Length < Operand[0]->Buffer.Length) &&  /* Length of input buffer */
464                (Length < Operand[1]->Integer.Value) &&  /* Length operand */
465                (Operand[0]->Buffer.Pointer[Length]))    /* Null terminator */
466         {
467             Length++;
468         }
469 
470         /* Allocate a new string object */
471 
472         ReturnDesc = AcpiUtCreateStringObject (Length);
473         if (!ReturnDesc)
474         {
475             Status = AE_NO_MEMORY;
476             goto Cleanup;
477         }
478 
479         /*
480          * Copy the raw buffer data with no transform.
481          * (NULL terminated already)
482          */
483         memcpy (ReturnDesc->String.Pointer,
484             Operand[0]->Buffer.Pointer, Length);
485         break;
486 
487     case AML_CONCATENATE_TEMPLATE_OP:
488 
489         /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */
490 
491         Status = AcpiExConcatTemplate (
492             Operand[0], Operand[1], &ReturnDesc, WalkState);
493         break;
494 
495     case AML_INDEX_OP:              /* Index (Source Index Result) */
496 
497         /* Create the internal return object */
498 
499         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
500         if (!ReturnDesc)
501         {
502             Status = AE_NO_MEMORY;
503             goto Cleanup;
504         }
505 
506         /* Initialize the Index reference object */
507 
508         Index = Operand[1]->Integer.Value;
509         ReturnDesc->Reference.Value = (UINT32) Index;
510         ReturnDesc->Reference.Class = ACPI_REFCLASS_INDEX;
511 
512         /*
513          * At this point, the Source operand is a String, Buffer, or Package.
514          * Verify that the index is within range.
515          */
516         switch ((Operand[0])->Common.Type)
517         {
518         case ACPI_TYPE_STRING:
519 
520             if (Index >= Operand[0]->String.Length)
521             {
522                 Length = Operand[0]->String.Length;
523                 Status = AE_AML_STRING_LIMIT;
524             }
525 
526             ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
527             ReturnDesc->Reference.IndexPointer =
528                 &(Operand[0]->Buffer.Pointer [Index]);
529             break;
530 
531         case ACPI_TYPE_BUFFER:
532 
533             if (Index >= Operand[0]->Buffer.Length)
534             {
535                 Length = Operand[0]->Buffer.Length;
536                 Status = AE_AML_BUFFER_LIMIT;
537             }
538 
539             ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
540             ReturnDesc->Reference.IndexPointer =
541                 &(Operand[0]->Buffer.Pointer [Index]);
542             break;
543 
544         case ACPI_TYPE_PACKAGE:
545 
546             if (Index >= Operand[0]->Package.Count)
547             {
548                 Length = Operand[0]->Package.Count;
549                 Status = AE_AML_PACKAGE_LIMIT;
550             }
551 
552             ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE;
553             ReturnDesc->Reference.Where =
554                 &Operand[0]->Package.Elements [Index];
555             break;
556 
557         default:
558 
559             ACPI_ERROR ((AE_INFO,
560                 "Invalid object type: %X", (Operand[0])->Common.Type));
561             Status = AE_AML_INTERNAL;
562             goto Cleanup;
563         }
564 
565         /* Failure means that the Index was beyond the end of the object */
566 
567         if (ACPI_FAILURE (Status))
568         {
569             ACPI_BIOS_EXCEPTION ((AE_INFO, Status,
570                 "Index (0x%X%8.8X) is beyond end of object (length 0x%X)",
571                 ACPI_FORMAT_UINT64 (Index), (UINT32) Length));
572             goto Cleanup;
573         }
574 
575         /*
576          * Save the target object and add a reference to it for the life
577          * of the index
578          */
579         ReturnDesc->Reference.Object = Operand[0];
580         AcpiUtAddReference (Operand[0]);
581 
582         /* Store the reference to the Target */
583 
584         Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
585 
586         /* Return the reference */
587 
588         WalkState->ResultObj = ReturnDesc;
589         goto Cleanup;
590 
591     default:
592 
593         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
594             WalkState->Opcode));
595         Status = AE_AML_BAD_OPCODE;
596         break;
597     }
598 
599 
600 StoreResultToTarget:
601 
602     if (ACPI_SUCCESS (Status))
603     {
604         /*
605          * Store the result of the operation (which is now in ReturnDesc) into
606          * the Target descriptor.
607          */
608         Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
609         if (ACPI_FAILURE (Status))
610         {
611             goto Cleanup;
612         }
613 
614         if (!WalkState->ResultObj)
615         {
616             WalkState->ResultObj = ReturnDesc;
617         }
618     }
619 
620 
621 Cleanup:
622 
623     /* Delete return object on error */
624 
625     if (ACPI_FAILURE (Status))
626     {
627         AcpiUtRemoveReference (ReturnDesc);
628         WalkState->ResultObj = NULL;
629     }
630 
631     return_ACPI_STATUS (Status);
632 }
633 
634 
635 /*******************************************************************************
636  *
637  * FUNCTION:    AcpiExOpcode_2A_0T_1R
638  *
639  * PARAMETERS:  WalkState           - Current walk state
640  *
641  * RETURN:      Status
642  *
643  * DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value
644  *
645  ******************************************************************************/
646 
647 ACPI_STATUS
648 AcpiExOpcode_2A_0T_1R (
649     ACPI_WALK_STATE         *WalkState)
650 {
651     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
652     ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
653     ACPI_STATUS             Status = AE_OK;
654     BOOLEAN                 LogicalResult = FALSE;
655 
656 
657     ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R,
658         AcpiPsGetOpcodeName (WalkState->Opcode));
659 
660 
661     /* Create the internal return object */
662 
663     ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
664     if (!ReturnDesc)
665     {
666         Status = AE_NO_MEMORY;
667         goto Cleanup;
668     }
669 
670     /* Execute the Opcode */
671 
672     if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC)
673     {
674         /* LogicalOp  (Operand0, Operand1) */
675 
676         Status = AcpiExDoLogicalNumericOp (WalkState->Opcode,
677             Operand[0]->Integer.Value, Operand[1]->Integer.Value,
678             &LogicalResult);
679         goto StoreLogicalResult;
680     }
681     else if (WalkState->OpInfo->Flags & AML_LOGICAL)
682     {
683         /* LogicalOp  (Operand0, Operand1) */
684 
685         Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0],
686             Operand[1], &LogicalResult);
687         goto StoreLogicalResult;
688     }
689 
690     switch (WalkState->Opcode)
691     {
692     case AML_ACQUIRE_OP:            /* Acquire (MutexObject, Timeout) */
693 
694         Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState);
695         if (Status == AE_TIME)
696         {
697             LogicalResult = TRUE;       /* TRUE = Acquire timed out */
698             Status = AE_OK;
699         }
700         break;
701 
702 
703     case AML_WAIT_OP:               /* Wait (EventObject, Timeout) */
704 
705         Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]);
706         if (Status == AE_TIME)
707         {
708             LogicalResult = TRUE;       /* TRUE, Wait timed out */
709             Status = AE_OK;
710         }
711         break;
712 
713     default:
714 
715         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
716             WalkState->Opcode));
717 
718         Status = AE_AML_BAD_OPCODE;
719         goto Cleanup;
720     }
721 
722 
723 StoreLogicalResult:
724     /*
725      * Set return value to according to LogicalResult. logical TRUE (all ones)
726      * Default is FALSE (zero)
727      */
728     if (LogicalResult)
729     {
730         ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
731     }
732 
733 Cleanup:
734 
735     /* Delete return object on error */
736 
737     if (ACPI_FAILURE (Status))
738     {
739         AcpiUtRemoveReference (ReturnDesc);
740     }
741 
742     /* Save return object on success */
743 
744     else
745     {
746         WalkState->ResultObj = ReturnDesc;
747     }
748 
749     return_ACPI_STATUS (Status);
750 }
751