dswstate.c revision 151937
167754Smsmith/****************************************************************************** 267754Smsmith * 367754Smsmith * Module Name: dswstate - Dispatcher parse tree walk management routines 4151937Sjkim * $Revision: 1.90 $ 567754Smsmith * 667754Smsmith *****************************************************************************/ 767754Smsmith 867754Smsmith/****************************************************************************** 967754Smsmith * 1067754Smsmith * 1. Copyright Notice 1167754Smsmith * 12151937Sjkim * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. 1370243Smsmith * All rights reserved. 1467754Smsmith * 1567754Smsmith * 2. License 1667754Smsmith * 1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1867754Smsmith * rights. You may have additional license terms from the party that provided 1967754Smsmith * you this software, covering your right to use that party's intellectual 2067754Smsmith * property rights. 2167754Smsmith * 2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2767754Smsmith * Code in any form, with the right to sublicense such rights; and 2867754Smsmith * 2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3067754Smsmith * license (with the right to sublicense), under only those claims of Intel 3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3467754Smsmith * license, and in no event shall the patent license extend to any additions 3567754Smsmith * to or modifications of the Original Intel Code. No other license or right 3667754Smsmith * is granted directly or by implication, estoppel or otherwise; 3767754Smsmith * 3867754Smsmith * The above copyright and patent license is granted only if the following 3967754Smsmith * conditions are met: 4067754Smsmith * 4167754Smsmith * 3. Conditions 4267754Smsmith * 4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4467754Smsmith * Redistribution of source code of any substantial portion of the Covered 4567754Smsmith * Code or modification with rights to further distribute source must include 4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4767754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5067754Smsmith * Code and the date of any change. Licensee must include in that file the 5167754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5267754Smsmith * must include a prominent statement that the modification is derived, 5367754Smsmith * directly or indirectly, from Original Intel Code. 5467754Smsmith * 5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5667754Smsmith * Redistribution of source code of any substantial portion of the Covered 5767754Smsmith * Code or modification without rights to further distribute source must 5867754Smsmith * include the following Disclaimer and Export Compliance provision in the 5967754Smsmith * documentation and/or other materials provided with distribution. In 6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6267754Smsmith * license from Licensee to its licensee is limited to the intellectual 6367754Smsmith * property embodied in the software Licensee provides to its licensee, and 6467754Smsmith * not to intellectual property embodied in modifications its licensee may 6567754Smsmith * make. 6667754Smsmith * 6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the 6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7067754Smsmith * provision in the documentation and/or other materials provided with the 7167754Smsmith * distribution. 7267754Smsmith * 7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7467754Smsmith * Intel Code. 7567754Smsmith * 7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7867754Smsmith * other dealings in products derived from or relating to the Covered Code 7967754Smsmith * without prior written authorization from Intel. 8067754Smsmith * 8167754Smsmith * 4. Disclaimer and Export Compliance 8267754Smsmith * 8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8467754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8967754Smsmith * PARTICULAR PURPOSE. 9067754Smsmith * 9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9867754Smsmith * LIMITED REMEDY. 9967754Smsmith * 10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10167754Smsmith * software or system incorporating such software without first obtaining any 10267754Smsmith * required license or other approval from the U. S. Department of Commerce or 10367754Smsmith * any other agency or department of the United States Government. In the 10467754Smsmith * event Licensee exports any such software from the United States or 10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10667754Smsmith * ensure that the distribution and export/re-export of the software is in 10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11067754Smsmith * software, or service, directly or indirectly, to any country for which the 11167754Smsmith * United States government or any agency thereof requires an export license, 11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11367754Smsmith * such license, approval or letter. 11467754Smsmith * 11567754Smsmith *****************************************************************************/ 11667754Smsmith 11767754Smsmith 11867754Smsmith#define __DSWSTATE_C__ 11967754Smsmith 120151600Sobrien#include <contrib/dev/acpica/acpi.h> 121151600Sobrien#include <contrib/dev/acpica/acparser.h> 122151600Sobrien#include <contrib/dev/acpica/acdispat.h> 123151600Sobrien#include <contrib/dev/acpica/acnamesp.h> 12467754Smsmith 12577424Smsmith#define _COMPONENT ACPI_DISPATCHER 12691116Smsmith ACPI_MODULE_NAME ("dswstate") 12767754Smsmith 128151937Sjkim/* Local prototypes */ 12967754Smsmith 130151937Sjkim#ifdef ACPI_OBSOLETE_FUNCTIONS 13167754SmsmithACPI_STATUS 13269746SmsmithAcpiDsResultInsert ( 13367754Smsmith void *Object, 13469746Smsmith UINT32 Index, 135151937Sjkim ACPI_WALK_STATE *WalkState); 13667754Smsmith 137151937SjkimACPI_STATUS 138151937SjkimAcpiDsObjStackDeleteAll ( 139151937Sjkim ACPI_WALK_STATE *WalkState); 14067754Smsmith 141151937SjkimACPI_STATUS 142151937SjkimAcpiDsObjStackPopObject ( 143151937Sjkim ACPI_OPERAND_OBJECT **Object, 144151937Sjkim ACPI_WALK_STATE *WalkState); 14577424Smsmith 146151937Sjkimvoid * 147151937SjkimAcpiDsObjStackGetValue ( 148151937Sjkim UINT32 Index, 149151937Sjkim ACPI_WALK_STATE *WalkState); 150151937Sjkim#endif 15177424Smsmith 15267754Smsmith 15367754Smsmith/******************************************************************************* 15467754Smsmith * 15569746Smsmith * FUNCTION: AcpiDsResultRemove 15667754Smsmith * 15767754Smsmith * PARAMETERS: Object - Where to return the popped object 158123315Snjl * Index - Where to extract the object 15967754Smsmith * WalkState - Current Walk state 16067754Smsmith * 16167754Smsmith * RETURN: Status 16267754Smsmith * 16367754Smsmith * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In 16467754Smsmith * other words, this is a FIFO. 16567754Smsmith * 16667754Smsmith ******************************************************************************/ 16767754Smsmith 16867754SmsmithACPI_STATUS 16969746SmsmithAcpiDsResultRemove ( 17067754Smsmith ACPI_OPERAND_OBJECT **Object, 17169746Smsmith UINT32 Index, 17267754Smsmith ACPI_WALK_STATE *WalkState) 17367754Smsmith{ 17469746Smsmith ACPI_GENERIC_STATE *State; 17567754Smsmith 17667754Smsmith 17791116Smsmith ACPI_FUNCTION_NAME ("DsResultRemove"); 17877424Smsmith 17977424Smsmith 18069746Smsmith State = WalkState->Results; 18169746Smsmith if (!State) 18269746Smsmith { 18382367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", 18469746Smsmith WalkState)); 18569746Smsmith return (AE_NOT_EXIST); 18669746Smsmith } 18767754Smsmith 188114237Snjl if (Index >= ACPI_OBJ_MAX_OPERAND) 18967754Smsmith { 19082367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 19182367Smsmith "Index out of range: %X State=%p Num=%X\n", 19269746Smsmith Index, WalkState, State->Results.NumResults)); 19369746Smsmith } 19469746Smsmith 19569746Smsmith /* Check for a valid result object */ 19669746Smsmith 19769746Smsmith if (!State->Results.ObjDesc [Index]) 19869746Smsmith { 19982367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 20082367Smsmith "Null operand! State=%p #Ops=%X, Index=%X\n", 20169746Smsmith WalkState, State->Results.NumResults, Index)); 20271867Smsmith return (AE_AML_NO_RETURN_VALUE); 20367754Smsmith } 20467754Smsmith 20569746Smsmith /* Remove the object */ 20667754Smsmith 20769746Smsmith State->Results.NumResults--; 20867754Smsmith 20969746Smsmith *Object = State->Results.ObjDesc [Index]; 21069746Smsmith State->Results.ObjDesc [Index] = NULL; 21167754Smsmith 21282367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 21382367Smsmith "Obj=%p [%s] Index=%X State=%p Num=%X\n", 21499679Siwasaki *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", 21569746Smsmith Index, WalkState, State->Results.NumResults)); 21669746Smsmith 21769746Smsmith return (AE_OK); 21869746Smsmith} 21969746Smsmith 22069746Smsmith 22169746Smsmith/******************************************************************************* 22269746Smsmith * 22369746Smsmith * FUNCTION: AcpiDsResultPop 22469746Smsmith * 22569746Smsmith * PARAMETERS: Object - Where to return the popped object 22669746Smsmith * WalkState - Current Walk state 22769746Smsmith * 22869746Smsmith * RETURN: Status 22969746Smsmith * 23069746Smsmith * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In 23169746Smsmith * other words, this is a FIFO. 23269746Smsmith * 23369746Smsmith ******************************************************************************/ 23469746Smsmith 23569746SmsmithACPI_STATUS 23669746SmsmithAcpiDsResultPop ( 23769746Smsmith ACPI_OPERAND_OBJECT **Object, 23869746Smsmith ACPI_WALK_STATE *WalkState) 23969746Smsmith{ 240114237Snjl ACPI_NATIVE_UINT Index; 24169746Smsmith ACPI_GENERIC_STATE *State; 24269746Smsmith 24369746Smsmith 24491116Smsmith ACPI_FUNCTION_NAME ("DsResultPop"); 24577424Smsmith 24677424Smsmith 24769746Smsmith State = WalkState->Results; 24869746Smsmith if (!State) 24969746Smsmith { 25069746Smsmith return (AE_OK); 25169746Smsmith } 25269746Smsmith 25369746Smsmith if (!State->Results.NumResults) 25469746Smsmith { 25582367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack is empty! State=%p\n", 25669746Smsmith WalkState)); 25771867Smsmith return (AE_AML_NO_RETURN_VALUE); 25869746Smsmith } 25969746Smsmith 26069746Smsmith /* Remove top element */ 26169746Smsmith 26269746Smsmith State->Results.NumResults--; 26369746Smsmith 264114237Snjl for (Index = ACPI_OBJ_NUM_OPERANDS; Index; Index--) 26569746Smsmith { 26669746Smsmith /* Check for a valid result object */ 26769746Smsmith 26869746Smsmith if (State->Results.ObjDesc [Index -1]) 26969746Smsmith { 27069746Smsmith *Object = State->Results.ObjDesc [Index -1]; 27169746Smsmith State->Results.ObjDesc [Index -1] = NULL; 27269746Smsmith 273151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 274151937Sjkim "Obj=%p [%s] Index=%X State=%p Num=%X\n", 275151937Sjkim *Object, 276151937Sjkim (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", 277107325Siwasaki (UINT32) Index -1, WalkState, State->Results.NumResults)); 27869746Smsmith 27969746Smsmith return (AE_OK); 28069746Smsmith } 28169746Smsmith } 28269746Smsmith 283151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 284151937Sjkim "No result objects! State=%p\n", WalkState)); 28571867Smsmith return (AE_AML_NO_RETURN_VALUE); 28669746Smsmith} 28769746Smsmith 288123315Snjl 28969746Smsmith/******************************************************************************* 29069746Smsmith * 29171867Smsmith * FUNCTION: AcpiDsResultPopFromBottom 29269746Smsmith * 29369746Smsmith * PARAMETERS: Object - Where to return the popped object 29469746Smsmith * WalkState - Current Walk state 29569746Smsmith * 29669746Smsmith * RETURN: Status 29769746Smsmith * 29869746Smsmith * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In 29969746Smsmith * other words, this is a FIFO. 30069746Smsmith * 30169746Smsmith ******************************************************************************/ 30269746Smsmith 30369746SmsmithACPI_STATUS 30469746SmsmithAcpiDsResultPopFromBottom ( 30569746Smsmith ACPI_OPERAND_OBJECT **Object, 30669746Smsmith ACPI_WALK_STATE *WalkState) 30769746Smsmith{ 308114237Snjl ACPI_NATIVE_UINT Index; 30969746Smsmith ACPI_GENERIC_STATE *State; 31069746Smsmith 31169746Smsmith 31291116Smsmith ACPI_FUNCTION_NAME ("DsResultPopFromBottom"); 31377424Smsmith 31477424Smsmith 31569746Smsmith State = WalkState->Results; 31669746Smsmith if (!State) 31769746Smsmith { 31882367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 31982367Smsmith "Warning: No result object pushed! State=%p\n", WalkState)); 32069746Smsmith return (AE_NOT_EXIST); 32169746Smsmith } 32269746Smsmith 32369746Smsmith if (!State->Results.NumResults) 32469746Smsmith { 325151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", 326151937Sjkim WalkState)); 32771867Smsmith return (AE_AML_NO_RETURN_VALUE); 32869746Smsmith } 32969746Smsmith 33069746Smsmith /* Remove Bottom element */ 33169746Smsmith 33269746Smsmith *Object = State->Results.ObjDesc [0]; 33369746Smsmith 33469746Smsmith /* Push entire stack down one element */ 33569746Smsmith 33669746Smsmith for (Index = 0; Index < State->Results.NumResults; Index++) 33769746Smsmith { 33869746Smsmith State->Results.ObjDesc [Index] = State->Results.ObjDesc [Index + 1]; 33969746Smsmith } 34069746Smsmith 34169746Smsmith State->Results.NumResults--; 34269746Smsmith 34367754Smsmith /* Check for a valid result object */ 34467754Smsmith 34569746Smsmith if (!*Object) 34667754Smsmith { 347151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 348151937Sjkim "Null operand! State=%p #Ops=%X Index=%X\n", 34999679Siwasaki WalkState, State->Results.NumResults, (UINT32) Index)); 35071867Smsmith return (AE_AML_NO_RETURN_VALUE); 35167754Smsmith } 35267754Smsmith 353151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Results=%p State=%p\n", 35499679Siwasaki *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", 35569746Smsmith State, WalkState)); 35670243Smsmith 35769746Smsmith return (AE_OK); 35869746Smsmith} 35967754Smsmith 36069746Smsmith 36169746Smsmith/******************************************************************************* 36269746Smsmith * 36371867Smsmith * FUNCTION: AcpiDsResultPush 36469746Smsmith * 36569746Smsmith * PARAMETERS: Object - Where to return the popped object 36669746Smsmith * WalkState - Current Walk state 36769746Smsmith * 36869746Smsmith * RETURN: Status 36969746Smsmith * 37071867Smsmith * DESCRIPTION: Push an object onto the current result stack 37169746Smsmith * 37269746Smsmith ******************************************************************************/ 37369746Smsmith 37469746SmsmithACPI_STATUS 37569746SmsmithAcpiDsResultPush ( 37669746Smsmith ACPI_OPERAND_OBJECT *Object, 37769746Smsmith ACPI_WALK_STATE *WalkState) 37869746Smsmith{ 37969746Smsmith ACPI_GENERIC_STATE *State; 38069746Smsmith 38169746Smsmith 38291116Smsmith ACPI_FUNCTION_NAME ("DsResultPush"); 38377424Smsmith 38477424Smsmith 38569746Smsmith State = WalkState->Results; 38669746Smsmith if (!State) 38769746Smsmith { 388126372Snjl ACPI_REPORT_ERROR (("No result stack frame during push\n")); 38971867Smsmith return (AE_AML_INTERNAL); 39069746Smsmith } 39169746Smsmith 392114237Snjl if (State->Results.NumResults == ACPI_OBJ_NUM_OPERANDS) 39369746Smsmith { 39482367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 39582367Smsmith "Result stack overflow: Obj=%p State=%p Num=%X\n", 39669746Smsmith Object, WalkState, State->Results.NumResults)); 39769746Smsmith return (AE_STACK_OVERFLOW); 39869746Smsmith } 39969746Smsmith 40069746Smsmith if (!Object) 40169746Smsmith { 402151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 403151937Sjkim "Null Object! Obj=%p State=%p Num=%X\n", 40469746Smsmith Object, WalkState, State->Results.NumResults)); 40569746Smsmith return (AE_BAD_PARAMETER); 40669746Smsmith } 40769746Smsmith 40869746Smsmith State->Results.ObjDesc [State->Results.NumResults] = Object; 40969746Smsmith State->Results.NumResults++; 41069746Smsmith 41182367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", 41299679Siwasaki Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL", 41369746Smsmith WalkState, State->Results.NumResults, WalkState->CurrentResult)); 41467754Smsmith 41567754Smsmith return (AE_OK); 41667754Smsmith} 41767754Smsmith 41867754Smsmith 41967754Smsmith/******************************************************************************* 42067754Smsmith * 42169746Smsmith * FUNCTION: AcpiDsResultStackPush 42269746Smsmith * 423123315Snjl * PARAMETERS: WalkState - Current Walk state 42469746Smsmith * 42569746Smsmith * RETURN: Status 42669746Smsmith * 427107325Siwasaki * DESCRIPTION: Push an object onto the WalkState result stack. 42869746Smsmith * 42969746Smsmith ******************************************************************************/ 43069746Smsmith 43169746SmsmithACPI_STATUS 43269746SmsmithAcpiDsResultStackPush ( 43369746Smsmith ACPI_WALK_STATE *WalkState) 43469746Smsmith{ 43569746Smsmith ACPI_GENERIC_STATE *State; 43669746Smsmith 43791116Smsmith ACPI_FUNCTION_NAME ("DsResultStackPush"); 43870243Smsmith 43982367Smsmith 44077424Smsmith State = AcpiUtCreateGenericState (); 44169746Smsmith if (!State) 44269746Smsmith { 44369746Smsmith return (AE_NO_MEMORY); 44469746Smsmith } 44569746Smsmith 44684491Smsmith State->Common.DataType = ACPI_DESC_TYPE_STATE_RESULT; 44777424Smsmith AcpiUtPushGenericState (&WalkState->Results, State); 44870243Smsmith 44982367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n", 45069746Smsmith State, WalkState)); 45169746Smsmith 45269746Smsmith return (AE_OK); 45369746Smsmith} 45469746Smsmith 45569746Smsmith 45669746Smsmith/******************************************************************************* 45769746Smsmith * 45869746Smsmith * FUNCTION: AcpiDsResultStackPop 45969746Smsmith * 46069746Smsmith * PARAMETERS: WalkState - Current Walk state 46169746Smsmith * 46269746Smsmith * RETURN: Status 46369746Smsmith * 464107325Siwasaki * DESCRIPTION: Pop an object off of the WalkState result stack. 46569746Smsmith * 46669746Smsmith ******************************************************************************/ 46769746Smsmith 46869746SmsmithACPI_STATUS 46969746SmsmithAcpiDsResultStackPop ( 47069746Smsmith ACPI_WALK_STATE *WalkState) 47169746Smsmith{ 47269746Smsmith ACPI_GENERIC_STATE *State; 47369746Smsmith 47491116Smsmith ACPI_FUNCTION_NAME ("DsResultStackPop"); 47569746Smsmith 47682367Smsmith 47769746Smsmith /* Check for stack underflow */ 47869746Smsmith 47969746Smsmith if (WalkState->Results == NULL) 48069746Smsmith { 48182367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Underflow - State=%p\n", 48269746Smsmith WalkState)); 48369746Smsmith return (AE_AML_NO_OPERAND); 48469746Smsmith } 48569746Smsmith 48677424Smsmith State = AcpiUtPopGenericState (&WalkState->Results); 48769746Smsmith 48882367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 48982367Smsmith "Result=%p RemainingResults=%X State=%p\n", 49069746Smsmith State, State->Results.NumResults, WalkState)); 49169746Smsmith 49277424Smsmith AcpiUtDeleteGenericState (State); 49369746Smsmith 49469746Smsmith return (AE_OK); 49569746Smsmith} 49669746Smsmith 49769746Smsmith 49869746Smsmith/******************************************************************************* 49969746Smsmith * 50067754Smsmith * FUNCTION: AcpiDsObjStackPush 50167754Smsmith * 50267754Smsmith * PARAMETERS: Object - Object to push 50367754Smsmith * WalkState - Current Walk state 50467754Smsmith * 50567754Smsmith * RETURN: Status 50667754Smsmith * 50767754Smsmith * DESCRIPTION: Push an object onto this walk's object/operand stack 50867754Smsmith * 50967754Smsmith ******************************************************************************/ 51067754Smsmith 51167754SmsmithACPI_STATUS 51267754SmsmithAcpiDsObjStackPush ( 51367754Smsmith void *Object, 51467754Smsmith ACPI_WALK_STATE *WalkState) 51567754Smsmith{ 51691116Smsmith ACPI_FUNCTION_NAME ("DsObjStackPush"); 51767754Smsmith 51867754Smsmith 51967754Smsmith /* Check for stack overflow */ 52067754Smsmith 521114237Snjl if (WalkState->NumOperands >= ACPI_OBJ_NUM_OPERANDS) 52267754Smsmith { 52382367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 52482367Smsmith "overflow! Obj=%p State=%p #Ops=%X\n", 52567754Smsmith Object, WalkState, WalkState->NumOperands)); 52667754Smsmith return (AE_STACK_OVERFLOW); 52767754Smsmith } 52867754Smsmith 52967754Smsmith /* Put the object onto the stack */ 53067754Smsmith 53167754Smsmith WalkState->Operands [WalkState->NumOperands] = Object; 53267754Smsmith WalkState->NumOperands++; 53367754Smsmith 53482367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", 53599679Siwasaki Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), 53669746Smsmith WalkState, WalkState->NumOperands)); 53767754Smsmith 53867754Smsmith return (AE_OK); 53967754Smsmith} 54067754Smsmith 54167754Smsmith 54267754Smsmith/******************************************************************************* 54367754Smsmith * 54467754Smsmith * FUNCTION: AcpiDsObjStackPop 54567754Smsmith * 54667754Smsmith * PARAMETERS: PopCount - Number of objects/entries to pop 54767754Smsmith * WalkState - Current Walk state 54867754Smsmith * 54967754Smsmith * RETURN: Status 55067754Smsmith * 55167754Smsmith * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT 55267754Smsmith * deleted by this routine. 55367754Smsmith * 55467754Smsmith ******************************************************************************/ 55567754Smsmith 55667754SmsmithACPI_STATUS 55767754SmsmithAcpiDsObjStackPop ( 55867754Smsmith UINT32 PopCount, 55967754Smsmith ACPI_WALK_STATE *WalkState) 56067754Smsmith{ 56167754Smsmith UINT32 i; 56267754Smsmith 56391116Smsmith ACPI_FUNCTION_NAME ("DsObjStackPop"); 56467754Smsmith 56582367Smsmith 56667754Smsmith for (i = 0; i < PopCount; i++) 56767754Smsmith { 56867754Smsmith /* Check for stack underflow */ 56967754Smsmith 57067754Smsmith if (WalkState->NumOperands == 0) 57167754Smsmith { 57282367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 57382367Smsmith "Underflow! Count=%X State=%p #Ops=%X\n", 57467754Smsmith PopCount, WalkState, WalkState->NumOperands)); 57567754Smsmith return (AE_STACK_UNDERFLOW); 57667754Smsmith } 57767754Smsmith 57867754Smsmith /* Just set the stack entry to null */ 57967754Smsmith 58067754Smsmith WalkState->NumOperands--; 58167754Smsmith WalkState->Operands [WalkState->NumOperands] = NULL; 58267754Smsmith } 58367754Smsmith 58482367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", 58567754Smsmith PopCount, WalkState, WalkState->NumOperands)); 58667754Smsmith 58767754Smsmith return (AE_OK); 58867754Smsmith} 58967754Smsmith 59067754Smsmith 59167754Smsmith/******************************************************************************* 59267754Smsmith * 59367754Smsmith * FUNCTION: AcpiDsObjStackPopAndDelete 59467754Smsmith * 59567754Smsmith * PARAMETERS: PopCount - Number of objects/entries to pop 59667754Smsmith * WalkState - Current Walk state 59767754Smsmith * 59867754Smsmith * RETURN: Status 59967754Smsmith * 60067754Smsmith * DESCRIPTION: Pop this walk's object stack and delete each object that is 60167754Smsmith * popped off. 60267754Smsmith * 60367754Smsmith ******************************************************************************/ 60467754Smsmith 60567754SmsmithACPI_STATUS 60667754SmsmithAcpiDsObjStackPopAndDelete ( 60767754Smsmith UINT32 PopCount, 60867754Smsmith ACPI_WALK_STATE *WalkState) 60967754Smsmith{ 61067754Smsmith UINT32 i; 61167754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 61267754Smsmith 613123315Snjl 61491116Smsmith ACPI_FUNCTION_NAME ("DsObjStackPopAndDelete"); 61567754Smsmith 61682367Smsmith 61767754Smsmith for (i = 0; i < PopCount; i++) 61867754Smsmith { 61967754Smsmith /* Check for stack underflow */ 62067754Smsmith 62167754Smsmith if (WalkState->NumOperands == 0) 62267754Smsmith { 62382367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 62482367Smsmith "Underflow! Count=%X State=%p #Ops=%X\n", 62567754Smsmith PopCount, WalkState, WalkState->NumOperands)); 62667754Smsmith return (AE_STACK_UNDERFLOW); 62767754Smsmith } 62867754Smsmith 62967754Smsmith /* Pop the stack and delete an object if present in this stack entry */ 63067754Smsmith 63167754Smsmith WalkState->NumOperands--; 63267754Smsmith ObjDesc = WalkState->Operands [WalkState->NumOperands]; 63367754Smsmith if (ObjDesc) 63467754Smsmith { 63577424Smsmith AcpiUtRemoveReference (WalkState->Operands [WalkState->NumOperands]); 63667754Smsmith WalkState->Operands [WalkState->NumOperands] = NULL; 63767754Smsmith } 63867754Smsmith } 63967754Smsmith 64082367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", 64167754Smsmith PopCount, WalkState, WalkState->NumOperands)); 64267754Smsmith 64367754Smsmith return (AE_OK); 64467754Smsmith} 64567754Smsmith 64667754Smsmith 64767754Smsmith/******************************************************************************* 64867754Smsmith * 64967754Smsmith * FUNCTION: AcpiDsGetCurrentWalkState 65067754Smsmith * 65187031Smsmith * PARAMETERS: Thread - Get current active state for this Thread 65267754Smsmith * 65367754Smsmith * RETURN: Pointer to the current walk state 65467754Smsmith * 65567754Smsmith * DESCRIPTION: Get the walk state that is at the head of the list (the "current" 65687031Smsmith * walk state.) 65767754Smsmith * 65867754Smsmith ******************************************************************************/ 65967754Smsmith 66067754SmsmithACPI_WALK_STATE * 66167754SmsmithAcpiDsGetCurrentWalkState ( 66287031Smsmith ACPI_THREAD_STATE *Thread) 66367754Smsmith 66467754Smsmith{ 66591116Smsmith ACPI_FUNCTION_NAME ("DsGetCurrentWalkState"); 66667754Smsmith 66782367Smsmith 66887031Smsmith if (!Thread) 66967754Smsmith { 67067754Smsmith return (NULL); 67167754Smsmith } 67267754Smsmith 673114237Snjl ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Current WalkState %p\n", 67487031Smsmith Thread->WalkStateList)); 67587031Smsmith 67687031Smsmith return (Thread->WalkStateList); 67767754Smsmith} 67867754Smsmith 67967754Smsmith 68067754Smsmith/******************************************************************************* 68167754Smsmith * 68267754Smsmith * FUNCTION: AcpiDsPushWalkState 68367754Smsmith * 68467754Smsmith * PARAMETERS: WalkState - State to push 685151937Sjkim * Thread - Thread state object 68667754Smsmith * 68767754Smsmith * RETURN: None 68867754Smsmith * 689151937Sjkim * DESCRIPTION: Place the Thread state at the head of the state list. 69067754Smsmith * 69167754Smsmith ******************************************************************************/ 69267754Smsmith 69384491Smsmithvoid 69467754SmsmithAcpiDsPushWalkState ( 69567754Smsmith ACPI_WALK_STATE *WalkState, 69687031Smsmith ACPI_THREAD_STATE *Thread) 69767754Smsmith{ 69891116Smsmith ACPI_FUNCTION_TRACE ("DsPushWalkState"); 69967754Smsmith 70067754Smsmith 70187031Smsmith WalkState->Next = Thread->WalkStateList; 70287031Smsmith Thread->WalkStateList = WalkState; 70367754Smsmith 70467754Smsmith return_VOID; 70567754Smsmith} 70667754Smsmith 70767754Smsmith 70867754Smsmith/******************************************************************************* 70967754Smsmith * 71067754Smsmith * FUNCTION: AcpiDsPopWalkState 71167754Smsmith * 712151937Sjkim * PARAMETERS: Thread - Current thread state 71367754Smsmith * 714151937Sjkim * RETURN: A WalkState object popped from the thread's stack 71567754Smsmith * 71667754Smsmith * DESCRIPTION: Remove and return the walkstate object that is at the head of 71767754Smsmith * the walk stack for the given walk list. NULL indicates that 71867754Smsmith * the list is empty. 71967754Smsmith * 72067754Smsmith ******************************************************************************/ 72167754Smsmith 72267754SmsmithACPI_WALK_STATE * 72367754SmsmithAcpiDsPopWalkState ( 72487031Smsmith ACPI_THREAD_STATE *Thread) 72567754Smsmith{ 72667754Smsmith ACPI_WALK_STATE *WalkState; 72767754Smsmith 72867754Smsmith 72991116Smsmith ACPI_FUNCTION_TRACE ("DsPopWalkState"); 73067754Smsmith 73167754Smsmith 73287031Smsmith WalkState = Thread->WalkStateList; 73367754Smsmith 73467754Smsmith if (WalkState) 73567754Smsmith { 73667754Smsmith /* Next walk state becomes the current walk state */ 73767754Smsmith 73887031Smsmith Thread->WalkStateList = WalkState->Next; 73967754Smsmith 74067754Smsmith /* 74167754Smsmith * Don't clear the NEXT field, this serves as an indicator 74267754Smsmith * that there is a parent WALK STATE 743151937Sjkim * Do Not: WalkState->Next = NULL; 74467754Smsmith */ 74567754Smsmith } 74667754Smsmith 74767754Smsmith return_PTR (WalkState); 74867754Smsmith} 74967754Smsmith 75067754Smsmith 75167754Smsmith/******************************************************************************* 75267754Smsmith * 75367754Smsmith * FUNCTION: AcpiDsCreateWalkState 75467754Smsmith * 755151937Sjkim * PARAMETERS: OwnerId - ID for object creation 756151937Sjkim * Origin - Starting point for this walk 757151937Sjkim * MthDesc - Method object 75887031Smsmith * Thread - Current thread state 75967754Smsmith * 76067754Smsmith * RETURN: Pointer to the new walk state. 76167754Smsmith * 76291116Smsmith * DESCRIPTION: Allocate and initialize a new walk state. The current walk 76387031Smsmith * state is set to this new state. 76467754Smsmith * 76567754Smsmith ******************************************************************************/ 76667754Smsmith 76767754SmsmithACPI_WALK_STATE * 76867754SmsmithAcpiDsCreateWalkState ( 76967754Smsmith ACPI_OWNER_ID OwnerId, 77067754Smsmith ACPI_PARSE_OBJECT *Origin, 77167754Smsmith ACPI_OPERAND_OBJECT *MthDesc, 77287031Smsmith ACPI_THREAD_STATE *Thread) 77367754Smsmith{ 77467754Smsmith ACPI_WALK_STATE *WalkState; 77571867Smsmith ACPI_STATUS Status; 77667754Smsmith 77767754Smsmith 77891116Smsmith ACPI_FUNCTION_TRACE ("DsCreateWalkState"); 77967754Smsmith 78067754Smsmith 781151937Sjkim WalkState = ACPI_MEM_CALLOCATE (sizeof (ACPI_WALK_STATE)); 78282367Smsmith if (!WalkState) 78367754Smsmith { 78482367Smsmith return_PTR (NULL); 78571867Smsmith } 78667754Smsmith 78767754Smsmith WalkState->DataType = ACPI_DESC_TYPE_WALK; 78867754Smsmith WalkState->OwnerId = OwnerId; 78967754Smsmith WalkState->Origin = Origin; 79067754Smsmith WalkState->MethodDesc = MthDesc; 79187031Smsmith WalkState->Thread = Thread; 79267754Smsmith 793102550Siwasaki WalkState->ParserState.StartOp = Origin; 794102550Siwasaki 79567754Smsmith /* Init the method args/local */ 79667754Smsmith 797100966Siwasaki#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) 79867754Smsmith AcpiDsMethodDataInit (WalkState); 79969450Smsmith#endif 80067754Smsmith 80171867Smsmith /* Create an initial result stack entry */ 80271867Smsmith 80371867Smsmith Status = AcpiDsResultStackPush (WalkState); 80471867Smsmith if (ACPI_FAILURE (Status)) 80571867Smsmith { 806151937Sjkim ACPI_MEM_FREE (WalkState); 80777424Smsmith return_PTR (NULL); 80871867Smsmith } 80971867Smsmith 81067754Smsmith /* Put the new state at the head of the walk list */ 81167754Smsmith 81287031Smsmith if (Thread) 81384491Smsmith { 81487031Smsmith AcpiDsPushWalkState (WalkState, Thread); 81584491Smsmith } 81667754Smsmith 81767754Smsmith return_PTR (WalkState); 81867754Smsmith} 81967754Smsmith 82067754Smsmith 82167754Smsmith/******************************************************************************* 82267754Smsmith * 82384491Smsmith * FUNCTION: AcpiDsInitAmlWalk 82484491Smsmith * 82584491Smsmith * PARAMETERS: WalkState - New state to be initialized 826123315Snjl * Op - Current parse op 827123315Snjl * MethodNode - Control method NS node, if any 828123315Snjl * AmlStart - Start of AML 829123315Snjl * AmlLength - Length of AML 830151937Sjkim * Info - Method info block (params, etc.) 831123315Snjl * PassNumber - 1, 2, or 3 83284491Smsmith * 833123315Snjl * RETURN: Status 83484491Smsmith * 83584491Smsmith * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk 83684491Smsmith * 83784491Smsmith ******************************************************************************/ 83884491Smsmith 83984491SmsmithACPI_STATUS 84084491SmsmithAcpiDsInitAmlWalk ( 84184491Smsmith ACPI_WALK_STATE *WalkState, 84284491Smsmith ACPI_PARSE_OBJECT *Op, 84384491Smsmith ACPI_NAMESPACE_NODE *MethodNode, 84484491Smsmith UINT8 *AmlStart, 84584491Smsmith UINT32 AmlLength, 846129684Snjl ACPI_PARAMETER_INFO *Info, 847151937Sjkim UINT8 PassNumber) 84884491Smsmith{ 84984491Smsmith ACPI_STATUS Status; 85084491Smsmith ACPI_PARSE_STATE *ParserState = &WalkState->ParserState; 851102550Siwasaki ACPI_PARSE_OBJECT *ExtraOp; 85284491Smsmith 85384491Smsmith 85491116Smsmith ACPI_FUNCTION_TRACE ("DsInitAmlWalk"); 85584491Smsmith 85684491Smsmith 85784491Smsmith WalkState->ParserState.Aml = 85884491Smsmith WalkState->ParserState.AmlStart = AmlStart; 85984491Smsmith WalkState->ParserState.AmlEnd = 86084491Smsmith WalkState->ParserState.PkgEnd = AmlStart + AmlLength; 86184491Smsmith 86284491Smsmith /* The NextOp of the NextWalk will be the beginning of the method */ 86384491Smsmith 864151937Sjkim WalkState->NextOp = NULL; 865151937Sjkim WalkState->PassNumber = PassNumber; 86684491Smsmith 867129684Snjl if (Info) 868129684Snjl { 869129684Snjl if (Info->ParameterType == ACPI_PARAM_GPE) 870129684Snjl { 871129684Snjl WalkState->GpeEventInfo = ACPI_CAST_PTR (ACPI_GPE_EVENT_INFO, 872129684Snjl Info->Parameters); 873129684Snjl } 874129684Snjl else 875129684Snjl { 876151937Sjkim WalkState->Params = Info->Parameters; 877151937Sjkim WalkState->CallerReturnDesc = &Info->ReturnObject; 878129684Snjl } 879129684Snjl } 880129684Snjl 88184491Smsmith Status = AcpiPsInitScope (&WalkState->ParserState, Op); 88284491Smsmith if (ACPI_FAILURE (Status)) 88384491Smsmith { 88484491Smsmith return_ACPI_STATUS (Status); 88584491Smsmith } 88684491Smsmith 88784491Smsmith if (MethodNode) 88884491Smsmith { 889123315Snjl WalkState->ParserState.StartNode = MethodNode; 890123315Snjl WalkState->WalkType = ACPI_WALK_METHOD; 891123315Snjl WalkState->MethodNode = MethodNode; 892123315Snjl WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode); 89384491Smsmith 89484491Smsmith /* Push start scope on scope stack and make it current */ 89584491Smsmith 89684491Smsmith Status = AcpiDsScopeStackPush (MethodNode, ACPI_TYPE_METHOD, WalkState); 89784491Smsmith if (ACPI_FAILURE (Status)) 89884491Smsmith { 89984491Smsmith return_ACPI_STATUS (Status); 90084491Smsmith } 90184491Smsmith 90284491Smsmith /* Init the method arguments */ 90384491Smsmith 904151937Sjkim Status = AcpiDsMethodDataInitArgs (WalkState->Params, 905151937Sjkim ACPI_METHOD_NUM_ARGS, WalkState); 90699679Siwasaki if (ACPI_FAILURE (Status)) 90799679Siwasaki { 90899679Siwasaki return_ACPI_STATUS (Status); 90999679Siwasaki } 91084491Smsmith } 91184491Smsmith else 91284491Smsmith { 913114237Snjl /* 914102550Siwasaki * Setup the current scope. 915102550Siwasaki * Find a Named Op that has a namespace node associated with it. 916102550Siwasaki * search upwards from this Op. Current scope is the first 917102550Siwasaki * Op with a namespace node. 918102550Siwasaki */ 919102550Siwasaki ExtraOp = ParserState->StartOp; 920102550Siwasaki while (ExtraOp && !ExtraOp->Common.Node) 921102550Siwasaki { 922102550Siwasaki ExtraOp = ExtraOp->Common.Parent; 923102550Siwasaki } 924123315Snjl 925102550Siwasaki if (!ExtraOp) 926102550Siwasaki { 927102550Siwasaki ParserState->StartNode = NULL; 928102550Siwasaki } 929102550Siwasaki else 930102550Siwasaki { 931102550Siwasaki ParserState->StartNode = ExtraOp->Common.Node; 932102550Siwasaki } 933114237Snjl 93484491Smsmith if (ParserState->StartNode) 93584491Smsmith { 93684491Smsmith /* Push start scope on scope stack and make it current */ 93784491Smsmith 93884491Smsmith Status = AcpiDsScopeStackPush (ParserState->StartNode, 93984491Smsmith ParserState->StartNode->Type, WalkState); 94084491Smsmith if (ACPI_FAILURE (Status)) 94184491Smsmith { 94284491Smsmith return_ACPI_STATUS (Status); 94384491Smsmith } 94484491Smsmith } 94584491Smsmith } 94684491Smsmith 94799679Siwasaki Status = AcpiDsInitCallbacks (WalkState, PassNumber); 94899679Siwasaki return_ACPI_STATUS (Status); 94984491Smsmith} 95084491Smsmith 95184491Smsmith 95284491Smsmith/******************************************************************************* 95384491Smsmith * 95467754Smsmith * FUNCTION: AcpiDsDeleteWalkState 95567754Smsmith * 95667754Smsmith * PARAMETERS: WalkState - State to delete 95767754Smsmith * 95867754Smsmith * RETURN: Status 95967754Smsmith * 96067754Smsmith * DESCRIPTION: Delete a walk state including all internal data structures 96167754Smsmith * 96267754Smsmith ******************************************************************************/ 96367754Smsmith 96467754Smsmithvoid 96567754SmsmithAcpiDsDeleteWalkState ( 96667754Smsmith ACPI_WALK_STATE *WalkState) 96767754Smsmith{ 96867754Smsmith ACPI_GENERIC_STATE *State; 96967754Smsmith 97067754Smsmith 97191116Smsmith ACPI_FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState); 97267754Smsmith 97367754Smsmith 97467754Smsmith if (!WalkState) 97567754Smsmith { 97667754Smsmith return; 97767754Smsmith } 97867754Smsmith 97967754Smsmith if (WalkState->DataType != ACPI_DESC_TYPE_WALK) 98067754Smsmith { 981151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", 982151937Sjkim WalkState)); 98367754Smsmith return; 98467754Smsmith } 98567754Smsmith 98684491Smsmith if (WalkState->ParserState.Scope) 98784491Smsmith { 988151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", 989151937Sjkim WalkState)); 99084491Smsmith } 99167754Smsmith 992123315Snjl /* Always must free any linked control states */ 99384491Smsmith 99467754Smsmith while (WalkState->ControlState) 99567754Smsmith { 99667754Smsmith State = WalkState->ControlState; 99767754Smsmith WalkState->ControlState = State->Common.Next; 99867754Smsmith 99977424Smsmith AcpiUtDeleteGenericState (State); 100067754Smsmith } 100167754Smsmith 100267754Smsmith /* Always must free any linked parse states */ 100367754Smsmith 100467754Smsmith while (WalkState->ScopeInfo) 100567754Smsmith { 100667754Smsmith State = WalkState->ScopeInfo; 100767754Smsmith WalkState->ScopeInfo = State->Common.Next; 100867754Smsmith 100977424Smsmith AcpiUtDeleteGenericState (State); 101067754Smsmith } 101167754Smsmith 101269746Smsmith /* Always must free any stacked result states */ 101369746Smsmith 101469746Smsmith while (WalkState->Results) 101569746Smsmith { 101669746Smsmith State = WalkState->Results; 101769746Smsmith WalkState->Results = State->Common.Next; 101869746Smsmith 101977424Smsmith AcpiUtDeleteGenericState (State); 102069746Smsmith } 102169746Smsmith 1022151937Sjkim ACPI_MEM_FREE (WalkState); 102367754Smsmith return_VOID; 102467754Smsmith} 102567754Smsmith 102667754Smsmith 1027151937Sjkim#ifdef ACPI_OBSOLETE_FUNCTIONS 1028151937Sjkim/******************************************************************************* 102967754Smsmith * 1030151937Sjkim * FUNCTION: AcpiDsResultInsert 103167754Smsmith * 1032151937Sjkim * PARAMETERS: Object - Object to push 1033151937Sjkim * Index - Where to insert the object 1034151937Sjkim * WalkState - Current Walk state 103567754Smsmith * 103667754Smsmith * RETURN: Status 103767754Smsmith * 1038151937Sjkim * DESCRIPTION: Insert an object onto this walk's result stack 103967754Smsmith * 104067754Smsmith ******************************************************************************/ 104167754Smsmith 1042151937SjkimACPI_STATUS 1043151937SjkimAcpiDsResultInsert ( 1044151937Sjkim void *Object, 1045151937Sjkim UINT32 Index, 1046151937Sjkim ACPI_WALK_STATE *WalkState) 104767754Smsmith{ 1048151937Sjkim ACPI_GENERIC_STATE *State; 104967754Smsmith 105067754Smsmith 1051151937Sjkim ACPI_FUNCTION_NAME ("DsResultInsert"); 1052151937Sjkim 1053151937Sjkim 1054151937Sjkim State = WalkState->Results; 1055151937Sjkim if (!State) 1056151937Sjkim { 1057151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", 1058151937Sjkim WalkState)); 1059151937Sjkim return (AE_NOT_EXIST); 1060151937Sjkim } 1061151937Sjkim 1062151937Sjkim if (Index >= ACPI_OBJ_NUM_OPERANDS) 1063151937Sjkim { 1064151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 1065151937Sjkim "Index out of range: %X Obj=%p State=%p Num=%X\n", 1066151937Sjkim Index, Object, WalkState, State->Results.NumResults)); 1067151937Sjkim return (AE_BAD_PARAMETER); 1068151937Sjkim } 1069151937Sjkim 1070151937Sjkim if (!Object) 1071151937Sjkim { 1072151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 1073151937Sjkim "Null Object! Index=%X Obj=%p State=%p Num=%X\n", 1074151937Sjkim Index, Object, WalkState, State->Results.NumResults)); 1075151937Sjkim return (AE_BAD_PARAMETER); 1076151937Sjkim } 1077151937Sjkim 1078151937Sjkim State->Results.ObjDesc [Index] = Object; 1079151937Sjkim State->Results.NumResults++; 1080151937Sjkim 1081151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 1082151937Sjkim "Obj=%p [%s] State=%p Num=%X Cur=%X\n", 1083151937Sjkim Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL", 1084151937Sjkim WalkState, State->Results.NumResults, WalkState->CurrentResult)); 1085151937Sjkim 1086151937Sjkim return (AE_OK); 108767754Smsmith} 108867754Smsmith 108967754Smsmith 1090151937Sjkim/******************************************************************************* 1091151937Sjkim * 1092151937Sjkim * FUNCTION: AcpiDsObjStackDeleteAll 1093151937Sjkim * 1094151937Sjkim * PARAMETERS: WalkState - Current Walk state 1095151937Sjkim * 1096151937Sjkim * RETURN: Status 1097151937Sjkim * 1098151937Sjkim * DESCRIPTION: Clear the object stack by deleting all objects that are on it. 1099151937Sjkim * Should be used with great care, if at all! 1100151937Sjkim * 1101151937Sjkim ******************************************************************************/ 1102151937Sjkim 1103151937SjkimACPI_STATUS 1104151937SjkimAcpiDsObjStackDeleteAll ( 1105151937Sjkim ACPI_WALK_STATE *WalkState) 1106151937Sjkim{ 1107151937Sjkim UINT32 i; 1108151937Sjkim 1109151937Sjkim 1110151937Sjkim ACPI_FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState); 1111151937Sjkim 1112151937Sjkim 1113151937Sjkim /* The stack size is configurable, but fixed */ 1114151937Sjkim 1115151937Sjkim for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) 1116151937Sjkim { 1117151937Sjkim if (WalkState->Operands[i]) 1118151937Sjkim { 1119151937Sjkim AcpiUtRemoveReference (WalkState->Operands[i]); 1120151937Sjkim WalkState->Operands[i] = NULL; 1121151937Sjkim } 1122151937Sjkim } 1123151937Sjkim 1124151937Sjkim return_ACPI_STATUS (AE_OK); 1125151937Sjkim} 1126151937Sjkim 1127151937Sjkim 1128151937Sjkim/******************************************************************************* 1129151937Sjkim * 1130151937Sjkim * FUNCTION: AcpiDsObjStackPopObject 1131151937Sjkim * 1132151937Sjkim * PARAMETERS: Object - Where to return the popped object 1133151937Sjkim * WalkState - Current Walk state 1134151937Sjkim * 1135151937Sjkim * RETURN: Status 1136151937Sjkim * 1137151937Sjkim * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT 1138151937Sjkim * deleted by this routine. 1139151937Sjkim * 1140151937Sjkim ******************************************************************************/ 1141151937Sjkim 1142151937SjkimACPI_STATUS 1143151937SjkimAcpiDsObjStackPopObject ( 1144151937Sjkim ACPI_OPERAND_OBJECT **Object, 1145151937Sjkim ACPI_WALK_STATE *WalkState) 1146151937Sjkim{ 1147151937Sjkim ACPI_FUNCTION_NAME ("DsObjStackPopObject"); 1148151937Sjkim 1149151937Sjkim 1150151937Sjkim /* Check for stack underflow */ 1151151937Sjkim 1152151937Sjkim if (WalkState->NumOperands == 0) 1153151937Sjkim { 1154151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 1155151937Sjkim "Missing operand/stack empty! State=%p #Ops=%X\n", 1156151937Sjkim WalkState, WalkState->NumOperands)); 1157151937Sjkim *Object = NULL; 1158151937Sjkim return (AE_AML_NO_OPERAND); 1159151937Sjkim } 1160151937Sjkim 1161151937Sjkim /* Pop the stack */ 1162151937Sjkim 1163151937Sjkim WalkState->NumOperands--; 1164151937Sjkim 1165151937Sjkim /* Check for a valid operand */ 1166151937Sjkim 1167151937Sjkim if (!WalkState->Operands [WalkState->NumOperands]) 1168151937Sjkim { 1169151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 1170151937Sjkim "Null operand! State=%p #Ops=%X\n", 1171151937Sjkim WalkState, WalkState->NumOperands)); 1172151937Sjkim *Object = NULL; 1173151937Sjkim return (AE_AML_NO_OPERAND); 1174151937Sjkim } 1175151937Sjkim 1176151937Sjkim /* Get operand and set stack entry to null */ 1177151937Sjkim 1178151937Sjkim *Object = WalkState->Operands [WalkState->NumOperands]; 1179151937Sjkim WalkState->Operands [WalkState->NumOperands] = NULL; 1180151937Sjkim 1181151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", 1182151937Sjkim *Object, AcpiUtGetObjectTypeName (*Object), 1183151937Sjkim WalkState, WalkState->NumOperands)); 1184151937Sjkim 1185151937Sjkim return (AE_OK); 1186151937Sjkim} 1187151937Sjkim 1188151937Sjkim 1189151937Sjkim/******************************************************************************* 1190151937Sjkim * 1191151937Sjkim * FUNCTION: AcpiDsObjStackGetValue 1192151937Sjkim * 1193151937Sjkim * PARAMETERS: Index - Stack index whose value is desired. Based 1194151937Sjkim * on the top of the stack (index=0 == top) 1195151937Sjkim * WalkState - Current Walk state 1196151937Sjkim * 1197151937Sjkim * RETURN: Pointer to the requested operand 1198151937Sjkim * 1199151937Sjkim * DESCRIPTION: Retrieve an object from this walk's operand stack. Index must 1200151937Sjkim * be within the range of the current stack pointer. 1201151937Sjkim * 1202151937Sjkim ******************************************************************************/ 1203151937Sjkim 1204151937Sjkimvoid * 1205151937SjkimAcpiDsObjStackGetValue ( 1206151937Sjkim UINT32 Index, 1207151937Sjkim ACPI_WALK_STATE *WalkState) 1208151937Sjkim{ 1209151937Sjkim 1210151937Sjkim ACPI_FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState); 1211151937Sjkim 1212151937Sjkim 1213151937Sjkim /* Can't do it if the stack is empty */ 1214151937Sjkim 1215151937Sjkim if (WalkState->NumOperands == 0) 1216151937Sjkim { 1217151937Sjkim return_PTR (NULL); 1218151937Sjkim } 1219151937Sjkim 1220151937Sjkim /* or if the index is past the top of the stack */ 1221151937Sjkim 1222151937Sjkim if (Index > (WalkState->NumOperands - (UINT32) 1)) 1223151937Sjkim { 1224151937Sjkim return_PTR (NULL); 1225151937Sjkim } 1226151937Sjkim 1227151937Sjkim return_PTR (WalkState->Operands[(ACPI_NATIVE_UINT)(WalkState->NumOperands - 1) - 1228151937Sjkim Index]); 1229151937Sjkim} 1230151937Sjkim#endif 1231151937Sjkim 1232151937Sjkim 1233