From c8d9ab124de90f9d7acea4de7dd86cd64e5e5f1a Mon Sep 17 00:00:00 2001 From: aystarik Date: Wed, 29 Jun 2005 17:15:02 +0000 Subject: [PATCH] Global rename of identifiers and constants date 2000.06.13.18.19.00; author rmoore1; state Exp; --- source/components/dispatcher/dswscope.c | 30 +- source/components/dispatcher/dswstate.c | 804 ++++++------------- source/components/executer/exconfig.c | 580 ++++++-------- source/components/executer/excreate.c | 976 +++++++++++++++--------- 4 files changed, 1079 insertions(+), 1311 deletions(-) diff --git a/source/components/dispatcher/dswscope.c b/source/components/dispatcher/dswscope.c index 3aae2dce1..9f07f76c9 100644 --- a/source/components/dispatcher/dswscope.c +++ b/source/components/dispatcher/dswscope.c @@ -116,9 +116,9 @@ #define __DSWSCOPE_C__ -#include -#include -#include +#include "acpi.h" +#include "interp.h" +#include "dispatch.h" #define _COMPONENT NAMESPACE @@ -131,7 +131,7 @@ /**************************************************************************** * - * FUNCTION: DsScopeStackClear + * FUNCTION: AcpiDsScopeStackClear * * PARAMETERS: None * @@ -141,7 +141,7 @@ ***************************************************************************/ void -DsScopeStackClear ( +AcpiDsScopeStackClear ( ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *ScopeInfo; @@ -155,7 +155,7 @@ DsScopeStackClear ( WalkState->ScopeInfo = ScopeInfo->Scope.Next; DEBUG_PRINT (TRACE_EXEC, ("Popped object type 0x%X\n", ScopeInfo->Common.Value)); - CmDeleteGenericState (ScopeInfo); + AcpiCmDeleteGenericState (ScopeInfo); } } @@ -163,7 +163,7 @@ DsScopeStackClear ( /**************************************************************************** * - * FUNCTION: DsScopeStackPush + * FUNCTION: AcpiDsScopeStackPush * * PARAMETERS: *NewScope, - Name to be made current * Type, - Type of frame being pushed @@ -174,7 +174,7 @@ DsScopeStackClear ( ***************************************************************************/ ACPI_STATUS -DsScopeStackPush ( +AcpiDsScopeStackPush ( NAME_TABLE_ENTRY *NewScope, OBJECT_TYPE_INTERNAL Type, ACPI_WALK_STATE *WalkState) @@ -195,7 +195,7 @@ DsScopeStackPush ( /* Make sure object type is valid */ - if (!AmlValidateObjectType (Type)) + if (!AcpiAmlValidateObjectType (Type)) { REPORT_WARNING ("DsScopeStackPush: type code out of range"); } @@ -203,7 +203,7 @@ DsScopeStackPush ( /* Allocate a new scope object */ - ScopeInfo = CmCreateGenericState (); + ScopeInfo = AcpiCmCreateGenericState (); if (!ScopeInfo) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -216,7 +216,7 @@ DsScopeStackPush ( /* Push new scope object onto stack */ - CmPushGenericState (&WalkState->ScopeInfo, ScopeInfo); + AcpiCmPushGenericState (&WalkState->ScopeInfo, ScopeInfo); return_ACPI_STATUS (AE_OK); } @@ -224,7 +224,7 @@ DsScopeStackPush ( /**************************************************************************** * - * FUNCTION: DsScopeStackPop + * FUNCTION: AcpiDsScopeStackPop * * PARAMETERS: Type - The type of frame to be found * @@ -240,7 +240,7 @@ DsScopeStackPush ( ***************************************************************************/ ACPI_STATUS -DsScopeStackPop ( +AcpiDsScopeStackPop ( ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *ScopeInfo; @@ -252,7 +252,7 @@ DsScopeStackPop ( * Pop scope info object off the stack. */ - ScopeInfo = CmPopGenericState (&WalkState->ScopeInfo); + ScopeInfo = AcpiCmPopGenericState (&WalkState->ScopeInfo); if (!ScopeInfo) { return_ACPI_STATUS (AE_STACK_UNDERFLOW); @@ -260,7 +260,7 @@ DsScopeStackPop ( DEBUG_PRINT (TRACE_EXEC, ("Popped object type 0x%X\n", ScopeInfo->Common.Value)); - CmDeleteGenericState (ScopeInfo); + AcpiCmDeleteGenericState (ScopeInfo); return_ACPI_STATUS (AE_OK); } diff --git a/source/components/dispatcher/dswstate.c b/source/components/dispatcher/dswstate.c index 181bad3d4..638644241 100644 --- a/source/components/dispatcher/dswstate.c +++ b/source/components/dispatcher/dswstate.c @@ -1,7 +1,6 @@ /****************************************************************************** - * + * * Module Name: dswstate - Dispatcher parse tree walk management routines - * $Revision: 1.72 $ * *****************************************************************************/ @@ -9,8 +8,8 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. - * All rights reserved. + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. * * 2. License * @@ -38,9 +37,9 @@ * The above copyright and patent license is granted only if the following * conditions are met: * - * 3. Conditions + * 3. Conditions * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, @@ -48,11 +47,11 @@ * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee + * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the @@ -86,7 +85,7 @@ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. + * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR @@ -118,331 +117,40 @@ #define __DSWSTATE_C__ #include "acpi.h" -#include "acparser.h" -#include "acdispat.h" -#include "acnamesp.h" +#include "amlcode.h" +#include "parser.h" +#include "dispatch.h" +#include "namesp.h" +#include "interp.h" + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dswstate"); + -#define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dswstate") /******************************************************************************* * - * FUNCTION: AcpiDsResultInsert + * FUNCTION: AcpiDsResultStackClear * - * PARAMETERS: Object - Object to push - * WalkState - Current Walk state + * PARAMETERS: WalkState - Current Walk state * * RETURN: Status * - * DESCRIPTION: Push an object onto this walk's result stack + * DESCRIPTION: Reset this walk's result stack pointers to zero, thus setting + * the stack to zero. * ******************************************************************************/ ACPI_STATUS -AcpiDsResultInsert ( - void *Object, - UINT32 Index, +AcpiDsResultStackClear ( ACPI_WALK_STATE *WalkState) { - ACPI_GENERIC_STATE *State; + WalkState->NumResults = 0; + WalkState->CurrentResult = 0; - ACPI_FUNCTION_NAME ("DsResultInsert"); - - - State = WalkState->Results; - if (!State) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", - WalkState)); - return (AE_NOT_EXIST); - } - - if (Index >= ACPI_OBJ_NUM_OPERANDS) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Index out of range: %X Obj=%p State=%p Num=%X\n", - Index, Object, WalkState, State->Results.NumResults)); - return (AE_BAD_PARAMETER); - } - - if (!Object) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null Object! Index=%X Obj=%p State=%p Num=%X\n", - Index, Object, WalkState, State->Results.NumResults)); - return (AE_BAD_PARAMETER); - } - - State->Results.ObjDesc [Index] = Object; - State->Results.NumResults++; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Obj=%p [%s] State=%p Num=%X Cur=%X\n", - Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL", - WalkState, State->Results.NumResults, WalkState->CurrentResult)); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsResultRemove - * - * PARAMETERS: Object - Where to return the popped object - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In - * other words, this is a FIFO. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsResultRemove ( - ACPI_OPERAND_OBJECT **Object, - UINT32 Index, - ACPI_WALK_STATE *WalkState) -{ - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_NAME ("DsResultRemove"); - - - State = WalkState->Results; - if (!State) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", - WalkState)); - return (AE_NOT_EXIST); - } - - if (Index >= ACPI_OBJ_MAX_OPERAND) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Index out of range: %X State=%p Num=%X\n", - Index, WalkState, State->Results.NumResults)); - } - - /* Check for a valid result object */ - - if (!State->Results.ObjDesc [Index]) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null operand! State=%p #Ops=%X, Index=%X\n", - WalkState, State->Results.NumResults, Index)); - return (AE_AML_NO_RETURN_VALUE); - } - - /* Remove the object */ - - State->Results.NumResults--; - - *Object = State->Results.ObjDesc [Index]; - State->Results.ObjDesc [Index] = NULL; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Obj=%p [%s] Index=%X State=%p Num=%X\n", - *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", - Index, WalkState, State->Results.NumResults)); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsResultPop - * - * PARAMETERS: Object - Where to return the popped object - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In - * other words, this is a FIFO. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsResultPop ( - ACPI_OPERAND_OBJECT **Object, - ACPI_WALK_STATE *WalkState) -{ - NATIVE_UINT Index; - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_NAME ("DsResultPop"); - - - State = WalkState->Results; - if (!State) - { - return (AE_OK); - } - - if (!State->Results.NumResults) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack is empty! State=%p\n", - WalkState)); - return (AE_AML_NO_RETURN_VALUE); - } - - /* Remove top element */ - - State->Results.NumResults--; - - for (Index = ACPI_OBJ_NUM_OPERANDS; Index; Index--) - { - /* Check for a valid result object */ - - if (State->Results.ObjDesc [Index -1]) - { - *Object = State->Results.ObjDesc [Index -1]; - State->Results.ObjDesc [Index -1] = NULL; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n", - *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", - (UINT32) Index -1, WalkState, State->Results.NumResults)); - - return (AE_OK); - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState)); - return (AE_AML_NO_RETURN_VALUE); -} - -/******************************************************************************* - * - * FUNCTION: AcpiDsResultPopFromBottom - * - * PARAMETERS: Object - Where to return the popped object - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In - * other words, this is a FIFO. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsResultPopFromBottom ( - ACPI_OPERAND_OBJECT **Object, - ACPI_WALK_STATE *WalkState) -{ - NATIVE_UINT Index; - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_NAME ("DsResultPopFromBottom"); - - - State = WalkState->Results; - if (!State) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Warning: No result object pushed! State=%p\n", WalkState)); - return (AE_NOT_EXIST); - } - - if (!State->Results.NumResults) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState)); - return (AE_AML_NO_RETURN_VALUE); - } - - /* Remove Bottom element */ - - *Object = State->Results.ObjDesc [0]; - - /* Push entire stack down one element */ - - for (Index = 0; Index < State->Results.NumResults; Index++) - { - State->Results.ObjDesc [Index] = State->Results.ObjDesc [Index + 1]; - } - - State->Results.NumResults--; - - /* Check for a valid result object */ - - if (!*Object) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X, Index=%X\n", - WalkState, State->Results.NumResults, (UINT32) Index)); - return (AE_AML_NO_RETURN_VALUE); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s], Results=%p State=%p\n", - *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", - State, WalkState)); - - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsResultPush - * - * PARAMETERS: Object - Where to return the popped object - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Push an object onto the current result stack - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsResultPush ( - ACPI_OPERAND_OBJECT *Object, - ACPI_WALK_STATE *WalkState) -{ - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_NAME ("DsResultPush"); - - - State = WalkState->Results; - if (!State) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result stack frame\n")); - return (AE_AML_INTERNAL); - } - - if (State->Results.NumResults == ACPI_OBJ_NUM_OPERANDS) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Result stack overflow: Obj=%p State=%p Num=%X\n", - Object, WalkState, State->Results.NumResults)); - return (AE_STACK_OVERFLOW); - } - - if (!Object) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Object! Obj=%p State=%p Num=%X\n", - Object, WalkState, State->Results.NumResults)); - return (AE_BAD_PARAMETER); - } - - State->Results.ObjDesc [State->Results.NumResults] = Object; - State->Results.NumResults++; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", - Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL", - WalkState, State->Results.NumResults, WalkState->CurrentResult)); - - return (AE_OK); + return AE_OK; } @@ -455,32 +163,31 @@ AcpiDsResultPush ( * * RETURN: Status * - * DESCRIPTION: Push an object onto the WalkState result stack. + * DESCRIPTION: Push an object onto this walk's result stack * ******************************************************************************/ ACPI_STATUS AcpiDsResultStackPush ( + void *Object, ACPI_WALK_STATE *WalkState) { - ACPI_GENERIC_STATE *State; - - ACPI_FUNCTION_NAME ("DsResultStackPush"); - State = AcpiUtCreateGenericState (); - if (!State) + if (WalkState->NumResults >= OBJ_NUM_OPERANDS) { - return (AE_NO_MEMORY); + DEBUG_PRINT (ACPI_ERROR, ("DsResultStackPush: overflow! Obj=%p State=%p Num=%X\n", + Object, WalkState, WalkState->NumResults)); + return AE_STACK_OVERFLOW; } - State->Common.DataType = ACPI_DESC_TYPE_STATE_RESULT; - AcpiUtPushGenericState (&WalkState->Results, State); + WalkState->Results [WalkState->NumResults] = Object; + WalkState->NumResults++; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n", - State, WalkState)); + DEBUG_PRINT (TRACE_EXEC, ("DsResultStackPush: Obj=%p State=%p Num=%X Cur=%X\n", + Object, WalkState, WalkState->NumResults, WalkState->CurrentResult)); - return (AE_OK); + return AE_OK; } @@ -488,42 +195,55 @@ AcpiDsResultStackPush ( * * FUNCTION: AcpiDsResultStackPop * - * PARAMETERS: WalkState - Current Walk state + * PARAMETERS: Object - Where to return the popped object + * WalkState - Current Walk state * * RETURN: Status * - * DESCRIPTION: Pop an object off of the WalkState result stack. + * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In + * other words, this is a FIFO. * ******************************************************************************/ ACPI_STATUS AcpiDsResultStackPop ( + ACPI_OBJECT_INTERNAL **Object, ACPI_WALK_STATE *WalkState) { - ACPI_GENERIC_STATE *State; - - ACPI_FUNCTION_NAME ("DsResultStackPop"); /* Check for stack underflow */ - if (WalkState->Results == NULL) + if (WalkState->NumResults == 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Underflow - State=%p\n", - WalkState)); - return (AE_AML_NO_OPERAND); + DEBUG_PRINT (ACPI_ERROR, ("DsResultStackPop: Underflow! State=%p Cur=%X Num=%X\n", + WalkState, WalkState->CurrentResult, WalkState->NumResults)); + return AE_AML_NO_OPERAND; } - State = AcpiUtPopGenericState (&WalkState->Results); + /* Pop the stack */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Result=%p RemainingResults=%X State=%p\n", - State, State->Results.NumResults, WalkState)); + WalkState->NumResults--; - AcpiUtDeleteGenericState (State); + /* Check for a valid result object */ - return (AE_OK); + if (!WalkState->Results [WalkState->NumResults]) + { + DEBUG_PRINT (ACPI_ERROR, ("DsResultStackPop: Null operand! State=%p #Ops=%X\n", + WalkState, WalkState->NumResults)); + return AE_AML_NO_OPERAND; + } + + + *Object = WalkState->Results [WalkState->NumResults]; + WalkState->Results [WalkState->NumResults] = NULL; + + + DEBUG_PRINT (TRACE_EXEC, ("DsResultStackPop: Obj=%p State=%p Num=%X Cur=%X\n", + *Object, WalkState, WalkState->NumResults, WalkState->CurrentResult)); + + return AE_OK; } @@ -547,16 +267,16 @@ AcpiDsObjStackDeleteAll ( UINT32 i; - ACPI_FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState); + FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState); /* The stack size is configurable, but fixed */ - for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) + for (i = 0; i < OBJ_NUM_OPERANDS; i++) { if (WalkState->Operands[i]) { - AcpiUtRemoveReference (WalkState->Operands[i]); + AcpiCmRemoveReference (WalkState->Operands[i]); WalkState->Operands[i] = NULL; } } @@ -565,6 +285,7 @@ AcpiDsObjStackDeleteAll ( } + /******************************************************************************* * * FUNCTION: AcpiDsObjStackPush @@ -583,17 +304,15 @@ AcpiDsObjStackPush ( void *Object, ACPI_WALK_STATE *WalkState) { - ACPI_FUNCTION_NAME ("DsObjStackPush"); /* Check for stack overflow */ - if (WalkState->NumOperands >= ACPI_OBJ_NUM_OPERANDS) + if (WalkState->NumOperands >= OBJ_NUM_OPERANDS) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "overflow! Obj=%p State=%p #Ops=%X\n", - Object, WalkState, WalkState->NumOperands)); - return (AE_STACK_OVERFLOW); + DEBUG_PRINT (ACPI_ERROR, ("DsObjStackPush: overflow! Obj=%p State=%p #Ops=%X\n", + Object, WalkState, WalkState->NumOperands)); + return AE_STACK_OVERFLOW; } /* Put the object onto the stack */ @@ -601,15 +320,13 @@ AcpiDsObjStackPush ( WalkState->Operands [WalkState->NumOperands] = Object; WalkState->NumOperands++; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", - Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), - WalkState, WalkState->NumOperands)); + DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPush: Obj=%p State=%p #Ops=%X\n", + Object, WalkState, WalkState->NumOperands)); - return (AE_OK); + return AE_OK; } -#if 0 /******************************************************************************* * * FUNCTION: AcpiDsObjStackPopObject @@ -626,23 +343,21 @@ AcpiDsObjStackPush ( ACPI_STATUS AcpiDsObjStackPopObject ( - ACPI_OPERAND_OBJECT **Object, + ACPI_OBJECT_INTERNAL **Object, ACPI_WALK_STATE *WalkState) { - ACPI_FUNCTION_NAME ("DsObjStackPopObject"); /* Check for stack underflow */ if (WalkState->NumOperands == 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Missing operand/stack empty! State=%p #Ops=%X\n", - WalkState, WalkState->NumOperands)); - *Object = NULL; - return (AE_AML_NO_OPERAND); + DEBUG_PRINT (ACPI_ERROR, ("DsObjStackPop: Missing operand/stack empty! State=%p #Ops=%X\n", + WalkState, WalkState->NumOperands)); + return AE_AML_NO_OPERAND; } + /* Pop the stack */ WalkState->NumOperands--; @@ -651,11 +366,9 @@ AcpiDsObjStackPopObject ( if (!WalkState->Operands [WalkState->NumOperands]) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null operand! State=%p #Ops=%X\n", - WalkState, WalkState->NumOperands)); - *Object = NULL; - return (AE_AML_NO_OPERAND); + DEBUG_PRINT (ACPI_ERROR, ("DsObjStackPop: Null operand! State=%p #Ops=%X\n", + WalkState, WalkState->NumOperands)); + return AE_AML_NO_OPERAND; } /* Get operand and set stack entry to null */ @@ -663,17 +376,16 @@ AcpiDsObjStackPopObject ( *Object = WalkState->Operands [WalkState->NumOperands]; WalkState->Operands [WalkState->NumOperands] = NULL; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", - *Object, AcpiUtGetObjectTypeName (*Object), + DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPopObject: State=%p #Ops=%X\n", WalkState, WalkState->NumOperands)); - return (AE_OK); + return AE_OK; } -#endif + /******************************************************************************* * - * FUNCTION: AcpiDsObjStackPop + * FUNCTION: AcpiDsObjStackPop * * PARAMETERS: PopCount - Number of objects/entries to pop * WalkState - Current Walk state @@ -692,7 +404,6 @@ AcpiDsObjStackPop ( { UINT32 i; - ACPI_FUNCTION_NAME ("DsObjStackPop"); for (i = 0; i < PopCount; i++) @@ -701,10 +412,9 @@ AcpiDsObjStackPop ( if (WalkState->NumOperands == 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Underflow! Count=%X State=%p #Ops=%X\n", - PopCount, WalkState, WalkState->NumOperands)); - return (AE_STACK_UNDERFLOW); + DEBUG_PRINT (ACPI_ERROR, ("DsObjStackPop: Underflow! Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); + return AE_STACK_UNDERFLOW; } /* Just set the stack entry to null */ @@ -713,13 +423,13 @@ AcpiDsObjStackPop ( WalkState->Operands [WalkState->NumOperands] = NULL; } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", + DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPop: Count=%X State=%p #Ops=%X\n", PopCount, WalkState, WalkState->NumOperands)); - return (AE_OK); + return AE_OK; } - + /******************************************************************************* * * FUNCTION: AcpiDsObjStackPopAndDelete @@ -740,9 +450,7 @@ AcpiDsObjStackPopAndDelete ( ACPI_WALK_STATE *WalkState) { UINT32 i; - ACPI_OPERAND_OBJECT *ObjDesc; - - ACPI_FUNCTION_NAME ("DsObjStackPopAndDelete"); + ACPI_OBJECT_INTERNAL *ObjDesc; for (i = 0; i < PopCount; i++) @@ -751,10 +459,9 @@ AcpiDsObjStackPopAndDelete ( if (WalkState->NumOperands == 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Underflow! Count=%X State=%p #Ops=%X\n", - PopCount, WalkState, WalkState->NumOperands)); - return (AE_STACK_UNDERFLOW); + DEBUG_PRINT (ACPI_ERROR, ("DsObjStackPop: Underflow! Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); + return AE_STACK_UNDERFLOW; } /* Pop the stack and delete an object if present in this stack entry */ @@ -763,21 +470,21 @@ AcpiDsObjStackPopAndDelete ( ObjDesc = WalkState->Operands [WalkState->NumOperands]; if (ObjDesc) { - AcpiUtRemoveReference (WalkState->Operands [WalkState->NumOperands]); + AcpiCmRemoveReference (WalkState->Operands [WalkState->NumOperands]); WalkState->Operands [WalkState->NumOperands] = NULL; } } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", + DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPop: Count=%X State=%p #Ops=%X\n", PopCount, WalkState, WalkState->NumOperands)); - return (AE_OK); + return AE_OK; } - + /******************************************************************************* * - * FUNCTION: AcpiDsObjStackGetValue + * FUNCTION: AcpiDsObjStackGetValue * * PARAMETERS: Index - Stack index whose value is desired. Based * on the top of the stack (index=0 == top) @@ -796,58 +503,57 @@ AcpiDsObjStackGetValue ( ACPI_WALK_STATE *WalkState) { - ACPI_FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState); + FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState); /* Can't do it if the stack is empty */ if (WalkState->NumOperands == 0) { - return_PTR (NULL); + return_VALUE (NULL); } /* or if the index is past the top of the stack */ if (Index > (WalkState->NumOperands - (UINT32) 1)) { - return_PTR (NULL); + return_VALUE (NULL); } - return_PTR (WalkState->Operands[(NATIVE_UINT)(WalkState->NumOperands - 1) - - Index]); + + return_PTR (WalkState->Operands [(NATIVE_UINT) (WalkState->NumOperands - 1) - Index]); } + + /******************************************************************************* * * FUNCTION: AcpiDsGetCurrentWalkState * - * PARAMETERS: Thread - Get current active state for this Thread + * PARAMETERS: WalkList - Get current active state for this walk list * * RETURN: Pointer to the current walk state * * DESCRIPTION: Get the walk state that is at the head of the list (the "current" - * walk state.) + * walk state. * ******************************************************************************/ ACPI_WALK_STATE * AcpiDsGetCurrentWalkState ( - ACPI_THREAD_STATE *Thread) + ACPI_WALK_LIST *WalkList) { - ACPI_FUNCTION_NAME ("DsGetCurrentWalkState"); + DEBUG_PRINT (TRACE_PARSE, ("DsGetCurrentWalkState, =%p\n", WalkList->WalkState)); - if (!Thread) + if (!WalkList) { - return (NULL); + return NULL; } - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "DsGetCurrentWalkState, =%p\n", - Thread->WalkStateList)); - - return (Thread->WalkStateList); + return WalkList->WalkState; } @@ -867,13 +573,15 @@ AcpiDsGetCurrentWalkState ( void AcpiDsPushWalkState ( ACPI_WALK_STATE *WalkState, - ACPI_THREAD_STATE *Thread) + ACPI_WALK_LIST *WalkList) { - ACPI_FUNCTION_TRACE ("DsPushWalkState"); - WalkState->Next = Thread->WalkStateList; - Thread->WalkStateList = WalkState; + FUNCTION_TRACE ("DsPushWalkState"); + + + WalkState->Next = WalkList->WalkState; + WalkList->WalkState = WalkState; return_VOID; } @@ -881,40 +589,40 @@ AcpiDsPushWalkState ( /******************************************************************************* * - * FUNCTION: AcpiDsPopWalkState + * FUNCTION: AcpiDsPopWalkState * * PARAMETERS: WalkList - The list that owns the walk stack * * RETURN: A WalkState object popped from the stack * * DESCRIPTION: Remove and return the walkstate object that is at the head of - * the walk stack for the given walk list. NULL indicates that + * the walk stack for the given walk list. NULL indicates that * the list is empty. * ******************************************************************************/ ACPI_WALK_STATE * AcpiDsPopWalkState ( - ACPI_THREAD_STATE *Thread) + ACPI_WALK_LIST *WalkList) { ACPI_WALK_STATE *WalkState; - ACPI_FUNCTION_TRACE ("DsPopWalkState"); + FUNCTION_TRACE ("DsPopWalkState"); - WalkState = Thread->WalkStateList; + WalkState = WalkList->WalkState; if (WalkState) { /* Next walk state becomes the current walk state */ - Thread->WalkStateList = WalkState->Next; + WalkList->WalkState = WalkState->Next; - /* + /* * Don't clear the NEXT field, this serves as an indicator - * that there is a parent WALK STATE - * NO: WalkState->Next = NULL; + * that there is a parent WALK STATE + * WalkState->Next = NULL; */ } @@ -927,179 +635,76 @@ AcpiDsPopWalkState ( * FUNCTION: AcpiDsCreateWalkState * * PARAMETERS: Origin - Starting point for this walk - * Thread - Current thread state + * WalkList - Owning walk list * * RETURN: Pointer to the new walk state. * - * DESCRIPTION: Allocate and initialize a new walk state. The current walk - * state is set to this new state. + * DESCRIPTION: Allocate and initialize a new walk state. The current walk state + * is set to this new state. * ******************************************************************************/ ACPI_WALK_STATE * AcpiDsCreateWalkState ( ACPI_OWNER_ID OwnerId, - ACPI_PARSE_OBJECT *Origin, - ACPI_OPERAND_OBJECT *MthDesc, - ACPI_THREAD_STATE *Thread) + ACPI_GENERIC_OP *Origin, + ACPI_OBJECT_INTERNAL *MthDesc, + ACPI_WALK_LIST *WalkList) { ACPI_WALK_STATE *WalkState; - ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("DsCreateWalkState"); + FUNCTION_TRACE ("DsCreateWalkState"); - WalkState = AcpiUtAcquireFromCache (ACPI_MEM_LIST_WALK); - if (!WalkState) + AcpiCmAcquireMutex (MTX_CACHES); + Acpi_GblWalkStateCacheRequests++; + + /* Check the cache first */ + + if (Acpi_GblWalkStateCache) { - return_PTR (NULL); + /* There is an object available, use it */ + + WalkState = Acpi_GblWalkStateCache; + Acpi_GblWalkStateCache = WalkState->Next; + + Acpi_GblWalkStateCacheHits++; + Acpi_GblWalkStateCacheDepth--; + + AcpiCmReleaseMutex (MTX_CACHES); + } + + else + { + /* The cache is empty, create a new object */ + + AcpiCmReleaseMutex (MTX_CACHES); /* Avoid deadlock with AcpiCmCallocate */ + + WalkState = AcpiCmCallocate (sizeof (ACPI_WALK_STATE)); + if (!WalkState) + { + return_VALUE (NULL); + } } - WalkState->DataType = ACPI_DESC_TYPE_WALK; - WalkState->OwnerId = OwnerId; + WalkState->DataType = DESC_TYPE_WALK; + WalkState->OwnerId = OwnerId; WalkState->Origin = Origin; WalkState->MethodDesc = MthDesc; - WalkState->Thread = Thread; - - WalkState->ParserState.StartOp = Origin; /* Init the method args/local */ -#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) AcpiDsMethodDataInit (WalkState); -#endif - - /* Create an initial result stack entry */ - - Status = AcpiDsResultStackPush (WalkState); - if (ACPI_FAILURE (Status)) - { - return_PTR (NULL); - } /* Put the new state at the head of the walk list */ - if (Thread) - { - AcpiDsPushWalkState (WalkState, Thread); - } + AcpiDsPushWalkState (WalkState, WalkList); return_PTR (WalkState); } -/******************************************************************************* - * - * FUNCTION: AcpiDsInitAmlWalk - * - * PARAMETERS: WalkState - New state to be initialized - * - * RETURN: None - * - * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsInitAmlWalk ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op, - ACPI_NAMESPACE_NODE *MethodNode, - UINT8 *AmlStart, - UINT32 AmlLength, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc, - UINT32 PassNumber) -{ - ACPI_STATUS Status; - ACPI_PARSE_STATE *ParserState = &WalkState->ParserState; - ACPI_PARSE_OBJECT *ExtraOp; - - - ACPI_FUNCTION_TRACE ("DsInitAmlWalk"); - - - WalkState->ParserState.Aml = - WalkState->ParserState.AmlStart = AmlStart; - WalkState->ParserState.AmlEnd = - WalkState->ParserState.PkgEnd = AmlStart + AmlLength; - - /* The NextOp of the NextWalk will be the beginning of the method */ - - WalkState->NextOp = NULL; - WalkState->Params = Params; - WalkState->CallerReturnDesc = ReturnObjDesc; - - Status = AcpiPsInitScope (&WalkState->ParserState, Op); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - if (MethodNode) - { - WalkState->ParserState.StartNode = MethodNode; - WalkState->WalkType = ACPI_WALK_METHOD; - WalkState->MethodNode = MethodNode; - WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode); - - /* Push start scope on scope stack and make it current */ - - Status = AcpiDsScopeStackPush (MethodNode, ACPI_TYPE_METHOD, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Init the method arguments */ - - Status = AcpiDsMethodDataInitArgs (Params, ACPI_METHOD_NUM_ARGS, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - else - { - /* - * Setup the current scope. - * Find a Named Op that has a namespace node associated with it. - * search upwards from this Op. Current scope is the first - * Op with a namespace node. - */ - ExtraOp = ParserState->StartOp; - while (ExtraOp && !ExtraOp->Common.Node) - { - ExtraOp = ExtraOp->Common.Parent; - } - if (!ExtraOp) - { - ParserState->StartNode = NULL; - } - else - { - ParserState->StartNode = ExtraOp->Common.Node; - } - - if (ParserState->StartNode) - { - /* Push start scope on scope stack and make it current */ - - Status = AcpiDsScopeStackPush (ParserState->StartNode, - ParserState->StartNode->Type, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - } - - Status = AcpiDsInitCallbacks (WalkState, PassNumber); - return_ACPI_STATUS (Status); -} - - /******************************************************************************* * * FUNCTION: AcpiDsDeleteWalkState @@ -1119,7 +724,7 @@ AcpiDsDeleteWalkState ( ACPI_GENERIC_STATE *State; - ACPI_FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState); + FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState); if (!WalkState) @@ -1127,27 +732,23 @@ AcpiDsDeleteWalkState ( return; } - if (WalkState->DataType != ACPI_DESC_TYPE_WALK) + if (WalkState->DataType != DESC_TYPE_WALK) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", WalkState)); + DEBUG_PRINT (ACPI_ERROR, ("DsDeleteWalkState: **** %p not a valid walk state\n", WalkState)); return; } - if (WalkState->ParserState.Scope) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", WalkState)); - } - - /* Always must free any linked control states */ + /* Always must free any linked control states */ while (WalkState->ControlState) { State = WalkState->ControlState; WalkState->ControlState = State->Common.Next; - AcpiUtDeleteGenericState (State); + AcpiCmDeleteGenericState (State); } + /* Always must free any linked parse states */ while (WalkState->ScopeInfo) @@ -1155,20 +756,37 @@ AcpiDsDeleteWalkState ( State = WalkState->ScopeInfo; WalkState->ScopeInfo = State->Common.Next; - AcpiUtDeleteGenericState (State); + AcpiCmDeleteGenericState (State); } - /* Always must free any stacked result states */ + /* If walk cache is full, just free this wallkstate object */ - while (WalkState->Results) + if (Acpi_GblWalkStateCacheDepth >= MAX_WALK_CACHE_DEPTH) { - State = WalkState->Results; - WalkState->Results = State->Common.Next; - - AcpiUtDeleteGenericState (State); + AcpiCmFree (WalkState); + } + + /* Otherwise put this object back into the cache */ + + else + { + AcpiCmAcquireMutex (MTX_CACHES); + + /* Clear the state */ + + MEMSET (WalkState, 0, sizeof (ACPI_WALK_STATE)); + WalkState->DataType = DESC_TYPE_WALK; + + /* Put the object at the head of the global cache list */ + + WalkState->Next = Acpi_GblWalkStateCache; + Acpi_GblWalkStateCache = WalkState; + Acpi_GblWalkStateCacheDepth++; + + + AcpiCmReleaseMutex (MTX_CACHES); } - AcpiUtReleaseToCache (ACPI_MEM_LIST_WALK, WalkState); return_VOID; } @@ -1178,9 +796,9 @@ AcpiDsDeleteWalkState ( * FUNCTION: AcpiDsDeleteWalkStateCache * * PARAMETERS: None - * + * * RETURN: Status - * + * * DESCRIPTION: Purge the global state object cache. Used during subsystem * termination. * @@ -1190,11 +808,25 @@ void AcpiDsDeleteWalkStateCache ( void) { - ACPI_FUNCTION_TRACE ("DsDeleteWalkStateCache"); + ACPI_WALK_STATE *Next; - AcpiUtDeleteGenericCache (ACPI_MEM_LIST_WALK); + FUNCTION_TRACE ("DsDeleteWalkStateCache"); + + + /* Traverse the global cache list */ + + while (Acpi_GblWalkStateCache) + { + /* Delete one cached state object */ + + Next = Acpi_GblWalkStateCache->Next; + AcpiCmFree (Acpi_GblWalkStateCache); + Acpi_GblWalkStateCache = Next; + } + return_VOID; } + diff --git a/source/components/executer/exconfig.c b/source/components/executer/exconfig.c index 1bd9a3b8e..a884381ee 100644 --- a/source/components/executer/exconfig.c +++ b/source/components/executer/exconfig.c @@ -1,7 +1,7 @@ + /****************************************************************************** - * - * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes) - * $Revision: 1.63 $ + * + * Module Name: ieconfig - Namespace reconfiguration (Load/Unload opcodes) * *****************************************************************************/ @@ -9,8 +9,8 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. - * All rights reserved. + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. * * 2. License * @@ -38,9 +38,9 @@ * The above copyright and patent license is granted only if the following * conditions are met: * - * 3. Conditions + * 3. Conditions * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, @@ -48,11 +48,11 @@ * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee + * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the @@ -87,7 +87,7 @@ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. + * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR @@ -115,63 +115,121 @@ * *****************************************************************************/ -#define __EXCONFIG_C__ +#define __IECONFIG_C__ #include "acpi.h" -#include "acinterp.h" +#include "parser.h" +#include "interp.h" #include "amlcode.h" -#include "acnamesp.h" -#include "acevents.h" -#include "actables.h" +#include "namesp.h" +#include "events.h" +#include "tables.h" +#include "dispatch.h" -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("exconfig") +#define _COMPONENT INTERPRETER + MODULE_NAME ("ieconfig"); -/******************************************************************************* + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecLoadTable * - * FUNCTION: AcpiExAddTable - * - * PARAMETERS: Table - Pointer to raw table - * ParentNode - Where to load the table (scope) - * DdbHandle - Where to return the table handle. + * PARAMETERS: RgnDesc - Op region where the table will be obtained + * DdbHandle - Where a handle to the table will be returned * * RETURN: Status * - * DESCRIPTION: Common function to Install and Load an ACPI table with a - * returned table handle. + * DESCRIPTION: Load an ACPI table * - ******************************************************************************/ + ****************************************************************************/ ACPI_STATUS -AcpiExAddTable ( - ACPI_TABLE_HEADER *Table, - ACPI_NAMESPACE_NODE *ParentNode, - ACPI_OPERAND_OBJECT **DdbHandle) +AcpiAmlExecLoadTable ( + ACPI_OBJECT_INTERNAL *RgnDesc, + ACPI_HANDLE *DdbHandle) { ACPI_STATUS Status; + ACPI_OBJECT_INTERNAL *TableDesc = NULL; + char *TablePtr; + char *TableDataPtr; + ACPI_TABLE_HEADER TableHeader; ACPI_TABLE_DESC TableInfo; - ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 i; - ACPI_FUNCTION_TRACE ("ExAddTable"); + FUNCTION_TRACE ("AmlExecLoadTable"); + + /* TBD: [Unhandled] Object can be either a field or an opregion */ - /* Create an object to be the table handle */ + /* Get the table header */ - ObjDesc = AcpiUtCreateInternalObject (INTERNAL_TYPE_REFERENCE); - if (!ObjDesc) + TableHeader.Length = 0; + for (i = 0; i < sizeof (ACPI_TABLE_HEADER); i++) + { + Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ, i, 8, + (UINT32 *) ((char *) &TableHeader + i)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Allocate a buffer for the entire table */ + + TablePtr = AcpiCmAllocate (TableHeader.Length); + if (!TablePtr) { return_ACPI_STATUS (AE_NO_MEMORY); } + /* Copy the header to the buffer */ + + MEMCPY (TablePtr, &TableHeader, sizeof (ACPI_TABLE_HEADER)); + TableDataPtr = TablePtr + sizeof (ACPI_TABLE_HEADER); + + + /* Get the table from the op region */ + + for (i = 0; i < TableHeader.Length; i++) + { + Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ, i, 8, + (UINT32 *) (TableDataPtr + i)); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + + + /* Table must be either an SSDT or a PSDT */ + + if ((!STRNCMP (TableHeader.Signature, Acpi_GblAcpiTableData[TABLE_PSDT].Signature, Acpi_GblAcpiTableData[TABLE_PSDT].SigLength)) && + (!STRNCMP (TableHeader.Signature, Acpi_GblAcpiTableData[TABLE_SSDT].Signature, Acpi_GblAcpiTableData[TABLE_SSDT].SigLength))) + { + DEBUG_PRINT (ACPI_ERROR, ("Table has invalid signature [%4.4s], must be SSDT or PSDT\n", TableHeader.Signature)); + Status = AE_BAD_SIGNATURE; + goto Cleanup; + } + + /* Create an object to be the table handle */ + + TableDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); + if (!TableDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Install the new table into the local data structures */ - TableInfo.Pointer = Table; - TableInfo.Length = Table->Length; + TableInfo.Pointer = (ACPI_TABLE_HEADER *) TablePtr; + TableInfo.Length = TableHeader.Length; TableInfo.Allocation = ACPI_MEM_ALLOCATED; - TableInfo.BasePointer = Table; + TableInfo.BasePointer = TablePtr; Status = AcpiTbInstallTable (NULL, &TableInfo); if (ACPI_FAILURE (Status)) @@ -181,331 +239,39 @@ AcpiExAddTable ( /* Add the table to the namespace */ - Status = AcpiNsLoadTable (TableInfo.InstalledDesc, ParentNode); + Status = AcpiLoadNamespace (); if (ACPI_FAILURE (Status)) { - /* Uninstall table on error */ + /* TBD: [Errors] Unload the table on failure ? */ - (void) AcpiTbUninstallTable (TableInfo.InstalledDesc); goto Cleanup; } + /* TBD: [Investigate] we need a pointer to the table desc */ + /* Init the table handle */ - ObjDesc->Reference.Opcode = AML_LOAD_OP; - ObjDesc->Reference.Object = TableInfo.InstalledDesc; - *DdbHandle = ObjDesc; - return_ACPI_STATUS (AE_OK); + TableDesc->Reference.OpCode = AML_LOAD_OP; + TableDesc->Reference.Object = TableInfo.InstalledDesc; - -Cleanup: - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExLoadTableOp - * - * PARAMETERS: WalkState - Current state with operands - * ReturnDesc - Where to store the return object - * - * RETURN: Status - * - * DESCRIPTION: Load an ACPI table - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExLoadTableOp ( - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT **ReturnDesc) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_TABLE_HEADER *Table; - ACPI_NAMESPACE_NODE *ParentNode; - ACPI_NAMESPACE_NODE *StartNode; - ACPI_NAMESPACE_NODE *ParameterNode = NULL; - ACPI_OPERAND_OBJECT *DdbHandle; - - - ACPI_FUNCTION_TRACE ("ExLoadTableOp"); - - - /* - * Make sure that the signature does not match one of the tables that - * is already loaded. - */ - Status = AcpiTbMatchSignature (Operand[0]->String.Pointer, NULL); - if (Status == AE_OK) - { - /* Signature matched -- don't allow override */ - - return_ACPI_STATUS (AE_ALREADY_EXISTS); - } - - /* Find the ACPI table */ - - Status = AcpiTbFindTable (Operand[0]->String.Pointer, - Operand[1]->String.Pointer, - Operand[2]->String.Pointer, &Table); - if (ACPI_FAILURE (Status)) - { - if (Status != AE_NOT_FOUND) - { - return_ACPI_STATUS (Status); - } - - /* Not found, return an Integer=0 and AE_OK */ - - DdbHandle = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!DdbHandle) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - DdbHandle->Integer.Value = 0; - *ReturnDesc = DdbHandle; - - return_ACPI_STATUS (AE_OK); - } - - /* Default nodes */ - - StartNode = WalkState->ScopeInfo->Scope.Node; - ParentNode = AcpiGbl_RootNode; - - /* RootPath (optional parameter) */ - - if (Operand[3]->String.Length > 0) - { - /* - * Find the node referenced by the RootPathString. This is the - * location within the namespace where the table will be loaded. - */ - Status = AcpiNsGetNodeByPath (Operand[3]->String.Pointer, StartNode, - ACPI_NS_SEARCH_PARENT, &ParentNode); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* ParameterPath (optional parameter) */ - - if (Operand[4]->String.Length > 0) - { - if ((Operand[4]->String.Pointer[0] != '\\') && - (Operand[4]->String.Pointer[0] != '^')) - { - /* - * Path is not absolute, so it will be relative to the node - * referenced by the RootPathString (or the NS root if omitted) - */ - StartNode = ParentNode; - } - - /* - * Find the node referenced by the ParameterPathString - */ - Status = AcpiNsGetNodeByPath (Operand[4]->String.Pointer, StartNode, - ACPI_NS_SEARCH_PARENT, &ParameterNode); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Load the table into the namespace */ - - Status = AcpiExAddTable (Table, ParentNode, &DdbHandle); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Parameter Data (optional) */ - - if (ParameterNode) - { - /* Store the parameter data into the optional parameter object */ - - Status = AcpiExStore (Operand[5], ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), - WalkState); - if (ACPI_FAILURE (Status)) - { - (void) AcpiExUnloadTable (DdbHandle); - } - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExLoadOp - * - * PARAMETERS: ObjDesc - Region or Field where the table will be - * obtained - * Target - Where a handle to the table will be stored - * WalkState - Current state - * - * RETURN: Status - * - * DESCRIPTION: Load an ACPI table from a field or operation region - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExLoadOp ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT *Target, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *DdbHandle; - ACPI_OPERAND_OBJECT *BufferDesc = NULL; - ACPI_TABLE_HEADER *TablePtr = NULL; - UINT8 *TableDataPtr; - ACPI_TABLE_HEADER TableHeader; - UINT32 i; - - ACPI_FUNCTION_TRACE ("ExLoadOp"); - - - /* Object can be either an OpRegion or a Field */ - - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) - { - case ACPI_TYPE_REGION: - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n", - ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type))); - - /* Get the table header */ - - TableHeader.Length = 0; - for (i = 0; i < sizeof (ACPI_TABLE_HEADER); i++) - { - Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, - (ACPI_PHYSICAL_ADDRESS) i, 8, - ((UINT8 *) &TableHeader) + i); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Allocate a buffer for the entire table */ - - TablePtr = ACPI_MEM_ALLOCATE (TableHeader.Length); - if (!TablePtr) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Copy the header to the buffer */ - - ACPI_MEMCPY (TablePtr, &TableHeader, sizeof (ACPI_TABLE_HEADER)); - TableDataPtr = ACPI_PTR_ADD (UINT8, TablePtr, sizeof (ACPI_TABLE_HEADER)); - - /* Get the table from the op region */ - - for (i = 0; i < TableHeader.Length; i++) - { - Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, - (ACPI_PHYSICAL_ADDRESS) i, 8, - ((UINT8 *) TableDataPtr + i)); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - } - break; - - - case ACPI_TYPE_BUFFER_FIELD: - case INTERNAL_TYPE_REGION_FIELD: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Field %p %s\n", - ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type))); - - /* - * The length of the field must be at least as large as the table. - * Read the entire field and thus the entire table. Buffer is - * allocated during the read. - */ - Status = AcpiExReadDataFromField (WalkState, ObjDesc, &BufferDesc); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - TablePtr = ACPI_CAST_PTR (ACPI_TABLE_HEADER, BufferDesc->Buffer.Pointer); - break; - - - default: - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - - /* The table must be either an SSDT or a PSDT */ - - if ((!ACPI_STRNCMP (TablePtr->Signature, - AcpiGbl_AcpiTableData[ACPI_TABLE_PSDT].Signature, - AcpiGbl_AcpiTableData[ACPI_TABLE_PSDT].SigLength)) && - (!ACPI_STRNCMP (TablePtr->Signature, - AcpiGbl_AcpiTableData[ACPI_TABLE_SSDT].Signature, - AcpiGbl_AcpiTableData[ACPI_TABLE_SSDT].SigLength))) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Table has invalid signature [%4.4s], must be SSDT or PSDT\n", - TablePtr->Signature)); - Status = AE_BAD_SIGNATURE; - goto Cleanup; - } - - /* Install the new table into the local data structures */ - - Status = AcpiExAddTable (TablePtr, AcpiGbl_RootNode, &DdbHandle); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Store the DdbHandle into the Target operand */ - - Status = AcpiExStore (DdbHandle, Target, WalkState); - if (ACPI_FAILURE (Status)) - { - (void) AcpiExUnloadTable (DdbHandle); - } + *DdbHandle = TableDesc; return_ACPI_STATUS (Status); Cleanup: - if (BufferDesc) - { - AcpiUtRemoveReference (BufferDesc); - } - else - { - ACPI_MEM_FREE (TablePtr); - } + AcpiCmFree (TableDesc); + AcpiCmFree (TablePtr); return_ACPI_STATUS (Status); + } + -/******************************************************************************* - * - * FUNCTION: AcpiExUnloadTable +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecUnloadTable * * PARAMETERS: DdbHandle - Handle to a previously loaded table * @@ -513,51 +279,139 @@ Cleanup: * * DESCRIPTION: Unload an ACPI table * - ******************************************************************************/ + ****************************************************************************/ + ACPI_STATUS -AcpiExUnloadTable ( - ACPI_OPERAND_OBJECT *DdbHandle) +AcpiAmlExecUnloadTable ( + ACPI_HANDLE DdbHandle) { ACPI_STATUS Status = AE_NOT_IMPLEMENTED; - ACPI_OPERAND_OBJECT *TableDesc = DdbHandle; + ACPI_OBJECT_INTERNAL *TableDesc = (ACPI_OBJECT_INTERNAL *) DdbHandle; ACPI_TABLE_DESC *TableInfo; - ACPI_FUNCTION_TRACE ("ExUnloadTable"); + FUNCTION_TRACE ("AmlExecUnloadTable"); - /* - * Validate the handle - * Although the handle is partially validated in AcpiExReconfiguration(), - * when it calls AcpiExResolveOperands(), the handle is more completely - * validated here. - */ + /* Validate the handle */ + /* TBD: [Errors] Wasn't this done earlier? */ + if ((!DdbHandle) || - (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) || - (((ACPI_OPERAND_OBJECT *)DdbHandle)->Common.Type != - INTERNAL_TYPE_REFERENCE)) + (!VALID_DESCRIPTOR_TYPE (DdbHandle, DESC_TYPE_ACPI_OBJ)) || + (((ACPI_OBJECT_INTERNAL *)DdbHandle)->Common.Type != INTERNAL_TYPE_REFERENCE)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } + /* Get the actual table descriptor from the DdbHandle */ TableInfo = (ACPI_TABLE_DESC *) TableDesc->Reference.Object; - /* - * Delete the entire namespace under this table Node + /* + * Delete the entire namespace under this table NTE * (Offset contains the TableId) */ - AcpiNsDeleteNamespaceByOwner (TableInfo->TableId); + + Status = AcpiNsDeleteNamespaceByOwner (TableInfo->TableId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } /* Delete the table itself */ - (void) AcpiTbUninstallTable (TableInfo->InstalledDesc); + AcpiTbDeleteSingleTable (TableInfo->InstalledDesc); /* Delete the table descriptor (DdbHandle) */ - AcpiUtRemoveReference (TableDesc); + AcpiCmRemoveReference (TableDesc); + + return_ACPI_STATUS (Status); +} + + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecReconfiguration + * + * PARAMETERS: Opcode - The opcode to be executed + * WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: Reconfiguration opcodes such as LOAD and UNLOAD + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecReconfiguration ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OBJECT_INTERNAL *RegionDesc = NULL; + ACPI_HANDLE *DdbHandle; + + + FUNCTION_TRACE ("AmlExecReconfiguration"); + + + /* Resolve the operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), 2, "after AcpiAmlResolveOperands"); + + /* Get the table handle, common for both opcodes */ + + Status |= AcpiDsObjStackPopObject ((ACPI_OBJECT_INTERNAL **) &DdbHandle, WalkState); + + switch (Opcode) + { + + case AML_LOAD_OP: + + /* Get the region or field descriptor */ + + Status |= AcpiDsObjStackPopObject (&RegionDesc, WalkState); + if (Status != AE_OK) + { + AcpiAmlAppendOperandDiag (_THIS_MODULE, __LINE__, Opcode, WALK_OPERANDS, 2); + goto Cleanup2; + } + + Status = AcpiAmlExecLoadTable (RegionDesc, DdbHandle); + break; + + + case AML_UN_LOAD_OP: + + if (Status != AE_OK) + { + AcpiAmlAppendOperandDiag (_THIS_MODULE, __LINE__, Opcode, WALK_OPERANDS, 1); + goto Cleanup1; + } + + Status = AcpiAmlExecUnloadTable (DdbHandle); + break; + + + default: + DEBUG_PRINT (ACPI_ERROR, ("AmlExecReconfiguration: bad opcode=%X\n", Opcode)); + + Status = AE_AML_BAD_OPCODE; + break; + } + +Cleanup2: + AcpiCmRemoveReference (RegionDesc); + +Cleanup1: +// AcpiCmRemoveReference (DdbHandle); + + return_ACPI_STATUS (Status); } diff --git a/source/components/executer/excreate.c b/source/components/executer/excreate.c index d34ee1208..a0a20dce8 100644 --- a/source/components/executer/excreate.c +++ b/source/components/executer/excreate.c @@ -1,7 +1,7 @@ + /****************************************************************************** - * - * Module Name: excreate - Named object creation - * $Revision: 1.98 $ + * + * Module Name: iecreate - Named object creation * *****************************************************************************/ @@ -9,8 +9,8 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. - * All rights reserved. + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. * * 2. License * @@ -38,9 +38,9 @@ * The above copyright and patent license is granted only if the following * conditions are met: * - * 3. Conditions + * 3. Conditions * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, @@ -48,11 +48,11 @@ * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee + * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the @@ -87,7 +87,7 @@ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. + * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR @@ -115,26 +115,349 @@ * *****************************************************************************/ -#define __EXCREATE_C__ +#define __IECREATE_C__ #include "acpi.h" -#include "acinterp.h" +#include "parser.h" +#include "interp.h" #include "amlcode.h" -#include "acnamesp.h" -#include "acevents.h" -#include "actables.h" +#include "namesp.h" +#include "events.h" +#include "dispatch.h" -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("excreate") +#define _COMPONENT INTERPRETER + MODULE_NAME ("iecreate"); + + + /***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreateField + * + * PARAMETERS: Opcode - The opcode to be executed + * Operands - List of operands for the opcode + * + * RETURN: Status + * + * DESCRIPTION: Execute CreateField operators: CreateBitFieldOp, + * CreateByteFieldOp, CreateWordFieldOp, CreateDWordFieldOp, + * CreateFieldOp (which define fields in buffers) + * + * ALLOCATION: Deletes CreateFieldOp's count operand descriptor + * + * + * ACPI SPECIFICATION REFERENCES: + * 16.2.4.2 DefCreateBitField := CreateBitFieldOp SourceBuff BitIndex NameString + * 16.2.4.2 DefCreateByteField := CreateByteFieldOp SourceBuff ByteIndex NameString + * 16.2.4.2 DefCreateDWordField := CreateDWordFieldOp SourceBuff ByteIndex NameString + * 16.2.4.2 DefCreateField := CreateFieldOp SourceBuff BitIndex NumBits NameString + * 16.2.4.2 DefCreateWordField := CreateWordFieldOp SourceBuff ByteIndex NameString + * 16.2.4.2 BitIndex := TermArg=>Integer + * 16.2.4.2 ByteIndex := TermArg=>Integer + * 16.2.4.2 NumBits := TermArg=>Integer + * 16.2.4.2 SourceBuff := TermArg=>Buffer + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreateField ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OBJECT_INTERNAL *ResDesc = NULL; + ACPI_OBJECT_INTERNAL *CntDesc = NULL; + ACPI_OBJECT_INTERNAL *OffDesc = NULL; + ACPI_OBJECT_INTERNAL *SrcDesc = NULL; + ACPI_OBJECT_INTERNAL *FieldDesc; + ACPI_OBJECT_INTERNAL *ObjDesc; + OBJECT_TYPE_INTERNAL ResType; + ACPI_STATUS Status; + UINT32 NumOperands = 3; + UINT32 Offset; + UINT32 BitOffset; + UINT16 BitCount; + UINT8 TypeFound; + + + + FUNCTION_TRACE ("AmlExecCreateField"); + + + /* Resolve the operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), NumOperands, "after AcpiAmlResolveOperands"); + + + /* Get the operands */ + + Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); + if (AML_CREATE_FIELD_OP == Opcode) + { + NumOperands = 4; + Status |= AcpiDsObjStackPopObject (&CntDesc, WalkState); + } + + Status |= AcpiDsObjStackPopObject (&OffDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&SrcDesc, WalkState); + + if (Status != AE_OK) + { + /* Invalid parameters on object stack */ + + AcpiAmlAppendOperandDiag (_THIS_MODULE, __LINE__, Opcode, WALK_OPERANDS, 3); + goto Cleanup; + } + + + + Offset = OffDesc->Number.Value; + + + + /* If ResDesc is a Name, it will be a direct name pointer after AcpiAmlResolveOperands() */ + + if (!VALID_DESCRIPTOR_TYPE (ResDesc, DESC_TYPE_NTE)) + { + DEBUG_PRINT (ACPI_ERROR, ("AmlExecCreateField (%s): destination must be a Name(NTE)\n", AcpiPsGetOpcodeName (Opcode))); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + + /* + * Setup the Bit offsets and counts, according to the opcode + */ + + switch (Opcode) + { + + /* DefCreateBitField := CreateBitFieldOp SourceBuff BitIndex NameString */ + + case AML_BIT_FIELD_OP: + + BitOffset = Offset; /* offset is in bits */ + BitCount = 1; /* field is a bit */ + break; + + + /* DefCreateByteField := CreateByteFieldOp SourceBuff ByteIndex NameString */ + + case AML_BYTE_FIELD_OP: + + BitOffset = 8 * Offset; /* offset is in bytes */ + BitCount = 8; /* field is a Byte */ + break; + + + /* DefCreateWordField := CreateWordFieldOp SourceBuff ByteIndex NameString */ + + case AML_WORD_FIELD_OP: + + BitOffset = 8 * Offset; /* offset is in bytes */ + BitCount = 16; /* field is a Word */ + break; + + + /* DefCreateDWordField := CreateDWordFieldOp SourceBuff ByteIndex NameString */ + + case AML_DWORD_FIELD_OP: + + BitOffset = 8 * Offset; /* offset is in bytes */ + BitCount = 32; /* field is a DWord */ + break; + + + /* DefCreateField := CreateFieldOp SourceBuff BitIndex NumBits NameString */ + + case AML_CREATE_FIELD_OP: + + BitOffset = Offset; /* offset is in bits */ + BitCount = (UINT16) CntDesc->Number.Value; /* as is count */ + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, ("AmlExecCreateField: Internal error - unknown field creation opcode %02x\n", + Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + + /* + * Setup field according to the object type + */ + + switch (SrcDesc->Common.Type) + { + + /* SourceBuff := TermArg=>Buffer */ + + case ACPI_TYPE_BUFFER: + + if (BitOffset + (UINT32) BitCount > 8 * (UINT32) SrcDesc->Buffer.Length) + { + DEBUG_PRINT (ACPI_ERROR, ("AmlExecCreateField: Field exceeds Buffer %d > %d\n", + BitOffset + (UINT32) BitCount, + 8 * (UINT32) SrcDesc->Buffer.Length)); + Status = AE_AML_BUFFER_LIMIT; + goto Cleanup; + } + + + /* Allocate an object for the field */ + + FieldDesc = AcpiCmCreateInternalObject (ACPI_TYPE_FIELD_UNIT); + if (!FieldDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Construct the field object */ + + FieldDesc->FieldUnit.Access = (UINT8) ACCESS_ANY_ACC; + FieldDesc->FieldUnit.LockRule = (UINT8) GLOCK_NEVER_LOCK; + FieldDesc->FieldUnit.UpdateRule = (UINT8) UPDATE_PRESERVE; + FieldDesc->FieldUnit.Length = BitCount; + FieldDesc->FieldUnit.BitOffset = (UINT8) (BitOffset % 8); + FieldDesc->FieldUnit.Offset = DIV_8 (BitOffset); + FieldDesc->FieldUnit.Container = SrcDesc; + FieldDesc->FieldUnit.Sequence = SrcDesc->Buffer.Sequence; + + /* An additional reference for SrcDesc */ + + AcpiCmAddReference (SrcDesc); + + break; + + + /* Improper object type */ + + default: + + TypeFound = SrcDesc->Common.Type; + + if ((TypeFound > (UINT8) INTERNAL_TYPE_REFERENCE) || + !AcpiCmValidObjectType (TypeFound)) + { + DEBUG_PRINT (ACPI_ERROR, ("AmlExecCreateField: Tried to create field in invalid object type - 0x%X\n", + TypeFound)); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, ("AmlExecCreateField: Tried to create field in improper object type - %s\n", + AcpiCmGetTypeName (TypeFound))); + } + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + + } /* switch */ + + + if (AML_CREATE_FIELD_OP == Opcode) + { + /* Delete object descriptor unique to CreateField */ + + AcpiCmRemoveReference (CntDesc); + CntDesc = NULL; + } + + /* + * This operation is supposed to cause the destination Name to refer + * to the defined FieldUnit -- it must not store the constructed + * FieldUnit object (or its current value) in some location that the + * Name may already be pointing to. So, if the Name currently contains + * a reference which would cause AcpiAmlExecStore() to perform an indirect + * store rather than setting the value of the Name itself, clobber that + * reference before calling AcpiAmlExecStore(). + */ + + ResType = AcpiNsGetType (ResDesc); + switch (ResType) /* Type of Name's existing value */ + { + + case ACPI_TYPE_FIELD_UNIT: + + case INTERNAL_TYPE_ALIAS: + case INTERNAL_TYPE_BANK_FIELD: + case INTERNAL_TYPE_DEF_FIELD: + case INTERNAL_TYPE_INDEX_FIELD: + + ObjDesc = AcpiNsGetAttachedObject (ResDesc); + if (ObjDesc) + { + /* There is an existing object here; delete it and zero out the NTE */ + + DUMP_PATHNAME (ResDesc, "AmlExecCreateField: Removing Current Reference", TRACE_BFIELD, _COMPONENT); + + DUMP_ENTRY (ResDesc, TRACE_BFIELD); + DUMP_STACK_ENTRY (ObjDesc); + + AcpiCmRemoveReference (ObjDesc); + AcpiNsAttachObject (ResDesc, NULL, ACPI_TYPE_ANY); + } + + /* Set the type to ANY (or the store below will fail) */ + + ((NAME_TABLE_ENTRY *) ResDesc)->Type = ACPI_TYPE_ANY; + + break; + + + default: + + break; + } + + + /* Store constructed field descriptor in result location */ + + Status = AcpiAmlExecStore (FieldDesc, ResDesc); + + /* + * If the field descriptor was not physically stored (or if a failure above), we + * must delete it + */ + if (FieldDesc->Common.ReferenceCount <= 1) + { + AcpiCmRemoveReference (FieldDesc); + } + + + +Cleanup: + + /* Always delete the operands */ + + AcpiCmRemoveReference (OffDesc); + AcpiCmRemoveReference (SrcDesc); + + if (AML_CREATE_FIELD_OP == Opcode) + { + AcpiCmRemoveReference (CntDesc); + } + + /* On failure, delete the result descriptor */ + + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ResDesc); /* Result descriptor */ + } + + return_ACPI_STATUS (Status); +} -#ifndef ACPI_NO_METHOD_EXECUTION /***************************************************************************** * - * FUNCTION: AcpiExCreateAlias + * FUNCTION: AcpiAmlExecCreateAlias * - * PARAMETERS: WalkState - Current state, contains operands + * PARAMETERS: Operands - List of operands for the opcode * * RETURN: Status * @@ -143,74 +466,45 @@ ****************************************************************************/ ACPI_STATUS -AcpiExCreateAlias ( +AcpiAmlExecCreateAlias ( ACPI_WALK_STATE *WalkState) { - ACPI_NAMESPACE_NODE *TargetNode; - ACPI_NAMESPACE_NODE *AliasNode; - ACPI_STATUS Status = AE_OK; + NAME_TABLE_ENTRY *SrcEntry; + NAME_TABLE_ENTRY *AliasEntry; + ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("ExCreateAlias"); + FUNCTION_TRACE ("AmlExecCreateAlias"); - /* Get the source/alias operands (both namespace nodes) */ + /* Get the source/alias operands (both NTEs) */ - AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; - TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1]; - - if (TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) + Status = AcpiDsObjStackPopObject ((ACPI_OBJECT_INTERNAL **) &SrcEntry, WalkState); + if (ACPI_FAILURE (Status)) { - /* - * Dereference an existing alias so that we don't create a chain - * of aliases. With this code, we guarantee that an alias is - * always exactly one level of indirection away from the - * actual aliased name. - */ - TargetNode = (ACPI_NAMESPACE_NODE *) TargetNode->Object; + return_ACPI_STATUS (Status); } - /* - * For objects that can never change (i.e., the NS node will - * permanently point to the same object), we can simply attach - * the object to the new NS node. For other objects (such as - * Integers, buffers, etc.), we have to point the Alias node - * to the original Node. + AliasEntry = AcpiDsObjStackGetValue (0, WalkState); /* Don't pop it, it gets popped later */ + + /* Add an additional reference to the object */ + + AcpiCmAddReference (SrcEntry->Object); + + /* + * Attach the original source NTE to the new Alias NTE. */ - switch (TargetNode->Type) - { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - case ACPI_TYPE_PACKAGE: - case ACPI_TYPE_BUFFER_FIELD: + Status = AcpiNsAttachObject (AliasEntry, SrcEntry->Object, SrcEntry->Type); - /* - * The new alias has the type ALIAS and points to the original - * NS node, not the object itself. This is because for these - * types, the object can change dynamically via a Store. - */ - AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS; - AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); - break; - default: + /* + * The new alias assumes the type of the source, but it points + * to the same object. The reference count of the object has two additional + * references to prevent deletion out from under either the source + * or the alias NTE + */ - /* Attach the original source object to the new Alias Node */ - - /* - * The new alias assumes the type of the target, and it points - * to the same object. The reference count of the object has an - * additional reference to prevent deletion out from under either the - * target node or the alias Node - */ - Status = AcpiNsAttachObject (AliasNode, - AcpiNsGetAttachedObject (TargetNode), - TargetNode->Type); - break; - } - - /* Since both operands are Nodes, we don't need to delete them */ + /* Since both operands are NTEs, we don't need to delete them */ return_ACPI_STATUS (Status); } @@ -218,9 +512,9 @@ AcpiExCreateAlias ( /***************************************************************************** * - * FUNCTION: AcpiExCreateEvent + * FUNCTION: AcpiAmlExecCreateEvent * - * PARAMETERS: WalkState - Current state + * PARAMETERS: None * * RETURN: Status * @@ -229,121 +523,136 @@ AcpiExCreateAlias ( ****************************************************************************/ ACPI_STATUS -AcpiExCreateEvent ( +AcpiAmlExecCreateEvent ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OBJECT_INTERNAL *ObjDesc; - ACPI_FUNCTION_TRACE ("ExCreateEvent"); + FUNCTION_TRACE ("AmlExecCreateEvent"); - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); + BREAKPOINT3; + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_EVENT); if (!ObjDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - /* - * Create the actual OS semaphore, with zero initial units -- meaning - * that the event is created in an unsignalled state - */ - Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, - &ObjDesc->Event.Semaphore); + /* Create the actual OS semaphore */ + + Status = AcpiOsdCreateSemaphore (1, &ObjDesc->Event.Semaphore); if (ACPI_FAILURE (Status)) { + AcpiCmRemoveReference (ObjDesc); + goto Cleanup; + } + + /* Attach object to the NTE */ + + Status = AcpiNsAttachObject (AcpiDsObjStackGetValue (0, WalkState), ObjDesc, (UINT8) ACPI_TYPE_EVENT); + if (ACPI_FAILURE (Status)) + { + AcpiOsdDeleteSemaphore (ObjDesc->Event.Semaphore); + AcpiCmRemoveReference (ObjDesc); goto Cleanup; } - /* Attach object to the Node */ - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], - ObjDesc, ACPI_TYPE_EVENT); Cleanup: - /* - * Remove local reference to the object (on error, will cause deletion - * of both object and semaphore if present.) - */ - AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); } /***************************************************************************** * - * FUNCTION: AcpiExCreateMutex + * FUNCTION: AcpiAmlExecCreateMutex * - * PARAMETERS: WalkState - Current state + * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) + * Operands - List of operands for the opcode * * RETURN: Status * * DESCRIPTION: Create a new mutex object * - * Mutex (Name[0], SyncLevel[1]) - * ****************************************************************************/ ACPI_STATUS -AcpiExCreateMutex ( +AcpiAmlExecCreateMutex ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OBJECT_INTERNAL *SyncDesc; + ACPI_OBJECT_INTERNAL *ObjDesc; - ACPI_FUNCTION_TRACE_PTR ("ExCreateMutex", ACPI_WALK_OPERANDS); + + FUNCTION_TRACE_PTR ("AmlExecCreateMutex", WALK_OPERANDS); - /* Create the new mutex object */ + /* Get the operand */ - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); + Status = AcpiDsObjStackPopObject (&SyncDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Attempt to allocate a new object */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_MUTEX); if (!ObjDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - /* - * Create the actual OS semaphore. - * One unit max to make it a mutex, with one initial unit to allow - * the mutex to be acquired. - */ - Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore); + /* Create the actual OS semaphore */ + + Status = AcpiOsdCreateSemaphore (1, &ObjDesc->Mutex.Semaphore); if (ACPI_FAILURE (Status)) { + AcpiCmRemoveReference (ObjDesc); goto Cleanup; } - /* Init object and attach to NS node */ + ObjDesc->Mutex.SyncLevel = (UINT8) SyncDesc->Number.Value; - ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value; - ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + /* ObjDesc was on the stack top, and the name is below it */ - Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, - ObjDesc, ACPI_TYPE_MUTEX); + Status = AcpiNsAttachObject (AcpiDsObjStackGetValue (0, WalkState), /* Name */ + ObjDesc, (UINT8) ACPI_TYPE_MUTEX); + if (ACPI_FAILURE (Status)) + { + AcpiOsdDeleteSemaphore (ObjDesc->Mutex.Semaphore); + AcpiCmRemoveReference (ObjDesc); + goto Cleanup; + } Cleanup: - /* - * Remove local reference to the object (on error, will cause deletion - * of both object and semaphore if present.) - */ - AcpiUtRemoveReference (ObjDesc); + + /* Always delete the operand */ + + AcpiCmRemoveReference (SyncDesc); + return_ACPI_STATUS (Status); } /***************************************************************************** * - * FUNCTION: AcpiExCreateRegion + * FUNCTION: AcpiAmlExecCreateRegion * - * PARAMETERS: AmlStart - Pointer to the region declaration AML + * PARAMETERS: AmlPtr - Pointer to the region declaration AML * AmlLength - Max length of the declaration AML * Operands - List of operands for the opcode - * WalkState - Current state + * InterpreterMode - Load1/Load2/Execute * * RETURN: Status * @@ -352,377 +661,350 @@ Cleanup: ****************************************************************************/ ACPI_STATUS -AcpiExCreateRegion ( - UINT8 *AmlStart, +AcpiAmlExecCreateRegion ( + UINT8 *AmlPtr, UINT32 AmlLength, - UINT8 RegionSpace, + UINT32 RegionSpace, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_NAMESPACE_NODE *Node; - ACPI_OPERAND_OBJECT *RegionObj2; + ACPI_OBJECT_INTERNAL *ObjDescRegion; + ACPI_HANDLE *Entry; - ACPI_FUNCTION_TRACE ("ExCreateRegion"); + FUNCTION_TRACE ("AmlExecCreateRegion"); - /* Get the Node from the object stack */ - - Node = WalkState->Op->Common.Node; - - /* - * If the region object is already attached to this node, - * just return - */ - if (AcpiNsGetAttachedObject (Node)) + if (RegionSpace >= NUM_REGION_TYPES) { - return_ACPI_STATUS (AE_OK); + /* TBD: [Errors] should this return an error, or should we just keep going? */ + + DEBUG_PRINT (TRACE_LOAD, ("AmlDoNamedObject: Type out of range [*???*]\n")); + REPORT_WARNING ("Unable to decode the RegionSpace"); } - /* - * Space ID must be one of the predefined IDs, or in the user-defined - * range - */ - if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) && - (RegionSpace < ACPI_USER_REGION_BEGIN)) - { - ACPI_REPORT_ERROR (("Invalid AddressSpace type %X\n", RegionSpace)); - return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); - } + DEBUG_PRINT (TRACE_LOAD, ("AmlDoNamedObject: Region Type [%s]\n", + Acpi_GblRegionTypes[RegionSpace])); - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", - AcpiUtGetRegionName (RegionSpace), RegionSpace)); + + /* Get the NTE from the object stack */ + + Entry = AcpiDsObjStackGetValue (0, WalkState); /* Create the region descriptor */ - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); - if (!ObjDesc) + ObjDescRegion = AcpiCmCreateInternalObject (ACPI_TYPE_REGION); + if (!ObjDescRegion) { Status = AE_NO_MEMORY; goto Cleanup; } /* + * Allocate a method object for this region. + */ + ObjDescRegion->Region.Method = AcpiCmCreateInternalObject (ACPI_TYPE_METHOD); + if (!ObjDescRegion->Region.Method) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Init the region from the operands */ + + ObjDescRegion->Region.SpaceId = (UINT16) RegionSpace; + ObjDescRegion->Region.Address = 0; + ObjDescRegion->Region.Length = 0; + ObjDescRegion->Region.RegionFlags = 0; + + /* * Remember location in AML stream of address & length * operands since they need to be evaluated at run time. */ - RegionObj2 = ObjDesc->Common.NextObject; - RegionObj2->Extra.AmlStart = AmlStart; - RegionObj2->Extra.AmlLength = AmlLength; + ObjDescRegion->Region.Method->Method.Pcode = AmlPtr; + ObjDescRegion->Region.Method->Method.PcodeLength = AmlLength; - /* Init the region from the operands */ + + /* Install the new region object in the parent NTE */ - ObjDesc->Region.SpaceId = RegionSpace; - ObjDesc->Region.Address = 0; - ObjDesc->Region.Length = 0; - ObjDesc->Region.Node = Node; + ObjDescRegion->Region.Nte = (NAME_TABLE_ENTRY *) Entry; - /* Install the new region object in the parent Node */ - - Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); - - -Cleanup: - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/***************************************************************************** - * - * FUNCTION: AcpiExCreateTableRegion - * - * PARAMETERS: WalkState - Current state - * - * RETURN: Status - * - * DESCRIPTION: Create a new DataTableRegion object - * - ****************************************************************************/ - -ACPI_STATUS -AcpiExCreateTableRegion ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_NAMESPACE_NODE *Node; - ACPI_TABLE_HEADER *Table; - ACPI_OPERAND_OBJECT *RegionObj2; - - - ACPI_FUNCTION_TRACE ("ExCreateTableRegion"); - - /* Get the Node from the object stack */ - - Node = WalkState->Op->Common.Node; - - /* - * If the region object is already attached to this node, - * just return - */ - if (AcpiNsGetAttachedObject (Node)) - { - return_ACPI_STATUS (AE_OK); - } - - /* Find the ACPI table */ - - Status = AcpiTbFindTable (Operand[1]->String.Pointer, - Operand[2]->String.Pointer, - Operand[3]->String.Pointer, &Table); - - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Create the region descriptor */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); - if (!ObjDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - RegionObj2 = ObjDesc->Common.NextObject; - RegionObj2->Extra.RegionContext = NULL; - - /* Init the region from the operands */ - - ObjDesc->Region.SpaceId = REGION_DATA_TABLE; - ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table); - ObjDesc->Region.Length = Table->Length; - ObjDesc->Region.Node = Node; - ObjDesc->Region.Flags = AOPOBJ_DATA_VALID; - - /* Install the new region object in the parent Node */ - - Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); + Status = AcpiNsAttachObject (Entry, ObjDescRegion, (UINT8) ACPI_TYPE_REGION); if (ACPI_FAILURE (Status)) { goto Cleanup; } - Status = AcpiEvInitializeRegion (ObjDesc, FALSE); - if (ACPI_FAILURE (Status)) +Cleanup: + + if (Status != AE_OK) { - if (Status == AE_NOT_EXIST) + /* Delete region object and method subobject */ + + if (ObjDescRegion) { - Status = AE_OK; - } - else - { - goto Cleanup; + AcpiCmRemoveReference (ObjDescRegion); /* Deletes both objects! */ + ObjDescRegion = NULL; } } - ObjDesc->Region.Flags |= AOPOBJ_SETUP_COMPLETE; + /* + * If we have a valid region, initialize it + */ + if (ObjDescRegion) + { + /* + * TBD: [Errors] Is there anything we can or could do when this fails? + * We need to do something useful with a failure. + */ + (void *) AcpiEvInitializeRegion (ObjDescRegion, TRUE); /* Namespace IS locked */ + } -Cleanup: - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } /***************************************************************************** * - * FUNCTION: AcpiExCreateProcessor + * FUNCTION: AcpiAmlExecCreateProcessor * - * PARAMETERS: WalkState - Current state + * PARAMETERS: Op - Op containing the Processor definition and args + * ProcessorNTE - NTE for the containing NTE * * RETURN: Status * * DESCRIPTION: Create a new processor object and populate the fields * - * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) - * ****************************************************************************/ ACPI_STATUS -AcpiExCreateProcessor ( - ACPI_WALK_STATE *WalkState) +AcpiAmlExecCreateProcessor ( + ACPI_GENERIC_OP *Op, + ACPI_HANDLE ProcessorNTE) { - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; + ACPI_GENERIC_OP *Arg; + ACPI_OBJECT_INTERNAL *ObjDesc; - ACPI_FUNCTION_TRACE_PTR ("ExCreateProcessor", WalkState); + FUNCTION_TRACE_PTR ("AmlExecCreateProcessor", Op); - /* Create the processor object */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR); + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_PROCESSOR); if (!ObjDesc) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + return_ACPI_STATUS (Status); } - /* - * Initialize the processor object from the operands - */ - ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; - ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value; - ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; + /* Install the new processor object in the parent NTE */ - /* Install the processor object in the parent Node */ + Status = AcpiNsAttachObject (ProcessorNTE, ObjDesc, (UINT8) ACPI_TYPE_PROCESSOR); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS(Status); + } - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_PROCESSOR); + Arg = Op->Value.Arg; + /* check existence */ - /* Remove local reference to the object */ + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); + /* First arg is the Processor ID */ + + ObjDesc->Processor.ProcId = (UINT8) Arg->Value.Integer; + + /* Move to next arg and check existence */ + + Arg = Arg->Next; + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } + + /* Second arg is the PBlock Address */ + + ObjDesc->Processor.PBLKAddress = (ACPI_IO_ADDRESS) Arg->Value.Integer; + + /* Move to next arg and check existence */ + + Arg = Arg->Next; + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } + + /* Third arg is the PBlock Length */ + + ObjDesc->Processor.PBLKLength = (UINT8) Arg->Value.Integer; + + return_ACPI_STATUS (AE_OK); } /***************************************************************************** * - * FUNCTION: AcpiExCreatePowerResource + * FUNCTION: AcpiAmlExecCreatePowerResource * - * PARAMETERS: WalkState - Current state + * PARAMETERS: Op - Op containing the PowerResource definition and args + * PowerResNTE - NTE for the containing NTE * * RETURN: Status * * DESCRIPTION: Create a new PowerResource object and populate the fields * - * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) - * ****************************************************************************/ ACPI_STATUS -AcpiExCreatePowerResource ( - ACPI_WALK_STATE *WalkState) +AcpiAmlExecCreatePowerResource ( + ACPI_GENERIC_OP *Op, + ACPI_HANDLE PowerResNTE) { - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_GENERIC_OP *Arg; + ACPI_OBJECT_INTERNAL *ObjDesc; - ACPI_FUNCTION_TRACE_PTR ("ExCreatePowerResource", WalkState); + FUNCTION_TRACE_PTR ("AmlExecCreatePowerResource", Op); - /* Create the power resource object */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER); + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_POWER); if (!ObjDesc) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + return_ACPI_STATUS (Status); } - /* Initialize the power object from the operands */ + /* Install the new power resource object in the parent NTE */ - ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value; - ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value; + Status = AcpiNsAttachObject (PowerResNTE, ObjDesc, (UINT8) ACPI_TYPE_POWER); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS(Status); + } - /* Install the power resource object in the parent Node */ + Arg = Op->Value.Arg; - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_POWER); + /* check existence */ + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } - /* Remove local reference to the object */ + /* First arg is the SystemLevel */ - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); + ObjDesc->PowerResource.SystemLevel = (UINT8) Arg->Value.Integer; + + /* Move to next arg and check existence */ + + Arg = Arg->Next; + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } + + /* Second arg is the PBlock Address */ + + ObjDesc->PowerResource.ResourceOrder = (UINT16) Arg->Value.Integer; + + return_ACPI_STATUS (AE_OK); } -#endif /***************************************************************************** * - * FUNCTION: AcpiExCreateMethod + * FUNCTION: AcpiAmlExecCreateMethod * - * PARAMETERS: AmlStart - First byte of the method's AML - * AmlLength - AML byte count for this method - * WalkState - Current state + * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) * * RETURN: Status * - * DESCRIPTION: Create a new method object + * DESCRIPTION: Create a new mutex object * ****************************************************************************/ ACPI_STATUS -AcpiExCreateMethod ( - UINT8 *AmlStart, +AcpiAmlExecCreateMethod ( + UINT8 *AmlPtr, UINT32 AmlLength, - ACPI_WALK_STATE *WalkState) + UINT32 MethodFlags, + ACPI_HANDLE Method) { - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OBJECT_INTERNAL *ObjDesc; ACPI_STATUS Status; - UINT8 MethodFlags; - ACPI_FUNCTION_TRACE_PTR ("ExCreateMethod", WalkState); + FUNCTION_TRACE_PTR ("AmlExecCreateMethod", Method); /* Create a new method object */ - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_METHOD); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - /* Save the method's AML pointer and length */ + /* Get the method's AML pointer/length from the Op */ - ObjDesc->Method.AmlStart = AmlStart; - ObjDesc->Method.AmlLength = AmlLength; + ObjDesc->Method.Pcode = AmlPtr; + ObjDesc->Method.PcodeLength = AmlLength; - /* disassemble the method flags */ + /* First argument is the Method Flags (contains parameter count for the method) */ - MethodFlags = (UINT8) Operand[1]->Integer.Value; - - ObjDesc->Method.MethodFlags = MethodFlags; + ObjDesc->Method.MethodFlags = (UINT8) MethodFlags; ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & METHOD_FLAGS_ARG_COUNT); - - /* - * Get the concurrency count. If required, a semaphore will be - * created for this method when it is parsed. + + /* + * Get the concurrency count + * If required, a semaphore will be created for this method when it is parsed. + * + * TBD: [Future] for APCI 2.0, there will be a SyncLevel value, not just a flag + * Concurrency = SyncLevel + 1;. */ if (MethodFlags & METHOD_FLAGS_SERIALIZED) { - /* - * ACPI 1.0: Concurrency = 1 - * ACPI 2.0: Concurrency = (SyncLevel (in method declaration) + 1) - */ - ObjDesc->Method.Concurrency = (UINT8) - (((MethodFlags & METHOD_FLAGS_SYNCH_LEVEL) >> 4) + 1); + ObjDesc->Method.Concurrency = 1; } - else { ObjDesc->Method.Concurrency = INFINITE_CONCURRENCY; } - /* Attach the new object to the method Node */ + /* Mark the Method as not parsed yet */ - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_METHOD); + ObjDesc->Method.ParserOp = NULL; - /* Remove local reference to the object */ + /* Another +1 gets added when AcpiPsxExecute is called, no need for: ObjDesc->Method.Pcode++; */ - AcpiUtRemoveReference (ObjDesc); + ObjDesc->Method.AcpiTable = NULL; /* TBD: [Restructure] was (UINT8 *) PcodeAddr; */ + ObjDesc->Method.TableLength = 0; /* TBD: [Restructure] needed? (UINT32) (WalkState->amlEnd - PcodeAddr); */ - /* Remove a reference to the operand */ + /* Attach the new object to the method NTE */ + + Status = AcpiNsAttachObject (Method, ObjDesc, (UINT8) ACPI_TYPE_METHOD); + if (ACPI_FAILURE (Status)) + { + AcpiCmFree (ObjDesc); + } - AcpiUtRemoveReference (Operand[1]); return_ACPI_STATUS (Status); } + + + +