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