Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygendswload2.c
Go to the documentation of this file.
00001 /****************************************************************************** 00002 * 00003 * Module Name: dswload2 - Dispatcher second pass namespace load callbacks 00004 * 00005 *****************************************************************************/ 00006 00007 /****************************************************************************** 00008 * 00009 * 1. Copyright Notice 00010 * 00011 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. 00012 * All rights reserved. 00013 * 00014 * 2. License 00015 * 00016 * 2.1. This is your license from Intel Corp. under its intellectual property 00017 * rights. You may have additional license terms from the party that provided 00018 * you this software, covering your right to use that party's intellectual 00019 * property rights. 00020 * 00021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 00022 * copy of the source code appearing in this file ("Covered Code") an 00023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 00024 * base code distributed originally by Intel ("Original Intel Code") to copy, 00025 * make derivatives, distribute, use and display any portion of the Covered 00026 * Code in any form, with the right to sublicense such rights; and 00027 * 00028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 00029 * license (with the right to sublicense), under only those claims of Intel 00030 * patents that are infringed by the Original Intel Code, to make, use, sell, 00031 * offer to sell, and import the Covered Code and derivative works thereof 00032 * solely to the minimum extent necessary to exercise the above copyright 00033 * license, and in no event shall the patent license extend to any additions 00034 * to or modifications of the Original Intel Code. No other license or right 00035 * is granted directly or by implication, estoppel or otherwise; 00036 * 00037 * The above copyright and patent license is granted only if the following 00038 * conditions are met: 00039 * 00040 * 3. Conditions 00041 * 00042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 00043 * Redistribution of source code of any substantial portion of the Covered 00044 * Code or modification with rights to further distribute source must include 00045 * the above Copyright Notice, the above License, this list of Conditions, 00046 * and the following Disclaimer and Export Compliance provision. In addition, 00047 * Licensee must cause all Covered Code to which Licensee contributes to 00048 * contain a file documenting the changes Licensee made to create that Covered 00049 * Code and the date of any change. Licensee must include in that file the 00050 * documentation of any changes made by any predecessor Licensee. Licensee 00051 * must include a prominent statement that the modification is derived, 00052 * directly or indirectly, from Original Intel Code. 00053 * 00054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 00055 * Redistribution of source code of any substantial portion of the Covered 00056 * Code or modification without rights to further distribute source must 00057 * include the following Disclaimer and Export Compliance provision in the 00058 * documentation and/or other materials provided with distribution. In 00059 * addition, Licensee may not authorize further sublicense of source of any 00060 * portion of the Covered Code, and must include terms to the effect that the 00061 * license from Licensee to its licensee is limited to the intellectual 00062 * property embodied in the software Licensee provides to its licensee, and 00063 * not to intellectual property embodied in modifications its licensee may 00064 * make. 00065 * 00066 * 3.3. Redistribution of Executable. Redistribution in executable form of any 00067 * substantial portion of the Covered Code or modification must reproduce the 00068 * above Copyright Notice, and the following Disclaimer and Export Compliance 00069 * provision in the documentation and/or other materials provided with the 00070 * distribution. 00071 * 00072 * 3.4. Intel retains all right, title, and interest in and to the Original 00073 * Intel Code. 00074 * 00075 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 00076 * Intel shall be used in advertising or otherwise to promote the sale, use or 00077 * other dealings in products derived from or relating to the Covered Code 00078 * without prior written authorization from Intel. 00079 * 00080 * 4. Disclaimer and Export Compliance 00081 * 00082 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 00083 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 00084 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 00085 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 00086 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 00087 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 00088 * PARTICULAR PURPOSE. 00089 * 00090 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 00091 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 00092 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 00093 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 00094 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 00095 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 00096 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 00097 * LIMITED REMEDY. 00098 * 00099 * 4.3. Licensee shall not export, either directly or indirectly, any of this 00100 * software or system incorporating such software without first obtaining any 00101 * required license or other approval from the U. S. Department of Commerce or 00102 * any other agency or department of the United States Government. In the 00103 * event Licensee exports any such software from the United States or 00104 * re-exports any such software from a foreign destination, Licensee shall 00105 * ensure that the distribution and export/re-export of the software is in 00106 * compliance with all laws, regulations, orders, or other restrictions of the 00107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 00108 * any of its subsidiaries will export/re-export any technical data, process, 00109 * software, or service, directly or indirectly, to any country for which the 00110 * United States government or any agency thereof requires an export license, 00111 * other governmental approval, or letter of assurance, without first obtaining 00112 * such license, approval or letter. 00113 * 00114 *****************************************************************************/ 00115 00116 #define __DSWLOAD2_C__ 00117 00118 #include "acpi.h" 00119 #include "accommon.h" 00120 #include "acparser.h" 00121 #include "amlcode.h" 00122 #include "acdispat.h" 00123 #include "acinterp.h" 00124 #include "acnamesp.h" 00125 #include "acevents.h" 00126 00127 #define _COMPONENT ACPI_DISPATCHER 00128 ACPI_MODULE_NAME ("dswload2") 00129 00130 00131 /******************************************************************************* 00132 * 00133 * FUNCTION: AcpiDsLoad2BeginOp 00134 * 00135 * PARAMETERS: WalkState - Current state of the parse tree walk 00136 * OutOp - Wher to return op if a new one is created 00137 * 00138 * RETURN: Status 00139 * 00140 * DESCRIPTION: Descending callback used during the loading of ACPI tables. 00141 * 00142 ******************************************************************************/ 00143 00144 ACPI_STATUS 00145 AcpiDsLoad2BeginOp ( 00146 ACPI_WALK_STATE *WalkState, 00147 ACPI_PARSE_OBJECT **OutOp) 00148 { 00149 ACPI_PARSE_OBJECT *Op; 00150 ACPI_NAMESPACE_NODE *Node; 00151 ACPI_STATUS Status; 00152 ACPI_OBJECT_TYPE ObjectType; 00153 char *BufferPtr; 00154 UINT32 Flags; 00155 00156 00157 ACPI_FUNCTION_TRACE (DsLoad2BeginOp); 00158 00159 00160 Op = WalkState->Op; 00161 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 00162 00163 if (Op) 00164 { 00165 if ((WalkState->ControlState) && 00166 (WalkState->ControlState->Common.State == 00167 ACPI_CONTROL_CONDITIONAL_EXECUTING)) 00168 { 00169 /* We are executing a while loop outside of a method */ 00170 00171 Status = AcpiDsExecBeginOp (WalkState, OutOp); 00172 return_ACPI_STATUS (Status); 00173 } 00174 00175 /* We only care about Namespace opcodes here */ 00176 00177 if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) && 00178 (WalkState->Opcode != AML_INT_NAMEPATH_OP)) || 00179 (!(WalkState->OpInfo->Flags & AML_NAMED))) 00180 { 00181 return_ACPI_STATUS (AE_OK); 00182 } 00183 00184 /* Get the name we are going to enter or lookup in the namespace */ 00185 00186 if (WalkState->Opcode == AML_INT_NAMEPATH_OP) 00187 { 00188 /* For Namepath op, get the path string */ 00189 00190 BufferPtr = Op->Common.Value.String; 00191 if (!BufferPtr) 00192 { 00193 /* No name, just exit */ 00194 00195 return_ACPI_STATUS (AE_OK); 00196 } 00197 } 00198 else 00199 { 00200 /* Get name from the op */ 00201 00202 BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name); 00203 } 00204 } 00205 else 00206 { 00207 /* Get the namestring from the raw AML */ 00208 00209 BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState); 00210 } 00211 00212 /* Map the opcode into an internal object type */ 00213 00214 ObjectType = WalkState->OpInfo->ObjectType; 00215 00216 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 00217 "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType)); 00218 00219 switch (WalkState->Opcode) 00220 { 00221 case AML_FIELD_OP: 00222 case AML_BANK_FIELD_OP: 00223 case AML_INDEX_FIELD_OP: 00224 00225 Node = NULL; 00226 Status = AE_OK; 00227 break; 00228 00229 case AML_INT_NAMEPATH_OP: 00230 /* 00231 * The NamePath is an object reference to an existing object. 00232 * Don't enter the name into the namespace, but look it up 00233 * for use later. 00234 */ 00235 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, 00236 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 00237 WalkState, &(Node)); 00238 break; 00239 00240 case AML_SCOPE_OP: 00241 00242 /* Special case for Scope(\) -> refers to the Root node */ 00243 00244 if (Op && (Op->Named.Node == AcpiGbl_RootNode)) 00245 { 00246 Node = Op->Named.Node; 00247 00248 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 00249 if (ACPI_FAILURE (Status)) 00250 { 00251 return_ACPI_STATUS (Status); 00252 } 00253 } 00254 else 00255 { 00256 /* 00257 * The Path is an object reference to an existing object. 00258 * Don't enter the name into the namespace, but look it up 00259 * for use later. 00260 */ 00261 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, 00262 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 00263 WalkState, &(Node)); 00264 if (ACPI_FAILURE (Status)) 00265 { 00266 #ifdef ACPI_ASL_COMPILER 00267 if (Status == AE_NOT_FOUND) 00268 { 00269 Status = AE_OK; 00270 } 00271 else 00272 { 00273 ACPI_ERROR_NAMESPACE (BufferPtr, Status); 00274 } 00275 #else 00276 ACPI_ERROR_NAMESPACE (BufferPtr, Status); 00277 #endif 00278 return_ACPI_STATUS (Status); 00279 } 00280 } 00281 00282 /* 00283 * We must check to make sure that the target is 00284 * one of the opcodes that actually opens a scope 00285 */ 00286 switch (Node->Type) 00287 { 00288 case ACPI_TYPE_ANY: 00289 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ 00290 case ACPI_TYPE_DEVICE: 00291 case ACPI_TYPE_POWER: 00292 case ACPI_TYPE_PROCESSOR: 00293 case ACPI_TYPE_THERMAL: 00294 00295 /* These are acceptable types */ 00296 break; 00297 00298 case ACPI_TYPE_INTEGER: 00299 case ACPI_TYPE_STRING: 00300 case ACPI_TYPE_BUFFER: 00301 00302 /* 00303 * These types we will allow, but we will change the type. 00304 * This enables some existing code of the form: 00305 * 00306 * Name (DEB, 0) 00307 * Scope (DEB) { ... } 00308 */ 00309 ACPI_WARNING ((AE_INFO, 00310 "Type override - [%4.4s] had invalid type (%s) " 00311 "for Scope operator, changed to type ANY\n", 00312 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type))); 00313 00314 Node->Type = ACPI_TYPE_ANY; 00315 WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; 00316 break; 00317 00318 default: 00319 00320 /* All other types are an error */ 00321 00322 ACPI_ERROR ((AE_INFO, 00323 "Invalid type (%s) for target of " 00324 "Scope operator [%4.4s] (Cannot override)", 00325 AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node))); 00326 00327 return (AE_AML_OPERAND_TYPE); 00328 } 00329 break; 00330 00331 default: 00332 00333 /* All other opcodes */ 00334 00335 if (Op && Op->Common.Node) 00336 { 00337 /* This op/node was previously entered into the namespace */ 00338 00339 Node = Op->Common.Node; 00340 00341 if (AcpiNsOpensScope (ObjectType)) 00342 { 00343 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 00344 if (ACPI_FAILURE (Status)) 00345 { 00346 return_ACPI_STATUS (Status); 00347 } 00348 } 00349 00350 return_ACPI_STATUS (AE_OK); 00351 } 00352 00353 /* 00354 * Enter the named type into the internal namespace. We enter the name 00355 * as we go downward in the parse tree. Any necessary subobjects that 00356 * involve arguments to the opcode must be created as we go back up the 00357 * parse tree later. 00358 * 00359 * Note: Name may already exist if we are executing a deferred opcode. 00360 */ 00361 if (WalkState->DeferredNode) 00362 { 00363 /* This name is already in the namespace, get the node */ 00364 00365 Node = WalkState->DeferredNode; 00366 Status = AE_OK; 00367 break; 00368 } 00369 00370 Flags = ACPI_NS_NO_UPSEARCH; 00371 if (WalkState->PassNumber == ACPI_IMODE_EXECUTE) 00372 { 00373 /* Execution mode, node cannot already exist, node is temporary */ 00374 00375 Flags |= ACPI_NS_ERROR_IF_FOUND; 00376 00377 if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) 00378 { 00379 Flags |= ACPI_NS_TEMPORARY; 00380 } 00381 } 00382 00383 /* Add new entry or lookup existing entry */ 00384 00385 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, 00386 ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node); 00387 00388 if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY)) 00389 { 00390 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 00391 "***New Node [%4.4s] %p is temporary\n", 00392 AcpiUtGetNodeName (Node), Node)); 00393 } 00394 break; 00395 } 00396 00397 if (ACPI_FAILURE (Status)) 00398 { 00399 ACPI_ERROR_NAMESPACE (BufferPtr, Status); 00400 return_ACPI_STATUS (Status); 00401 } 00402 00403 if (!Op) 00404 { 00405 /* Create a new op */ 00406 00407 Op = AcpiPsAllocOp (WalkState->Opcode); 00408 if (!Op) 00409 { 00410 return_ACPI_STATUS (AE_NO_MEMORY); 00411 } 00412 00413 /* Initialize the new op */ 00414 00415 if (Node) 00416 { 00417 Op->Named.Name = Node->Name.Integer; 00418 } 00419 *OutOp = Op; 00420 } 00421 00422 /* 00423 * Put the Node in the "op" object that the parser uses, so we 00424 * can get it again quickly when this scope is closed 00425 */ 00426 Op->Common.Node = Node; 00427 return_ACPI_STATUS (Status); 00428 } 00429 00430 00431 /******************************************************************************* 00432 * 00433 * FUNCTION: AcpiDsLoad2EndOp 00434 * 00435 * PARAMETERS: WalkState - Current state of the parse tree walk 00436 * 00437 * RETURN: Status 00438 * 00439 * DESCRIPTION: Ascending callback used during the loading of the namespace, 00440 * both control methods and everything else. 00441 * 00442 ******************************************************************************/ 00443 00444 ACPI_STATUS 00445 AcpiDsLoad2EndOp ( 00446 ACPI_WALK_STATE *WalkState) 00447 { 00448 ACPI_PARSE_OBJECT *Op; 00449 ACPI_STATUS Status = AE_OK; 00450 ACPI_OBJECT_TYPE ObjectType; 00451 ACPI_NAMESPACE_NODE *Node; 00452 ACPI_PARSE_OBJECT *Arg; 00453 ACPI_NAMESPACE_NODE *NewNode; 00454 #ifndef ACPI_NO_METHOD_EXECUTION 00455 UINT32 i; 00456 UINT8 RegionSpace; 00457 #endif 00458 00459 00460 ACPI_FUNCTION_TRACE (DsLoad2EndOp); 00461 00462 Op = WalkState->Op; 00463 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", 00464 WalkState->OpInfo->Name, Op, WalkState)); 00465 00466 /* Check if opcode had an associated namespace object */ 00467 00468 if (!(WalkState->OpInfo->Flags & AML_NSOBJECT)) 00469 { 00470 return_ACPI_STATUS (AE_OK); 00471 } 00472 00473 if (Op->Common.AmlOpcode == AML_SCOPE_OP) 00474 { 00475 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 00476 "Ending scope Op=%p State=%p\n", Op, WalkState)); 00477 } 00478 00479 ObjectType = WalkState->OpInfo->ObjectType; 00480 00481 /* 00482 * Get the Node/name from the earlier lookup 00483 * (It was saved in the *op structure) 00484 */ 00485 Node = Op->Common.Node; 00486 00487 /* 00488 * Put the Node on the object stack (Contains the ACPI Name of 00489 * this object) 00490 */ 00491 WalkState->Operands[0] = (void *) Node; 00492 WalkState->NumOperands = 1; 00493 00494 /* Pop the scope stack */ 00495 00496 if (AcpiNsOpensScope (ObjectType) && 00497 (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)) 00498 { 00499 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", 00500 AcpiUtGetTypeName (ObjectType), Op)); 00501 00502 Status = AcpiDsScopeStackPop (WalkState); 00503 if (ACPI_FAILURE (Status)) 00504 { 00505 goto Cleanup; 00506 } 00507 } 00508 00509 /* 00510 * Named operations are as follows: 00511 * 00512 * AML_ALIAS 00513 * AML_BANKFIELD 00514 * AML_CREATEBITFIELD 00515 * AML_CREATEBYTEFIELD 00516 * AML_CREATEDWORDFIELD 00517 * AML_CREATEFIELD 00518 * AML_CREATEQWORDFIELD 00519 * AML_CREATEWORDFIELD 00520 * AML_DATA_REGION 00521 * AML_DEVICE 00522 * AML_EVENT 00523 * AML_FIELD 00524 * AML_INDEXFIELD 00525 * AML_METHOD 00526 * AML_METHODCALL 00527 * AML_MUTEX 00528 * AML_NAME 00529 * AML_NAMEDFIELD 00530 * AML_OPREGION 00531 * AML_POWERRES 00532 * AML_PROCESSOR 00533 * AML_SCOPE 00534 * AML_THERMALZONE 00535 */ 00536 00537 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 00538 "Create-Load [%s] State=%p Op=%p NamedObj=%p\n", 00539 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node)); 00540 00541 /* Decode the opcode */ 00542 00543 Arg = Op->Common.Value.Arg; 00544 00545 switch (WalkState->OpInfo->Type) 00546 { 00547 #ifndef ACPI_NO_METHOD_EXECUTION 00548 00549 case AML_TYPE_CREATE_FIELD: 00550 /* 00551 * Create the field object, but the field buffer and index must 00552 * be evaluated later during the execution phase 00553 */ 00554 Status = AcpiDsCreateBufferField (Op, WalkState); 00555 break; 00556 00557 00558 case AML_TYPE_NAMED_FIELD: 00559 /* 00560 * If we are executing a method, initialize the field 00561 */ 00562 if (WalkState->MethodNode) 00563 { 00564 Status = AcpiDsInitFieldObjects (Op, WalkState); 00565 } 00566 00567 switch (Op->Common.AmlOpcode) 00568 { 00569 case AML_INDEX_FIELD_OP: 00570 00571 Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node, 00572 WalkState); 00573 break; 00574 00575 case AML_BANK_FIELD_OP: 00576 00577 Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState); 00578 break; 00579 00580 case AML_FIELD_OP: 00581 00582 Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState); 00583 break; 00584 00585 default: 00586 /* All NAMED_FIELD opcodes must be handled above */ 00587 break; 00588 } 00589 break; 00590 00591 00592 case AML_TYPE_NAMED_SIMPLE: 00593 00594 Status = AcpiDsCreateOperands (WalkState, Arg); 00595 if (ACPI_FAILURE (Status)) 00596 { 00597 goto Cleanup; 00598 } 00599 00600 switch (Op->Common.AmlOpcode) 00601 { 00602 case AML_PROCESSOR_OP: 00603 00604 Status = AcpiExCreateProcessor (WalkState); 00605 break; 00606 00607 case AML_POWER_RES_OP: 00608 00609 Status = AcpiExCreatePowerResource (WalkState); 00610 break; 00611 00612 case AML_MUTEX_OP: 00613 00614 Status = AcpiExCreateMutex (WalkState); 00615 break; 00616 00617 case AML_EVENT_OP: 00618 00619 Status = AcpiExCreateEvent (WalkState); 00620 break; 00621 00622 00623 case AML_ALIAS_OP: 00624 00625 Status = AcpiExCreateAlias (WalkState); 00626 break; 00627 00628 default: 00629 /* Unknown opcode */ 00630 00631 Status = AE_OK; 00632 goto Cleanup; 00633 } 00634 00635 /* Delete operands */ 00636 00637 for (i = 1; i < WalkState->NumOperands; i++) 00638 { 00639 AcpiUtRemoveReference (WalkState->Operands[i]); 00640 WalkState->Operands[i] = NULL; 00641 } 00642 00643 break; 00644 #endif /* ACPI_NO_METHOD_EXECUTION */ 00645 00646 case AML_TYPE_NAMED_COMPLEX: 00647 00648 switch (Op->Common.AmlOpcode) 00649 { 00650 #ifndef ACPI_NO_METHOD_EXECUTION 00651 case AML_REGION_OP: 00652 case AML_DATA_REGION_OP: 00653 00654 if (Op->Common.AmlOpcode == AML_REGION_OP) 00655 { 00656 RegionSpace = (ACPI_ADR_SPACE_TYPE) 00657 ((Op->Common.Value.Arg)->Common.Value.Integer); 00658 } 00659 else 00660 { 00661 RegionSpace = ACPI_ADR_SPACE_DATA_TABLE; 00662 } 00663 00664 /* 00665 * The OpRegion is not fully parsed at this time. The only valid 00666 * argument is the SpaceId. (We must save the address of the 00667 * AML of the address and length operands) 00668 * 00669 * If we have a valid region, initialize it. The namespace is 00670 * unlocked at this point. 00671 * 00672 * Need to unlock interpreter if it is locked (if we are running 00673 * a control method), in order to allow _REG methods to be run 00674 * during AcpiEvInitializeRegion. 00675 */ 00676 if (WalkState->MethodNode) 00677 { 00678 /* 00679 * Executing a method: initialize the region and unlock 00680 * the interpreter 00681 */ 00682 Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, 00683 RegionSpace, WalkState); 00684 if (ACPI_FAILURE (Status)) 00685 { 00686 return (Status); 00687 } 00688 00689 AcpiExExitInterpreter (); 00690 } 00691 00692 Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), 00693 FALSE); 00694 if (WalkState->MethodNode) 00695 { 00696 AcpiExEnterInterpreter (); 00697 } 00698 00699 if (ACPI_FAILURE (Status)) 00700 { 00701 /* 00702 * If AE_NOT_EXIST is returned, it is not fatal 00703 * because many regions get created before a handler 00704 * is installed for said region. 00705 */ 00706 if (AE_NOT_EXIST == Status) 00707 { 00708 Status = AE_OK; 00709 } 00710 } 00711 break; 00712 00713 00714 case AML_NAME_OP: 00715 00716 Status = AcpiDsCreateNode (WalkState, Node, Op); 00717 break; 00718 00719 00720 case AML_METHOD_OP: 00721 /* 00722 * MethodOp PkgLength NameString MethodFlags TermList 00723 * 00724 * Note: We must create the method node/object pair as soon as we 00725 * see the method declaration. This allows later pass1 parsing 00726 * of invocations of the method (need to know the number of 00727 * arguments.) 00728 */ 00729 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 00730 "LOADING-Method: State=%p Op=%p NamedObj=%p\n", 00731 WalkState, Op, Op->Named.Node)); 00732 00733 if (!AcpiNsGetAttachedObject (Op->Named.Node)) 00734 { 00735 WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); 00736 WalkState->NumOperands = 1; 00737 00738 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); 00739 if (ACPI_SUCCESS (Status)) 00740 { 00741 Status = AcpiExCreateMethod (Op->Named.Data, 00742 Op->Named.Length, WalkState); 00743 } 00744 WalkState->Operands[0] = NULL; 00745 WalkState->NumOperands = 0; 00746 00747 if (ACPI_FAILURE (Status)) 00748 { 00749 return_ACPI_STATUS (Status); 00750 } 00751 } 00752 break; 00753 00754 #endif /* ACPI_NO_METHOD_EXECUTION */ 00755 00756 default: 00757 /* All NAMED_COMPLEX opcodes must be handled above */ 00758 break; 00759 } 00760 break; 00761 00762 00763 case AML_CLASS_INTERNAL: 00764 00765 /* case AML_INT_NAMEPATH_OP: */ 00766 break; 00767 00768 00769 case AML_CLASS_METHOD_CALL: 00770 00771 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 00772 "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n", 00773 WalkState, Op, Node)); 00774 00775 /* 00776 * Lookup the method name and save the Node 00777 */ 00778 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, 00779 ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2, 00780 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 00781 WalkState, &(NewNode)); 00782 if (ACPI_SUCCESS (Status)) 00783 { 00784 /* 00785 * Make sure that what we found is indeed a method 00786 * We didn't search for a method on purpose, to see if the name 00787 * would resolve 00788 */ 00789 if (NewNode->Type != ACPI_TYPE_METHOD) 00790 { 00791 Status = AE_AML_OPERAND_TYPE; 00792 } 00793 00794 /* We could put the returned object (Node) on the object stack for 00795 * later, but for now, we will put it in the "op" object that the 00796 * parser uses, so we can get it again at the end of this scope 00797 */ 00798 Op->Common.Node = NewNode; 00799 } 00800 else 00801 { 00802 ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); 00803 } 00804 break; 00805 00806 00807 default: 00808 break; 00809 } 00810 00811 Cleanup: 00812 00813 /* Remove the Node pushed at the very beginning */ 00814 00815 WalkState->Operands[0] = NULL; 00816 WalkState->NumOperands = 0; 00817 return_ACPI_STATUS (Status); 00818 } 00819 Generated on Fri May 25 2012 04:25:27 for ReactOS by
1.7.6.1
|