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