From ac5eb8e2f15a22885d623222b28c044cb50044d2 Mon Sep 17 00:00:00 2001 From: aystarik Date: Wed, 29 Jun 2005 17:12:52 +0000 Subject: [PATCH] Eliminated construction of full parse tree for main table AML date 2000.07.14.21.51.00; author rmoore1; state Exp; --- source/components/dispatcher/dswload.c | 363 +++++++---- source/components/dispatcher/dswstate.c | 767 ++++++------------------ 2 files changed, 431 insertions(+), 699 deletions(-) diff --git a/source/components/dispatcher/dswload.c b/source/components/dispatcher/dswload.c index ff9685538..90cc66788 100644 --- a/source/components/dispatcher/dswload.c +++ b/source/components/dispatcher/dswload.c @@ -117,12 +117,12 @@ #define __DSWLOAD_C__ #include "acpi.h" -#include "parser.h" +#include "acparser.h" #include "amlcode.h" -#include "dispatch.h" -#include "interp.h" -#include "namesp.h" -#include "events.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" #define _COMPONENT DISPATCHER @@ -145,20 +145,24 @@ ACPI_STATUS AcpiDsLoad1BeginOp ( + UINT16 Opcode, + ACPI_GENERIC_OP *Op, ACPI_WALK_STATE *WalkState, - ACPI_GENERIC_OP *Op) + ACPI_GENERIC_OP **OutOp) { - NAME_TABLE_ENTRY *NewEntry; + ACPI_NAMED_OBJECT *Entry; ACPI_STATUS Status; OBJECT_TYPE_INTERNAL DataType; + char *Path; - DEBUG_PRINT (TRACE_DISPATCH, ("Load1BeginOp: Op=%p State=%p\n", Op, WalkState)); + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1BeginOp: Op=%p State=%p\n", Op, WalkState)); /* We are only interested in opcodes that have an associated name */ - if (!AcpiPsIsNamedOp (Op->Opcode)) + if (!AcpiPsIsNamedOp (Opcode)) { return AE_OK; } @@ -166,29 +170,20 @@ AcpiDsLoad1BeginOp ( /* Check if this object has already been installed in the namespace */ - if (Op->NameTableEntry) + if (Op && Op->AcpiNamedObject) { return AE_OK; } + Path = AcpiPsGetNextNamestring (WalkState->ParserState); + /* Map the raw opcode into an internal object type */ - DataType = AcpiDsMapNamedOpcodeToDataType (Op->Opcode); + DataType = AcpiDsMapNamedOpcodeToDataType (Opcode); - /* Attempt to type a NAME opcode by examining the argument */ - /* TBD: [Investigate] is this the right place to do this? */ - - if (Op->Opcode == AML_NAME_OP) - { - if (Op->Value.Arg) - { - - DataType = AcpiDsMapOpcodeToDataType ((Op->Value.Arg)->Opcode, NULL); - } - } - - DEBUG_PRINT (TRACE_DISPATCH, ("Load1BeginOp: State=%p Op=%p Type=%x\n", WalkState, Op, DataType)); + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1BeginOp: State=%p Op=%p Type=%x\n", WalkState, Op, DataType)); /* @@ -196,18 +191,40 @@ AcpiDsLoad1BeginOp ( * as we go downward in the parse tree. Any necessary subobjects that involve * arguments to the opcode must be created as we go back up the parse tree later. */ - Status = AcpiNsLookup (WalkState->ScopeInfo, (char *) &((ACPI_NAMED_OP *)Op)->Name, DataType, IMODE_LOAD_PASS1, - NS_NO_UPSEARCH, WalkState, &(NewEntry)); + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, + DataType, IMODE_LOAD_PASS1, + NS_NO_UPSEARCH, WalkState, &(Entry)); - if (ACPI_SUCCESS (Status)) + if (ACPI_FAILURE (Status)) { - /* - * Put the NTE in the "op" object that the parser uses, so we - * can get it again quickly when this scope is closed - */ - Op->NameTableEntry = NewEntry; + return (Status); } + if (!Op) + { + /* Create a new op */ + + Op = AcpiPsAllocOp (Opcode); + if (!Op) + { + return (AE_NO_MEMORY); + } + } + + /* Initialize */ + + ((ACPI_NAMED_OP *)Op)->Name = Entry->Name; + + /* + * Put the NTE in the "op" object that the parser uses, so we + * can get it again quickly when this scope is closed + */ + Op->AcpiNamedObject = Entry; + + + AcpiPsAppendArg (AcpiPsGetParentScope (WalkState->ParserState), Op); + + *OutOp = Op; return (Status); } @@ -236,7 +253,8 @@ AcpiDsLoad1EndOp ( OBJECT_TYPE_INTERNAL DataType; - DEBUG_PRINT (TRACE_DISPATCH, ("Load1EndOp: Op=%p State=%p\n", Op, WalkState)); + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1EndOp: Op=%p State=%p\n", Op, WalkState)); /* We are only interested in opcodes that have an associated name */ @@ -245,28 +263,33 @@ AcpiDsLoad1EndOp ( return AE_OK; } - /* TBD: [Investigate] can this be removed? */ - if (Op->Opcode == AML_SCOPE_OP) + /* Get the type to determine if we should pop the scope */ + + DataType = AcpiDsMapNamedOpcodeToDataType (Op->Opcode); + + if (Op->Opcode == AML_NAME_OP) { - DEBUG_PRINT (TRACE_DISPATCH, ("Load1EndOp: ending scope Op=%p State=%p\n", Op, WalkState)); - if (((ACPI_NAMED_OP *)Op)->Name == -1) + /* For Name opcode, check the argument */ + + if (Op->Value.Arg) { - DEBUG_PRINT (ACPI_ERROR, ("Load1EndOp: Un-named scope! Op=%p State=%p\n", Op, WalkState)); - return AE_OK; + DataType = AcpiDsMapOpcodeToDataType ( + (Op->Value.Arg)->Opcode, NULL); + ((ACPI_NAMED_OBJECT*)Op->AcpiNamedObject)->Type = + (UINT8) DataType; } } - DataType = AcpiDsMapNamedOpcodeToDataType (Op->Opcode); - /* Pop the scope stack */ if (AcpiNsOpensScope (DataType)) { - DEBUG_PRINT (TRACE_DISPATCH, ("AmlEndNamespaceScope/%s: Popping scope for Op %p\n", - AcpiCmGetTypeName (DataType), Op)); + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1EndOp/%s: Popping scope for Op %p\n", + AcpiCmGetTypeName (DataType), Op)); AcpiDsScopeStackPop (WalkState); } @@ -291,87 +314,103 @@ AcpiDsLoad1EndOp ( ACPI_STATUS AcpiDsLoad2BeginOp ( + UINT16 Opcode, + ACPI_GENERIC_OP *Op, ACPI_WALK_STATE *WalkState, - ACPI_GENERIC_OP *Op) + ACPI_GENERIC_OP **OutOp) { - NAME_TABLE_ENTRY *NewEntry; + ACPI_NAMED_OBJECT *NewEntry; ACPI_STATUS Status; OBJECT_TYPE_INTERNAL DataType; char *BufferPtr; void *Original = NULL; - DEBUG_PRINT (TRACE_DISPATCH, ("Load2BeginOp: Op=%p State=%p\n", Op, WalkState)); + DEBUG_PRINT (TRACE_DISPATCH, + ("Load2BeginOp: Op=%p State=%p\n", Op, WalkState)); /* We only care about Namespace opcodes here */ - if (!AcpiPsIsNamespaceOp (Op->Opcode) && - Op->Opcode != AML_NAMEPATH_OP) + if (!AcpiPsIsNamespaceOp (Opcode) && + Opcode != AML_NAMEPATH_OP) { return AE_OK; } - /* - * Get the name we are going to enter or lookup in the namespace - */ - if (Op->Opcode == AML_NAMEPATH_OP) + if (Op) { - /* For Namepath op , get the path string */ - - BufferPtr = Op->Value.String; - if (!BufferPtr) + /* + * Get the name we are going to enter or lookup in the namespace + */ + if (Opcode == AML_NAMEPATH_OP) { - /* No name, just exit */ + /* For Namepath op, get the path string */ - return AE_OK; + BufferPtr = Op->Value.String; + if (!BufferPtr) + { + /* No name, just exit */ + + return AE_OK; + } + } + + else + { + /* Get name from the op */ + + BufferPtr = (char *) &((ACPI_NAMED_OP *)Op)->Name; } } else { - /* Get name from the op */ - - BufferPtr = (char *) &((ACPI_NAMED_OP *)Op)->Name; + BufferPtr = AcpiPsGetNextNamestring (WalkState->ParserState); } /* Map the raw opcode into an internal object type */ - DataType = AcpiDsMapNamedOpcodeToDataType (Op->Opcode); + DataType = AcpiDsMapNamedOpcodeToDataType (Opcode); - DEBUG_PRINT (TRACE_DISPATCH, ("Load2BeginOp: State=%p Op=%p Type=%x\n", WalkState, Op, DataType)); + DEBUG_PRINT (TRACE_DISPATCH, + ("Load2BeginOp: State=%p Op=%p Type=%x\n", WalkState, Op, DataType)); - if (Op->Opcode == AML_DEF_FIELD_OP || - Op->Opcode == AML_BANK_FIELD_OP || - Op->Opcode == AML_INDEX_FIELD_OP) + if (Opcode == AML_DEF_FIELD_OP || + Opcode == AML_BANK_FIELD_OP || + Opcode == AML_INDEX_FIELD_OP) { NewEntry = NULL; Status = AE_OK; } - else if (Op->Opcode == AML_NAMEPATH_OP) + else if (Opcode == AML_NAMEPATH_OP) { /* * The NamePath is an object reference to an existing object. Don't enter the * name into the namespace, but look it up for use later */ - Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, DataType, IMODE_EXECUTE, - NS_SEARCH_PARENT, WalkState, &(NewEntry)); + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, + DataType, IMODE_EXECUTE, + NS_SEARCH_PARENT, WalkState, + &(NewEntry)); } else { - if (Op->NameTableEntry) + if (Op && Op->AcpiNamedObject) { - Original = Op->NameTableEntry; - NewEntry = Op->NameTableEntry; + Original = Op->AcpiNamedObject; + NewEntry = Op->AcpiNamedObject; if (AcpiNsOpensScope (DataType)) { - Status = AcpiDsScopeStackPush (NewEntry->Scope, DataType, WalkState); + Status = AcpiDsScopeStackPush (NewEntry->ChildTable, + DataType, + WalkState); if (ACPI_FAILURE (Status)) { return (Status); @@ -386,24 +425,46 @@ AcpiDsLoad2BeginOp ( * as we go downward in the parse tree. Any necessary subobjects that involve * arguments to the opcode must be created as we go back up the parse tree later. */ - Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, DataType, IMODE_EXECUTE, - NS_NO_UPSEARCH, WalkState, &(NewEntry)); + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, + DataType, IMODE_EXECUTE, + NS_NO_UPSEARCH, WalkState, + &(NewEntry)); } if (ACPI_SUCCESS (Status)) { + if (!Op) + { + /* Create a new op */ + + Op = AcpiPsAllocOp (Opcode); + if (!Op) + { + return (AE_NO_MEMORY); + } + + /* Initialize */ + + ((ACPI_NAMED_OP *)Op)->Name = NewEntry->Name; + *OutOp = Op; + } + + /* * Put the NTE in the "op" object that the parser uses, so we * can get it again quickly when this scope is closed */ - Op->NameTableEntry = NewEntry; + Op->AcpiNamedObject = NewEntry; if (Original) { - DEBUG_PRINT (ACPI_INFO, ("Lookup: old %p new %p\n", Original, NewEntry)); + DEBUG_PRINT (ACPI_INFO, + ("Lookup: old %p new %p\n", Original, NewEntry)); + if (Original != NewEntry) { - DEBUG_PRINT (ACPI_INFO, ("Lookup match error: old %p new %p\n", Original, NewEntry)); + DEBUG_PRINT (ACPI_INFO, + ("Lookup match error: old %p new %p\n", Original, NewEntry)); } } } @@ -435,9 +496,9 @@ AcpiDsLoad2EndOp ( { ACPI_STATUS Status = AE_OK; OBJECT_TYPE_INTERNAL DataType; - NAME_TABLE_ENTRY *Entry; + ACPI_NAMED_OBJECT *Entry; ACPI_GENERIC_OP *Arg; - NAME_TABLE_ENTRY *NewEntry; + ACPI_NAMED_OBJECT *NewEntry; DEBUG_PRINT (TRACE_DISPATCH, ("Load2EndOp: Op=%p State=%p\n", Op, WalkState)); @@ -449,10 +510,14 @@ AcpiDsLoad2EndOp ( if (Op->Opcode == AML_SCOPE_OP) { - DEBUG_PRINT (TRACE_DISPATCH, ("Load2EndOp: ending scope Op=%p State=%p\n", Op, WalkState)); + DEBUG_PRINT (TRACE_DISPATCH, + ("Load2EndOp: ending scope Op=%p State=%p\n", Op, WalkState)); + if (((ACPI_NAMED_OP *)Op)->Name == -1) { - DEBUG_PRINT (ACPI_ERROR, ("Load2EndOp: Un-named scope! Op=%p State=%p\n", Op, WalkState)); + DEBUG_PRINT (ACPI_ERROR, + ("Load2EndOp: Un-named scope! Op=%p State=%p\n", Op, + WalkState)); return AE_OK; } } @@ -464,9 +529,12 @@ AcpiDsLoad2EndOp ( * Get the NTE/name from the earlier lookup * (It was saved in the *op structure) */ - Entry = Op->NameTableEntry; + Entry = Op->AcpiNamedObject; - /* Put the NTE on the object stack (Contains the ACPI Name of this object) */ + /* + * Put the NTE on the object stack (Contains the ACPI Name of + * this object) + */ WalkState->Operands[0] = (void *) Entry; WalkState->NumOperands = 1; @@ -476,8 +544,9 @@ AcpiDsLoad2EndOp ( if (AcpiNsOpensScope (DataType)) { - DEBUG_PRINT (TRACE_DISPATCH, ("AmlEndNamespaceScope/%s: Popping scope for Op %p\n", - AcpiCmGetTypeName (DataType), Op)); + DEBUG_PRINT (TRACE_DISPATCH, + ("AmlEndNamespaceScope/%s: Popping scope for Op %p\n", + AcpiCmGetTypeName (DataType), Op)); AcpiDsScopeStackPop (WalkState); } @@ -522,8 +591,9 @@ AcpiDsLoad2EndOp ( case AML_WORD_FIELD_OP: case AML_DWORD_FIELD_OP: - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-CreateXxxField: State=%p Op=%p nte=%p\n", - WalkState, Op, Entry)); + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-CreateXxxField: State=%p Op=%p nte=%p\n", + WalkState, Op, Entry)); /* Get the NameString argument */ @@ -542,15 +612,20 @@ AcpiDsLoad2EndOp ( * Enter the NameString into the namespace */ - Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String, INTERNAL_TYPE_DEF_ANY, IMODE_LOAD_PASS1, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, WalkState, &(NewEntry)); + Status = AcpiNsLookup (WalkState->ScopeInfo, + Arg->Value.String, + INTERNAL_TYPE_DEF_ANY, + IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + WalkState, &(NewEntry)); + if (ACPI_SUCCESS (Status)) { /* We could put the returned object (NTE) on the object stack for later, but * for now, we will put it in the "op" object that the parser uses, so we * can get it again at the end of this scope */ - Op->NameTableEntry = NewEntry; + Op->AcpiNamedObject = NewEntry; } break; @@ -558,15 +633,19 @@ AcpiDsLoad2EndOp ( case AML_METHODCALL_OP: - DEBUG_PRINT (TRACE_DISPATCH, ("RESOLVING-MethodCall: State=%p Op=%p nte=%p\n", - WalkState, Op, Entry)); + DEBUG_PRINT (TRACE_DISPATCH, + ("RESOLVING-MethodCall: State=%p Op=%p nte=%p\n", + WalkState, Op, Entry)); /* * Lookup the method name and save the NTE */ - Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String, ACPI_TYPE_ANY, IMODE_LOAD_PASS2, - NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, WalkState, &(NewEntry)); + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String, + ACPI_TYPE_ANY, IMODE_LOAD_PASS2, + NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, + WalkState, &(NewEntry)); + if (ACPI_SUCCESS (Status)) { @@ -579,7 +658,7 @@ AcpiDsLoad2EndOp ( * for now, we will put it in the "op" object that the parser uses, so we * can get it again at the end of this scope */ - Op->NameTableEntry = NewEntry; + Op->AcpiNamedObject = NewEntry; } @@ -590,8 +669,9 @@ AcpiDsLoad2EndOp ( /* Nothing to do other than enter object into namespace */ - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-Processor: State=%p Op=%p nte=%p\n", - WalkState, Op, Entry)); + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Processor: State=%p Op=%p nte=%p\n", + WalkState, Op, Entry)); Status = AcpiAmlExecCreateProcessor (Op, (ACPI_HANDLE) Entry); if (ACPI_FAILURE (Status)) @@ -599,7 +679,9 @@ AcpiDsLoad2EndOp ( goto Cleanup; } - DEBUG_PRINT (TRACE_DISPATCH, ("Completed Processor Init, Op=%p State=%p entry=%p\n", Op, WalkState, Entry)); + DEBUG_PRINT (TRACE_DISPATCH, + ("Completed Processor Init, Op=%p State=%p entry=%p\n", + Op, WalkState, Entry)); break; @@ -607,8 +689,9 @@ AcpiDsLoad2EndOp ( /* Nothing to do other than enter object into namespace */ - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-PowerResource: State=%p Op=%p nte=%p\n", - WalkState, Op, Entry)); + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-PowerResource: State=%p Op=%p nte=%p\n", + WalkState, Op, Entry)); Status = AcpiAmlExecCreatePowerResource (Op, (ACPI_HANDLE) Entry); if (ACPI_FAILURE (Status)) @@ -616,7 +699,9 @@ AcpiDsLoad2EndOp ( goto Cleanup; } - DEBUG_PRINT (TRACE_DISPATCH, ("Completed PowerResource Init, Op=%p State=%p entry=%p\n", Op, WalkState, Entry)); + DEBUG_PRINT (TRACE_DISPATCH, + ("Completed PowerResource Init, Op=%p State=%p entry=%p\n", + Op, WalkState, Entry)); break; @@ -624,41 +709,50 @@ AcpiDsLoad2EndOp ( /* Nothing to do other than enter object into namespace */ - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-ThermalZone: State=%p Op=%p nte=%p\n", - WalkState, Op, Entry)); - + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-ThermalZone: State=%p Op=%p nte=%p\n", + WalkState, Op, Entry)); break; case AML_DEF_FIELD_OP: - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-Field: State=%p Op=%p nte=%p\n", - WalkState, Op, Entry)); + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Field: State=%p Op=%p nte=%p\n", + WalkState, Op, Entry)); Arg = Op->Value.Arg; - Status = AcpiDsCreateField (Op, (ACPI_HANDLE) Arg->NameTableEntry, WalkState); + Status = AcpiDsCreateField (Op, + (ACPI_HANDLE) Arg->AcpiNamedObject, + WalkState); break; case AML_INDEX_FIELD_OP: - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-IndexField: State=%p Op=%p nte=%p\n", - WalkState, Op, Entry)); + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-IndexField: State=%p Op=%p nte=%p\n", + WalkState, Op, Entry)); Arg = Op->Value.Arg; - Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->NameTableEntry, WalkState); + Status = AcpiDsCreateIndexField (Op, + (ACPI_HANDLE) Arg->AcpiNamedObject, + WalkState); break; case AML_BANK_FIELD_OP: - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-BankField: State=%p Op=%p nte=%p\n", - WalkState, Op, Entry)); + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-BankField: State=%p Op=%p nte=%p\n", + WalkState, Op, Entry)); Arg = Op->Value.Arg; - Status = AcpiDsCreateBankField (Op, (ACPI_HANDLE) Arg->NameTableEntry, WalkState); + Status = AcpiDsCreateBankField (Op, + (ACPI_HANDLE) Arg->AcpiNamedObject, + WalkState); break; @@ -667,13 +761,15 @@ AcpiDsLoad2EndOp ( */ case AML_METHOD_OP: - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-Method: State=%p Op=%p nte=%p\n", - WalkState, Op, Entry)); + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Method: State=%p Op=%p nte=%p\n", + WalkState, Op, Entry)); if (!Entry->Object) { - Status = AcpiAmlExecCreateMethod (((ACPI_DEFERRED_OP *) Op)->Body, ((ACPI_DEFERRED_OP *) Op)->BodyLength, - Arg->Value.Integer, (ACPI_HANDLE) Entry); + Status = AcpiAmlExecCreateMethod (((ACPI_DEFERRED_OP *) Op)->Body, + ((ACPI_DEFERRED_OP *) Op)->BodyLength, + Arg->Value.Integer, (ACPI_HANDLE) Entry); } break; @@ -681,7 +777,8 @@ AcpiDsLoad2EndOp ( case AML_MUTEX_OP: - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-Mutex: Op=%p State=%p\n", Op, WalkState)); + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Mutex: Op=%p State=%p\n", Op, WalkState)); Status = AcpiDsCreateOperands (WalkState, Arg); if (ACPI_FAILURE (Status)) @@ -695,7 +792,8 @@ AcpiDsLoad2EndOp ( case AML_EVENT_OP: - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-Event: Op=%p State=%p\n", Op, WalkState)); + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Event: Op=%p State=%p\n", Op, WalkState)); Status = AcpiDsCreateOperands (WalkState, Arg); if (ACPI_FAILURE (Status)) @@ -709,7 +807,8 @@ AcpiDsLoad2EndOp ( case AML_REGION_OP: - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-Opregion: Op=%p State=%p Nte=%p\n", Op, WalkState, Entry)); + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Opregion: Op=%p State=%p Nte=%p\n", Op, WalkState, Entry)); /* @@ -717,10 +816,13 @@ AcpiDsLoad2EndOp ( * (We must save the address of the AML of the address and length operands) */ - Status = AcpiAmlExecCreateRegion (((ACPI_DEFERRED_OP *) Op)->Body, ((ACPI_DEFERRED_OP *) Op)->BodyLength, + Status = AcpiAmlExecCreateRegion (((ACPI_DEFERRED_OP *) Op)->Body, + ((ACPI_DEFERRED_OP *) Op)->BodyLength, Arg->Value.Integer, WalkState); - DEBUG_PRINT (TRACE_DISPATCH, ("Completed OpRegion Init, Op=%p State=%p entry=%p\n", Op, WalkState, Entry)); + DEBUG_PRINT (TRACE_DISPATCH, + ("Completed OpRegion Init, Op=%p State=%p entry=%p\n", + Op, WalkState, Entry)); break; @@ -728,7 +830,8 @@ AcpiDsLoad2EndOp ( case AML_ALIAS_OP: - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-Alias: Op=%p State=%p\n", Op, WalkState)); + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Alias: Op=%p State=%p\n", Op, WalkState)); Status = AcpiDsCreateOperands (WalkState, Arg); if (ACPI_FAILURE (Status)) @@ -742,7 +845,8 @@ AcpiDsLoad2EndOp ( case AML_NAME_OP: - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-Name: Op=%p State=%p\n", Op, WalkState)); + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Name: Op=%p State=%p\n", Op, WalkState)); Status = AcpiDsCreateNamedObject (WalkState, Entry, Op); @@ -751,8 +855,9 @@ AcpiDsLoad2EndOp ( case AML_NAMEPATH_OP: - DEBUG_PRINT (TRACE_DISPATCH, ("LOADING-NamePath object: State=%p Op=%p nte=%p\n", - WalkState, Op, Entry)); + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-NamePath object: State=%p Op=%p nte=%p\n", + WalkState, Op, Entry)); break; @@ -762,8 +867,8 @@ AcpiDsLoad2EndOp ( Cleanup: - - AcpiDsObjStackPop (1, WalkState); /* Remove the NTE pushed at the very beginning */ + /* Remove the NTE pushed at the very beginning */ + AcpiDsObjStackPop (1, WalkState); return (Status); } diff --git a/source/components/dispatcher/dswstate.c b/source/components/dispatcher/dswstate.c index e04b603ce..9d8478e61 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.77 $ * *****************************************************************************/ @@ -9,8 +8,8 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. - * All rights reserved. + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. * * 2. License * @@ -118,333 +117,38 @@ #define __DSWSTATE_C__ #include "acpi.h" +#include "amlcode.h" #include "acparser.h" #include "acdispat.h" #include "acnamesp.h" +#include "acinterp.h" -#define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dswstate") +#define _COMPONENT DISPATCHER + MODULE_NAME ("dswstate"); /******************************************************************************* * - * FUNCTION: AcpiDsResultInsert + * FUNCTION: AcpiDsResultStackClear * - * PARAMETERS: Object - Object to push - * Index - Where to insert the object - * WalkState - Current Walk state + * PARAMETERS: WalkState - Current Walk state * * RETURN: Status * - * DESCRIPTION: Insert 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 - * Index - Where to extract the 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) -{ - ACPI_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) -{ - ACPI_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; } @@ -452,36 +156,38 @@ AcpiDsResultPush ( * * FUNCTION: AcpiDsResultStackPush * - * PARAMETERS: WalkState - Current Walk state + * PARAMETERS: Object - Object to push + * WalkState - Current Walk state * * 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; } @@ -489,41 +195,56 @@ 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); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Result=%p RemainingResults=%X State=%p\n", - State, State->Results.NumResults, WalkState)); + /* Pop the stack */ - AcpiUtDeleteGenericState (State); + WalkState->NumResults--; - return (AE_OK); + /* Check for a valid result object */ + + 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 +268,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; } } @@ -583,17 +304,16 @@ 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", + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPush: overflow! Obj=%p State=%p #Ops=%X\n", Object, WalkState, WalkState->NumOperands)); - return (AE_STACK_OVERFLOW); + return AE_STACK_OVERFLOW; } /* Put the object onto the stack */ @@ -601,15 +321,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 +344,22 @@ 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", + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPop: Missing operand/stack empty! State=%p #Ops=%X\n", WalkState, WalkState->NumOperands)); - *Object = NULL; - return (AE_AML_NO_OPERAND); + return AE_AML_NO_OPERAND; } + /* Pop the stack */ WalkState->NumOperands--; @@ -651,11 +368,10 @@ AcpiDsObjStackPopObject ( if (!WalkState->Operands [WalkState->NumOperands]) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null operand! State=%p #Ops=%X\n", + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPop: Null operand! State=%p #Ops=%X\n", WalkState, WalkState->NumOperands)); - *Object = NULL; - return (AE_AML_NO_OPERAND); + return AE_AML_NO_OPERAND; } /* Get operand and set stack entry to null */ @@ -663,13 +379,11 @@ 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 /******************************************************************************* @@ -693,8 +407,6 @@ AcpiDsObjStackPop ( { UINT32 i; - ACPI_FUNCTION_NAME ("DsObjStackPop"); - for (i = 0; i < PopCount; i++) { @@ -702,10 +414,10 @@ AcpiDsObjStackPop ( if (WalkState->NumOperands == 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Underflow! Count=%X State=%p #Ops=%X\n", + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPop: Underflow! Count=%X State=%p #Ops=%X\n", PopCount, WalkState, WalkState->NumOperands)); - return (AE_STACK_UNDERFLOW); + return AE_STACK_UNDERFLOW; } /* Just set the stack entry to null */ @@ -714,10 +426,10 @@ 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; } @@ -741,10 +453,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++) @@ -753,10 +462,10 @@ AcpiDsObjStackPopAndDelete ( if (WalkState->NumOperands == 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Underflow! Count=%X State=%p #Ops=%X\n", + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPop: Underflow! Count=%X State=%p #Ops=%X\n", PopCount, WalkState, WalkState->NumOperands)); - return (AE_STACK_UNDERFLOW); + return AE_STACK_UNDERFLOW; } /* Pop the stack and delete an object if present in this stack entry */ @@ -765,15 +474,15 @@ 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; } @@ -798,24 +507,25 @@ 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[(ACPI_NATIVE_UINT)(WalkState->NumOperands - 1) - + + return_PTR (WalkState->Operands[(NATIVE_UINT)(WalkState->NumOperands - 1) - Index]); } @@ -824,32 +534,29 @@ AcpiDsObjStackGetValue ( * * 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, "Current WalkState %p\n", - Thread->WalkStateList)); - - return (Thread->WalkStateList); + return WalkList->WalkState; } @@ -869,13 +576,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; } @@ -897,26 +606,26 @@ AcpiDsPushWalkState ( 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; + * WalkState->Next = NULL; */ } @@ -929,187 +638,77 @@ 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 (ACPI_MTX_CACHES); + AcpiGbl_WalkStateCacheRequests++; + + /* Check the cache first */ + + if (AcpiGbl_WalkStateCache) { - return_PTR (NULL); + /* There is an object available, use it */ + + WalkState = AcpiGbl_WalkStateCache; + AcpiGbl_WalkStateCache = WalkState->Next; + + AcpiGbl_WalkStateCacheHits++; + AcpiGbl_WalkStateCacheDepth--; + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + + else + { + /* The cache is empty, create a new object */ + + /* Avoid deadlock with AcpiCmCallocate */ + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + + WalkState = AcpiCmCallocate (sizeof (ACPI_WALK_STATE)); + if (!WalkState) + { + return_VALUE (NULL); + } } WalkState->DataType = ACPI_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 - * Op - Current parse op - * MethodNode - Control method NS node, if any - * AmlStart - Start of AML - * AmlLength - Length of AML - * Params - Method args, if any - * ReturnObjDesc - Where to store a return object, if any - * PassNumber - 1, 2, or 3 - * - * RETURN: Status - * - * 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 @@ -1129,7 +728,7 @@ AcpiDsDeleteWalkState ( ACPI_GENERIC_STATE *State; - ACPI_FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState); + FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState); if (!WalkState) @@ -1139,15 +738,11 @@ AcpiDsDeleteWalkState ( if (WalkState->DataType != ACPI_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 */ while (WalkState->ControlState) @@ -1155,9 +750,10 @@ AcpiDsDeleteWalkState ( State = WalkState->ControlState; WalkState->ControlState = State->Common.Next; - AcpiUtDeleteGenericState (State); + AcpiCmDeleteGenericState (State); } + /* Always must free any linked parse states */ while (WalkState->ScopeInfo) @@ -1165,20 +761,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 (AcpiGbl_WalkStateCacheDepth >= 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 (ACPI_MTX_CACHES); + + /* Clear the state */ + + MEMSET (WalkState, 0, sizeof (ACPI_WALK_STATE)); + WalkState->DataType = ACPI_DESC_TYPE_WALK; + + /* Put the object at the head of the global cache list */ + + WalkState->Next = AcpiGbl_WalkStateCache; + AcpiGbl_WalkStateCache = WalkState; + AcpiGbl_WalkStateCacheDepth++; + + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); } - AcpiUtReleaseToCache (ACPI_MEM_LIST_WALK, WalkState); return_VOID; } @@ -1200,10 +813,24 @@ 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 (AcpiGbl_WalkStateCache) + { + /* Delete one cached state object */ + + Next = AcpiGbl_WalkStateCache->Next; + AcpiCmFree (AcpiGbl_WalkStateCache); + AcpiGbl_WalkStateCache = Next; + AcpiGbl_WalkStateCacheDepth--; + } + return_VOID; }