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