Merge from vendor branch LIBPCAP:
[dragonfly.git] / sys / contrib / dev / acpica / exoparg2.c
1 /******************************************************************************
2  *
3  * Module Name: exoparg2 - AML execution - opcodes with 2 arguments
4  *              $Revision: 117 $
5  *
6  *****************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2003, 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 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/exoparg2.c,v 1.1 2003/09/24 03:32:16 drhodus Exp $                                                               */
117
118
119 #define __EXOPARG2_C__
120
121 #include "acpi.h"
122 #include "acparser.h"
123 #include "acinterp.h"
124 #include "acevents.h"
125 #include "amlcode.h"
126
127
128 #define _COMPONENT          ACPI_EXECUTER
129         ACPI_MODULE_NAME    ("exoparg2")
130
131
132 /*!
133  * Naming convention for AML interpreter execution routines.
134  *
135  * The routines that begin execution of AML opcodes are named with a common
136  * convention based upon the number of arguments, the number of target operands,
137  * and whether or not a value is returned:
138  *
139  *      AcpiExOpcode_xA_yT_zR
140  *
141  * Where:
142  *
143  * xA - ARGUMENTS:    The number of arguments (input operands) that are
144  *                    required for this opcode type (1 through 6 args).
145  * yT - TARGETS:      The number of targets (output operands) that are required
146  *                    for this opcode type (0, 1, or 2 targets).
147  * zR - RETURN VALUE: Indicates whether this opcode type returns a value
148  *                    as the function return (0 or 1).
149  *
150  * The AcpiExOpcode* functions are called via the Dispatcher component with
151  * fully resolved operands.
152 !*/
153
154
155 /*******************************************************************************
156  *
157  * FUNCTION:    AcpiExOpcode_2A_0T_0R
158  *
159  * PARAMETERS:  WalkState           - Current walk state
160  *
161  * RETURN:      Status
162  *
163  * DESCRIPTION: Execute opcode with two arguments, no target, and no return
164  *              value.
165  *
166  * ALLOCATION:  Deletes both operands
167  *
168  ******************************************************************************/
169
170 ACPI_STATUS
171 AcpiExOpcode_2A_0T_0R (
172     ACPI_WALK_STATE         *WalkState)
173 {
174     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
175     ACPI_NAMESPACE_NODE     *Node;
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         /* Notifies allowed on this object? */
194
195         if (!AcpiEvIsNotifyObject (Node))
196         {
197             ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unexpected notify object type [%s]\n",
198                     AcpiUtGetTypeName (Node->Type)));
199
200             Status = AE_AML_OPERAND_TYPE;
201             break;
202         }
203
204         /*
205          * Dispatch the notify to the appropriate handler
206          * NOTE: the request is queued for execution after this method
207          * completes.  The notify handlers are NOT invoked synchronously
208          * from this thread -- because handlers may in turn run other
209          * control methods.
210          */
211         Status = AcpiEvQueueNotifyRequest (Node,
212                         (UINT32) Operand[1]->Integer.Value);
213         break;
214
215
216     default:
217
218         ACPI_REPORT_ERROR (("AcpiExOpcode_2A_0T_0R: Unknown opcode %X\n",
219                 WalkState->Opcode));
220         Status = AE_AML_BAD_OPCODE;
221     }
222
223     return_ACPI_STATUS (Status);
224 }
225
226
227 /*******************************************************************************
228  *
229  * FUNCTION:    AcpiExOpcode_2A_2T_1R
230  *
231  * PARAMETERS:  WalkState           - Current walk state
232  *
233  * RETURN:      Status
234  *
235  * DESCRIPTION: Execute a dyadic operator (2 operands) with 2 output targets
236  *              and one implicit return value.
237  *
238  ******************************************************************************/
239
240 ACPI_STATUS
241 AcpiExOpcode_2A_2T_1R (
242     ACPI_WALK_STATE         *WalkState)
243 {
244     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
245     ACPI_OPERAND_OBJECT     *ReturnDesc1 = NULL;
246     ACPI_OPERAND_OBJECT     *ReturnDesc2 = NULL;
247     ACPI_STATUS             Status;
248
249
250     ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_2T_1R", AcpiPsGetOpcodeName (WalkState->Opcode));
251
252
253     /*
254      * Execute the opcode
255      */
256     switch (WalkState->Opcode)
257     {
258     case AML_DIVIDE_OP:             /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */
259
260         ReturnDesc1 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
261         if (!ReturnDesc1)
262         {
263             Status = AE_NO_MEMORY;
264             goto Cleanup;
265         }
266
267         ReturnDesc2 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
268         if (!ReturnDesc2)
269         {
270             Status = AE_NO_MEMORY;
271             goto Cleanup;
272         }
273
274         /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */
275
276         Status = AcpiUtDivide (&Operand[0]->Integer.Value, &Operand[1]->Integer.Value,
277                                &ReturnDesc1->Integer.Value, &ReturnDesc2->Integer.Value);
278         if (ACPI_FAILURE (Status))
279         {
280             goto Cleanup;
281         }
282         break;
283
284
285     default:
286
287         ACPI_REPORT_ERROR (("AcpiExOpcode_2A_2T_1R: Unknown opcode %X\n",
288                 WalkState->Opcode));
289         Status = AE_AML_BAD_OPCODE;
290         goto Cleanup;
291     }
292
293
294     /* Store the results to the target reference operands */
295
296     Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState);
297     if (ACPI_FAILURE (Status))
298     {
299         goto Cleanup;
300     }
301
302     Status = AcpiExStore (ReturnDesc1, Operand[3], WalkState);
303     if (ACPI_FAILURE (Status))
304     {
305         goto Cleanup;
306     }
307
308     /* Return the remainder */
309
310     WalkState->ResultObj = ReturnDesc1;
311
312
313 Cleanup:
314     /*
315      * Since the remainder is not returned indirectly, remove a reference to
316      * it. Only the quotient is returned indirectly.
317      */
318     AcpiUtRemoveReference (ReturnDesc2);
319
320     if (ACPI_FAILURE (Status))
321     {
322         /* Delete the return object */
323
324         AcpiUtRemoveReference (ReturnDesc1);
325     }
326
327     return_ACPI_STATUS (Status);
328 }
329
330
331 /*******************************************************************************
332  *
333  * FUNCTION:    AcpiExOpcode_2A_1T_1R
334  *
335  * PARAMETERS:  WalkState           - Current walk state
336  *
337  * RETURN:      Status
338  *
339  * DESCRIPTION: Execute opcode with two arguments, one target, and a return
340  *              value.
341  *
342  ******************************************************************************/
343
344 ACPI_STATUS
345 AcpiExOpcode_2A_1T_1R (
346     ACPI_WALK_STATE         *WalkState)
347 {
348     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
349     ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
350     ACPI_OPERAND_OBJECT     *TempDesc = NULL;
351     UINT32                  Index;
352     ACPI_STATUS             Status = AE_OK;
353     ACPI_SIZE               Length;
354
355
356     ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode));
357
358
359     /*
360      * Execute the opcode
361      */
362     if (WalkState->OpInfo->Flags & AML_MATH)
363     {
364         /* All simple math opcodes (add, etc.) */
365
366         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
367         if (!ReturnDesc)
368         {
369             Status = AE_NO_MEMORY;
370             goto Cleanup;
371         }
372
373         ReturnDesc->Integer.Value = AcpiExDoMathOp (WalkState->Opcode,
374                                                 Operand[0]->Integer.Value,
375                                                 Operand[1]->Integer.Value);
376         goto StoreResultToTarget;
377     }
378
379
380     switch (WalkState->Opcode)
381     {
382     case AML_MOD_OP:                /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */
383
384         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
385         if (!ReturnDesc)
386         {
387             Status = AE_NO_MEMORY;
388             goto Cleanup;
389         }
390
391         /* ReturnDesc will contain the remainder */
392
393         Status = AcpiUtDivide (&Operand[0]->Integer.Value, &Operand[1]->Integer.Value,
394                         NULL, &ReturnDesc->Integer.Value);
395         break;
396
397
398     case AML_CONCAT_OP:             /* Concatenate (Data1, Data2, Result) */
399
400         /*
401          * Convert the second operand if necessary.  The first operand
402          * determines the type of the second operand, (See the Data Types
403          * section of the ACPI specification.)  Both object types are
404          * guaranteed to be either Integer/String/Buffer by the operand
405          * resolution mechanism above.
406          */
407         switch (ACPI_GET_OBJECT_TYPE (Operand[0]))
408         {
409         case ACPI_TYPE_INTEGER:
410             Status = AcpiExConvertToInteger (Operand[1], &TempDesc, WalkState);
411             break;
412
413         case ACPI_TYPE_STRING:
414             Status = AcpiExConvertToString (Operand[1], &TempDesc, 16, ACPI_UINT32_MAX, WalkState);
415             break;
416
417         case ACPI_TYPE_BUFFER:
418             Status = AcpiExConvertToBuffer (Operand[1], &TempDesc, WalkState);
419             break;
420
421         default:
422             Status = AE_AML_INTERNAL;
423         }
424
425         if (ACPI_FAILURE (Status))
426         {
427             goto Cleanup;
428         }
429
430         /*
431          * Both operands are now known to be the same object type
432          * (Both are Integer, String, or Buffer), and we can now perform the
433          * concatenation.
434          */
435         Status = AcpiExDoConcatenate (Operand[0], TempDesc, &ReturnDesc, WalkState);
436         if (TempDesc != Operand[1])
437         {
438             AcpiUtRemoveReference (TempDesc);
439         }
440         break;
441
442
443     case AML_TO_STRING_OP:          /* ToString (Buffer, Length, Result) (ACPI 2.0) */
444
445         /*
446          * Input object is guaranteed to be a buffer at this point (it may have
447          * been converted.)  Copy the raw buffer data to a new object of type String.
448          */
449
450         /* Get the length of the new string */
451
452         Length = 0;
453         if (Operand[1]->Integer.Value == 0)
454         {
455             /* Handle optional length value */
456
457             Operand[1]->Integer.Value = ACPI_INTEGER_MAX;
458         }
459
460         while ((Length < Operand[0]->Buffer.Length) &&
461                (Length < Operand[1]->Integer.Value) &&
462                (Operand[0]->Buffer.Pointer[Length]))
463         {
464             Length++;
465         }
466
467         if (Length > ACPI_MAX_STRING_CONVERSION)
468         {
469             Status = AE_AML_STRING_LIMIT;
470             goto Cleanup;
471         }
472
473         /* Create the internal return object */
474
475         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING);
476         if (!ReturnDesc)
477         {
478             Status = AE_NO_MEMORY;
479             goto Cleanup;
480         }
481
482         /* Allocate a new string buffer (Length + 1 for null terminator) */
483
484         ReturnDesc->String.Pointer = ACPI_MEM_CALLOCATE (Length + 1);
485         if (!ReturnDesc->String.Pointer)
486         {
487             Status = AE_NO_MEMORY;
488             goto Cleanup;
489         }
490
491         /* Copy the raw buffer data with no transform */
492
493         ACPI_MEMCPY (ReturnDesc->String.Pointer, Operand[0]->Buffer.Pointer, Length);
494
495         /* Set the string length */
496
497         ReturnDesc->String.Length = (UINT32) Length;
498         break;
499
500
501     case AML_CONCAT_RES_OP:         /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */
502
503         Status = AcpiExConcatTemplate (Operand[0], Operand[1], &ReturnDesc, WalkState);
504         break;
505
506
507     case AML_INDEX_OP:              /* Index (Source Index Result) */
508
509         /* Create the internal return object */
510
511         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
512         if (!ReturnDesc)
513         {
514             Status = AE_NO_MEMORY;
515             goto Cleanup;
516         }
517
518         Index = (UINT32) Operand[1]->Integer.Value;
519
520         /*
521          * At this point, the Source operand is either a Package or a Buffer
522          */
523         if (ACPI_GET_OBJECT_TYPE (Operand[0]) == ACPI_TYPE_PACKAGE)
524         {
525             /* Object to be indexed is a Package */
526
527             if (Index >= Operand[0]->Package.Count)
528             {
529                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index value (%X) beyond package end (%X)\n",
530                     Index, Operand[0]->Package.Count));
531                 Status = AE_AML_PACKAGE_LIMIT;
532                 goto Cleanup;
533             }
534
535             ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE;
536             ReturnDesc->Reference.Object     = Operand[0]->Package.Elements [Index];
537             ReturnDesc->Reference.Where      = &Operand[0]->Package.Elements [Index];
538         }
539         else
540         {
541             /* Object to be indexed is a Buffer */
542
543             if (Index >= Operand[0]->Buffer.Length)
544             {
545                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index value (%X) beyond end of buffer (%X)\n",
546                     Index, Operand[0]->Buffer.Length));
547                 Status = AE_AML_BUFFER_LIMIT;
548                 goto Cleanup;
549             }
550
551             ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
552             ReturnDesc->Reference.Object     = Operand[0];
553         }
554
555         /* Complete the Index reference object */
556
557         ReturnDesc->Reference.Opcode     = AML_INDEX_OP;
558         ReturnDesc->Reference.Offset     = Index;
559
560         /* Store the reference to the Target */
561
562         Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
563
564         /* Return the reference */
565
566         WalkState->ResultObj = ReturnDesc;
567         goto Cleanup;
568
569
570     default:
571
572         ACPI_REPORT_ERROR (("AcpiExOpcode_2A_1T_1R: Unknown opcode %X\n",
573                 WalkState->Opcode));
574         Status = AE_AML_BAD_OPCODE;
575         break;
576     }
577
578
579 StoreResultToTarget:
580
581     if (ACPI_SUCCESS (Status))
582     {
583         /*
584          * Store the result of the operation (which is now in ReturnDesc) into
585          * the Target descriptor.
586          */
587         Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
588         if (ACPI_FAILURE (Status))
589         {
590             goto Cleanup;
591         }
592
593         if (!WalkState->ResultObj)
594         {
595             WalkState->ResultObj = ReturnDesc;
596         }
597     }
598
599
600 Cleanup:
601
602     /* Delete return object on error */
603
604     if (ACPI_FAILURE (Status))
605     {
606         AcpiUtRemoveReference (ReturnDesc);
607     }
608
609     return_ACPI_STATUS (Status);
610 }
611
612
613 /*******************************************************************************
614  *
615  * FUNCTION:    AcpiExOpcode_2A_0T_1R
616  *
617  * PARAMETERS:  WalkState           - Current walk state
618  *
619  * RETURN:      Status
620  *
621  * DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value
622  *
623  ******************************************************************************/
624
625 ACPI_STATUS
626 AcpiExOpcode_2A_0T_1R (
627     ACPI_WALK_STATE         *WalkState)
628 {
629     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
630     ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
631     ACPI_STATUS             Status = AE_OK;
632     BOOLEAN                 LogicalResult = FALSE;
633
634
635     ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode));
636
637
638     /* Create the internal return object */
639
640     ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
641     if (!ReturnDesc)
642     {
643         Status = AE_NO_MEMORY;
644         goto Cleanup;
645     }
646
647     /*
648      * Execute the Opcode
649      */
650     if (WalkState->OpInfo->Flags & AML_LOGICAL) /* LogicalOp  (Operand0, Operand1) */
651     {
652         LogicalResult = AcpiExDoLogicalOp (WalkState->Opcode,
653                                             Operand[0]->Integer.Value,
654                                             Operand[1]->Integer.Value);
655         goto StoreLogicalResult;
656     }
657
658
659     switch (WalkState->Opcode)
660     {
661     case AML_ACQUIRE_OP:            /* Acquire (MutexObject, Timeout) */
662
663         Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState);
664         if (Status == AE_TIME)
665         {
666             LogicalResult = TRUE;       /* TRUE = Acquire timed out */
667             Status = AE_OK;
668         }
669         break;
670
671
672     case AML_WAIT_OP:               /* Wait (EventObject, Timeout) */
673
674         Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]);
675         if (Status == AE_TIME)
676         {
677             LogicalResult = TRUE;       /* TRUE, Wait timed out */
678             Status = AE_OK;
679         }
680         break;
681
682
683     default:
684
685         ACPI_REPORT_ERROR (("AcpiExOpcode_2A_0T_1R: Unknown opcode %X\n",
686             WalkState->Opcode));
687         Status = AE_AML_BAD_OPCODE;
688         goto Cleanup;
689     }
690
691
692 StoreLogicalResult:
693     /*
694      * Set return value to according to LogicalResult. logical TRUE (all ones)
695      * Default is FALSE (zero)
696      */
697     if (LogicalResult)
698     {
699         ReturnDesc->Integer.Value = ACPI_INTEGER_MAX;
700     }
701
702     WalkState->ResultObj = ReturnDesc;
703
704
705 Cleanup:
706
707     /* Delete return object on error */
708
709     if (ACPI_FAILURE (Status))
710     {
711         AcpiUtRemoveReference (ReturnDesc);
712     }
713
714     return_ACPI_STATUS (Status);
715 }
716
717