Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygendswstate.c
Go to the documentation of this file.
00001 /****************************************************************************** 00002 * 00003 * Module Name: dswstate - Dispatcher parse tree walk management routines 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 00117 #define __DSWSTATE_C__ 00118 00119 #include "acpi.h" 00120 #include "accommon.h" 00121 #include "acparser.h" 00122 #include "acdispat.h" 00123 #include "acnamesp.h" 00124 00125 #define _COMPONENT ACPI_DISPATCHER 00126 ACPI_MODULE_NAME ("dswstate") 00127 00128 /* Local prototypes */ 00129 00130 static ACPI_STATUS 00131 AcpiDsResultStackPush ( 00132 ACPI_WALK_STATE *WalkState); 00133 00134 static ACPI_STATUS 00135 AcpiDsResultStackPop ( 00136 ACPI_WALK_STATE *WalkState); 00137 00138 00139 /******************************************************************************* 00140 * 00141 * FUNCTION: AcpiDsResultPop 00142 * 00143 * PARAMETERS: Object - Where to return the popped object 00144 * WalkState - Current Walk state 00145 * 00146 * RETURN: Status 00147 * 00148 * DESCRIPTION: Pop an object off the top of this walk's result stack 00149 * 00150 ******************************************************************************/ 00151 00152 ACPI_STATUS 00153 AcpiDsResultPop ( 00154 ACPI_OPERAND_OBJECT **Object, 00155 ACPI_WALK_STATE *WalkState) 00156 { 00157 UINT32 Index; 00158 ACPI_GENERIC_STATE *State; 00159 ACPI_STATUS Status; 00160 00161 00162 ACPI_FUNCTION_NAME (DsResultPop); 00163 00164 00165 State = WalkState->Results; 00166 00167 /* Incorrect state of result stack */ 00168 00169 if (State && !WalkState->ResultCount) 00170 { 00171 ACPI_ERROR ((AE_INFO, "No results on result stack")); 00172 return (AE_AML_INTERNAL); 00173 } 00174 00175 if (!State && WalkState->ResultCount) 00176 { 00177 ACPI_ERROR ((AE_INFO, "No result state for result stack")); 00178 return (AE_AML_INTERNAL); 00179 } 00180 00181 /* Empty result stack */ 00182 00183 if (!State) 00184 { 00185 ACPI_ERROR ((AE_INFO, "Result stack is empty! State=%p", WalkState)); 00186 return (AE_AML_NO_RETURN_VALUE); 00187 } 00188 00189 /* Return object of the top element and clean that top element result stack */ 00190 00191 WalkState->ResultCount--; 00192 Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; 00193 00194 *Object = State->Results.ObjDesc [Index]; 00195 if (!*Object) 00196 { 00197 ACPI_ERROR ((AE_INFO, "No result objects on result stack, State=%p", 00198 WalkState)); 00199 return (AE_AML_NO_RETURN_VALUE); 00200 } 00201 00202 State->Results.ObjDesc [Index] = NULL; 00203 if (Index == 0) 00204 { 00205 Status = AcpiDsResultStackPop (WalkState); 00206 if (ACPI_FAILURE (Status)) 00207 { 00208 return (Status); 00209 } 00210 } 00211 00212 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 00213 "Obj=%p [%s] Index=%X State=%p Num=%X\n", *Object, 00214 AcpiUtGetObjectTypeName (*Object), 00215 Index, WalkState, WalkState->ResultCount)); 00216 00217 return (AE_OK); 00218 } 00219 00220 00221 /******************************************************************************* 00222 * 00223 * FUNCTION: AcpiDsResultPush 00224 * 00225 * PARAMETERS: Object - Where to return the popped object 00226 * WalkState - Current Walk state 00227 * 00228 * RETURN: Status 00229 * 00230 * DESCRIPTION: Push an object onto the current result stack 00231 * 00232 ******************************************************************************/ 00233 00234 ACPI_STATUS 00235 AcpiDsResultPush ( 00236 ACPI_OPERAND_OBJECT *Object, 00237 ACPI_WALK_STATE *WalkState) 00238 { 00239 ACPI_GENERIC_STATE *State; 00240 ACPI_STATUS Status; 00241 UINT32 Index; 00242 00243 00244 ACPI_FUNCTION_NAME (DsResultPush); 00245 00246 00247 if (WalkState->ResultCount > WalkState->ResultSize) 00248 { 00249 ACPI_ERROR ((AE_INFO, "Result stack is full")); 00250 return (AE_AML_INTERNAL); 00251 } 00252 else if (WalkState->ResultCount == WalkState->ResultSize) 00253 { 00254 /* Extend the result stack */ 00255 00256 Status = AcpiDsResultStackPush (WalkState); 00257 if (ACPI_FAILURE (Status)) 00258 { 00259 ACPI_ERROR ((AE_INFO, "Failed to extend the result stack")); 00260 return (Status); 00261 } 00262 } 00263 00264 if (!(WalkState->ResultCount < WalkState->ResultSize)) 00265 { 00266 ACPI_ERROR ((AE_INFO, "No free elements in result stack")); 00267 return (AE_AML_INTERNAL); 00268 } 00269 00270 State = WalkState->Results; 00271 if (!State) 00272 { 00273 ACPI_ERROR ((AE_INFO, "No result stack frame during push")); 00274 return (AE_AML_INTERNAL); 00275 } 00276 00277 if (!Object) 00278 { 00279 ACPI_ERROR ((AE_INFO, 00280 "Null Object! Obj=%p State=%p Num=%u", 00281 Object, WalkState, WalkState->ResultCount)); 00282 return (AE_BAD_PARAMETER); 00283 } 00284 00285 /* Assign the address of object to the top free element of result stack */ 00286 00287 Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; 00288 State->Results.ObjDesc [Index] = Object; 00289 WalkState->ResultCount++; 00290 00291 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", 00292 Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), 00293 WalkState, WalkState->ResultCount, WalkState->CurrentResult)); 00294 00295 return (AE_OK); 00296 } 00297 00298 00299 /******************************************************************************* 00300 * 00301 * FUNCTION: AcpiDsResultStackPush 00302 * 00303 * PARAMETERS: WalkState - Current Walk state 00304 * 00305 * RETURN: Status 00306 * 00307 * DESCRIPTION: Push an object onto the WalkState result stack 00308 * 00309 ******************************************************************************/ 00310 00311 static ACPI_STATUS 00312 AcpiDsResultStackPush ( 00313 ACPI_WALK_STATE *WalkState) 00314 { 00315 ACPI_GENERIC_STATE *State; 00316 00317 00318 ACPI_FUNCTION_NAME (DsResultStackPush); 00319 00320 00321 /* Check for stack overflow */ 00322 00323 if (((UINT32) WalkState->ResultSize + ACPI_RESULTS_FRAME_OBJ_NUM) > 00324 ACPI_RESULTS_OBJ_NUM_MAX) 00325 { 00326 ACPI_ERROR ((AE_INFO, "Result stack overflow: State=%p Num=%u", 00327 WalkState, WalkState->ResultSize)); 00328 return (AE_STACK_OVERFLOW); 00329 } 00330 00331 State = AcpiUtCreateGenericState (); 00332 if (!State) 00333 { 00334 return (AE_NO_MEMORY); 00335 } 00336 00337 State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RESULT; 00338 AcpiUtPushGenericState (&WalkState->Results, State); 00339 00340 /* Increase the length of the result stack by the length of frame */ 00341 00342 WalkState->ResultSize += ACPI_RESULTS_FRAME_OBJ_NUM; 00343 00344 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n", 00345 State, WalkState)); 00346 00347 return (AE_OK); 00348 } 00349 00350 00351 /******************************************************************************* 00352 * 00353 * FUNCTION: AcpiDsResultStackPop 00354 * 00355 * PARAMETERS: WalkState - Current Walk state 00356 * 00357 * RETURN: Status 00358 * 00359 * DESCRIPTION: Pop an object off of the WalkState result stack 00360 * 00361 ******************************************************************************/ 00362 00363 static ACPI_STATUS 00364 AcpiDsResultStackPop ( 00365 ACPI_WALK_STATE *WalkState) 00366 { 00367 ACPI_GENERIC_STATE *State; 00368 00369 00370 ACPI_FUNCTION_NAME (DsResultStackPop); 00371 00372 00373 /* Check for stack underflow */ 00374 00375 if (WalkState->Results == NULL) 00376 { 00377 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Result stack underflow - State=%p\n", 00378 WalkState)); 00379 return (AE_AML_NO_OPERAND); 00380 } 00381 00382 if (WalkState->ResultSize < ACPI_RESULTS_FRAME_OBJ_NUM) 00383 { 00384 ACPI_ERROR ((AE_INFO, "Insufficient result stack size")); 00385 return (AE_AML_INTERNAL); 00386 } 00387 00388 State = AcpiUtPopGenericState (&WalkState->Results); 00389 AcpiUtDeleteGenericState (State); 00390 00391 /* Decrease the length of result stack by the length of frame */ 00392 00393 WalkState->ResultSize -= ACPI_RESULTS_FRAME_OBJ_NUM; 00394 00395 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 00396 "Result=%p RemainingResults=%X State=%p\n", 00397 State, WalkState->ResultCount, WalkState)); 00398 00399 return (AE_OK); 00400 } 00401 00402 00403 /******************************************************************************* 00404 * 00405 * FUNCTION: AcpiDsObjStackPush 00406 * 00407 * PARAMETERS: Object - Object to push 00408 * WalkState - Current Walk state 00409 * 00410 * RETURN: Status 00411 * 00412 * DESCRIPTION: Push an object onto this walk's object/operand stack 00413 * 00414 ******************************************************************************/ 00415 00416 ACPI_STATUS 00417 AcpiDsObjStackPush ( 00418 void *Object, 00419 ACPI_WALK_STATE *WalkState) 00420 { 00421 ACPI_FUNCTION_NAME (DsObjStackPush); 00422 00423 00424 /* Check for stack overflow */ 00425 00426 if (WalkState->NumOperands >= ACPI_OBJ_NUM_OPERANDS) 00427 { 00428 ACPI_ERROR ((AE_INFO, 00429 "Object stack overflow! Obj=%p State=%p #Ops=%u", 00430 Object, WalkState, WalkState->NumOperands)); 00431 return (AE_STACK_OVERFLOW); 00432 } 00433 00434 /* Put the object onto the stack */ 00435 00436 WalkState->Operands [WalkState->OperandIndex] = Object; 00437 WalkState->NumOperands++; 00438 00439 /* For the usual order of filling the operand stack */ 00440 00441 WalkState->OperandIndex++; 00442 00443 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", 00444 Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), 00445 WalkState, WalkState->NumOperands)); 00446 00447 return (AE_OK); 00448 } 00449 00450 00451 /******************************************************************************* 00452 * 00453 * FUNCTION: AcpiDsObjStackPop 00454 * 00455 * PARAMETERS: PopCount - Number of objects/entries to pop 00456 * WalkState - Current Walk state 00457 * 00458 * RETURN: Status 00459 * 00460 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT 00461 * deleted by this routine. 00462 * 00463 ******************************************************************************/ 00464 00465 ACPI_STATUS 00466 AcpiDsObjStackPop ( 00467 UINT32 PopCount, 00468 ACPI_WALK_STATE *WalkState) 00469 { 00470 UINT32 i; 00471 00472 00473 ACPI_FUNCTION_NAME (DsObjStackPop); 00474 00475 00476 for (i = 0; i < PopCount; i++) 00477 { 00478 /* Check for stack underflow */ 00479 00480 if (WalkState->NumOperands == 0) 00481 { 00482 ACPI_ERROR ((AE_INFO, 00483 "Object stack underflow! Count=%X State=%p #Ops=%u", 00484 PopCount, WalkState, WalkState->NumOperands)); 00485 return (AE_STACK_UNDERFLOW); 00486 } 00487 00488 /* Just set the stack entry to null */ 00489 00490 WalkState->NumOperands--; 00491 WalkState->Operands [WalkState->NumOperands] = NULL; 00492 } 00493 00494 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%u\n", 00495 PopCount, WalkState, WalkState->NumOperands)); 00496 00497 return (AE_OK); 00498 } 00499 00500 00501 /******************************************************************************* 00502 * 00503 * FUNCTION: AcpiDsObjStackPopAndDelete 00504 * 00505 * PARAMETERS: PopCount - Number of objects/entries to pop 00506 * WalkState - Current Walk state 00507 * 00508 * RETURN: Status 00509 * 00510 * DESCRIPTION: Pop this walk's object stack and delete each object that is 00511 * popped off. 00512 * 00513 ******************************************************************************/ 00514 00515 void 00516 AcpiDsObjStackPopAndDelete ( 00517 UINT32 PopCount, 00518 ACPI_WALK_STATE *WalkState) 00519 { 00520 INT32 i; 00521 ACPI_OPERAND_OBJECT *ObjDesc; 00522 00523 00524 ACPI_FUNCTION_NAME (DsObjStackPopAndDelete); 00525 00526 00527 if (PopCount == 0) 00528 { 00529 return; 00530 } 00531 00532 for (i = (INT32) PopCount - 1; i >= 0; i--) 00533 { 00534 if (WalkState->NumOperands == 0) 00535 { 00536 return; 00537 } 00538 00539 /* Pop the stack and delete an object if present in this stack entry */ 00540 00541 WalkState->NumOperands--; 00542 ObjDesc = WalkState->Operands [i]; 00543 if (ObjDesc) 00544 { 00545 AcpiUtRemoveReference (WalkState->Operands [i]); 00546 WalkState->Operands [i] = NULL; 00547 } 00548 } 00549 00550 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", 00551 PopCount, WalkState, WalkState->NumOperands)); 00552 } 00553 00554 00555 /******************************************************************************* 00556 * 00557 * FUNCTION: AcpiDsGetCurrentWalkState 00558 * 00559 * PARAMETERS: Thread - Get current active state for this Thread 00560 * 00561 * RETURN: Pointer to the current walk state 00562 * 00563 * DESCRIPTION: Get the walk state that is at the head of the list (the "current" 00564 * walk state.) 00565 * 00566 ******************************************************************************/ 00567 00568 ACPI_WALK_STATE * 00569 AcpiDsGetCurrentWalkState ( 00570 ACPI_THREAD_STATE *Thread) 00571 { 00572 ACPI_FUNCTION_NAME (DsGetCurrentWalkState); 00573 00574 00575 if (!Thread) 00576 { 00577 return (NULL); 00578 } 00579 00580 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Current WalkState %p\n", 00581 Thread->WalkStateList)); 00582 00583 return (Thread->WalkStateList); 00584 } 00585 00586 00587 /******************************************************************************* 00588 * 00589 * FUNCTION: AcpiDsPushWalkState 00590 * 00591 * PARAMETERS: WalkState - State to push 00592 * Thread - Thread state object 00593 * 00594 * RETURN: None 00595 * 00596 * DESCRIPTION: Place the Thread state at the head of the state list 00597 * 00598 ******************************************************************************/ 00599 00600 void 00601 AcpiDsPushWalkState ( 00602 ACPI_WALK_STATE *WalkState, 00603 ACPI_THREAD_STATE *Thread) 00604 { 00605 ACPI_FUNCTION_TRACE (DsPushWalkState); 00606 00607 00608 WalkState->Next = Thread->WalkStateList; 00609 Thread->WalkStateList = WalkState; 00610 00611 return_VOID; 00612 } 00613 00614 00615 /******************************************************************************* 00616 * 00617 * FUNCTION: AcpiDsPopWalkState 00618 * 00619 * PARAMETERS: Thread - Current thread state 00620 * 00621 * RETURN: A WalkState object popped from the thread's stack 00622 * 00623 * DESCRIPTION: Remove and return the walkstate object that is at the head of 00624 * the walk stack for the given walk list. NULL indicates that 00625 * the list is empty. 00626 * 00627 ******************************************************************************/ 00628 00629 ACPI_WALK_STATE * 00630 AcpiDsPopWalkState ( 00631 ACPI_THREAD_STATE *Thread) 00632 { 00633 ACPI_WALK_STATE *WalkState; 00634 00635 00636 ACPI_FUNCTION_TRACE (DsPopWalkState); 00637 00638 00639 WalkState = Thread->WalkStateList; 00640 00641 if (WalkState) 00642 { 00643 /* Next walk state becomes the current walk state */ 00644 00645 Thread->WalkStateList = WalkState->Next; 00646 00647 /* 00648 * Don't clear the NEXT field, this serves as an indicator 00649 * that there is a parent WALK STATE 00650 * Do Not: WalkState->Next = NULL; 00651 */ 00652 } 00653 00654 return_PTR (WalkState); 00655 } 00656 00657 00658 /******************************************************************************* 00659 * 00660 * FUNCTION: AcpiDsCreateWalkState 00661 * 00662 * PARAMETERS: OwnerId - ID for object creation 00663 * Origin - Starting point for this walk 00664 * MethodDesc - Method object 00665 * Thread - Current thread state 00666 * 00667 * RETURN: Pointer to the new walk state. 00668 * 00669 * DESCRIPTION: Allocate and initialize a new walk state. The current walk 00670 * state is set to this new state. 00671 * 00672 ******************************************************************************/ 00673 00674 ACPI_WALK_STATE * 00675 AcpiDsCreateWalkState ( 00676 ACPI_OWNER_ID OwnerId, 00677 ACPI_PARSE_OBJECT *Origin, 00678 ACPI_OPERAND_OBJECT *MethodDesc, 00679 ACPI_THREAD_STATE *Thread) 00680 { 00681 ACPI_WALK_STATE *WalkState; 00682 00683 00684 ACPI_FUNCTION_TRACE (DsCreateWalkState); 00685 00686 00687 WalkState = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_WALK_STATE)); 00688 if (!WalkState) 00689 { 00690 return_PTR (NULL); 00691 } 00692 00693 WalkState->DescriptorType = ACPI_DESC_TYPE_WALK; 00694 WalkState->MethodDesc = MethodDesc; 00695 WalkState->OwnerId = OwnerId; 00696 WalkState->Origin = Origin; 00697 WalkState->Thread = Thread; 00698 00699 WalkState->ParserState.StartOp = Origin; 00700 00701 /* Init the method args/local */ 00702 00703 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) 00704 AcpiDsMethodDataInit (WalkState); 00705 #endif 00706 00707 /* Put the new state at the head of the walk list */ 00708 00709 if (Thread) 00710 { 00711 AcpiDsPushWalkState (WalkState, Thread); 00712 } 00713 00714 return_PTR (WalkState); 00715 } 00716 00717 00718 /******************************************************************************* 00719 * 00720 * FUNCTION: AcpiDsInitAmlWalk 00721 * 00722 * PARAMETERS: WalkState - New state to be initialized 00723 * Op - Current parse op 00724 * MethodNode - Control method NS node, if any 00725 * AmlStart - Start of AML 00726 * AmlLength - Length of AML 00727 * Info - Method info block (params, etc.) 00728 * PassNumber - 1, 2, or 3 00729 * 00730 * RETURN: Status 00731 * 00732 * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk 00733 * 00734 ******************************************************************************/ 00735 00736 ACPI_STATUS 00737 AcpiDsInitAmlWalk ( 00738 ACPI_WALK_STATE *WalkState, 00739 ACPI_PARSE_OBJECT *Op, 00740 ACPI_NAMESPACE_NODE *MethodNode, 00741 UINT8 *AmlStart, 00742 UINT32 AmlLength, 00743 ACPI_EVALUATE_INFO *Info, 00744 UINT8 PassNumber) 00745 { 00746 ACPI_STATUS Status; 00747 ACPI_PARSE_STATE *ParserState = &WalkState->ParserState; 00748 ACPI_PARSE_OBJECT *ExtraOp; 00749 00750 00751 ACPI_FUNCTION_TRACE (DsInitAmlWalk); 00752 00753 00754 WalkState->ParserState.Aml = 00755 WalkState->ParserState.AmlStart = AmlStart; 00756 WalkState->ParserState.AmlEnd = 00757 WalkState->ParserState.PkgEnd = AmlStart + AmlLength; 00758 00759 /* The NextOp of the NextWalk will be the beginning of the method */ 00760 00761 WalkState->NextOp = NULL; 00762 WalkState->PassNumber = PassNumber; 00763 00764 if (Info) 00765 { 00766 WalkState->Params = Info->Parameters; 00767 WalkState->CallerReturnDesc = &Info->ReturnObject; 00768 } 00769 00770 Status = AcpiPsInitScope (&WalkState->ParserState, Op); 00771 if (ACPI_FAILURE (Status)) 00772 { 00773 return_ACPI_STATUS (Status); 00774 } 00775 00776 if (MethodNode) 00777 { 00778 WalkState->ParserState.StartNode = MethodNode; 00779 WalkState->WalkType = ACPI_WALK_METHOD; 00780 WalkState->MethodNode = MethodNode; 00781 WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode); 00782 00783 /* Push start scope on scope stack and make it current */ 00784 00785 Status = AcpiDsScopeStackPush (MethodNode, ACPI_TYPE_METHOD, WalkState); 00786 if (ACPI_FAILURE (Status)) 00787 { 00788 return_ACPI_STATUS (Status); 00789 } 00790 00791 /* Init the method arguments */ 00792 00793 Status = AcpiDsMethodDataInitArgs (WalkState->Params, 00794 ACPI_METHOD_NUM_ARGS, WalkState); 00795 if (ACPI_FAILURE (Status)) 00796 { 00797 return_ACPI_STATUS (Status); 00798 } 00799 } 00800 else 00801 { 00802 /* 00803 * Setup the current scope. 00804 * Find a Named Op that has a namespace node associated with it. 00805 * search upwards from this Op. Current scope is the first 00806 * Op with a namespace node. 00807 */ 00808 ExtraOp = ParserState->StartOp; 00809 while (ExtraOp && !ExtraOp->Common.Node) 00810 { 00811 ExtraOp = ExtraOp->Common.Parent; 00812 } 00813 00814 if (!ExtraOp) 00815 { 00816 ParserState->StartNode = NULL; 00817 } 00818 else 00819 { 00820 ParserState->StartNode = ExtraOp->Common.Node; 00821 } 00822 00823 if (ParserState->StartNode) 00824 { 00825 /* Push start scope on scope stack and make it current */ 00826 00827 Status = AcpiDsScopeStackPush (ParserState->StartNode, 00828 ParserState->StartNode->Type, WalkState); 00829 if (ACPI_FAILURE (Status)) 00830 { 00831 return_ACPI_STATUS (Status); 00832 } 00833 } 00834 } 00835 00836 Status = AcpiDsInitCallbacks (WalkState, PassNumber); 00837 return_ACPI_STATUS (Status); 00838 } 00839 00840 00841 /******************************************************************************* 00842 * 00843 * FUNCTION: AcpiDsDeleteWalkState 00844 * 00845 * PARAMETERS: WalkState - State to delete 00846 * 00847 * RETURN: Status 00848 * 00849 * DESCRIPTION: Delete a walk state including all internal data structures 00850 * 00851 ******************************************************************************/ 00852 00853 void 00854 AcpiDsDeleteWalkState ( 00855 ACPI_WALK_STATE *WalkState) 00856 { 00857 ACPI_GENERIC_STATE *State; 00858 00859 00860 ACPI_FUNCTION_TRACE_PTR (DsDeleteWalkState, WalkState); 00861 00862 00863 if (!WalkState) 00864 { 00865 return; 00866 } 00867 00868 if (WalkState->DescriptorType != ACPI_DESC_TYPE_WALK) 00869 { 00870 ACPI_ERROR ((AE_INFO, "%p is not a valid walk state", 00871 WalkState)); 00872 return; 00873 } 00874 00875 /* There should not be any open scopes */ 00876 00877 if (WalkState->ParserState.Scope) 00878 { 00879 ACPI_ERROR ((AE_INFO, "%p walk still has a scope list", 00880 WalkState)); 00881 AcpiPsCleanupScope (&WalkState->ParserState); 00882 } 00883 00884 /* Always must free any linked control states */ 00885 00886 while (WalkState->ControlState) 00887 { 00888 State = WalkState->ControlState; 00889 WalkState->ControlState = State->Common.Next; 00890 00891 AcpiUtDeleteGenericState (State); 00892 } 00893 00894 /* Always must free any linked parse states */ 00895 00896 while (WalkState->ScopeInfo) 00897 { 00898 State = WalkState->ScopeInfo; 00899 WalkState->ScopeInfo = State->Common.Next; 00900 00901 AcpiUtDeleteGenericState (State); 00902 } 00903 00904 /* Always must free any stacked result states */ 00905 00906 while (WalkState->Results) 00907 { 00908 State = WalkState->Results; 00909 WalkState->Results = State->Common.Next; 00910 00911 AcpiUtDeleteGenericState (State); 00912 } 00913 00914 ACPI_FREE (WalkState); 00915 return_VOID; 00916 } 00917 00918 Generated on Sun May 27 2012 04:27:15 for ReactOS by
1.7.6.1
|