![]() |
|
|||
File indexing completed on 2025-05-11 08:24:03
0001 /****************************************************************************** 0002 * 0003 * Module Name: psloop - Main AML parse loop 0004 * 0005 *****************************************************************************/ 0006 0007 /****************************************************************************** 0008 * 0009 * 1. Copyright Notice 0010 * 0011 * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp. 0012 * All rights reserved. 0013 * 0014 * 2. License 0015 * 0016 * 2.1. This is your license from Intel Corp. under its intellectual property 0017 * rights. You may have additional license terms from the party that provided 0018 * you this software, covering your right to use that party's intellectual 0019 * property rights. 0020 * 0021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 0022 * copy of the source code appearing in this file ("Covered Code") an 0023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 0024 * base code distributed originally by Intel ("Original Intel Code") to copy, 0025 * make derivatives, distribute, use and display any portion of the Covered 0026 * Code in any form, with the right to sublicense such rights; and 0027 * 0028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 0029 * license (with the right to sublicense), under only those claims of Intel 0030 * patents that are infringed by the Original Intel Code, to make, use, sell, 0031 * offer to sell, and import the Covered Code and derivative works thereof 0032 * solely to the minimum extent necessary to exercise the above copyright 0033 * license, and in no event shall the patent license extend to any additions 0034 * to or modifications of the Original Intel Code. No other license or right 0035 * is granted directly or by implication, estoppel or otherwise; 0036 * 0037 * The above copyright and patent license is granted only if the following 0038 * conditions are met: 0039 * 0040 * 3. Conditions 0041 * 0042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 0043 * Redistribution of source code of any substantial portion of the Covered 0044 * Code or modification with rights to further distribute source must include 0045 * the above Copyright Notice, the above License, this list of Conditions, 0046 * and the following Disclaimer and Export Compliance provision. In addition, 0047 * Licensee must cause all Covered Code to which Licensee contributes to 0048 * contain a file documenting the changes Licensee made to create that Covered 0049 * Code and the date of any change. Licensee must include in that file the 0050 * documentation of any changes made by any predecessor Licensee. Licensee 0051 * must include a prominent statement that the modification is derived, 0052 * directly or indirectly, from Original Intel Code. 0053 * 0054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 0055 * Redistribution of source code of any substantial portion of the Covered 0056 * Code or modification without rights to further distribute source must 0057 * include the following Disclaimer and Export Compliance provision in the 0058 * documentation and/or other materials provided with distribution. In 0059 * addition, Licensee may not authorize further sublicense of source of any 0060 * portion of the Covered Code, and must include terms to the effect that the 0061 * license from Licensee to its licensee is limited to the intellectual 0062 * property embodied in the software Licensee provides to its licensee, and 0063 * not to intellectual property embodied in modifications its licensee may 0064 * make. 0065 * 0066 * 3.3. Redistribution of Executable. Redistribution in executable form of any 0067 * substantial portion of the Covered Code or modification must reproduce the 0068 * above Copyright Notice, and the following Disclaimer and Export Compliance 0069 * provision in the documentation and/or other materials provided with the 0070 * distribution. 0071 * 0072 * 3.4. Intel retains all right, title, and interest in and to the Original 0073 * Intel Code. 0074 * 0075 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 0076 * Intel shall be used in advertising or otherwise to promote the sale, use or 0077 * other dealings in products derived from or relating to the Covered Code 0078 * without prior written authorization from Intel. 0079 * 0080 * 4. Disclaimer and Export Compliance 0081 * 0082 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 0083 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 0084 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 0085 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 0086 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 0087 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 0088 * PARTICULAR PURPOSE. 0089 * 0090 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 0091 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 0092 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 0093 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 0094 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 0095 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 0096 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 0097 * LIMITED REMEDY. 0098 * 0099 * 4.3. Licensee shall not export, either directly or indirectly, any of this 0100 * software or system incorporating such software without first obtaining any 0101 * required license or other approval from the U. S. Department of Commerce or 0102 * any other agency or department of the United States Government. In the 0103 * event Licensee exports any such software from the United States or 0104 * re-exports any such software from a foreign destination, Licensee shall 0105 * ensure that the distribution and export/re-export of the software is in 0106 * compliance with all laws, regulations, orders, or other restrictions of the 0107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 0108 * any of its subsidiaries will export/re-export any technical data, process, 0109 * software, or service, directly or indirectly, to any country for which the 0110 * United States government or any agency thereof requires an export license, 0111 * other governmental approval, or letter of assurance, without first obtaining 0112 * such license, approval or letter. 0113 * 0114 ***************************************************************************** 0115 * 0116 * Alternatively, you may choose to be licensed under the terms of the 0117 * following license: 0118 * 0119 * Redistribution and use in source and binary forms, with or without 0120 * modification, are permitted provided that the following conditions 0121 * are met: 0122 * 1. Redistributions of source code must retain the above copyright 0123 * notice, this list of conditions, and the following disclaimer, 0124 * without modification. 0125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 0126 * substantially similar to the "NO WARRANTY" disclaimer below 0127 * ("Disclaimer") and any redistribution must be conditioned upon 0128 * including a substantially similar Disclaimer requirement for further 0129 * binary redistribution. 0130 * 3. Neither the names of the above-listed copyright holders nor the names 0131 * of any contributors may be used to endorse or promote products derived 0132 * from this software without specific prior written permission. 0133 * 0134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0145 * 0146 * Alternatively, you may choose to be licensed under the terms of the 0147 * GNU General Public License ("GPL") version 2 as published by the Free 0148 * Software Foundation. 0149 * 0150 *****************************************************************************/ 0151 0152 /* 0153 * Parse the AML and build an operation tree as most interpreters, (such as 0154 * Perl) do. Parsing is done by hand rather than with a YACC generated parser 0155 * to tightly constrain stack and dynamic memory usage. Parsing is kept 0156 * flexible and the code fairly compact by parsing based on a list of AML 0157 * opcode templates in AmlOpInfo[]. 0158 */ 0159 0160 #include "acpi.h" 0161 #include "accommon.h" 0162 #include "acinterp.h" 0163 #include "acparser.h" 0164 #include "acdispat.h" 0165 #include "amlcode.h" 0166 #include "acconvert.h" 0167 #include "acnamesp.h" 0168 0169 #define _COMPONENT ACPI_PARSER 0170 ACPI_MODULE_NAME ("psloop") 0171 0172 0173 /* Local prototypes */ 0174 0175 static ACPI_STATUS 0176 AcpiPsGetArguments ( 0177 ACPI_WALK_STATE *WalkState, 0178 UINT8 *AmlOpStart, 0179 ACPI_PARSE_OBJECT *Op); 0180 0181 0182 /******************************************************************************* 0183 * 0184 * FUNCTION: AcpiPsGetArguments 0185 * 0186 * PARAMETERS: WalkState - Current state 0187 * AmlOpStart - Op start in AML 0188 * Op - Current Op 0189 * 0190 * RETURN: Status 0191 * 0192 * DESCRIPTION: Get arguments for passed Op. 0193 * 0194 ******************************************************************************/ 0195 0196 static ACPI_STATUS 0197 AcpiPsGetArguments ( 0198 ACPI_WALK_STATE *WalkState, 0199 UINT8 *AmlOpStart, 0200 ACPI_PARSE_OBJECT *Op) 0201 { 0202 ACPI_STATUS Status = AE_OK; 0203 ACPI_PARSE_OBJECT *Arg = NULL; 0204 0205 0206 ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState); 0207 0208 0209 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 0210 "Get arguments for opcode [%s]\n", Op->Common.AmlOpName)); 0211 0212 switch (Op->Common.AmlOpcode) 0213 { 0214 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ 0215 case AML_WORD_OP: /* AML_WORDDATA_ARG */ 0216 case AML_DWORD_OP: /* AML_DWORDATA_ARG */ 0217 case AML_QWORD_OP: /* AML_QWORDATA_ARG */ 0218 case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ 0219 0220 /* Fill in constant or string argument directly */ 0221 0222 AcpiPsGetNextSimpleArg (&(WalkState->ParserState), 0223 GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op); 0224 break; 0225 0226 case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ 0227 0228 Status = AcpiPsGetNextNamepath (WalkState, 0229 &(WalkState->ParserState), Op, ACPI_POSSIBLE_METHOD_CALL); 0230 if (ACPI_FAILURE (Status)) 0231 { 0232 return_ACPI_STATUS (Status); 0233 } 0234 0235 WalkState->ArgTypes = 0; 0236 break; 0237 0238 default: 0239 /* 0240 * Op is not a constant or string, append each argument to the Op 0241 */ 0242 while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && 0243 !WalkState->ArgCount) 0244 { 0245 WalkState->Aml = WalkState->ParserState.Aml; 0246 0247 switch (Op->Common.AmlOpcode) 0248 { 0249 case AML_METHOD_OP: 0250 case AML_BUFFER_OP: 0251 case AML_PACKAGE_OP: 0252 case AML_VARIABLE_PACKAGE_OP: 0253 case AML_WHILE_OP: 0254 0255 break; 0256 0257 default: 0258 0259 ASL_CV_CAPTURE_COMMENTS (WalkState); 0260 break; 0261 } 0262 0263 Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState), 0264 GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); 0265 if (ACPI_FAILURE (Status)) 0266 { 0267 return_ACPI_STATUS (Status); 0268 } 0269 0270 if (Arg) 0271 { 0272 AcpiPsAppendArg (Op, Arg); 0273 } 0274 0275 INCREMENT_ARG_LIST (WalkState->ArgTypes); 0276 } 0277 0278 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 0279 "Final argument count: %8.8X pass %u\n", 0280 WalkState->ArgCount, WalkState->PassNumber)); 0281 0282 /* Special processing for certain opcodes */ 0283 0284 switch (Op->Common.AmlOpcode) 0285 { 0286 case AML_METHOD_OP: 0287 /* 0288 * Skip parsing of control method because we don't have enough 0289 * info in the first pass to parse it correctly. 0290 * 0291 * Save the length and address of the body 0292 */ 0293 Op->Named.Data = WalkState->ParserState.Aml; 0294 Op->Named.Length = (UINT32) 0295 (WalkState->ParserState.PkgEnd - WalkState->ParserState.Aml); 0296 0297 /* Skip body of method */ 0298 0299 WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; 0300 WalkState->ArgCount = 0; 0301 break; 0302 0303 case AML_BUFFER_OP: 0304 case AML_PACKAGE_OP: 0305 case AML_VARIABLE_PACKAGE_OP: 0306 0307 if ((Op->Common.Parent) && 0308 (Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && 0309 (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2)) 0310 { 0311 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 0312 "Setup Package/Buffer: Pass %u, AML Ptr: %p\n", 0313 WalkState->PassNumber, AmlOpStart)); 0314 0315 /* 0316 * Skip parsing of Buffers and Packages because we don't have 0317 * enough info in the first pass to parse them correctly. 0318 */ 0319 Op->Named.Data = AmlOpStart; 0320 Op->Named.Length = (UINT32) 0321 (WalkState->ParserState.PkgEnd - AmlOpStart); 0322 0323 /* Skip body */ 0324 0325 WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; 0326 WalkState->ArgCount = 0; 0327 } 0328 break; 0329 0330 case AML_WHILE_OP: 0331 0332 if (WalkState->ControlState) 0333 { 0334 WalkState->ControlState->Control.PackageEnd = 0335 WalkState->ParserState.PkgEnd; 0336 } 0337 break; 0338 0339 default: 0340 0341 /* No action for all other opcodes */ 0342 0343 break; 0344 } 0345 0346 break; 0347 } 0348 0349 return_ACPI_STATUS (AE_OK); 0350 } 0351 0352 0353 /******************************************************************************* 0354 * 0355 * FUNCTION: AcpiPsParseLoop 0356 * 0357 * PARAMETERS: WalkState - Current state 0358 * 0359 * RETURN: Status 0360 * 0361 * DESCRIPTION: Parse AML (pointed to by the current parser state) and return 0362 * a tree of ops. 0363 * 0364 ******************************************************************************/ 0365 0366 ACPI_STATUS 0367 AcpiPsParseLoop ( 0368 ACPI_WALK_STATE *WalkState) 0369 { 0370 ACPI_STATUS Status = AE_OK; 0371 ACPI_PARSE_OBJECT *Op = NULL; /* current op */ 0372 ACPI_PARSE_STATE *ParserState; 0373 UINT8 *AmlOpStart = NULL; 0374 UINT8 OpcodeLength; 0375 0376 0377 ACPI_FUNCTION_TRACE_PTR (PsParseLoop, WalkState); 0378 0379 0380 if (WalkState->DescendingCallback == NULL) 0381 { 0382 return_ACPI_STATUS (AE_BAD_PARAMETER); 0383 } 0384 0385 ParserState = &WalkState->ParserState; 0386 WalkState->ArgTypes = 0; 0387 0388 #ifndef ACPI_CONSTANT_EVAL_ONLY 0389 0390 if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART) 0391 { 0392 /* We are restarting a preempted control method */ 0393 0394 if (AcpiPsHasCompletedScope (ParserState)) 0395 { 0396 /* 0397 * We must check if a predicate to an IF or WHILE statement 0398 * was just completed 0399 */ 0400 if ((ParserState->Scope->ParseScope.Op) && 0401 ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) || 0402 (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) && 0403 (WalkState->ControlState) && 0404 (WalkState->ControlState->Common.State == 0405 ACPI_CONTROL_PREDICATE_EXECUTING)) 0406 { 0407 /* 0408 * A predicate was just completed, get the value of the 0409 * predicate and branch based on that value 0410 */ 0411 WalkState->Op = NULL; 0412 Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE)); 0413 if (ACPI_FAILURE (Status) && !ACPI_CNTL_EXCEPTION (Status)) 0414 { 0415 if (Status == AE_AML_NO_RETURN_VALUE) 0416 { 0417 ACPI_EXCEPTION ((AE_INFO, Status, 0418 "Invoked method did not return a value")); 0419 } 0420 0421 ACPI_EXCEPTION ((AE_INFO, Status, "GetPredicate Failed")); 0422 return_ACPI_STATUS (Status); 0423 } 0424 0425 Status = AcpiPsNextParseState (WalkState, Op, Status); 0426 } 0427 0428 AcpiPsPopScope (ParserState, &Op, 0429 &WalkState->ArgTypes, &WalkState->ArgCount); 0430 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op)); 0431 } 0432 else if (WalkState->PrevOp) 0433 { 0434 /* We were in the middle of an op */ 0435 0436 Op = WalkState->PrevOp; 0437 WalkState->ArgTypes = WalkState->PrevArgTypes; 0438 } 0439 } 0440 #endif 0441 0442 /* Iterative parsing loop, while there is more AML to process: */ 0443 0444 while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) 0445 { 0446 ASL_CV_CAPTURE_COMMENTS (WalkState); 0447 0448 AmlOpStart = ParserState->Aml; 0449 if (!Op) 0450 { 0451 Status = AcpiPsCreateOp (WalkState, AmlOpStart, &Op); 0452 if (ACPI_FAILURE (Status)) 0453 { 0454 /* 0455 * ACPI_PARSE_MODULE_LEVEL means that we are loading a table by 0456 * executing it as a control method. However, if we encounter 0457 * an error while loading the table, we need to keep trying to 0458 * load the table rather than aborting the table load. Set the 0459 * status to AE_OK to proceed with the table load. 0460 */ 0461 if ((WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL) && 0462 ((Status == AE_ALREADY_EXISTS) || (Status == AE_NOT_FOUND))) 0463 { 0464 Status = AE_OK; 0465 } 0466 if (Status == AE_CTRL_PARSE_CONTINUE) 0467 { 0468 continue; 0469 } 0470 0471 if (Status == AE_CTRL_PARSE_PENDING) 0472 { 0473 Status = AE_OK; 0474 } 0475 0476 if (Status == AE_CTRL_TERMINATE) 0477 { 0478 return_ACPI_STATUS (Status); 0479 } 0480 0481 Status = AcpiPsCompleteOp (WalkState, &Op, Status); 0482 if (ACPI_FAILURE (Status)) 0483 { 0484 return_ACPI_STATUS (Status); 0485 } 0486 if (AcpiNsOpensScope ( 0487 AcpiPsGetOpcodeInfo (WalkState->Opcode)->ObjectType)) 0488 { 0489 /* 0490 * If the scope/device op fails to parse, skip the body of 0491 * the scope op because the parse failure indicates that 0492 * the device may not exist. 0493 */ 0494 ACPI_INFO (("Skipping parse of AML opcode: %s (0x%4.4X)", 0495 AcpiPsGetOpcodeName (WalkState->Opcode), WalkState->Opcode)); 0496 0497 /* 0498 * Determine the opcode length before skipping the opcode. 0499 * An opcode can be 1 byte or 2 bytes in length. 0500 */ 0501 OpcodeLength = 1; 0502 if ((WalkState->Opcode & 0xFF00) == AML_EXTENDED_OPCODE) 0503 { 0504 OpcodeLength = 2; 0505 } 0506 WalkState->ParserState.Aml = WalkState->Aml + OpcodeLength; 0507 0508 WalkState->ParserState.Aml = 0509 AcpiPsGetNextPackageEnd(&WalkState->ParserState); 0510 WalkState->Aml = WalkState->ParserState.Aml; 0511 } 0512 0513 continue; 0514 } 0515 0516 AcpiExStartTraceOpcode (Op, WalkState); 0517 } 0518 0519 /* 0520 * Start ArgCount at zero because we don't know if there are 0521 * any args yet 0522 */ 0523 WalkState->ArgCount = 0; 0524 0525 switch (Op->Common.AmlOpcode) 0526 { 0527 case AML_BYTE_OP: 0528 case AML_WORD_OP: 0529 case AML_DWORD_OP: 0530 case AML_QWORD_OP: 0531 0532 break; 0533 0534 default: 0535 0536 ASL_CV_CAPTURE_COMMENTS (WalkState); 0537 break; 0538 } 0539 0540 /* Are there any arguments that must be processed? */ 0541 0542 if (WalkState->ArgTypes) 0543 { 0544 /* Get arguments */ 0545 0546 Status = AcpiPsGetArguments (WalkState, AmlOpStart, Op); 0547 if (ACPI_FAILURE (Status)) 0548 { 0549 Status = AcpiPsCompleteOp (WalkState, &Op, Status); 0550 if (ACPI_FAILURE (Status)) 0551 { 0552 return_ACPI_STATUS (Status); 0553 } 0554 if ((WalkState->ControlState) && 0555 ((WalkState->ControlState->Control.Opcode == AML_IF_OP) || 0556 (WalkState->ControlState->Control.Opcode == AML_WHILE_OP))) 0557 { 0558 /* 0559 * If the if/while op fails to parse, we will skip parsing 0560 * the body of the op. 0561 */ 0562 ParserState->Aml = 0563 WalkState->ControlState->Control.AmlPredicateStart + 1; 0564 ParserState->Aml = 0565 AcpiPsGetNextPackageEnd (ParserState); 0566 WalkState->Aml = ParserState->Aml; 0567 0568 ACPI_ERROR ((AE_INFO, "Skipping While/If block")); 0569 if (*WalkState->Aml == AML_ELSE_OP) 0570 { 0571 ACPI_ERROR ((AE_INFO, "Skipping Else block")); 0572 WalkState->ParserState.Aml = WalkState->Aml + 1; 0573 WalkState->ParserState.Aml = 0574 AcpiPsGetNextPackageEnd (ParserState); 0575 WalkState->Aml = ParserState->Aml; 0576 } 0577 ACPI_FREE(AcpiUtPopGenericState (&WalkState->ControlState)); 0578 } 0579 Op = NULL; 0580 continue; 0581 } 0582 } 0583 0584 /* Check for arguments that need to be processed */ 0585 0586 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 0587 "Parseloop: argument count: %8.8X\n", WalkState->ArgCount)); 0588 0589 if (WalkState->ArgCount) 0590 { 0591 /* 0592 * There are arguments (complex ones), push Op and 0593 * prepare for argument 0594 */ 0595 Status = AcpiPsPushScope (ParserState, Op, 0596 WalkState->ArgTypes, WalkState->ArgCount); 0597 if (ACPI_FAILURE (Status)) 0598 { 0599 Status = AcpiPsCompleteOp (WalkState, &Op, Status); 0600 if (ACPI_FAILURE (Status)) 0601 { 0602 return_ACPI_STATUS (Status); 0603 } 0604 0605 continue; 0606 } 0607 0608 Op = NULL; 0609 continue; 0610 } 0611 0612 /* 0613 * All arguments have been processed -- Op is complete, 0614 * prepare for next 0615 */ 0616 WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 0617 if (WalkState->OpInfo->Flags & AML_NAMED) 0618 { 0619 if (Op->Common.AmlOpcode == AML_REGION_OP || 0620 Op->Common.AmlOpcode == AML_DATA_REGION_OP) 0621 { 0622 /* 0623 * Skip parsing of control method or opregion body, 0624 * because we don't have enough info in the first pass 0625 * to parse them correctly. 0626 * 0627 * Completed parsing an OpRegion declaration, we now 0628 * know the length. 0629 */ 0630 Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); 0631 } 0632 } 0633 0634 if (WalkState->OpInfo->Flags & AML_CREATE) 0635 { 0636 /* 0637 * Backup to beginning of CreateXXXfield declaration (1 for 0638 * Opcode) 0639 * 0640 * BodyLength is unknown until we parse the body 0641 */ 0642 Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); 0643 } 0644 0645 if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP) 0646 { 0647 /* 0648 * Backup to beginning of BankField declaration 0649 * 0650 * BodyLength is unknown until we parse the body 0651 */ 0652 Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); 0653 } 0654 0655 /* This op complete, notify the dispatcher */ 0656 0657 if (WalkState->AscendingCallback != NULL) 0658 { 0659 WalkState->Op = Op; 0660 WalkState->Opcode = Op->Common.AmlOpcode; 0661 0662 Status = WalkState->AscendingCallback (WalkState); 0663 Status = AcpiPsNextParseState (WalkState, Op, Status); 0664 if (Status == AE_CTRL_PENDING) 0665 { 0666 Status = AE_OK; 0667 } 0668 else if ((WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL) && 0669 (ACPI_AML_EXCEPTION(Status) || Status == AE_ALREADY_EXISTS || 0670 Status == AE_NOT_FOUND)) 0671 { 0672 /* 0673 * ACPI_PARSE_MODULE_LEVEL flag means that we are currently 0674 * loading a table by executing it as a control method. 0675 * However, if we encounter an error while loading the table, 0676 * we need to keep trying to load the table rather than 0677 * aborting the table load (setting the status to AE_OK 0678 * continues the table load). If we get a failure at this 0679 * point, it means that the dispatcher got an error while 0680 * trying to execute the Op. 0681 */ 0682 Status = AE_OK; 0683 } 0684 } 0685 0686 Status = AcpiPsCompleteOp (WalkState, &Op, Status); 0687 if (ACPI_FAILURE (Status)) 0688 { 0689 return_ACPI_STATUS (Status); 0690 } 0691 0692 } /* while ParserState->Aml */ 0693 0694 Status = AcpiPsCompleteFinalOp (WalkState, Op, Status); 0695 return_ACPI_STATUS (Status); 0696 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |