OSDN Git Service

klibc基本機能実装. ACPICAの準備
[vaneos/DivergeMirror.git] / drivers / acpi / components / parser / psparse.c
1 /******************************************************************************
2  *
3  * Module Name: psparse - Parser top level AML parse routines
4  *
5  *****************************************************************************/
6
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2015, 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 /*
117  * Parse the AML and build an operation tree as most interpreters,
118  * like Perl, do. Parsing is done by hand rather than with a YACC
119  * generated parser to tightly constrain stack and dynamic memory
120  * usage. At the same time, parsing is kept flexible and the code
121  * fairly compact by parsing based on a list of AML opcode
122  * templates in AmlOpInfo[]
123  */
124
125 #include "acpi.h"
126 #include "accommon.h"
127 #include "acparser.h"
128 #include "acdispat.h"
129 #include "amlcode.h"
130 #include "acinterp.h"
131
132 #define _COMPONENT          ACPI_PARSER
133         ACPI_MODULE_NAME    ("psparse")
134
135
136 /*******************************************************************************
137  *
138  * FUNCTION:    AcpiPsGetOpcodeSize
139  *
140  * PARAMETERS:  Opcode          - An AML opcode
141  *
142  * RETURN:      Size of the opcode, in bytes (1 or 2)
143  *
144  * DESCRIPTION: Get the size of the current opcode.
145  *
146  ******************************************************************************/
147
148 UINT32
149 AcpiPsGetOpcodeSize (
150     UINT32                  Opcode)
151 {
152
153     /* Extended (2-byte) opcode if > 255 */
154
155     if (Opcode > 0x00FF)
156     {
157         return (2);
158     }
159
160     /* Otherwise, just a single byte opcode */
161
162     return (1);
163 }
164
165
166 /*******************************************************************************
167  *
168  * FUNCTION:    AcpiPsPeekOpcode
169  *
170  * PARAMETERS:  ParserState         - A parser state object
171  *
172  * RETURN:      Next AML opcode
173  *
174  * DESCRIPTION: Get next AML opcode (without incrementing AML pointer)
175  *
176  ******************************************************************************/
177
178 UINT16
179 AcpiPsPeekOpcode (
180     ACPI_PARSE_STATE        *ParserState)
181 {
182     UINT8                   *Aml;
183     UINT16                  Opcode;
184
185
186     Aml = ParserState->Aml;
187     Opcode = (UINT16) ACPI_GET8 (Aml);
188
189     if (Opcode == AML_EXTENDED_OP_PREFIX)
190     {
191         /* Extended opcode, get the second opcode byte */
192
193         Aml++;
194         Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml));
195     }
196
197     return (Opcode);
198 }
199
200
201 /*******************************************************************************
202  *
203  * FUNCTION:    AcpiPsCompleteThisOp
204  *
205  * PARAMETERS:  WalkState       - Current State
206  *              Op              - Op to complete
207  *
208  * RETURN:      Status
209  *
210  * DESCRIPTION: Perform any cleanup at the completion of an Op.
211  *
212  ******************************************************************************/
213
214 ACPI_STATUS
215 AcpiPsCompleteThisOp (
216     ACPI_WALK_STATE         *WalkState,
217     ACPI_PARSE_OBJECT       *Op)
218 {
219     ACPI_PARSE_OBJECT       *Prev;
220     ACPI_PARSE_OBJECT       *Next;
221     const ACPI_OPCODE_INFO  *ParentInfo;
222     ACPI_PARSE_OBJECT       *ReplacementOp = NULL;
223     ACPI_STATUS             Status = AE_OK;
224
225
226     ACPI_FUNCTION_TRACE_PTR (PsCompleteThisOp, Op);
227
228
229     /* Check for null Op, can happen if AML code is corrupt */
230
231     if (!Op)
232     {
233         return_ACPI_STATUS (AE_OK);  /* OK for now */
234     }
235
236     /* Delete this op and the subtree below it if asked to */
237
238     if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) ||
239          (WalkState->OpInfo->Class == AML_CLASS_ARGUMENT))
240     {
241         return_ACPI_STATUS (AE_OK);
242     }
243
244     /* Make sure that we only delete this subtree */
245
246     if (Op->Common.Parent)
247     {
248         Prev = Op->Common.Parent->Common.Value.Arg;
249         if (!Prev)
250         {
251             /* Nothing more to do */
252
253             goto Cleanup;
254         }
255
256         /*
257          * Check if we need to replace the operator and its subtree
258          * with a return value op (placeholder op)
259          */
260         ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
261
262         switch (ParentInfo->Class)
263         {
264         case AML_CLASS_CONTROL:
265
266             break;
267
268         case AML_CLASS_CREATE:
269             /*
270              * These opcodes contain TermArg operands. The current
271              * op must be replaced by a placeholder return op
272              */
273             ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
274             if (!ReplacementOp)
275             {
276                 Status = AE_NO_MEMORY;
277             }
278             break;
279
280         case AML_CLASS_NAMED_OBJECT:
281             /*
282              * These opcodes contain TermArg operands. The current
283              * op must be replaced by a placeholder return op
284              */
285             if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP)       ||
286                 (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP)  ||
287                 (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP)       ||
288                 (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP)      ||
289                 (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP)   ||
290                 (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
291             {
292                 ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
293                 if (!ReplacementOp)
294                 {
295                     Status = AE_NO_MEMORY;
296                 }
297             }
298             else if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
299                      (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2))
300             {
301                 if ((Op->Common.AmlOpcode == AML_BUFFER_OP) ||
302                     (Op->Common.AmlOpcode == AML_PACKAGE_OP) ||
303                     (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
304                 {
305                     ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode);
306                     if (!ReplacementOp)
307                     {
308                         Status = AE_NO_MEMORY;
309                     }
310                     else
311                     {
312                         ReplacementOp->Named.Data = Op->Named.Data;
313                         ReplacementOp->Named.Length = Op->Named.Length;
314                     }
315                 }
316             }
317             break;
318
319         default:
320
321             ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
322             if (!ReplacementOp)
323             {
324                 Status = AE_NO_MEMORY;
325             }
326         }
327
328         /* We must unlink this op from the parent tree */
329
330         if (Prev == Op)
331         {
332             /* This op is the first in the list */
333
334             if (ReplacementOp)
335             {
336                 ReplacementOp->Common.Parent        = Op->Common.Parent;
337                 ReplacementOp->Common.Value.Arg     = NULL;
338                 ReplacementOp->Common.Node          = Op->Common.Node;
339                 Op->Common.Parent->Common.Value.Arg = ReplacementOp;
340                 ReplacementOp->Common.Next          = Op->Common.Next;
341             }
342             else
343             {
344                 Op->Common.Parent->Common.Value.Arg = Op->Common.Next;
345             }
346         }
347
348         /* Search the parent list */
349
350         else while (Prev)
351         {
352             /* Traverse all siblings in the parent's argument list */
353
354             Next = Prev->Common.Next;
355             if (Next == Op)
356             {
357                 if (ReplacementOp)
358                 {
359                     ReplacementOp->Common.Parent    = Op->Common.Parent;
360                     ReplacementOp->Common.Value.Arg = NULL;
361                     ReplacementOp->Common.Node      = Op->Common.Node;
362                     Prev->Common.Next               = ReplacementOp;
363                     ReplacementOp->Common.Next      = Op->Common.Next;
364                     Next = NULL;
365                 }
366                 else
367                 {
368                     Prev->Common.Next = Op->Common.Next;
369                     Next = NULL;
370                 }
371             }
372             Prev = Next;
373         }
374     }
375
376
377 Cleanup:
378
379     /* Now we can actually delete the subtree rooted at Op */
380
381     AcpiPsDeleteParseTree (Op);
382     return_ACPI_STATUS (Status);
383 }
384
385
386 /*******************************************************************************
387  *
388  * FUNCTION:    AcpiPsNextParseState
389  *
390  * PARAMETERS:  WalkState           - Current state
391  *              Op                  - Current parse op
392  *              CallbackStatus      - Status from previous operation
393  *
394  * RETURN:      Status
395  *
396  * DESCRIPTION: Update the parser state based upon the return exception from
397  *              the parser callback.
398  *
399  ******************************************************************************/
400
401 ACPI_STATUS
402 AcpiPsNextParseState (
403     ACPI_WALK_STATE         *WalkState,
404     ACPI_PARSE_OBJECT       *Op,
405     ACPI_STATUS             CallbackStatus)
406 {
407     ACPI_PARSE_STATE        *ParserState = &WalkState->ParserState;
408     ACPI_STATUS             Status = AE_CTRL_PENDING;
409
410
411     ACPI_FUNCTION_TRACE_PTR (PsNextParseState, Op);
412
413
414     switch (CallbackStatus)
415     {
416     case AE_CTRL_TERMINATE:
417         /*
418          * A control method was terminated via a RETURN statement.
419          * The walk of this method is complete.
420          */
421         ParserState->Aml = ParserState->AmlEnd;
422         Status = AE_CTRL_TERMINATE;
423         break;
424
425     case AE_CTRL_BREAK:
426
427         ParserState->Aml = WalkState->AmlLastWhile;
428         WalkState->ControlState->Common.Value = FALSE;
429         Status = AE_CTRL_BREAK;
430         break;
431
432     case AE_CTRL_CONTINUE:
433
434         ParserState->Aml = WalkState->AmlLastWhile;
435         Status = AE_CTRL_CONTINUE;
436         break;
437
438     case AE_CTRL_PENDING:
439
440         ParserState->Aml = WalkState->AmlLastWhile;
441         break;
442
443 #if 0
444     case AE_CTRL_SKIP:
445
446         ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
447         Status = AE_OK;
448         break;
449 #endif
450
451     case AE_CTRL_TRUE:
452         /*
453          * Predicate of an IF was true, and we are at the matching ELSE.
454          * Just close out this package
455          */
456         ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState);
457         Status = AE_CTRL_PENDING;
458         break;
459
460     case AE_CTRL_FALSE:
461         /*
462          * Either an IF/WHILE Predicate was false or we encountered a BREAK
463          * opcode. In both cases, we do not execute the rest of the
464          * package;  We simply close out the parent (finishing the walk of
465          * this branch of the tree) and continue execution at the parent
466          * level.
467          */
468         ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
469
470         /* In the case of a BREAK, just force a predicate (if any) to FALSE */
471
472         WalkState->ControlState->Common.Value = FALSE;
473         Status = AE_CTRL_END;
474         break;
475
476     case AE_CTRL_TRANSFER:
477
478         /* A method call (invocation) -- transfer control */
479
480         Status = AE_CTRL_TRANSFER;
481         WalkState->PrevOp = Op;
482         WalkState->MethodCallOp = Op;
483         WalkState->MethodCallNode = (Op->Common.Value.Arg)->Common.Node;
484
485         /* Will return value (if any) be used by the caller? */
486
487         WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState);
488         break;
489
490     default:
491
492         Status = CallbackStatus;
493         if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL)
494         {
495             Status = AE_OK;
496         }
497         break;
498     }
499
500     return_ACPI_STATUS (Status);
501 }
502
503
504 /*******************************************************************************
505  *
506  * FUNCTION:    AcpiPsParseAml
507  *
508  * PARAMETERS:  WalkState       - Current state
509  *
510  *
511  * RETURN:      Status
512  *
513  * DESCRIPTION: Parse raw AML and return a tree of ops
514  *
515  ******************************************************************************/
516
517 ACPI_STATUS
518 AcpiPsParseAml (
519     ACPI_WALK_STATE         *WalkState)
520 {
521     ACPI_STATUS             Status;
522     ACPI_THREAD_STATE       *Thread;
523     ACPI_THREAD_STATE       *PrevWalkList = AcpiGbl_CurrentWalkList;
524     ACPI_WALK_STATE         *PreviousWalkState;
525
526
527     ACPI_FUNCTION_TRACE (PsParseAml);
528
529     ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
530         "Entered with WalkState=%p Aml=%p size=%X\n",
531         WalkState, WalkState->ParserState.Aml,
532         WalkState->ParserState.AmlSize));
533
534     if (!WalkState->ParserState.Aml)
535     {
536         return_ACPI_STATUS (AE_NULL_OBJECT);
537     }
538
539     /* Create and initialize a new thread state */
540
541     Thread = AcpiUtCreateThreadState ();
542     if (!Thread)
543     {
544         if (WalkState->MethodDesc)
545         {
546             /* Executing a control method - additional cleanup */
547
548             AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
549         }
550
551         AcpiDsDeleteWalkState (WalkState);
552         return_ACPI_STATUS (AE_NO_MEMORY);
553     }
554
555     WalkState->Thread = Thread;
556
557     /*
558      * If executing a method, the starting SyncLevel is this method's
559      * SyncLevel
560      */
561     if (WalkState->MethodDesc)
562     {
563         WalkState->Thread->CurrentSyncLevel = WalkState->MethodDesc->Method.SyncLevel;
564     }
565
566     AcpiDsPushWalkState (WalkState, Thread);
567
568     /*
569      * This global allows the AML debugger to get a handle to the currently
570      * executing control method.
571      */
572     AcpiGbl_CurrentWalkList = Thread;
573
574     /*
575      * Execute the walk loop as long as there is a valid Walk State. This
576      * handles nested control method invocations without recursion.
577      */
578     ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", WalkState));
579
580     Status = AE_OK;
581     while (WalkState)
582     {
583         if (ACPI_SUCCESS (Status))
584         {
585             /*
586              * The ParseLoop executes AML until the method terminates
587              * or calls another method.
588              */
589             Status = AcpiPsParseLoop (WalkState);
590         }
591
592         ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
593             "Completed one call to walk loop, %s State=%p\n",
594             AcpiFormatException (Status), WalkState));
595
596         if (Status == AE_CTRL_TRANSFER)
597         {
598             /*
599              * A method call was detected.
600              * Transfer control to the called control method
601              */
602             Status = AcpiDsCallControlMethod (Thread, WalkState, NULL);
603             if (ACPI_FAILURE (Status))
604             {
605                 Status = AcpiDsMethodError (Status, WalkState);
606             }
607
608             /*
609              * If the transfer to the new method method call worked, a new walk
610              * state was created -- get it
611              */
612             WalkState = AcpiDsGetCurrentWalkState (Thread);
613             continue;
614         }
615         else if (Status == AE_CTRL_TERMINATE)
616         {
617             Status = AE_OK;
618         }
619         else if ((Status != AE_OK) && (WalkState->MethodDesc))
620         {
621             /* Either the method parse or actual execution failed */
622
623             ACPI_ERROR_METHOD ("Method parse/execution failed",
624                 WalkState->MethodNode, NULL, Status);
625
626             /* Check for possible multi-thread reentrancy problem */
627
628             if ((Status == AE_ALREADY_EXISTS) &&
629                 (!(WalkState->MethodDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED)))
630             {
631                 /*
632                  * Method is not serialized and tried to create an object
633                  * twice. The probable cause is that the method cannot
634                  * handle reentrancy. Mark as "pending serialized" now, and
635                  * then mark "serialized" when the last thread exits.
636                  */
637                 WalkState->MethodDesc->Method.InfoFlags |=
638                     ACPI_METHOD_SERIALIZED_PENDING;
639             }
640         }
641
642         /* We are done with this walk, move on to the parent if any */
643
644         WalkState = AcpiDsPopWalkState (Thread);
645
646         /* Reset the current scope to the beginning of scope stack */
647
648         AcpiDsScopeStackClear (WalkState);
649
650         /*
651          * If we just returned from the execution of a control method or if we
652          * encountered an error during the method parse phase, there's lots of
653          * cleanup to do
654          */
655         if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) ||
656             (ACPI_FAILURE (Status)))
657         {
658             AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
659         }
660
661         /* Delete this walk state and all linked control states */
662
663         AcpiPsCleanupScope (&WalkState->ParserState);
664         PreviousWalkState = WalkState;
665
666         ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
667             "ReturnValue=%p, ImplicitValue=%p State=%p\n",
668             WalkState->ReturnDesc, WalkState->ImplicitReturnObj, WalkState));
669
670         /* Check if we have restarted a preempted walk */
671
672         WalkState = AcpiDsGetCurrentWalkState (Thread);
673         if (WalkState)
674         {
675             if (ACPI_SUCCESS (Status))
676             {
677                 /*
678                  * There is another walk state, restart it.
679                  * If the method return value is not used by the parent,
680                  * The object is deleted
681                  */
682                 if (!PreviousWalkState->ReturnDesc)
683                 {
684                     /*
685                      * In slack mode execution, if there is no return value
686                      * we should implicitly return zero (0) as a default value.
687                      */
688                     if (AcpiGbl_EnableInterpreterSlack &&
689                         !PreviousWalkState->ImplicitReturnObj)
690                     {
691                         PreviousWalkState->ImplicitReturnObj =
692                             AcpiUtCreateIntegerObject ((UINT64) 0);
693                         if (!PreviousWalkState->ImplicitReturnObj)
694                         {
695                             return_ACPI_STATUS (AE_NO_MEMORY);
696                         }
697                     }
698
699                     /* Restart the calling control method */
700
701                     Status = AcpiDsRestartControlMethod (WalkState,
702                                 PreviousWalkState->ImplicitReturnObj);
703                 }
704                 else
705                 {
706                     /*
707                      * We have a valid return value, delete any implicit
708                      * return value.
709                      */
710                     AcpiDsClearImplicitReturn (PreviousWalkState);
711
712                     Status = AcpiDsRestartControlMethod (WalkState,
713                                 PreviousWalkState->ReturnDesc);
714                 }
715                 if (ACPI_SUCCESS (Status))
716                 {
717                     WalkState->WalkType |= ACPI_WALK_METHOD_RESTART;
718                 }
719             }
720             else
721             {
722                 /* On error, delete any return object or implicit return */
723
724                 AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
725                 AcpiDsClearImplicitReturn (PreviousWalkState);
726             }
727         }
728
729         /*
730          * Just completed a 1st-level method, save the final internal return
731          * value (if any)
732          */
733         else if (PreviousWalkState->CallerReturnDesc)
734         {
735             if (PreviousWalkState->ImplicitReturnObj)
736             {
737                 *(PreviousWalkState->CallerReturnDesc) =
738                     PreviousWalkState->ImplicitReturnObj;
739             }
740             else
741             {
742                  /* NULL if no return value */
743
744                 *(PreviousWalkState->CallerReturnDesc) =
745                     PreviousWalkState->ReturnDesc;
746             }
747         }
748         else
749         {
750             if (PreviousWalkState->ReturnDesc)
751             {
752                 /* Caller doesn't want it, must delete it */
753
754                 AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
755             }
756             if (PreviousWalkState->ImplicitReturnObj)
757             {
758                 /* Caller doesn't want it, must delete it */
759
760                 AcpiUtRemoveReference (PreviousWalkState->ImplicitReturnObj);
761             }
762         }
763
764         AcpiDsDeleteWalkState (PreviousWalkState);
765     }
766
767     /* Normal exit */
768
769     AcpiExReleaseAllMutexes (Thread);
770     AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread));
771     AcpiGbl_CurrentWalkList = PrevWalkList;
772     return_ACPI_STATUS (Status);
773 }