![]() |
|
|||
File indexing completed on 2025-05-11 08:24:02
0001 /****************************************************************************** 0002 * 0003 * Module Name: dswload - Dispatcher first pass namespace load callbacks 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 #include "acpi.h" 0153 #include "accommon.h" 0154 #include "acparser.h" 0155 #include "amlcode.h" 0156 #include "acdispat.h" 0157 #include "acinterp.h" 0158 #include "acnamesp.h" 0159 #ifdef ACPI_ASL_COMPILER 0160 #include "acdisasm.h" 0161 #endif 0162 0163 #define _COMPONENT ACPI_DISPATCHER 0164 ACPI_MODULE_NAME ("dswload") 0165 0166 0167 /******************************************************************************* 0168 * 0169 * FUNCTION: AcpiDsInitCallbacks 0170 * 0171 * PARAMETERS: WalkState - Current state of the parse tree walk 0172 * PassNumber - 1, 2, or 3 0173 * 0174 * RETURN: Status 0175 * 0176 * DESCRIPTION: Init walk state callbacks 0177 * 0178 ******************************************************************************/ 0179 0180 ACPI_STATUS 0181 AcpiDsInitCallbacks ( 0182 ACPI_WALK_STATE *WalkState, 0183 UINT32 PassNumber) 0184 { 0185 0186 switch (PassNumber) 0187 { 0188 case 0: 0189 0190 /* Parse only - caller will setup callbacks */ 0191 0192 WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | 0193 ACPI_PARSE_DELETE_TREE | 0194 ACPI_PARSE_DISASSEMBLE; 0195 WalkState->DescendingCallback = NULL; 0196 WalkState->AscendingCallback = NULL; 0197 break; 0198 0199 case 1: 0200 0201 /* Load pass 1 */ 0202 0203 WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | 0204 ACPI_PARSE_DELETE_TREE; 0205 WalkState->DescendingCallback = AcpiDsLoad1BeginOp; 0206 WalkState->AscendingCallback = AcpiDsLoad1EndOp; 0207 break; 0208 0209 case 2: 0210 0211 /* Load pass 2 */ 0212 0213 WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | 0214 ACPI_PARSE_DELETE_TREE; 0215 WalkState->DescendingCallback = AcpiDsLoad2BeginOp; 0216 WalkState->AscendingCallback = AcpiDsLoad2EndOp; 0217 break; 0218 0219 case 3: 0220 0221 /* Execution pass */ 0222 0223 WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | 0224 ACPI_PARSE_DELETE_TREE; 0225 WalkState->DescendingCallback = AcpiDsExecBeginOp; 0226 WalkState->AscendingCallback = AcpiDsExecEndOp; 0227 break; 0228 0229 default: 0230 0231 return (AE_BAD_PARAMETER); 0232 } 0233 0234 return (AE_OK); 0235 } 0236 0237 0238 /******************************************************************************* 0239 * 0240 * FUNCTION: AcpiDsLoad1BeginOp 0241 * 0242 * PARAMETERS: WalkState - Current state of the parse tree walk 0243 * OutOp - Where to return op if a new one is created 0244 * 0245 * RETURN: Status 0246 * 0247 * DESCRIPTION: Descending callback used during the loading of ACPI tables. 0248 * 0249 ******************************************************************************/ 0250 0251 ACPI_STATUS 0252 AcpiDsLoad1BeginOp ( 0253 ACPI_WALK_STATE *WalkState, 0254 ACPI_PARSE_OBJECT **OutOp) 0255 { 0256 ACPI_PARSE_OBJECT *Op; 0257 ACPI_NAMESPACE_NODE *Node; 0258 ACPI_STATUS Status; 0259 ACPI_OBJECT_TYPE ObjectType; 0260 char *Path; 0261 UINT32 Flags; 0262 0263 0264 ACPI_FUNCTION_TRACE_PTR (DsLoad1BeginOp, WalkState->Op); 0265 0266 0267 Op = WalkState->Op; 0268 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 0269 0270 /* We are only interested in opcodes that have an associated name */ 0271 0272 if (Op) 0273 { 0274 if (!(WalkState->OpInfo->Flags & AML_NAMED)) 0275 { 0276 *OutOp = Op; 0277 return_ACPI_STATUS (AE_OK); 0278 } 0279 0280 /* Check if this object has already been installed in the namespace */ 0281 0282 if (Op->Common.Node) 0283 { 0284 *OutOp = Op; 0285 return_ACPI_STATUS (AE_OK); 0286 } 0287 } 0288 0289 Path = AcpiPsGetNextNamestring (&WalkState->ParserState); 0290 0291 /* Map the raw opcode into an internal object type */ 0292 0293 ObjectType = WalkState->OpInfo->ObjectType; 0294 0295 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 0296 "State=%p Op=%p [%s]\n", WalkState, Op, 0297 AcpiUtGetTypeName (ObjectType))); 0298 0299 switch (WalkState->Opcode) 0300 { 0301 case AML_SCOPE_OP: 0302 /* 0303 * The target name of the Scope() operator must exist at this point so 0304 * that we can actually open the scope to enter new names underneath it. 0305 * Allow search-to-root for single namesegs. 0306 */ 0307 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 0308 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); 0309 #ifdef ACPI_ASL_COMPILER 0310 if (Status == AE_NOT_FOUND) 0311 { 0312 /* 0313 * Table disassembly: 0314 * Target of Scope() not found. Generate an External for it, and 0315 * insert the name into the namespace. 0316 */ 0317 AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0, 0); 0318 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 0319 ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, 0320 WalkState, &Node); 0321 } 0322 #endif 0323 if (ACPI_FAILURE (Status)) 0324 { 0325 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Path, Status); 0326 return_ACPI_STATUS (Status); 0327 } 0328 0329 /* 0330 * Check to make sure that the target is 0331 * one of the opcodes that actually opens a scope 0332 */ 0333 switch (Node->Type) 0334 { 0335 case ACPI_TYPE_ANY: 0336 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ 0337 case ACPI_TYPE_DEVICE: 0338 case ACPI_TYPE_POWER: 0339 case ACPI_TYPE_PROCESSOR: 0340 case ACPI_TYPE_THERMAL: 0341 0342 /* These are acceptable types */ 0343 break; 0344 0345 case ACPI_TYPE_INTEGER: 0346 case ACPI_TYPE_STRING: 0347 case ACPI_TYPE_BUFFER: 0348 /* 0349 * These types we will allow, but we will change the type. 0350 * This enables some existing code of the form: 0351 * 0352 * Name (DEB, 0) 0353 * Scope (DEB) { ... } 0354 * 0355 * Note: silently change the type here. On the second pass, 0356 * we will report a warning 0357 */ 0358 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 0359 "Type override - [%4.4s] had invalid type (%s) " 0360 "for Scope operator, changed to type ANY\n", 0361 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type))); 0362 0363 Node->Type = ACPI_TYPE_ANY; 0364 WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; 0365 break; 0366 0367 case ACPI_TYPE_METHOD: 0368 /* 0369 * Allow scope change to root during execution of module-level 0370 * code. Root is typed METHOD during this time. 0371 */ 0372 if ((Node == AcpiGbl_RootNode) && 0373 (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) 0374 { 0375 break; 0376 } 0377 0378 ACPI_FALLTHROUGH; 0379 0380 default: 0381 0382 /* All other types are an error */ 0383 0384 ACPI_ERROR ((AE_INFO, 0385 "Invalid type (%s) for target of " 0386 "Scope operator [%4.4s] (Cannot override)", 0387 AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node))); 0388 0389 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 0390 } 0391 break; 0392 0393 default: 0394 /* 0395 * For all other named opcodes, we will enter the name into 0396 * the namespace. 0397 * 0398 * Setup the search flags. 0399 * Since we are entering a name into the namespace, we do not want to 0400 * enable the search-to-root upsearch. 0401 * 0402 * There are only two conditions where it is acceptable that the name 0403 * already exists: 0404 * 1) the Scope() operator can reopen a scoping object that was 0405 * previously defined (Scope, Method, Device, etc.) 0406 * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer, 0407 * BufferField, or Package), the name of the object is already 0408 * in the namespace. 0409 */ 0410 if (WalkState->DeferredNode) 0411 { 0412 /* This name is already in the namespace, get the node */ 0413 0414 Node = WalkState->DeferredNode; 0415 Status = AE_OK; 0416 break; 0417 } 0418 0419 /* 0420 * If we are executing a method, do not create any namespace objects 0421 * during the load phase, only during execution. 0422 */ 0423 if (WalkState->MethodNode) 0424 { 0425 Node = NULL; 0426 Status = AE_OK; 0427 break; 0428 } 0429 0430 Flags = ACPI_NS_NO_UPSEARCH; 0431 if ((WalkState->Opcode != AML_SCOPE_OP) && 0432 (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP))) 0433 { 0434 if (WalkState->NamespaceOverride) 0435 { 0436 Flags |= ACPI_NS_OVERRIDE_IF_FOUND; 0437 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Override allowed\n", 0438 AcpiUtGetTypeName (ObjectType))); 0439 } 0440 else 0441 { 0442 Flags |= ACPI_NS_ERROR_IF_FOUND; 0443 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", 0444 AcpiUtGetTypeName (ObjectType))); 0445 } 0446 } 0447 else 0448 { 0449 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 0450 "[%s] Both Find or Create allowed\n", 0451 AcpiUtGetTypeName (ObjectType))); 0452 } 0453 0454 /* 0455 * Enter the named type into the internal namespace. We enter the name 0456 * as we go downward in the parse tree. Any necessary subobjects that 0457 * involve arguments to the opcode must be created as we go back up the 0458 * parse tree later. 0459 */ 0460 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 0461 ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); 0462 if (ACPI_FAILURE (Status)) 0463 { 0464 if (Status == AE_ALREADY_EXISTS) 0465 { 0466 /* The name already exists in this scope */ 0467 0468 if (Node->Flags & ANOBJ_IS_EXTERNAL) 0469 { 0470 /* 0471 * Allow one create on an object or segment that was 0472 * previously declared External 0473 */ 0474 Node->Flags &= ~ANOBJ_IS_EXTERNAL; 0475 Node->Type = (UINT8) ObjectType; 0476 0477 /* Just retyped a node, probably will need to open a scope */ 0478 0479 if (AcpiNsOpensScope (ObjectType)) 0480 { 0481 Status = AcpiDsScopeStackPush ( 0482 Node, ObjectType, WalkState); 0483 if (ACPI_FAILURE (Status)) 0484 { 0485 return_ACPI_STATUS (Status); 0486 } 0487 } 0488 0489 Status = AE_OK; 0490 } 0491 } 0492 0493 if (ACPI_FAILURE (Status)) 0494 { 0495 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Path, Status); 0496 return_ACPI_STATUS (Status); 0497 } 0498 } 0499 break; 0500 } 0501 0502 /* Common exit */ 0503 0504 if (!Op) 0505 { 0506 /* Create a new op */ 0507 0508 Op = AcpiPsAllocOp (WalkState->Opcode, WalkState->Aml); 0509 if (!Op) 0510 { 0511 return_ACPI_STATUS (AE_NO_MEMORY); 0512 } 0513 } 0514 0515 /* Initialize the op */ 0516 0517 #ifdef ACPI_CONSTANT_EVAL_ONLY 0518 Op->Named.Path = Path; 0519 #endif 0520 0521 if (Node) 0522 { 0523 /* 0524 * Put the Node in the "op" object that the parser uses, so we 0525 * can get it again quickly when this scope is closed 0526 */ 0527 Op->Common.Node = Node; 0528 Op->Named.Name = Node->Name.Integer; 0529 } 0530 0531 AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op); 0532 *OutOp = Op; 0533 return_ACPI_STATUS (Status); 0534 } 0535 0536 0537 /******************************************************************************* 0538 * 0539 * FUNCTION: AcpiDsLoad1EndOp 0540 * 0541 * PARAMETERS: WalkState - Current state of the parse tree walk 0542 * 0543 * RETURN: Status 0544 * 0545 * DESCRIPTION: Ascending callback used during the loading of the namespace, 0546 * both control methods and everything else. 0547 * 0548 ******************************************************************************/ 0549 0550 ACPI_STATUS 0551 AcpiDsLoad1EndOp ( 0552 ACPI_WALK_STATE *WalkState) 0553 { 0554 ACPI_PARSE_OBJECT *Op; 0555 ACPI_OBJECT_TYPE ObjectType; 0556 ACPI_STATUS Status = AE_OK; 0557 #ifdef ACPI_ASL_COMPILER 0558 UINT8 ParamCount; 0559 #endif 0560 0561 0562 ACPI_FUNCTION_TRACE (DsLoad1EndOp); 0563 0564 0565 Op = WalkState->Op; 0566 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 0567 0568 /* 0569 * Disassembler: handle create field operators here. 0570 * 0571 * CreateBufferField is a deferred op that is typically processed in load 0572 * pass 2. However, disassembly of control method contents walk the parse 0573 * tree with ACPI_PARSE_LOAD_PASS1 and AML_CREATE operators are processed 0574 * in a later walk. This is a problem when there is a control method that 0575 * has the same name as the AML_CREATE object. In this case, any use of the 0576 * name segment will be detected as a method call rather than a reference 0577 * to a buffer field. 0578 * 0579 * This earlier creation during disassembly solves this issue by inserting 0580 * the named object in the ACPI namespace so that references to this name 0581 * would be a name string rather than a method call. 0582 */ 0583 if ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) && 0584 (WalkState->OpInfo->Flags & AML_CREATE)) 0585 { 0586 Status = AcpiDsCreateBufferField (Op, WalkState); 0587 return_ACPI_STATUS (Status); 0588 } 0589 0590 /* We are only interested in opcodes that have an associated name */ 0591 0592 if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD))) 0593 { 0594 return_ACPI_STATUS (AE_OK); 0595 } 0596 0597 /* Get the object type to determine if we should pop the scope */ 0598 0599 ObjectType = WalkState->OpInfo->ObjectType; 0600 0601 if (WalkState->OpInfo->Flags & AML_FIELD) 0602 { 0603 /* 0604 * If we are executing a method, do not create any namespace objects 0605 * during the load phase, only during execution. 0606 */ 0607 if (!WalkState->MethodNode) 0608 { 0609 if (WalkState->Opcode == AML_FIELD_OP || 0610 WalkState->Opcode == AML_BANK_FIELD_OP || 0611 WalkState->Opcode == AML_INDEX_FIELD_OP) 0612 { 0613 Status = AcpiDsInitFieldObjects (Op, WalkState); 0614 } 0615 } 0616 return_ACPI_STATUS (Status); 0617 } 0618 0619 /* 0620 * If we are executing a method, do not create any namespace objects 0621 * during the load phase, only during execution. 0622 */ 0623 if (!WalkState->MethodNode) 0624 { 0625 if (Op->Common.AmlOpcode == AML_REGION_OP) 0626 { 0627 Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, 0628 (ACPI_ADR_SPACE_TYPE) 0629 ((Op->Common.Value.Arg)->Common.Value.Integer), 0630 WalkState); 0631 if (ACPI_FAILURE (Status)) 0632 { 0633 return_ACPI_STATUS (Status); 0634 } 0635 } 0636 else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP) 0637 { 0638 Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, 0639 ACPI_ADR_SPACE_DATA_TABLE, WalkState); 0640 if (ACPI_FAILURE (Status)) 0641 { 0642 return_ACPI_STATUS (Status); 0643 } 0644 } 0645 } 0646 0647 if (Op->Common.AmlOpcode == AML_NAME_OP) 0648 { 0649 /* For Name opcode, get the object type from the argument */ 0650 0651 if (Op->Common.Value.Arg) 0652 { 0653 ObjectType = (AcpiPsGetOpcodeInfo ( 0654 (Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType; 0655 0656 /* Set node type if we have a namespace node */ 0657 0658 if (Op->Common.Node) 0659 { 0660 Op->Common.Node->Type = (UINT8) ObjectType; 0661 } 0662 } 0663 } 0664 0665 #ifdef ACPI_ASL_COMPILER 0666 /* 0667 * For external opcode, get the object type from the argument and 0668 * get the parameter count from the argument's next. 0669 */ 0670 if (AcpiGbl_DisasmFlag && 0671 Op->Common.Node && 0672 Op->Common.AmlOpcode == AML_EXTERNAL_OP) 0673 { 0674 /* 0675 * Note, if this external is not a method 0676 * Op->Common.Value.Arg->Common.Next->Common.Value.Integer == 0 0677 * Therefore, ParamCount will be 0. 0678 */ 0679 ParamCount = (UINT8) Op->Common.Value.Arg->Common.Next->Common.Value.Integer; 0680 ObjectType = (UINT8) Op->Common.Value.Arg->Common.Value.Integer; 0681 Op->Common.Node->Flags |= ANOBJ_IS_EXTERNAL; 0682 Op->Common.Node->Type = (UINT8) ObjectType; 0683 0684 AcpiDmCreateSubobjectForExternal ((UINT8)ObjectType, 0685 &Op->Common.Node, ParamCount); 0686 0687 /* 0688 * Add the external to the external list because we may be 0689 * emitting code based off of the items within the external list. 0690 */ 0691 AcpiDmAddOpToExternalList (Op, Op->Named.Path, (UINT8)ObjectType, ParamCount, 0692 ACPI_EXT_ORIGIN_FROM_OPCODE | ACPI_EXT_RESOLVED_REFERENCE); 0693 } 0694 #endif 0695 0696 /* 0697 * If we are executing a method, do not create any namespace objects 0698 * during the load phase, only during execution. 0699 */ 0700 if (!WalkState->MethodNode) 0701 { 0702 if (Op->Common.AmlOpcode == AML_METHOD_OP) 0703 { 0704 /* 0705 * MethodOp PkgLength NameString MethodFlags TermList 0706 * 0707 * Note: We must create the method node/object pair as soon as we 0708 * see the method declaration. This allows later pass1 parsing 0709 * of invocations of the method (need to know the number of 0710 * arguments.) 0711 */ 0712 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 0713 "LOADING-Method: State=%p Op=%p NamedObj=%p\n", 0714 WalkState, Op, Op->Named.Node)); 0715 0716 if (!AcpiNsGetAttachedObject (Op->Named.Node)) 0717 { 0718 WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); 0719 WalkState->NumOperands = 1; 0720 0721 Status = AcpiDsCreateOperands ( 0722 WalkState, Op->Common.Value.Arg); 0723 if (ACPI_SUCCESS (Status)) 0724 { 0725 Status = AcpiExCreateMethod (Op->Named.Data, 0726 Op->Named.Length, WalkState); 0727 } 0728 0729 WalkState->Operands[0] = NULL; 0730 WalkState->NumOperands = 0; 0731 0732 if (ACPI_FAILURE (Status)) 0733 { 0734 return_ACPI_STATUS (Status); 0735 } 0736 } 0737 } 0738 } 0739 0740 /* Pop the scope stack (only if loading a table) */ 0741 0742 if (!WalkState->MethodNode && 0743 Op->Common.AmlOpcode != AML_EXTERNAL_OP && 0744 AcpiNsOpensScope (ObjectType)) 0745 { 0746 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n", 0747 AcpiUtGetTypeName (ObjectType), Op)); 0748 0749 Status = AcpiDsScopeStackPop (WalkState); 0750 } 0751 0752 return_ACPI_STATUS (Status); 0753 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |