From 0aa1813870ba304ef4d92632c605b4f3d1d44a6c Mon Sep 17 00:00:00 2001 From: aystarik Date: Wed, 29 Jun 2005 17:03:51 +0000 Subject: [PATCH] Deployed new UtGetObjectTypeName function. Fully deployed use of ACPI_GET_OBJECT_TYPE macro for consistency. date 2002.06.07.21.28.00; author rmoore1; state Exp; --- source/components/dispatcher/dsmthdat.c | 77 +-- source/components/dispatcher/dsobject.c | 565 +++++++++------- source/components/dispatcher/dsopcode.c | 815 +++++++++++++++--------- source/components/dispatcher/dswexec.c | 53 +- source/components/dispatcher/dswstate.c | 515 +++++++-------- source/components/executer/exconfig.c | 571 ++++++++++------- source/components/executer/exconvrt.c | 497 +++++++++------ 7 files changed, 1859 insertions(+), 1234 deletions(-) diff --git a/source/components/dispatcher/dsmthdat.c b/source/components/dispatcher/dsmthdat.c index a16ff2676..622055e04 100644 --- a/source/components/dispatcher/dsmthdat.c +++ b/source/components/dispatcher/dsmthdat.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dsmthdat - control method arguments and local variables - * $Revision: 1.56 $ + * $Revision: 1.62 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -117,15 +117,13 @@ #define __DSMTHDAT_C__ #include "acpi.h" -#include "acparser.h" #include "acdispat.h" -#include "acinterp.h" #include "amlcode.h" #include "acnamesp.h" #define _COMPONENT ACPI_DISPATCHER - MODULE_NAME ("dsmthdat") + ACPI_MODULE_NAME ("dsmthdat") /******************************************************************************* @@ -149,42 +147,42 @@ * ******************************************************************************/ -ACPI_STATUS +void AcpiDsMethodDataInit ( ACPI_WALK_STATE *WalkState) { UINT32 i; - FUNCTION_TRACE ("DsMethodDataInit"); + ACPI_FUNCTION_TRACE ("DsMethodDataInit"); /* Init the method arguments */ for (i = 0; i < MTH_NUM_ARGS; i++) { - MOVE_UNALIGNED32_TO_32 (&WalkState->Arguments[i].Name, + ACPI_MOVE_UNALIGNED32_TO_32 (&WalkState->Arguments[i].Name, NAMEOF_ARG_NTE); - WalkState->Arguments[i].Name |= (i << 24); - WalkState->Arguments[i].Descriptor = ACPI_DESC_TYPE_NAMED; - WalkState->Arguments[i].Type = ACPI_TYPE_ANY; - WalkState->Arguments[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; + WalkState->Arguments[i].Name.Integer |= (i << 24); + WalkState->Arguments[i].Descriptor = ACPI_DESC_TYPE_NAMED; + WalkState->Arguments[i].Type = ACPI_TYPE_ANY; + WalkState->Arguments[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; } /* Init the method locals */ for (i = 0; i < MTH_NUM_LOCALS; i++) { - MOVE_UNALIGNED32_TO_32 (&WalkState->LocalVariables[i].Name, + ACPI_MOVE_UNALIGNED32_TO_32 (&WalkState->LocalVariables[i].Name, NAMEOF_LOCAL_NTE); - WalkState->LocalVariables[i].Name |= (i << 24); - WalkState->LocalVariables[i].Descriptor = ACPI_DESC_TYPE_NAMED; - WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY; - WalkState->LocalVariables[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; + WalkState->LocalVariables[i].Name.Integer |= (i << 24); + WalkState->LocalVariables[i].Descriptor = ACPI_DESC_TYPE_NAMED; + WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY; + WalkState->LocalVariables[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; } - return_ACPI_STATUS (AE_OK); + return_VOID; } @@ -194,21 +192,21 @@ AcpiDsMethodDataInit ( * * PARAMETERS: WalkState - Current walk state object * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Delete method locals and arguments. Arguments are only * deleted if this method was called from another method. * ******************************************************************************/ -ACPI_STATUS +void AcpiDsMethodDataDeleteAll ( ACPI_WALK_STATE *WalkState) { UINT32 Index; - FUNCTION_TRACE ("DsMethodDataDeleteAll"); + ACPI_FUNCTION_TRACE ("DsMethodDataDeleteAll"); /* Detach the locals */ @@ -223,7 +221,7 @@ AcpiDsMethodDataDeleteAll ( /* Detach object (if present) and remove a reference */ AcpiNsDetachObject (&WalkState->LocalVariables[Index]); - } + } } /* Detach the arguments */ @@ -241,7 +239,7 @@ AcpiDsMethodDataDeleteAll ( } } - return_ACPI_STATUS (AE_OK); + return_VOID; } @@ -271,7 +269,7 @@ AcpiDsMethodDataInitArgs ( UINT32 Index = 0; - FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params); + ACPI_FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params); if (!Params) @@ -323,7 +321,7 @@ AcpiDsMethodDataGetNode ( ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **Node) { - FUNCTION_TRACE ("DsMethodDataGetNode"); + ACPI_FUNCTION_TRACE ("DsMethodDataGetNode"); /* @@ -394,7 +392,7 @@ AcpiDsMethodDataSetValue ( ACPI_NAMESPACE_NODE *Node; - FUNCTION_TRACE ("DsMethodDataSetValue"); + ACPI_FUNCTION_TRACE ("DsMethodDataSetValue"); /* Get the namespace node for the arg/local */ @@ -440,7 +438,7 @@ AcpiDsMethodDataGetType ( ACPI_OPERAND_OBJECT *Object; - FUNCTION_TRACE ("DsMethodDataGetType"); + ACPI_FUNCTION_TRACE ("DsMethodDataGetType"); /* Get the namespace node for the arg/local */ @@ -463,7 +461,7 @@ AcpiDsMethodDataGetType ( /* Get the object type */ - return_VALUE (Object->Common.Type); + return_VALUE (ACPI_GET_OBJECT_TYPE (Object)); } @@ -497,7 +495,7 @@ AcpiDsMethodDataGetValue ( ACPI_OPERAND_OBJECT *Object; - FUNCTION_TRACE ("DsMethodDataGetValue"); + ACPI_FUNCTION_TRACE ("DsMethodDataGetValue"); /* Validate the object descriptor */ @@ -546,6 +544,9 @@ AcpiDsMethodDataGetValue ( Index, Node)); return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); + + default: + return_ACPI_STATUS (AE_AML_INTERNAL); } } @@ -568,14 +569,14 @@ AcpiDsMethodDataGetValue ( * Index - Which localVar or argument to delete * WalkState - Current walk state object * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts * a null into the stack slot after the object is deleted. * ******************************************************************************/ -ACPI_STATUS +void AcpiDsMethodDataDeleteValue ( UINT16 Opcode, UINT32 Index, @@ -586,7 +587,7 @@ AcpiDsMethodDataDeleteValue ( ACPI_OPERAND_OBJECT *Object; - FUNCTION_TRACE ("DsMethodDataDeleteValue"); + ACPI_FUNCTION_TRACE ("DsMethodDataDeleteValue"); /* Get the namespace node for the arg/local */ @@ -594,7 +595,7 @@ AcpiDsMethodDataDeleteValue ( Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + return_VOID; } /* Get the associated object */ @@ -609,7 +610,7 @@ AcpiDsMethodDataDeleteValue ( Node->Object = NULL; if ((Object) && - (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_INTERNAL)) + (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND)) { /* * There is a valid object. @@ -619,7 +620,7 @@ AcpiDsMethodDataDeleteValue ( AcpiUtRemoveReference (Object); } - return_ACPI_STATUS (AE_OK); + return_VOID; } @@ -652,7 +653,7 @@ AcpiDsStoreObjectToLocal ( ACPI_OPERAND_OBJECT *CurrentObjDesc; - FUNCTION_TRACE ("DsStoreObjectToLocal"); + ACPI_FUNCTION_TRACE ("DsStoreObjectToLocal"); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n", Opcode, Index, ObjDesc)); @@ -718,8 +719,8 @@ AcpiDsStoreObjectToLocal ( * Store this object into the Node * (perform the indirect store) */ - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc, - ObjDesc, ObjDesc->Common.Type); + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc, + ObjDesc, ACPI_GET_OBJECT_TYPE (ObjDesc)); return_ACPI_STATUS (Status); } diff --git a/source/components/dispatcher/dsobject.c b/source/components/dispatcher/dsobject.c index 14806efd1..13853841a 100644 --- a/source/components/dispatcher/dsobject.c +++ b/source/components/dispatcher/dsobject.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsobject - Dispatcher object management routines - * $Revision: 1.87 $ + * $Revision: 1.103 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -120,11 +120,11 @@ #include "acparser.h" #include "amlcode.h" #include "acdispat.h" -#include "acinterp.h" #include "acnamesp.h" +#include "acinterp.h" #define _COMPONENT ACPI_DISPATCHER - MODULE_NAME ("dsobject") + ACPI_MODULE_NAME ("dsobject") /******************************************************************************* @@ -139,11 +139,11 @@ * RETURN: Status * * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object - * within the namespace. + * within the namespace. * * Currently, the only objects that require initialization are: * 1) Methods - * 2) Op Regions + * 2) Operation Regions * ******************************************************************************/ @@ -157,15 +157,11 @@ AcpiDsInitOneObject ( ACPI_OBJECT_TYPE Type; ACPI_STATUS Status; ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; - UINT8 TableRevision; - PROC_NAME ("DsInitOneObject"); + ACPI_FUNCTION_NAME ("DsInitOneObject"); - Info->ObjectCount++; - TableRevision = Info->TableDesc->Pointer->Revision; - /* * We are only interested in objects owned by the table that * was just loaded @@ -176,6 +172,7 @@ AcpiDsInitOneObject ( return (AE_OK); } + Info->ObjectCount++; /* And even then, we are only interested in a few object types */ @@ -185,7 +182,13 @@ AcpiDsInitOneObject ( { case ACPI_TYPE_REGION: - AcpiDsInitializeRegion (ObjHandle); + Status = AcpiDsInitializeRegion (ObjHandle); + if (ACPI_FAILURE (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %p [%4.4s] - Init failure, %s\n", + ObjHandle, ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii, + AcpiFormatException (Status))); + } Info->OpRegionCount++; break; @@ -203,10 +206,12 @@ AcpiDsInitOneObject ( /* * Set the execution data width (32 or 64) based upon the * revision number of the parent ACPI table. + * TBD: This is really for possible future support of integer width + * on a per-table basis. Currently, we just use a global for the width. */ - if (TableRevision == 1) + if (Info->TableDesc->Pointer->Revision == 1) { - ((ACPI_NAMESPACE_NODE *)ObjHandle)->Flags |= ANOBJ_DATA_WIDTH_32; + ((ACPI_NAMESPACE_NODE *) ObjHandle)->Flags |= ANOBJ_DATA_WIDTH_32; } /* @@ -217,7 +222,7 @@ AcpiDsInitOneObject ( if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n", - ObjHandle, (char *) &((ACPI_NAMESPACE_NODE *) ObjHandle)->Name, + ObjHandle, ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii, AcpiFormatException (Status))); /* This parse failed, but we will continue parsing more methods */ @@ -233,6 +238,13 @@ AcpiDsInitOneObject ( AcpiNsDeleteNamespaceByOwner (((ACPI_NAMESPACE_NODE *) ObjHandle)->Object->Method.OwningId); break; + + case ACPI_TYPE_DEVICE: + + Info->DeviceCount++; + break; + + default: break; } @@ -249,12 +261,13 @@ AcpiDsInitOneObject ( * * FUNCTION: AcpiDsInitializeObjects * - * PARAMETERS: None + * PARAMETERS: TableDesc - Descriptor for parent ACPI table + * StartNode - Root of subtree to be initialized. * * RETURN: Status * - * DESCRIPTION: Walk the entire namespace and perform any necessary - * initialization on the objects found therein + * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any + * necessary initialization on the objects found therein * ******************************************************************************/ @@ -267,36 +280,36 @@ AcpiDsInitializeObjects ( ACPI_INIT_WALK_INFO Info; - FUNCTION_TRACE ("DsInitializeObjects"); + ACPI_FUNCTION_TRACE ("DsInitializeObjects"); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "**** Starting initialization of namespace objects ****\n")); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "Parsing Methods:")); - Info.MethodCount = 0; Info.OpRegionCount = 0; Info.ObjectCount = 0; + Info.DeviceCount = 0; Info.TableDesc = TableDesc; - /* Walk entire namespace from the supplied root */ Status = AcpiWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX, AcpiDsInitOneObject, &Info, NULL); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "WalkNamespace failed! %x\n", Status)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "WalkNamespace failed, %s\n", + AcpiFormatException (Status))); } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, - "\n%d Control Methods found and parsed (%d nodes total)\n", - Info.MethodCount, Info.ObjectCount)); + "\nTable [%4.4s] - %hd Objects with %hd Devices %hd Methods %hd Regions\n", + TableDesc->Pointer->Signature, Info.ObjectCount, + Info.DeviceCount, Info.MethodCount, Info.OpRegionCount)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "%d Control Methods found\n", Info.MethodCount)); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "%d Op Regions found\n", Info.OpRegionCount)); + "%hd Methods, %hd Regions\n", Info.MethodCount, Info.OpRegionCount)); return_ACPI_STATUS (AE_OK); } @@ -306,9 +319,10 @@ AcpiDsInitializeObjects ( * * FUNCTION: AcpiDsInitObjectFromOp * - * PARAMETERS: Op - Parser op used to init the internal object + * PARAMETERS: WalkState - Current walk state + * Op - Parser op used to init the internal object * Opcode - AML opcode associated with the object - * ObjDesc - Namespace object to be initialized + * RetObjDesc - Namespace object to be initialized * * RETURN: Status * @@ -325,15 +339,12 @@ AcpiDsInitObjectFromOp ( UINT16 Opcode, ACPI_OPERAND_OBJECT **RetObjDesc) { - ACPI_STATUS Status; - ACPI_PARSE_OBJECT *Arg; - ACPI_PARSE2_OBJECT *ByteList; - ACPI_OPERAND_OBJECT *ArgDesc; const ACPI_OPCODE_INFO *OpInfo; ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status = AE_OK; - PROC_NAME ("DsInitObjectFromOp"); + ACPI_FUNCTION_TRACE ("DsInitObjectFromOp"); ObjDesc = *RetObjDesc; @@ -342,113 +353,102 @@ AcpiDsInitObjectFromOp ( { /* Unknown opcode */ - return (AE_TYPE); + return_ACPI_STATUS (AE_TYPE); } + /* Perform per-object initialization */ - /* Get and prepare the first argument */ - - switch (ObjDesc->Common.Type) + switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_BUFFER: - ObjDesc->Buffer.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; - - /* First arg is a number */ - - AcpiDsCreateOperand (WalkState, Op->Value.Arg, 0); - ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; - AcpiDsObjStackPop (1, WalkState); - - /* Resolve the object (could be an arg or local) */ - - Status = AcpiExResolveToValue (&ArgDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (ArgDesc); - return (Status); - } - - /* We are expecting a number */ - - if (ArgDesc->Common.Type != ACPI_TYPE_INTEGER) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Expecting number, got obj: %p type %X\n", - ArgDesc, ArgDesc->Common.Type)); - AcpiUtRemoveReference (ArgDesc); - return (AE_TYPE); - } - - /* Get the value, delete the internal object */ - - ObjDesc->Buffer.Length = (UINT32) ArgDesc->Integer.Value; - AcpiUtRemoveReference (ArgDesc); - - /* Allocate the buffer */ - - if (ObjDesc->Buffer.Length == 0) - { - ObjDesc->Buffer.Pointer = NULL; - REPORT_WARNING (("Buffer created with zero length in AML\n")); - break; - } - - else - { - ObjDesc->Buffer.Pointer = ACPI_MEM_CALLOCATE ( - ObjDesc->Buffer.Length); - - if (!ObjDesc->Buffer.Pointer) - { - return (AE_NO_MEMORY); - } - } - /* - * Second arg is the buffer data (optional) ByteList can be either - * individual bytes or a string initializer. + * Defer evaluation of Buffer TermArg operand */ - Arg = Op->Value.Arg; /* skip first arg */ - - ByteList = (ACPI_PARSE2_OBJECT *) Arg->Next; - if (ByteList) - { - if (ByteList->Opcode != AML_INT_BYTELIST_OP) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Expecting bytelist, got: %p\n", - ByteList)); - return (AE_TYPE); - } - - MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Data, - ObjDesc->Buffer.Length); - } - + ObjDesc->Buffer.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + ObjDesc->Buffer.AmlStart = Op->Named.Data; + ObjDesc->Buffer.AmlLength = Op->Named.Length; break; case ACPI_TYPE_PACKAGE: /* - * When called, an internal package object has already been built and - * is pointed to by ObjDesc. AcpiDsBuildInternalObject builds another - * internal package object, so remove reference to the original so - * that it is deleted. Error checking is done within the remove - * reference function. + * Defer evaluation of Package TermArg operand */ - AcpiUtRemoveReference (ObjDesc); - Status = AcpiDsBuildInternalObject (WalkState, Op, RetObjDesc); + ObjDesc->Package.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + ObjDesc->Package.AmlStart = Op->Named.Data; + ObjDesc->Package.AmlLength = Op->Named.Length; break; - case ACPI_TYPE_INTEGER: - ObjDesc->Integer.Value = Op->Value.Integer; + + case ACPI_TYPE_INTEGER: + + switch (OpInfo->Type) + { + case AML_TYPE_CONSTANT: + /* + * Resolve AML Constants here - AND ONLY HERE! + * All constants are integers. + * We mark the integer with a flag that indicates that it started life + * as a constant -- so that stores to constants will perform as expected (noop). + * (ZeroOp is used as a placeholder for optional target operands.) + */ + ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT; + + switch (Opcode) + { + case AML_ZERO_OP: + + ObjDesc->Integer.Value = 0; + break; + + case AML_ONE_OP: + + ObjDesc->Integer.Value = 1; + break; + + case AML_ONES_OP: + + ObjDesc->Integer.Value = ACPI_INTEGER_MAX; + + /* Truncate value if we are executing from a 32-bit ACPI table */ + + AcpiExTruncateFor32bitTable (ObjDesc); + break; + + case AML_REVISION_OP: + + ObjDesc->Integer.Value = ACPI_CA_SUPPORT_LEVEL; + break; + + default: + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown constant opcode %X\n", Opcode)); + Status = AE_AML_OPERAND_TYPE; + break; + } + break; + + + case AML_TYPE_LITERAL: + + ObjDesc->Integer.Value = Op->Common.Value.Integer; + break; + + + default: + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", OpInfo->Type)); + Status = AE_AML_OPERAND_TYPE; + break; + } break; case ACPI_TYPE_STRING: - ObjDesc->String.Pointer = Op->Value.String; - ObjDesc->String.Length = STRLEN (Op->Value.String); + + ObjDesc->String.Pointer = Op->Common.Value.String; + ObjDesc->String.Length = ACPI_STRLEN (Op->Common.Value.String); /* * The string is contained in the ACPI table, don't ever try @@ -484,39 +484,40 @@ AcpiDsInitObjectFromOp ( break; - default: /* Constants, Literals, etc.. */ + default: /* Other literals, etc.. */ - if (Op->Opcode == AML_INT_NAMEPATH_OP) + if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) { /* Node was saved in Op */ - ObjDesc->Reference.Node = Op->Node; + ObjDesc->Reference.Node = Op->Common.Node; } ObjDesc->Reference.Opcode = Opcode; break; } - break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented data type: %x\n", - ObjDesc->Common.Type)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented data type: %X\n", + ACPI_GET_OBJECT_TYPE (ObjDesc))); + Status = AE_AML_OPERAND_TYPE; break; } - return (AE_OK); + return_ACPI_STATUS (Status); } /***************************************************************************** * - * FUNCTION: AcpiDsBuildInternalSimpleObj + * FUNCTION: AcpiDsBuildInternalObject * - * PARAMETERS: Op - Parser object to be translated + * PARAMETERS: WalkState - Current walk state + * Op - Parser object to be translated * ObjDescPtr - Where the ACPI internal object is returned * * RETURN: Status @@ -526,8 +527,8 @@ AcpiDsInitObjectFromOp ( * ****************************************************************************/ -static ACPI_STATUS -AcpiDsBuildInternalSimpleObj ( +ACPI_STATUS +AcpiDsBuildInternalObject ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT **ObjDescPtr) @@ -537,46 +538,43 @@ AcpiDsBuildInternalSimpleObj ( char *Name; - FUNCTION_TRACE ("DsBuildInternalSimpleObj"); + ACPI_FUNCTION_TRACE ("DsBuildInternalObject"); - if (Op->Opcode == AML_INT_NAMEPATH_OP) + if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) { /* - * This is an object reference. If this name was + * This is an named object reference. If this name was * previously looked up in the namespace, it was stored in this op. * Otherwise, go ahead and look it up now */ - if (!Op->Node) + if (!Op->Common.Node) { - Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Value.String, - ACPI_TYPE_ANY, IMODE_EXECUTE, - NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, NULL, - (ACPI_NAMESPACE_NODE **) &(Op->Node)); + Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, + (ACPI_NAMESPACE_NODE **) &(Op->Common.Node)); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) { Name = NULL; - AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Value.String, NULL, &Name); - - if (Name) + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Common.Value.String, NULL, &Name); + if (ACPI_SUCCESS (Status)) { - REPORT_WARNING (("Reference %s at AML %X not found\n", - Name, Op->AmlOffset)); + ACPI_REPORT_WARNING (("Reference %s at AML %X not found\n", + Name, Op->Common.AmlOffset)); ACPI_MEM_FREE (Name); } - else { - REPORT_WARNING (("Reference %s at AML %X not found\n", - Op->Value.String, Op->AmlOffset)); + ACPI_REPORT_WARNING (("Reference %s at AML %X not found\n", + Op->Common.Value.String, Op->Common.AmlOffset)); } *ObjDescPtr = NULL; } - else { return_ACPI_STATUS (Status); @@ -587,13 +585,13 @@ AcpiDsBuildInternalSimpleObj ( /* Create and init the internal ACPI object */ - ObjDesc = AcpiUtCreateInternalObject ((AcpiPsGetOpcodeInfo (Op->Opcode))->ObjectType); + ObjDesc = AcpiUtCreateInternalObject ((AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Opcode, &ObjDesc); + Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Common.AmlOpcode, &ObjDesc); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ObjDesc); @@ -601,7 +599,123 @@ AcpiDsBuildInternalSimpleObj ( } *ObjDescPtr = ObjDesc; + return_ACPI_STATUS (AE_OK); +} + +/***************************************************************************** + * + * FUNCTION: AcpiDsBuildInternalBufferObj + * + * PARAMETERS: WalkState - Current walk state + * Op - Parser object to be translated + * BufferLength - Length of the buffer + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op package object to the equivalent + * namespace object + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsBuildInternalBufferObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 BufferLength, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_PARSE_OBJECT *Arg; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARSE_OBJECT *ByteList; + UINT32 ByteListLength = 0; + + + ACPI_FUNCTION_TRACE ("DsBuildInternalBufferObj"); + + + ObjDesc = *ObjDescPtr; + if (ObjDesc) + { + /* + * We are evaluating a Named buffer object "Name (xxxx, Buffer)". + * The buffer object already exists (from the NS node) + */ + } + else + { + /* Create a new buffer object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + *ObjDescPtr = ObjDesc; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + + /* + * Second arg is the buffer data (optional) ByteList can be either + * individual bytes or a string initializer. In either case, a + * ByteList appears in the AML. + */ + Arg = Op->Common.Value.Arg; /* skip first arg */ + + ByteList = Arg->Named.Next; + if (ByteList) + { + if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Expecting bytelist, got AML opcode %X in op %p\n", + ByteList->Common.AmlOpcode, ByteList)); + + AcpiUtRemoveReference (ObjDesc); + return (AE_TYPE); + } + + ByteListLength = ByteList->Common.Value.Integer32; + } + + /* + * The buffer length (number of bytes) will be the larger of: + * 1) The specified buffer length and + * 2) The length of the initializer byte list + */ + ObjDesc->Buffer.Length = BufferLength; + if (ByteListLength > BufferLength) + { + ObjDesc->Buffer.Length = ByteListLength; + } + + /* Allocate the buffer */ + + if (ObjDesc->Buffer.Length == 0) + { + ObjDesc->Buffer.Pointer = NULL; + ACPI_REPORT_WARNING (("Buffer created with zero length in AML\n")); + return_ACPI_STATUS (AE_OK); + } + + ObjDesc->Buffer.Pointer = ACPI_MEM_CALLOCATE ( + ObjDesc->Buffer.Length); + if (!ObjDesc->Buffer.Pointer) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize buffer from the ByteList (if present) */ + + if (ByteList) + { + ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Named.Data, + ByteListLength); + } + + ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; + Op->Common.Node = (ACPI_NAMESPACE_NODE *) ObjDesc; return_ACPI_STATUS (AE_OK); } @@ -610,7 +724,9 @@ AcpiDsBuildInternalSimpleObj ( * * FUNCTION: AcpiDsBuildInternalPackageObj * - * PARAMETERS: Op - Parser object to be translated + * PARAMETERS: WalkState - Current walk state + * Op - Parser object to be translated + * PackageLength - Number of elements in the package * ObjDescPtr - Where the ACPI internal object is returned * * RETURN: Status @@ -624,43 +740,78 @@ ACPI_STATUS AcpiDsBuildInternalPackageObj ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, + UINT32 PackageLength, ACPI_OPERAND_OBJECT **ObjDescPtr) { ACPI_PARSE_OBJECT *Arg; - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARSE_OBJECT *Parent; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + UINT32 PackageListLength; ACPI_STATUS Status = AE_OK; + UINT32 i; - FUNCTION_TRACE ("DsBuildInternalPackageObj"); + ACPI_FUNCTION_TRACE ("DsBuildInternalPackageObj"); - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); - *ObjDescPtr = ObjDesc; - if (!ObjDesc) + /* Find the parent of a possibly nested package */ + + Parent = Op->Common.Parent; + while ((Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) { - return_ACPI_STATUS (AE_NO_MEMORY); + Parent = Parent->Common.Parent; } - if (Op->Opcode == AML_VAR_PACKAGE_OP) + ObjDesc = *ObjDescPtr; + if (ObjDesc) { /* - * Variable length package parameters are evaluated JIT + * We are evaluating a Named package object "Name (xxxx, Package)". + * Get the existing package object from the NS node */ - return_ACPI_STATUS (AE_OK); + } + else + { + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); + *ObjDescPtr = ObjDesc; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Package.Node = Parent->Common.Node; } - /* The first argument must be the package length */ + ObjDesc->Package.Count = PackageLength; - Arg = Op->Value.Arg; - ObjDesc->Package.Count = Arg->Value.Integer32; + /* Count the number of items in the package list */ + + PackageListLength = 0; + Arg = Op->Common.Value.Arg; + Arg = Arg->Common.Next; + while (Arg) + { + PackageListLength++; + Arg = Arg->Common.Next; + } /* - * Allocate the array of pointers (ptrs to the - * individual objects) Add an extra pointer slot so + * The package length (number of elements) will be the greater + * of the specified length and the length of the initializer list + */ + if (PackageListLength > PackageLength) + { + ObjDesc->Package.Count = PackageListLength; + } + + /* + * Allocate the pointer array (array of pointers to the + * individual objects). Add an extra pointer slot so * that the list is always null terminated. */ ObjDesc->Package.Elements = ACPI_MEM_CALLOCATE ( - (ObjDesc->Package.Count + 1) * sizeof (void *)); + ((ACPI_SIZE) ObjDesc->Package.Count + 1) * sizeof (void *)); if (!ObjDesc->Package.Elements) { @@ -668,87 +819,47 @@ AcpiDsBuildInternalPackageObj ( return_ACPI_STATUS (AE_NO_MEMORY); } - ObjDesc->Package.NextElement = ObjDesc->Package.Elements; - /* * Now init the elements of the package */ - Arg = Arg->Next; + i = 0; + Arg = Op->Common.Value.Arg; + Arg = Arg->Common.Next; while (Arg) { - if (Arg->Opcode == AML_PACKAGE_OP) + if (Arg->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) { - Status = AcpiDsBuildInternalPackageObj (WalkState, Arg, - ObjDesc->Package.NextElement); - } + /* Object (package or buffer) is already built */ + ObjDesc->Package.Elements[i] = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node); + } else { - Status = AcpiDsBuildInternalSimpleObj (WalkState, Arg, - ObjDesc->Package.NextElement); + Status = AcpiDsBuildInternalObject (WalkState, Arg, + &ObjDesc->Package.Elements[i]); } - ObjDesc->Package.NextElement++; - Arg = Arg->Next; + i++; + Arg = Arg->Common.Next; } ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID; + Op->Common.Node = (ACPI_NAMESPACE_NODE *) ObjDesc; return_ACPI_STATUS (Status); } -/***************************************************************************** - * - * FUNCTION: AcpiDsBuildInternalObject - * - * PARAMETERS: Op - Parser object to be translated - * ObjDescPtr - Where the ACPI internal object is returned - * - * RETURN: Status - * - * DESCRIPTION: Translate a parser Op object to the equivalent namespace - * object - * - ****************************************************************************/ - -ACPI_STATUS -AcpiDsBuildInternalObject ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op, - ACPI_OPERAND_OBJECT **ObjDescPtr) -{ - ACPI_STATUS Status; - - - switch (Op->Opcode) - { - case AML_PACKAGE_OP: - case AML_VAR_PACKAGE_OP: - - Status = AcpiDsBuildInternalPackageObj (WalkState, Op, ObjDescPtr); - break; - - - default: - - Status = AcpiDsBuildInternalSimpleObj (WalkState, Op, ObjDescPtr); - break; - } - - return (Status); -} - - /***************************************************************************** * * FUNCTION: AcpiDsCreateNode * - * PARAMETERS: Op - Parser object to be translated - * ObjDescPtr - Where the ACPI internal object is returned + * PARAMETERS: WalkState - Current walk state + * Node - NS Node to be initialized + * Op - Parser object to be translated * * RETURN: Status * - * DESCRIPTION: + * DESCRIPTION: Create the object to be associated with a namespace node * ****************************************************************************/ @@ -762,7 +873,7 @@ AcpiDsCreateNode ( ACPI_OPERAND_OBJECT *ObjDesc; - FUNCTION_TRACE_PTR ("DsCreateNode", Op); + ACPI_FUNCTION_TRACE_PTR ("DsCreateNode", Op); /* @@ -775,7 +886,7 @@ AcpiDsCreateNode ( return_ACPI_STATUS (AE_OK); } - if (!Op->Value.Arg) + if (!Op->Common.Value.Arg) { /* No arguments, there is nothing to do */ @@ -784,7 +895,7 @@ AcpiDsCreateNode ( /* Build an internal object for the argument(s) */ - Status = AcpiDsBuildInternalObject (WalkState, Op->Value.Arg, &ObjDesc); + Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -792,9 +903,9 @@ AcpiDsCreateNode ( /* Re-type the object according to it's argument */ - Node->Type = ObjDesc->Common.Type; + Node->Type = ACPI_GET_OBJECT_TYPE (ObjDesc); - /* Init obj */ + /* Attach obj to node */ Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type); diff --git a/source/components/dispatcher/dsopcode.c b/source/components/dispatcher/dsopcode.c index 0659f8c2a..2def73c8c 100644 --- a/source/components/dispatcher/dsopcode.c +++ b/source/components/dispatcher/dsopcode.c @@ -2,7 +2,7 @@ * * Module Name: dsopcode - Dispatcher Op Region support and handling of * "control" opcodes - * $Revision: 1.67 $ + * $Revision: 1.80 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -124,10 +124,9 @@ #include "acinterp.h" #include "acnamesp.h" #include "acevents.h" -#include "actables.h" #define _COMPONENT ACPI_DISPATCHER - MODULE_NAME ("dsopcode") + ACPI_MODULE_NAME ("dsopcode") /***************************************************************************** @@ -135,7 +134,8 @@ * FUNCTION: AcpiDsExecuteArguments * * PARAMETERS: Node - Parent NS node - * ExtraDesc - Has AML pointer and length + * AmlLength - Length of executable AML + * AmlStart - Pointer to the AML * * RETURN: Status. * @@ -146,7 +146,9 @@ ACPI_STATUS AcpiDsExecuteArguments ( ACPI_NAMESPACE_NODE *Node, - ACPI_OPERAND_OBJECT *ExtraDesc) + ACPI_NAMESPACE_NODE *ScopeNode, + UINT32 AmlLength, + UINT8 *AmlStart) { ACPI_STATUS Status; ACPI_PARSE_OBJECT *Op; @@ -154,14 +156,13 @@ AcpiDsExecuteArguments ( ACPI_PARSE_OBJECT *Arg; - FUNCTION_TRACE ("AcpiDsExecuteArguments"); + ACPI_FUNCTION_TRACE ("AcpiDsExecuteArguments"); /* - * Allocate a new parser op to be the root of the parsed - * BufferField tree + * Allocate a new parser op to be the root of the parsed tree */ - Op = AcpiPsAllocOp (AML_SCOPE_OP); + Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); if (!Op) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -169,7 +170,7 @@ AcpiDsExecuteArguments ( /* Save the Node for use in AcpiPsParseAml */ - Op->Node = AcpiNsGetParentObject (Node); + Op->Common.Node = ScopeNode; /* Create and initialize a new parser state */ @@ -179,8 +180,8 @@ AcpiDsExecuteArguments ( return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, ExtraDesc->Extra.AmlStart, - ExtraDesc->Extra.AmlLength, NULL, NULL, 1); + Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, + AmlLength, NULL, NULL, 1); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -189,7 +190,7 @@ AcpiDsExecuteArguments ( WalkState->ParseFlags = 0; - /* Pass1: Parse the entire BufferField declaration */ + /* Pass1: Parse the entire declaration */ Status = AcpiPsParseAml (WalkState); if (ACPI_FAILURE (Status)) @@ -198,22 +199,22 @@ AcpiDsExecuteArguments ( return_ACPI_STATUS (Status); } - /* Get and init the actual FieldUnit Op created above */ + /* Get and init the Op created above */ - Arg = Op->Value.Arg; - Op->Node = Node; - Arg->Node = Node; + Arg = Op->Common.Value.Arg; + Op->Common.Node = Node; + Arg->Common.Node = Node; AcpiPsDeleteParseTree (Op); /* Evaluate the address and length arguments for the Buffer Field */ - Op = AcpiPsAllocOp (AML_SCOPE_OP); + Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); if (!Op) { return_ACPI_STATUS (AE_NO_MEMORY); } - Op->Node = AcpiNsGetParentObject (Node); + Op->Common.Node = ScopeNode; /* Create and initialize a new parser state */ @@ -223,8 +224,8 @@ AcpiDsExecuteArguments ( return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, ExtraDesc->Extra.AmlStart, - ExtraDesc->Extra.AmlLength, NULL, NULL, 3); + Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, + AmlLength, NULL, NULL, 3); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -233,7 +234,6 @@ AcpiDsExecuteArguments ( Status = AcpiPsParseAml (WalkState); AcpiPsDeleteParseTree (Op); - return_ACPI_STATUS (Status); } @@ -260,7 +260,7 @@ AcpiDsGetBufferFieldArguments ( ACPI_STATUS Status; - FUNCTION_TRACE_PTR ("DsGetBufferFieldArguments", ObjDesc); + ACPI_FUNCTION_TRACE_PTR ("DsGetBufferFieldArguments", ObjDesc); if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) @@ -273,13 +273,112 @@ AcpiDsGetBufferFieldArguments ( ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); Node = ObjDesc->BufferField.Node; - DEBUG_EXEC(AcpiUtDisplayInitPathname (Node, " [Field]")); + ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (Node, " [Field]")); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField JIT Init\n", - (char *) &Node->Name)); + Node->Name.Ascii)); /* Execute the AML code for the TermArg arguments */ - Status = AcpiDsExecuteArguments (Node, ExtraDesc); + Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsGetBufferArguments + * + * PARAMETERS: ObjDesc - A valid Bufferobject + * + * RETURN: Status. + * + * DESCRIPTION: Get Buffer length and initializer byte list. This implements + * the late evaluation of these attributes. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsGetBufferArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR ("DsGetBufferArguments", ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the Buffer node */ + + Node = ObjDesc->Buffer.Node; + if (!Node) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "No pointer back to NS node in buffer %p\n", ObjDesc)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer JIT Init\n")); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, Node, + ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsGetPackageArguments + * + * PARAMETERS: ObjDesc - A valid Packageobject + * + * RETURN: Status. + * + * DESCRIPTION: Get Package length and initializer byte list. This implements + * the late evaluation of these attributes. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsGetPackageArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR ("DsGetPackageArguments", ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the Package node */ + + Node = ObjDesc->Package.Node; + if (!Node) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "No pointer back to NS node in package %p\n", ObjDesc)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package JIT Init\n")); + + /* Execute the AML code for the TermArg arguments */ + + Status = AcpiDsExecuteArguments (Node, Node, + ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart); return_ACPI_STATUS (Status); } @@ -303,10 +402,10 @@ AcpiDsGetRegionArguments ( { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *RegionObj2; + ACPI_OPERAND_OBJECT *ExtraDesc; - FUNCTION_TRACE_PTR ("DsGetRegionArguments", ObjDesc); + ACPI_FUNCTION_TRACE_PTR ("DsGetRegionArguments", ObjDesc); if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) @@ -314,24 +413,24 @@ AcpiDsGetRegionArguments ( return_ACPI_STATUS (AE_OK); } - RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc); - if (!RegionObj2) + ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); + if (!ExtraDesc) { return_ACPI_STATUS (AE_NOT_EXIST); } - /* Get the AML pointer (method object) and region node */ + /* Get the Region node */ Node = ObjDesc->Region.Node; - DEBUG_EXEC(AcpiUtDisplayInitPathname (Node, " [Operation Region]")); + ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (Node, " [Operation Region]")); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Init at AML %p\n", - (char *) &Node->Name, RegionObj2->Extra.AmlStart)); + Node->Name.Ascii, ExtraDesc->Extra.AmlStart)); - Status = AcpiDsExecuteArguments (Node, RegionObj2); - + Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), + ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); return_ACPI_STATUS (Status); } @@ -344,7 +443,7 @@ AcpiDsGetRegionArguments ( * * RETURN: Status * - * DESCRIPTION: + * DESCRIPTION: Front end to EvInitializeRegion * ****************************************************************************/ @@ -361,16 +460,209 @@ AcpiDsInitializeRegion ( /* Namespace is NOT locked */ Status = AcpiEvInitializeRegion (ObjDesc, FALSE); - return (Status); } +/***************************************************************************** + * + * FUNCTION: AcpiDsInitBufferField + * + * PARAMETERS: AmlOpcode - CreateXxxField + * ObjDesc - BufferField object + * BufferDesc - Host Buffer + * OffsetDesc - Offset into buffer + * Length - Length of field (CREATE_FIELD_OP only) + * Result - Where to store the result + * + * RETURN: Status + * + * DESCRIPTION: Perform actual initialization of a buffer field + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsInitBufferField ( + UINT16 AmlOpcode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *BufferDesc, + ACPI_OPERAND_OBJECT *OffsetDesc, + ACPI_OPERAND_OBJECT *LengthDesc, + ACPI_OPERAND_OBJECT *ResultDesc) +{ + UINT32 Offset; + UINT32 BitOffset; + UINT32 BitCount; + UINT8 FieldFlags; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR ("DsInitBufferField", ObjDesc); + + + /* Host object must be a Buffer */ + + if (ACPI_GET_OBJECT_TYPE (BufferDesc) != ACPI_TYPE_BUFFER) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Target of Create Field is not a Buffer object - %s\n", + AcpiUtGetObjectTypeName (BufferDesc))); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* + * The last parameter to all of these opcodes (ResultDesc) started + * out as a NameString, and should therefore now be a NS node + * after resolution in AcpiExResolveOperands(). + */ + if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a NS Node\n", + AcpiPsGetOpcodeName (AmlOpcode))); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + Offset = (UINT32) OffsetDesc->Integer.Value; + + /* + * Setup the Bit offsets and counts, according to the opcode + */ + switch (AmlOpcode) + { + case AML_CREATE_FIELD_OP: + + /* Offset is in bits, count is in bits */ + + BitOffset = Offset; + BitCount = (UINT32) LengthDesc->Integer.Value; + FieldFlags = AML_FIELD_ACCESS_BYTE; + break; + + case AML_CREATE_BIT_FIELD_OP: + + /* Offset is in bits, Field is one bit */ + + BitOffset = Offset; + BitCount = 1; + FieldFlags = AML_FIELD_ACCESS_BYTE; + break; + + case AML_CREATE_BYTE_FIELD_OP: + + /* Offset is in bytes, field is one byte */ + + BitOffset = 8 * Offset; + BitCount = 8; + FieldFlags = AML_FIELD_ACCESS_BYTE; + break; + + case AML_CREATE_WORD_FIELD_OP: + + /* Offset is in bytes, field is one word */ + + BitOffset = 8 * Offset; + BitCount = 16; + FieldFlags = AML_FIELD_ACCESS_WORD; + break; + + case AML_CREATE_DWORD_FIELD_OP: + + /* Offset is in bytes, field is one dword */ + + BitOffset = 8 * Offset; + BitCount = 32; + FieldFlags = AML_FIELD_ACCESS_DWORD; + break; + + case AML_CREATE_QWORD_FIELD_OP: + + /* Offset is in bytes, field is one qword */ + + BitOffset = 8 * Offset; + BitCount = 64; + FieldFlags = AML_FIELD_ACCESS_QWORD; + break; + + default: + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown field creation opcode %02x\n", + AmlOpcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + + /* Entire field must fit within the current length of the buffer */ + + if ((BitOffset + BitCount) > + (8 * (UINT32) BufferDesc->Buffer.Length)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Field size %d exceeds Buffer size %d (bits)\n", + BitOffset + BitCount, 8 * (UINT32) BufferDesc->Buffer.Length)); + Status = AE_AML_BUFFER_LIMIT; + goto Cleanup; + } + + /* + * Initialize areas of the field object that are common to all fields + * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE) + */ + Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0, + BitOffset, BitCount); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + ObjDesc->BufferField.BufferObj = BufferDesc; + + /* Reference count for BufferDesc inherits ObjDesc count */ + + BufferDesc->Common.ReferenceCount = (UINT16) (BufferDesc->Common.ReferenceCount + + ObjDesc->Common.ReferenceCount); + + +Cleanup: + + /* Always delete the operands */ + + AcpiUtRemoveReference (OffsetDesc); + AcpiUtRemoveReference (BufferDesc); + + if (AmlOpcode == AML_CREATE_FIELD_OP) + { + AcpiUtRemoveReference (LengthDesc); + } + + /* On failure, delete the result descriptor */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ResultDesc); /* Result descriptor */ + } + else + { + /* Now the address and length are valid for this BufferField */ + + ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID; + } + + return_ACPI_STATUS (Status); +} + + /***************************************************************************** * * FUNCTION: AcpiDsEvalBufferFieldOperands * - * PARAMETERS: Op - A valid BufferField Op object + * PARAMETERS: WalkState - Current walk + * Op - A valid BufferField Op object * * RETURN: Status * @@ -388,30 +680,22 @@ AcpiDsEvalBufferFieldOperands ( ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; ACPI_PARSE_OBJECT *NextOp; - UINT32 Offset; - UINT32 BitOffset; - UINT32 BitCount; - UINT8 FieldFlags; - ACPI_OPERAND_OBJECT *ResDesc = NULL; - ACPI_OPERAND_OBJECT *CntDesc = NULL; - ACPI_OPERAND_OBJECT *OffDesc = NULL; - ACPI_OPERAND_OBJECT *SrcDesc = NULL; - FUNCTION_TRACE_PTR ("DsEvalBufferFieldOperands", Op); + ACPI_FUNCTION_TRACE_PTR ("DsEvalBufferFieldOperands", Op); /* * This is where we evaluate the address and length fields of the * CreateXxxField declaration */ - Node = Op->Node; + Node = Op->Common.Node; /* NextOp points to the op that holds the Buffer */ - NextOp = Op->Value.Arg; + NextOp = Op->Common.Value.Arg; - /* AcpiEvaluate/create the address and length operands */ + /* Evaluate/create the address and length operands */ Status = AcpiDsCreateOperands (WalkState, NextOp); if (ACPI_FAILURE (Status)) @@ -427,212 +711,38 @@ AcpiDsEvalBufferFieldOperands ( /* Resolve the operands */ - Status = AcpiExResolveOperands (Op->Opcode, WALK_OPERANDS, WalkState); - DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Op->Opcode), + Status = AcpiExResolveOperands (Op->Common.AmlOpcode, + ACPI_WALK_OPERANDS, WalkState); + + ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState->NumOperands, "after AcpiExResolveOperands"); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", - AcpiPsGetOpcodeName (Op->Opcode), Status)); + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status)); - goto Cleanup; + return_ACPI_STATUS (Status); } - /* Get the operands */ + /* Initialize the Buffer Field */ - if (AML_CREATE_FIELD_OP == Op->Opcode) + if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) { - ResDesc = WalkState->Operands[3]; - CntDesc = WalkState->Operands[2]; + /* NOTE: Slightly different operands for this opcode */ + + Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, + WalkState->Operands[0], WalkState->Operands[1], + WalkState->Operands[2], WalkState->Operands[3]); } else { - ResDesc = WalkState->Operands[2]; - } + /* All other, CreateXxxField opcodes */ - OffDesc = WalkState->Operands[1]; - SrcDesc = WalkState->Operands[0]; - Offset = (UINT32) OffDesc->Integer.Value; - - /* - * If ResDesc is a Name, it will be a direct name pointer after - * AcpiExResolveOperands() - */ - if (ACPI_GET_DESCRIPTOR_TYPE (ResDesc) != ACPI_DESC_TYPE_NAMED) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a NS Node\n", - AcpiPsGetOpcodeName (Op->Opcode))); - - Status = AE_AML_OPERAND_TYPE; - goto Cleanup; - } - - /* - * Setup the Bit offsets and counts, according to the opcode - */ - switch (Op->Opcode) - { - - case AML_CREATE_FIELD_OP: - - /* Offset is in bits, count is in bits */ - - BitOffset = Offset; - BitCount = (UINT32) CntDesc->Integer.Value; - FieldFlags = AML_FIELD_ACCESS_BYTE; - break; - - case AML_CREATE_BIT_FIELD_OP: - - /* Offset is in bits, Field is one bit */ - - BitOffset = Offset; - BitCount = 1; - FieldFlags = AML_FIELD_ACCESS_BYTE; - break; - - case AML_CREATE_BYTE_FIELD_OP: - - /* Offset is in bytes, field is one byte */ - - BitOffset = 8 * Offset; - BitCount = 8; - FieldFlags = AML_FIELD_ACCESS_BYTE; - break; - - case AML_CREATE_WORD_FIELD_OP: - - /* Offset is in bytes, field is one word */ - - BitOffset = 8 * Offset; - BitCount = 16; - FieldFlags = AML_FIELD_ACCESS_WORD; - break; - - case AML_CREATE_DWORD_FIELD_OP: - - /* Offset is in bytes, field is one dword */ - - BitOffset = 8 * Offset; - BitCount = 32; - FieldFlags = AML_FIELD_ACCESS_DWORD; - break; - - case AML_CREATE_QWORD_FIELD_OP: - - /* Offset is in bytes, field is one qword */ - - BitOffset = 8 * Offset; - BitCount = 64; - FieldFlags = AML_FIELD_ACCESS_QWORD; - break; - - default: - - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Internal error - unknown field creation opcode %02x\n", - Op->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 + BitCount) > - (8 * (UINT32) SrcDesc->Buffer.Length)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Field size %d exceeds Buffer size %d (bits)\n", - BitOffset + BitCount, 8 * (UINT32) SrcDesc->Buffer.Length)); - Status = AE_AML_BUFFER_LIMIT; - goto Cleanup; - } - - /* - * Initialize areas of the field object that are common to all fields - * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE) - */ - Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0, - BitOffset, BitCount); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - ObjDesc->BufferField.BufferObj = SrcDesc; - - /* Reference count for SrcDesc inherits ObjDesc count */ - - SrcDesc->Common.ReferenceCount = (UINT16) (SrcDesc->Common.ReferenceCount + - ObjDesc->Common.ReferenceCount); - break; - - - /* Improper object type */ - - default: - - if ((SrcDesc->Common.Type > (UINT8) INTERNAL_TYPE_REFERENCE) || !AcpiUtValidObjectType (SrcDesc->Common.Type)) /* This line MUST be a single line until AcpiSrc can handle it (block deletion) */ - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Tried to create field in invalid object type %X\n", - SrcDesc->Common.Type)); - } - - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Tried to create field in improper object type - %s\n", - AcpiUtGetTypeName (SrcDesc->Common.Type))); - } - - Status = AE_AML_OPERAND_TYPE; - goto Cleanup; - } - - - if (AML_CREATE_FIELD_OP == Op->Opcode) - { - /* Delete object descriptor unique to CreateField */ - - AcpiUtRemoveReference (CntDesc); - CntDesc = NULL; - } - - -Cleanup: - - /* Always delete the operands */ - - AcpiUtRemoveReference (OffDesc); - AcpiUtRemoveReference (SrcDesc); - - if (AML_CREATE_FIELD_OP == Op->Opcode) - { - AcpiUtRemoveReference (CntDesc); - } - - /* On failure, delete the result descriptor */ - - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (ResDesc); /* Result descriptor */ - } - - else - { - /* Now the address and length are valid for this BufferField */ - - ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID; + Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, + WalkState->Operands[0], WalkState->Operands[1], + NULL, WalkState->Operands[2]); } return_ACPI_STATUS (Status); @@ -643,7 +753,8 @@ Cleanup: * * FUNCTION: AcpiDsEvalRegionOperands * - * PARAMETERS: Op - A valid region Op object + * PARAMETERS: WalkState - Current walk + * Op - A valid region Op object * * RETURN: Status * @@ -664,23 +775,23 @@ AcpiDsEvalRegionOperands ( ACPI_PARSE_OBJECT *NextOp; - FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op); + ACPI_FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op); /* * This is where we evaluate the address and length fields of the OpRegion declaration */ - Node = Op->Node; + Node = Op->Common.Node; /* NextOp points to the op that holds the SpaceID */ - NextOp = Op->Value.Arg; + NextOp = Op->Common.Value.Arg; /* NextOp points to address op */ - NextOp = NextOp->Next; + NextOp = NextOp->Common.Next; - /* AcpiEvaluate/create the address and length operands */ + /* Evaluate/create the address and length operands */ Status = AcpiDsCreateOperands (WalkState, NextOp); if (ACPI_FAILURE (Status)) @@ -690,17 +801,16 @@ AcpiDsEvalRegionOperands ( /* Resolve the length and address operands to numbers */ - Status = AcpiExResolveOperands (Op->Opcode, WALK_OPERANDS, WalkState); + Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, - AcpiPsGetOpcodeName (Op->Opcode), + ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 1, "after AcpiExResolveOperands"); - ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { @@ -725,9 +835,9 @@ AcpiDsEvalRegionOperands ( ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) OperandDesc->Integer.Value; AcpiUtRemoveReference (OperandDesc); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", - ObjDesc, HIDWORD(ObjDesc->Region.Address), LODWORD(ObjDesc->Region.Address), + ObjDesc, + ACPI_HIDWORD (ObjDesc->Region.Address), ACPI_LODWORD (ObjDesc->Region.Address), ObjDesc->Region.Length)); /* Now the address and length are valid for this opregion */ @@ -738,6 +848,109 @@ AcpiDsEvalRegionOperands ( } + +/***************************************************************************** + * + * FUNCTION: AcpiDsEvalDataObjectOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid DataObject Op object + * ObjDesc - DataObject + * + * RETURN: Status + * + * DESCRIPTION: Get the operands and complete the following data objec types: + * Buffer + * Package + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsEvalDataObjectOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ArgDesc; + UINT32 Length; + + + ACPI_FUNCTION_TRACE ("DsEvalDataObjectOperands"); + + + /* The first operand (for all of these data objects) is the length */ + + Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiExResolveOperands (WalkState->Opcode, + &(WalkState->Operands [WalkState->NumOperands -1]), + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Extract length operand */ + + ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; + Length = (UINT32) ArgDesc->Integer.Value; + + /* Cleanup for length operand */ + + Status = AcpiDsObjStackPop (1, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiUtRemoveReference (ArgDesc); + + /* + * Create the actual data object + */ + switch (Op->Common.AmlOpcode) + { + case AML_BUFFER_OP: + + Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc); + break; + + case AML_PACKAGE_OP: + case AML_VAR_PACKAGE_OP: + + Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc); + break; + + default: + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + if (ACPI_SUCCESS (Status)) + { + /* + * Return the object in the WalkState, unless the parent is a package -- + * in this case, the return object will be stored in the parse tree + * for the package. + */ + if ((!Op->Common.Parent) || + ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) && + (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) && + (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP))) + { + WalkState->ResultObj = ObjDesc; + } + } + + return_ACPI_STATUS (Status); +} + + + /******************************************************************************* * * FUNCTION: AcpiDsExecBeginControlOp @@ -761,13 +974,13 @@ AcpiDsExecBeginControlOp ( ACPI_GENERIC_STATE *ControlState; - PROC_NAME ("DsExecBeginControlOp"); + ACPI_FUNCTION_NAME ("DsExecBeginControlOp"); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op, - Op->Opcode, WalkState)); + Op->Common.AmlOpcode, WalkState)); - switch (Op->Opcode) + switch (Op->Common.AmlOpcode) { case AML_IF_OP: case AML_WHILE_OP: @@ -783,15 +996,18 @@ AcpiDsExecBeginControlOp ( Status = AE_NO_MEMORY; break; } - - AcpiUtPushGenericState (&WalkState->ControlState, ControlState); - /* * Save a pointer to the predicate for multiple executions * of a loop */ - WalkState->ControlState->Control.AmlPredicateStart = - WalkState->ParserState.Aml - 1; + ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1; + ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd; + ControlState->Control.Opcode = Op->Common.AmlOpcode; + + + /* Push the control state on this walk's control stack */ + + AcpiUtPushGenericState (&WalkState->ControlState, ControlState); break; case AML_ELSE_OP: @@ -841,10 +1057,10 @@ AcpiDsExecEndControlOp ( ACPI_GENERIC_STATE *ControlState; - PROC_NAME ("DsExecEndControlOp"); + ACPI_FUNCTION_NAME ("DsExecEndControlOp"); - switch (Op->Opcode) + switch (Op->Common.AmlOpcode) { case AML_IF_OP: @@ -896,18 +1112,18 @@ AcpiDsExecEndControlOp ( case AML_RETURN_OP: ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Value.Arg)); + "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg)); /* * One optional operand -- the return value * It can be either an immediate operand or a result that * has been bubbled up the tree */ - if (Op->Value.Arg) + if (Op->Common.Value.Arg) { /* Return statement has an immediate operand */ - Status = AcpiDsCreateOperands (WalkState, Op->Value.Arg); + Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); if (ACPI_FAILURE (Status)) { return (Status); @@ -931,7 +1147,6 @@ AcpiDsExecEndControlOp ( */ WalkState->ReturnDesc = WalkState->Operands[0]; } - else if ((WalkState->Results) && (WalkState->Results->Results.NumResults > 0)) { @@ -944,8 +1159,8 @@ AcpiDsExecEndControlOp ( * * Allow references created by the Index operator to return unchanged. */ - if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_INTERNAL) && - ((WalkState->Results->Results.ObjDesc [0])->Common.Type == INTERNAL_TYPE_REFERENCE) && + if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) && + (ACPI_GET_OBJECT_TYPE (WalkState->Results->Results.ObjDesc [0]) == INTERNAL_TYPE_REFERENCE) && ((WalkState->Results->Results.ObjDesc [0])->Reference.Opcode != AML_INDEX_OP)) { Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState); @@ -957,7 +1172,6 @@ AcpiDsExecEndControlOp ( WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0]; } - else { /* No return operand */ @@ -993,7 +1207,7 @@ AcpiDsExecEndControlOp ( /* Call up to the OS service layer to handle this */ - AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode"); + Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode"); /* If and when it returns, all done. */ @@ -1001,37 +1215,46 @@ AcpiDsExecEndControlOp ( case AML_BREAK_OP: - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Break to end of current package, Op=%p\n", Op)); - - /* TBD: update behavior for ACPI 2.0 */ - - /* - * As per the ACPI specification: - * "The break operation causes the current package - * execution to complete" - * "Break -- Stop executing the current code package - * at this point" - * - * Returning AE_FALSE here will cause termination of - * the current package, and execution will continue one - * level up, starting with the completion of the parent Op. - */ - Status = AE_CTRL_FALSE; - break; - - case AML_CONTINUE_OP: /* ACPI 2.0 */ - Status = AE_NOT_IMPLEMENTED; + + /* Pop and delete control states until we find a while */ + + while (WalkState->ControlState && + (WalkState->ControlState->Control.Opcode != AML_WHILE_OP)) + { + ControlState = AcpiUtPopGenericState (&WalkState->ControlState); + AcpiUtDeleteGenericState (ControlState); + } + + /* No while found? */ + + if (!WalkState->ControlState) + { + return (AE_AML_NO_WHILE); + } + + /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */ + + WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd; + + /* Return status depending on opcode */ + + if (Op->Common.AmlOpcode == AML_BREAK_OP) + { + Status = AE_CTRL_BREAK; + } + else + { + Status = AE_CTRL_CONTINUE; + } break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n", - Op->Opcode, Op)); + Op->Common.AmlOpcode, Op)); Status = AE_AML_BAD_OPCODE; break; diff --git a/source/components/dispatcher/dswexec.c b/source/components/dispatcher/dswexec.c index 38b308568..d3d2d03af 100644 --- a/source/components/dispatcher/dswexec.c +++ b/source/components/dispatcher/dswexec.c @@ -2,7 +2,7 @@ * * Module Name: dswexec - Dispatcher method execution callbacks; * dispatch to interpreter. - * $Revision: 1.90 $ + * $Revision: 1.94 $ * *****************************************************************************/ @@ -132,7 +132,7 @@ /* * Dispatch table for opcode classes */ -ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = { +static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = { AcpiExOpcode_1A_0T_0R, AcpiExOpcode_1A_0T_1R, AcpiExOpcode_1A_1T_0R, @@ -212,11 +212,11 @@ AcpiDsGetPredicateValue ( * Result of predicate evaluation currently must * be a number */ - if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad predicate (not a number) ObjDesc=%p State=%p Type=%X\n", - ObjDesc, WalkState, ObjDesc->Common.Type)); + ObjDesc, WalkState, ACPI_GET_OBJECT_TYPE (ObjDesc))); Status = AE_AML_OPERAND_TYPE; goto Cleanup; @@ -224,7 +224,7 @@ AcpiDsGetPredicateValue ( /* Truncate the predicate to 32-bits if necessary */ - AcpiExTruncateFor32bitTable (ObjDesc, WalkState); + AcpiExTruncateFor32bitTable (ObjDesc); /* * Save the result of the predicate evaluation on @@ -304,14 +304,19 @@ AcpiDsExecBeginOp ( Op = *OutOp; WalkState->Op = Op; - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); - WalkState->Opcode = Op->Opcode; + WalkState->Opcode = Op->Common.AmlOpcode; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType)) { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op)); - AcpiDsScopeStackPop (WalkState); + + Status = AcpiDsScopeStackPop (WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } } } @@ -349,7 +354,7 @@ AcpiDsExecBeginOp ( /* We want to send namepaths to the load code */ - if (Op->Opcode == AML_INT_NAMEPATH_OP) + if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) { OpcodeClass = AML_CLASS_NAMED_OBJECT; } @@ -385,7 +390,7 @@ AcpiDsExecBeginOp ( Status = AcpiDsLoad2BeginOp (WalkState, NULL); } - if (Op->Opcode == AML_REGION_OP) + if (Op->Common.AmlOpcode == AML_REGION_OP) { Status = AcpiDsResultStackPush (WalkState); } @@ -451,11 +456,11 @@ AcpiDsExecEndOp ( if (OpClass == AML_CLASS_UNKNOWN) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", Op->Opcode)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", Op->Common.AmlOpcode)); return_ACPI_STATUS (AE_NOT_IMPLEMENTED); } - FirstArg = Op->Value.Arg; + FirstArg = Op->Common.Value.Arg; /* Init the walk state */ @@ -555,8 +560,12 @@ AcpiDsExecEndOp ( /* 1 Operand, 0 ExternalResult, 0 InternalResult */ Status = AcpiDsExecEndControlOp (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } - AcpiDsResultStackPop (WalkState); + Status = AcpiDsResultStackPop (WalkState); break; @@ -574,7 +583,7 @@ AcpiDsExecEndOp ( /* NextOp points to first argument op */ - NextOp = NextOp->Next; + NextOp = NextOp->Common.Next; /* * Get the method's arguments and put them on the operand stack @@ -629,7 +638,7 @@ AcpiDsExecEndOp ( ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Executing CreateObject (Buffer/Package) Op=%p\n", Op)); - switch (Op->Parent->Opcode) + switch (Op->Common.Parent->Common.AmlOpcode) { case AML_NAME_OP: @@ -637,20 +646,22 @@ AcpiDsExecEndOp ( * Put the Node on the object stack (Contains the ACPI Name of * this object) */ - WalkState->Operands[0] = (void *) Op->Parent->Node; + WalkState->Operands[0] = (void *) Op->Common.Parent->Common.Node; WalkState->NumOperands = 1; - Status = AcpiDsCreateNode (WalkState, Op->Parent->Node, Op->Parent); + Status = AcpiDsCreateNode (WalkState, Op->Common.Parent->Common.Node, Op->Common.Parent); if (ACPI_FAILURE (Status)) { break; } /* Fall through */ + /*lint -fallthrough */ case AML_INT_EVAL_SUBTREE_OP: - Status = AcpiDsEvalDataObjectOperands (WalkState, Op, AcpiNsGetAttachedObject (Op->Parent->Node)); + Status = AcpiDsEvalDataObjectOperands (WalkState, Op, + AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node)); break; default: @@ -682,7 +693,7 @@ AcpiDsExecEndOp ( break; } - if (Op->Opcode == AML_REGION_OP) + if (Op->Common.AmlOpcode == AML_REGION_OP) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Executing OpRegion Address/Length Op=%p\n", Op)); @@ -717,7 +728,7 @@ AcpiDsExecEndOp ( ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n", - OpClass, OpType, Op->Opcode, Op)); + OpClass, OpType, Op->Common.AmlOpcode, Op)); Status = AE_NOT_IMPLEMENTED; break; @@ -728,7 +739,7 @@ AcpiDsExecEndOp ( * ACPI 2.0 support for 64-bit integers: Truncate numeric * result value if we are executing from a 32-bit ACPI table */ - AcpiExTruncateFor32bitTable (WalkState->ResultObj, WalkState); + AcpiExTruncateFor32bitTable (WalkState->ResultObj); /* * Check if we just completed the evaluation of a diff --git a/source/components/dispatcher/dswstate.c b/source/components/dispatcher/dswstate.c index 7f33ffad7..db1796a90 100644 --- a/source/components/dispatcher/dswstate.c +++ b/source/components/dispatcher/dswstate.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dswstate - Dispatcher parse tree walk management routines - * $Revision: 1.35 $ + * $Revision: 1.65 $ * *****************************************************************************/ @@ -9,8 +9,8 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights - * reserved. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. + * All rights reserved. * * 2. License * @@ -118,39 +118,12 @@ #define __DSWSTATE_C__ #include "acpi.h" -#include "amlcode.h" #include "acparser.h" #include "acdispat.h" #include "acnamesp.h" -#include "acinterp.h" -#define _COMPONENT DISPATCHER - MODULE_NAME ("dswstate") - - -/******************************************************************************* - * - * FUNCTION: AcpiDsResultStackClear - * - * PARAMETERS: WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Reset this walk's result stack pointers to zero, thus setting - * the stack to zero. - * - ******************************************************************************/ - -ACPI_STATUS -xxxAcpiDsResultStackClear ( - ACPI_WALK_STATE *WalkState) -{ -/* - WalkState->NumResults = 0; - WalkState->CurrentResult = 0; -*/ - return (AE_OK); -} +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dswstate") /******************************************************************************* @@ -175,27 +148,29 @@ AcpiDsResultInsert ( ACPI_GENERIC_STATE *State; + ACPI_FUNCTION_NAME ("DsResultInsert"); + + State = WalkState->Results; if (!State) { - DEBUG_PRINT (ACPI_ERROR, - ("DsResultInsert: No result object pushed! State=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", WalkState)); return (AE_NOT_EXIST); } if (Index >= OBJ_NUM_OPERANDS) { - DEBUG_PRINT (ACPI_ERROR, - ("DsResultInsert: Index out of range: %X Obj=%p State=%p Num=%X\n", + 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) { - DEBUG_PRINT (ACPI_ERROR, - ("DsResultInsert: Null Object! Index=%X Obj=%p State=%p Num=%X\n", + 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); } @@ -203,16 +178,15 @@ AcpiDsResultInsert ( State->Results.ObjDesc [Index] = Object; State->Results.NumResults++; - DEBUG_PRINT (TRACE_EXEC, - ("DsResultStackPush: Obj=%p [%s] State=%p Num=%X Cur=%X\n", - Object, Object ? AcpiCmGetTypeName (((ACPI_OPERAND_OBJECT *) Object)->Common.Type) : "NULL", + 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 @@ -236,31 +210,32 @@ AcpiDsResultRemove ( ACPI_GENERIC_STATE *State; + ACPI_FUNCTION_NAME ("DsResultRemove"); + + State = WalkState->Results; if (!State) { - DEBUG_PRINT (ACPI_ERROR, - ("DsResultRemove: No result object pushed! State=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", WalkState)); return (AE_NOT_EXIST); } - if (Index >= OBJ_NUM_OPERANDS) + if (Index >= OBJ_MAX_OPERAND) { - DEBUG_PRINT (ACPI_ERROR, - ("DsResultRemove: Index out of range: %X State=%p Num=%X\n", + 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]) { - DEBUG_PRINT (ACPI_ERROR, - ("DsResultStackRemove: Null operand! State=%p #Ops=%X, Index=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Null operand! State=%p #Ops=%X, Index=%X\n", WalkState, State->Results.NumResults, Index)); - return (AE_AML_NO_OPERAND); + return (AE_AML_NO_RETURN_VALUE); } /* Remove the object */ @@ -270,9 +245,9 @@ AcpiDsResultRemove ( *Object = State->Results.ObjDesc [Index]; State->Results.ObjDesc [Index] = NULL; - DEBUG_PRINT (TRACE_EXEC, - ("DsResultStackRemove: Obj=%p [%s] Index=%X State=%p Num=%X\n", - *Object, (*Object) ? AcpiCmGetTypeName ((*Object)->Common.Type) : "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); @@ -302,19 +277,20 @@ AcpiDsResultPop ( ACPI_GENERIC_STATE *State; + ACPI_FUNCTION_NAME ("DsResultPop"); + + State = WalkState->Results; if (!State) { return (AE_OK); } - if (!State->Results.NumResults) { - DEBUG_PRINT (ACPI_ERROR, - ("DsResultPop: No result objects! State=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack is empty! State=%p\n", WalkState)); - return (AE_STACK_UNDERFLOW); + return (AE_AML_NO_RETURN_VALUE); } /* Remove top element */ @@ -330,25 +306,21 @@ AcpiDsResultPop ( *Object = State->Results.ObjDesc [Index -1]; State->Results.ObjDesc [Index -1] = NULL; - DEBUG_PRINT (TRACE_EXEC, - ("DsResultStackRemove: Obj=%p [%s] Index=%X State=%p Num=%X\n", - *Object, (*Object) ? AcpiCmGetTypeName ((*Object)->Common.Type) : "NULL", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n", + *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", Index -1, WalkState, State->Results.NumResults)); return (AE_OK); } } - - DEBUG_PRINT (ACPI_ERROR, - ("DsResultPop: No result objects! State=%p\n", - WalkState)); - return (AE_STACK_UNDERFLOW); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState)); + return (AE_AML_NO_RETURN_VALUE); } /******************************************************************************* * - * FUNCTION: AcpiDsResultPop + * FUNCTION: AcpiDsResultPopFromBottom * * PARAMETERS: Object - Where to return the popped object * WalkState - Current Walk state @@ -365,33 +337,31 @@ AcpiDsResultPopFromBottom ( ACPI_OPERAND_OBJECT **Object, ACPI_WALK_STATE *WalkState) { - UINT32 Index; + NATIVE_UINT Index; ACPI_GENERIC_STATE *State; + ACPI_FUNCTION_NAME ("DsResultPopFromBottom"); + + State = WalkState->Results; if (!State) { - DEBUG_PRINT (ACPI_ERROR, - ("DsResultPopFromBottom: Warning: No result object pushed! State=%p\n", - WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Warning: No result object pushed! State=%p\n", WalkState)); return (AE_NOT_EXIST); } - if (!State->Results.NumResults) { - DEBUG_PRINT (ACPI_ERROR, - ("DsResultPopFromBottom: No result objects! State=%p\n", - WalkState)); - return (AE_STACK_UNDERFLOW); + 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++) @@ -405,34 +375,30 @@ AcpiDsResultPopFromBottom ( if (!*Object) { - DEBUG_PRINT (ACPI_ERROR, - ("DsResultPopFromBottom: Null operand! State=%p #Ops=%X, Index=%X\n", - WalkState, State->Results.NumResults, Index)); - return (AE_AML_NO_OPERAND); + 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); } - DEBUG_PRINT (TRACE_EXEC, - ("DsResultPopFromBottom: Obj=%p [%s], Results=%p State=%p\n", - *Object, (*Object) ? AcpiCmGetTypeName ((*Object)->Common.Type) : "NULL", + 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: AcpiDsResultPop + * FUNCTION: AcpiDsResultPush * * 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. + * DESCRIPTION: Push an object onto the current result stack * ******************************************************************************/ @@ -444,43 +410,42 @@ AcpiDsResultPush ( ACPI_GENERIC_STATE *State; + ACPI_FUNCTION_NAME ("DsResultPush"); + + State = WalkState->Results; if (!State) { - return (AE_OK); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result stack frame\n")); + return (AE_AML_INTERNAL); } if (State->Results.NumResults == OBJ_NUM_OPERANDS) { - DEBUG_PRINT (ACPI_ERROR, - ("DsResultPush: Result stack overflow: Obj=%p State=%p Num=%X\n", + 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) { - DEBUG_PRINT (ACPI_ERROR, - ("DsResultPush: Null Object! Obj=%p State=%p Num=%X\n", + 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++; - DEBUG_PRINT (TRACE_EXEC, - ("DsResultPush: Obj=%p [%s] State=%p Num=%X Cur=%X\n", - Object, Object ? AcpiCmGetTypeName (((ACPI_OPERAND_OBJECT *) Object)->Common.Type) : "NULL", + 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: AcpiDsResultStackPush @@ -490,7 +455,7 @@ AcpiDsResultPush ( * * RETURN: Status * - * DESCRIPTION: + * DESCRIPTION: * ******************************************************************************/ @@ -500,17 +465,19 @@ AcpiDsResultStackPush ( { ACPI_GENERIC_STATE *State; - - State = AcpiCmCreateGenericState (); + ACPI_FUNCTION_NAME ("DsResultStackPush"); + + + State = AcpiUtCreateGenericState (); if (!State) { return (AE_NO_MEMORY); } - AcpiCmPushGenericState (&WalkState->Results, State); - - DEBUG_PRINT (TRACE_EXEC, - ("DsResultStackPush: Results=%p State=%p\n", + State->Common.DataType = ACPI_DESC_TYPE_STATE_RESULT; + AcpiUtPushGenericState (&WalkState->Results, State); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n", State, WalkState)); return (AE_OK); @@ -525,7 +492,7 @@ AcpiDsResultStackPush ( * * RETURN: Status * - * DESCRIPTION: + * DESCRIPTION: * ******************************************************************************/ @@ -535,32 +502,31 @@ AcpiDsResultStackPop ( { ACPI_GENERIC_STATE *State; + ACPI_FUNCTION_NAME ("DsResultStackPop"); + /* Check for stack underflow */ if (WalkState->Results == NULL) { - DEBUG_PRINT (TRACE_EXEC, - ("DsResultStackPop: Underflow - State=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Underflow - State=%p\n", WalkState)); return (AE_AML_NO_OPERAND); } - State = AcpiCmPopGenericState (&WalkState->Results); + State = AcpiUtPopGenericState (&WalkState->Results); - DEBUG_PRINT (TRACE_EXEC, - ("DsResultStackPop: Result=%p RemainingResults=%X State=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Result=%p RemainingResults=%X State=%p\n", State, State->Results.NumResults, WalkState)); - AcpiCmDeleteGenericState (State); + AcpiUtDeleteGenericState (State); return (AE_OK); } - - /******************************************************************************* * * FUNCTION: AcpiDsObjStackDeleteAll @@ -581,7 +547,7 @@ AcpiDsObjStackDeleteAll ( UINT32 i; - FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState); + ACPI_FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState); /* The stack size is configurable, but fixed */ @@ -590,7 +556,7 @@ AcpiDsObjStackDeleteAll ( { if (WalkState->Operands[i]) { - AcpiCmRemoveReference (WalkState->Operands[i]); + AcpiUtRemoveReference (WalkState->Operands[i]); WalkState->Operands[i] = NULL; } } @@ -617,14 +583,15 @@ AcpiDsObjStackPush ( void *Object, ACPI_WALK_STATE *WalkState) { + ACPI_FUNCTION_NAME ("DsObjStackPush"); /* Check for stack overflow */ if (WalkState->NumOperands >= OBJ_NUM_OPERANDS) { - DEBUG_PRINT (ACPI_ERROR, - ("DsObjStackPush: overflow! Obj=%p State=%p #Ops=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "overflow! Obj=%p State=%p #Ops=%X\n", Object, WalkState, WalkState->NumOperands)); return (AE_STACK_OVERFLOW); } @@ -634,14 +601,15 @@ AcpiDsObjStackPush ( WalkState->Operands [WalkState->NumOperands] = Object; WalkState->NumOperands++; - DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPush: Obj=%p [%s] State=%p #Ops=%X\n", - Object, AcpiCmGetTypeName (((ACPI_OPERAND_OBJECT *) Object)->Common.Type), + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", + Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), WalkState, WalkState->NumOperands)); return (AE_OK); } +#if 0 /******************************************************************************* * * FUNCTION: AcpiDsObjStackPopObject @@ -661,19 +629,20 @@ AcpiDsObjStackPopObject ( ACPI_OPERAND_OBJECT **Object, ACPI_WALK_STATE *WalkState) { + ACPI_FUNCTION_NAME ("DsObjStackPopObject"); /* Check for stack underflow */ if (WalkState->NumOperands == 0) { - DEBUG_PRINT (ACPI_ERROR, - ("DsObjStackPop: Missing operand/stack empty! State=%p #Ops=%X\n", + 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); } - /* Pop the stack */ WalkState->NumOperands--; @@ -682,9 +651,10 @@ AcpiDsObjStackPopObject ( if (!WalkState->Operands [WalkState->NumOperands]) { - DEBUG_PRINT (ACPI_ERROR, - ("DsObjStackPop: Null operand! State=%p #Ops=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Null operand! State=%p #Ops=%X\n", WalkState, WalkState->NumOperands)); + *Object = NULL; return (AE_AML_NO_OPERAND); } @@ -693,13 +663,13 @@ AcpiDsObjStackPopObject ( *Object = WalkState->Operands [WalkState->NumOperands]; WalkState->Operands [WalkState->NumOperands] = NULL; - DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPopObject: Obj=%p [%s] State=%p #Ops=%X\n", - *Object, AcpiCmGetTypeName ((*Object)->Common.Type), + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", + *Object, AcpiUtGetObjectTypeName (*Object), WalkState, WalkState->NumOperands)); return (AE_OK); } - +#endif /******************************************************************************* * @@ -722,6 +692,8 @@ AcpiDsObjStackPop ( { UINT32 i; + ACPI_FUNCTION_NAME ("DsObjStackPop"); + for (i = 0; i < PopCount; i++) { @@ -729,8 +701,8 @@ AcpiDsObjStackPop ( if (WalkState->NumOperands == 0) { - DEBUG_PRINT (ACPI_ERROR, - ("DsObjStackPop: Underflow! Count=%X State=%p #Ops=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Underflow! Count=%X State=%p #Ops=%X\n", PopCount, WalkState, WalkState->NumOperands)); return (AE_STACK_UNDERFLOW); } @@ -741,7 +713,7 @@ AcpiDsObjStackPop ( WalkState->Operands [WalkState->NumOperands] = NULL; } - DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPop: Count=%X State=%p #Ops=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", PopCount, WalkState, WalkState->NumOperands)); return (AE_OK); @@ -770,6 +742,8 @@ AcpiDsObjStackPopAndDelete ( UINT32 i; ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_FUNCTION_NAME ("DsObjStackPopAndDelete"); + for (i = 0; i < PopCount; i++) { @@ -777,8 +751,8 @@ AcpiDsObjStackPopAndDelete ( if (WalkState->NumOperands == 0) { - DEBUG_PRINT (ACPI_ERROR, - ("DsObjStackPop: Underflow! Count=%X State=%p #Ops=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Underflow! Count=%X State=%p #Ops=%X\n", PopCount, WalkState, WalkState->NumOperands)); return (AE_STACK_UNDERFLOW); } @@ -789,12 +763,12 @@ AcpiDsObjStackPopAndDelete ( ObjDesc = WalkState->Operands [WalkState->NumOperands]; if (ObjDesc) { - AcpiCmRemoveReference (WalkState->Operands [WalkState->NumOperands]); + AcpiUtRemoveReference (WalkState->Operands [WalkState->NumOperands]); WalkState->Operands [WalkState->NumOperands] = NULL; } } - DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPop: Count=%X State=%p #Ops=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", PopCount, WalkState, WalkState->NumOperands)); return (AE_OK); @@ -822,24 +796,23 @@ AcpiDsObjStackGetValue ( ACPI_WALK_STATE *WalkState) { - FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState); + ACPI_FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState); /* Can't do it if the stack is empty */ if (WalkState->NumOperands == 0) { - return_VALUE (NULL); + return_PTR (NULL); } /* or if the index is past the top of the stack */ if (Index > (WalkState->NumOperands - (UINT32) 1)) { - return_VALUE (NULL); + return_PTR (NULL); } - return_PTR (WalkState->Operands[(NATIVE_UINT)(WalkState->NumOperands - 1) - Index]); } @@ -849,29 +822,32 @@ AcpiDsObjStackGetValue ( * * FUNCTION: AcpiDsGetCurrentWalkState * - * PARAMETERS: WalkList - Get current active state for this walk list + * PARAMETERS: Thread - Get current active state for this Thread * * 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_WALK_LIST *WalkList) + ACPI_THREAD_STATE *Thread) { + ACPI_FUNCTION_NAME ("DsGetCurrentWalkState"); - DEBUG_PRINT (TRACE_PARSE, ("DsGetCurrentWalkState, =%p\n", WalkList->WalkState)); - if (!WalkList) + if (!Thread) { return (NULL); } - return (WalkList->WalkState); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "DsGetCurrentWalkState, =%p\n", + Thread->WalkStateList)); + + return (Thread->WalkStateList); } @@ -888,18 +864,16 @@ AcpiDsGetCurrentWalkState ( * ******************************************************************************/ -static void +void AcpiDsPushWalkState ( ACPI_WALK_STATE *WalkState, - ACPI_WALK_LIST *WalkList) + ACPI_THREAD_STATE *Thread) { + ACPI_FUNCTION_TRACE ("DsPushWalkState"); - FUNCTION_TRACE ("DsPushWalkState"); - - - WalkState->Next = WalkList->WalkState; - WalkList->WalkState = WalkState; + WalkState->Next = Thread->WalkStateList; + Thread->WalkStateList = WalkState; return_VOID; } @@ -921,26 +895,26 @@ AcpiDsPushWalkState ( ACPI_WALK_STATE * AcpiDsPopWalkState ( - ACPI_WALK_LIST *WalkList) + ACPI_THREAD_STATE *Thread) { ACPI_WALK_STATE *WalkState; - FUNCTION_TRACE ("DsPopWalkState"); + ACPI_FUNCTION_TRACE ("DsPopWalkState"); - WalkState = WalkList->WalkState; + WalkState = Thread->WalkStateList; if (WalkState) { /* Next walk state becomes the current walk state */ - WalkList->WalkState = WalkState->Next; + Thread->WalkStateList = WalkState->Next; /* * Don't clear the NEXT field, this serves as an indicator * that there is a parent WALK STATE - * WalkState->Next = NULL; + * NO: WalkState->Next = NULL; */ } @@ -953,12 +927,12 @@ AcpiDsPopWalkState ( * FUNCTION: AcpiDsCreateWalkState * * PARAMETERS: Origin - Starting point for this walk - * WalkList - Owning walk list + * Thread - Current thread state * * 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. * ******************************************************************************/ @@ -967,53 +941,26 @@ AcpiDsCreateWalkState ( ACPI_OWNER_ID OwnerId, ACPI_PARSE_OBJECT *Origin, ACPI_OPERAND_OBJECT *MthDesc, - ACPI_WALK_LIST *WalkList) + ACPI_THREAD_STATE *Thread) { ACPI_WALK_STATE *WalkState; + ACPI_STATUS Status; - FUNCTION_TRACE ("DsCreateWalkState"); + ACPI_FUNCTION_TRACE ("DsCreateWalkState"); - AcpiCmAcquireMutex (ACPI_MTX_CACHES); - AcpiGbl_WalkStateCacheRequests++; - - /* Check the cache first */ - - if (AcpiGbl_WalkStateCache) + WalkState = AcpiUtAcquireFromCache (ACPI_MEM_LIST_WALK); + if (!WalkState) { - /* There is an object available, use it */ - - WalkState = AcpiGbl_WalkStateCache; - AcpiGbl_WalkStateCache = WalkState->Next; - - AcpiGbl_WalkStateCacheHits++; - AcpiGbl_WalkStateCacheDepth--; - - DEBUG_PRINT (TRACE_EXEC, ("DsCreateWalkState: State %p from cache\n", WalkState)); - - 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); - } + return_PTR (NULL); } WalkState->DataType = ACPI_DESC_TYPE_WALK; WalkState->OwnerId = OwnerId; WalkState->Origin = Origin; WalkState->MethodDesc = MthDesc; + WalkState->Thread = Thread; /* Init the method args/local */ @@ -1021,14 +968,120 @@ AcpiDsCreateWalkState ( 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 */ - AcpiDsPushWalkState (WalkState, WalkList); + if (Thread) + { + AcpiDsPushWalkState (WalkState, Thread); + } return_PTR (WalkState); } +#ifndef _ACPI_ASL_COMPILER +/******************************************************************************* + * + * 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_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, MTH_NUM_ARGS, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else + { + /* Setup the current scope */ + + ParserState->StartNode = ParserState->StartOp->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); +} +#endif + + /******************************************************************************* * * FUNCTION: AcpiDsDeleteWalkState @@ -1048,7 +1101,7 @@ AcpiDsDeleteWalkState ( ACPI_GENERIC_STATE *State; - FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState); + ACPI_FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState); if (!WalkState) @@ -1058,20 +1111,23 @@ AcpiDsDeleteWalkState ( if (WalkState->DataType != ACPI_DESC_TYPE_WALK) { - DEBUG_PRINT (ACPI_ERROR, - ("DsDeleteWalkState: **** %p not a valid walk state\n", WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is 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; - AcpiCmDeleteGenericState (State); + AcpiUtDeleteGenericState (State); } /* Always must free any linked parse states */ @@ -1081,7 +1137,7 @@ AcpiDsDeleteWalkState ( State = WalkState->ScopeInfo; WalkState->ScopeInfo = State->Common.Next; - AcpiCmDeleteGenericState (State); + AcpiUtDeleteGenericState (State); } /* Always must free any stacked result states */ @@ -1091,39 +1147,10 @@ AcpiDsDeleteWalkState ( State = WalkState->Results; WalkState->Results = State->Common.Next; - AcpiCmDeleteGenericState (State); - } - - - - /* If walk cache is full, just free this wallkstate object */ - - if (AcpiGbl_WalkStateCacheDepth >= MAX_WALK_CACHE_DEPTH) - { - 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); + AcpiUtDeleteGenericState (State); } + AcpiUtReleaseToCache (ACPI_MEM_LIST_WALK, WalkState); return_VOID; } @@ -1145,24 +1172,10 @@ void AcpiDsDeleteWalkStateCache ( void) { - ACPI_WALK_STATE *Next; + ACPI_FUNCTION_TRACE ("DsDeleteWalkStateCache"); - 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--; - } - + AcpiUtDeleteGenericCache (ACPI_MEM_LIST_WALK); return_VOID; } diff --git a/source/components/executer/exconfig.c b/source/components/executer/exconfig.c index 8ea63a300..dc46bcc0d 100644 --- a/source/components/executer/exconfig.c +++ b/source/components/executer/exconfig.c @@ -1,7 +1,7 @@ /****************************************************************************** * - * Module Name: amconfig - Namespace reconfiguration (Load/Unload opcodes) - * $Revision: 1.32 $ + * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes) + * $Revision: 1.66 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -115,130 +115,65 @@ * *****************************************************************************/ -#define __AMCONFIG_C__ +#define __EXCONFIG_C__ #include "acpi.h" -#include "acparser.h" #include "acinterp.h" #include "amlcode.h" #include "acnamesp.h" #include "acevents.h" #include "actables.h" -#include "acdispat.h" #define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amconfig") + ACPI_MODULE_NAME ("exconfig") -/***************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiAmlExecLoadTable + * FUNCTION: AcpiExAddTable * - * PARAMETERS: RgnDesc - Op region where the table will be obtained - * DdbHandle - Where a handle to the table will be returned + * PARAMETERS: Table - Pointer to raw table + * ParentNode - Where to load the table (scope) + * DdbHandle - Where to return the table handle. * * RETURN: Status * - * DESCRIPTION: Load an ACPI table + * DESCRIPTION: Common function to Install and Load an ACPI table with a + * returned table handle. * - ****************************************************************************/ + ******************************************************************************/ -static ACPI_STATUS -AcpiAmlExecLoadTable ( - ACPI_OPERAND_OBJECT *RgnDesc, - ACPI_HANDLE *DdbHandle) +ACPI_STATUS +AcpiExAddTable ( + ACPI_TABLE_HEADER *Table, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_OPERAND_OBJECT **DdbHandle) { ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *TableDesc = NULL; - UINT8 *TablePtr; - UINT8 *TableDataPtr; - ACPI_TABLE_HEADER TableHeader; ACPI_TABLE_DESC TableInfo; - UINT32 i; + ACPI_OPERAND_OBJECT *ObjDesc; - FUNCTION_TRACE ("AmlExecLoadTable"); - - /* TBD: [Unhandled] Object can be either a field or an opregion */ + ACPI_FUNCTION_TRACE ("ExAddTable"); - /* Get the table header */ + /* Create an object to be the table handle */ - TableHeader.Length = 0; - for (i = 0; i < sizeof (ACPI_TABLE_HEADER); i++) - { - Status = AcpiEvAddressSpaceDispatch (RgnDesc, ACPI_READ_ADR_SPACE, - (ACPI_PHYSICAL_ADDRESS) i, 8, - (UINT32 *) ((UINT8 *) &TableHeader + i)); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Allocate a buffer for the entire table */ - - TablePtr = AcpiCmAllocate (TableHeader.Length); - if (!TablePtr) + ObjDesc = AcpiUtCreateInternalObject (INTERNAL_TYPE_REFERENCE); + if (!ObjDesc) { 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, ACPI_READ_ADR_SPACE, - (ACPI_PHYSICAL_ADDRESS) i, 8, - (UINT32 *) (TableDataPtr + i)); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - } - - - /* Table must be either an SSDT or a PSDT */ - - if ((!STRNCMP (TableHeader.Signature, - AcpiGbl_AcpiTableData[ACPI_TABLE_PSDT].Signature, - AcpiGbl_AcpiTableData[ACPI_TABLE_PSDT].SigLength)) && - (!STRNCMP (TableHeader.Signature, - AcpiGbl_AcpiTableData[ACPI_TABLE_SSDT].Signature, - AcpiGbl_AcpiTableData[ACPI_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 = (ACPI_TABLE_HEADER *) TablePtr; - TableInfo.Length = TableHeader.Length; + TableInfo.Pointer = Table; + TableInfo.Length = (ACPI_SIZE) Table->Length; TableInfo.Allocation = ACPI_MEM_ALLOCATED; - TableInfo.BasePointer = TablePtr; + TableInfo.BasePointer = Table; - Status = AcpiTbInstallTable (NULL, &TableInfo); + Status = AcpiTbInstallTable (&TableInfo); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -246,43 +181,331 @@ AcpiAmlExecLoadTable ( /* Add the table to the namespace */ - /* TBD: [Restructure] - change to whatever new interface is appropriate */ -/* - Status = AcpiLoadNamespace (); + Status = AcpiNsLoadTable (TableInfo.InstalledDesc, ParentNode); if (ACPI_FAILURE (Status)) { -*/ - /* TBD: [Errors] Unload the table on failure ? */ -/* + /* Uninstall table on error */ + + (void) AcpiTbUninstallTable (TableInfo.InstalledDesc); goto Cleanup; } -*/ - - - /* TBD: [Investigate] we need a pointer to the table desc */ /* Init the table handle */ - TableDesc->Reference.Opcode = AML_LOAD_OP; - TableDesc->Reference.Object = TableInfo.InstalledDesc; + ObjDesc->Reference.Opcode = AML_LOAD_OP; + ObjDesc->Reference.Object = TableInfo.InstalledDesc; + *DdbHandle = ObjDesc; + return_ACPI_STATUS (AE_OK); - *DdbHandle = TableDesc; + +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, AcpiUtGetObjectTypeName (ObjDesc))); + + /* 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, AcpiUtGetObjectTypeName (ObjDesc))); + + /* + * 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); + } return_ACPI_STATUS (Status); Cleanup: - AcpiCmFree (TableDesc); - AcpiCmFree (TablePtr); + if (BufferDesc) + { + AcpiUtRemoveReference (BufferDesc); + } + else + { + ACPI_MEM_FREE (TablePtr); + } return_ACPI_STATUS (Status); - } -/***************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiAmlExecUnloadTable + * FUNCTION: AcpiExUnloadTable * * PARAMETERS: DdbHandle - Handle to a previously loaded table * @@ -290,35 +513,33 @@ Cleanup: * * DESCRIPTION: Unload an ACPI table * - ****************************************************************************/ + ******************************************************************************/ -static ACPI_STATUS -AcpiAmlExecUnloadTable ( - ACPI_HANDLE DdbHandle) +ACPI_STATUS +AcpiExUnloadTable ( + ACPI_OPERAND_OBJECT *DdbHandle) { ACPI_STATUS Status = AE_NOT_IMPLEMENTED; - ACPI_OPERAND_OBJECT *TableDesc = (ACPI_OPERAND_OBJECT *) DdbHandle; + ACPI_OPERAND_OBJECT *TableDesc = DdbHandle; ACPI_TABLE_DESC *TableInfo; - FUNCTION_TRACE ("AmlExecUnloadTable"); + ACPI_FUNCTION_TRACE ("ExUnloadTable"); - /* Validate the handle */ - /* Although the handle is partially validated in AcpiAmlExecReconfiguration(), - * when it calls AcpiAmlResolveOperands(), the handle is more completely - * validated here. + /* + * Validate the handle + * Although the handle is partially validated in AcpiExReconfiguration(), + * when it calls AcpiExResolveOperands(), the handle is more completely + * validated here. */ - if ((!DdbHandle) || - (!VALID_DESCRIPTOR_TYPE (DdbHandle, ACPI_DESC_TYPE_INTERNAL)) || - (((ACPI_OPERAND_OBJECT *)DdbHandle)->Common.Type != - INTERNAL_TYPE_REFERENCE)) + (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) || + (ACPI_GET_OBJECT_TYPE (DdbHandle) != INTERNAL_TYPE_REFERENCE)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Get the actual table descriptor from the DdbHandle */ TableInfo = (ACPI_TABLE_DESC *) TableDesc->Reference.Object; @@ -327,109 +548,15 @@ AcpiAmlExecUnloadTable ( * Delete the entire namespace under this table Node * (Offset contains the TableId) */ - - Status = AcpiNsDeleteNamespaceByOwner (TableInfo->TableId); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + AcpiNsDeleteNamespaceByOwner (TableInfo->TableId); /* Delete the table itself */ - AcpiTbUninstallTable (TableInfo->InstalledDesc); + (void) AcpiTbUninstallTable (TableInfo->InstalledDesc); /* Delete the table descriptor (DdbHandle) */ - 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_OPERAND_OBJECT *RegionDesc = NULL; - ACPI_HANDLE *DdbHandle; - - - FUNCTION_TRACE ("AmlExecReconfiguration"); - - - /* Resolve the operands */ - - Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); - DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), - 2, "after AcpiAmlResolveOperands"); - - /* Get the table handle, common for both opcodes */ - - Status |= AcpiDsObjStackPopObject ((ACPI_OPERAND_OBJECT **) &DdbHandle, - WalkState); - - switch (Opcode) - { - - case AML_LOAD_OP: - - /* Get the region or field descriptor */ - - Status |= AcpiDsObjStackPopObject (&RegionDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_ERROR, - ("ExecReconfiguration/AML_LOAD_OP: bad operand(s) (%X)\n", - Status)); - - AcpiCmRemoveReference (RegionDesc); - return_ACPI_STATUS (Status); - } - - Status = AcpiAmlExecLoadTable (RegionDesc, DdbHandle); - break; - - - case AML_UNLOAD_OP: - - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_ERROR, - ("ExecReconfiguration/AML_UNLOAD_OP: bad operand(s) (%X)\n", - Status)); - - return_ACPI_STATUS (Status); - } - - Status = AcpiAmlExecUnloadTable (DdbHandle); - break; - - - default: - - DEBUG_PRINT (ACPI_ERROR, ("AmlExecReconfiguration: bad opcode=%X\n", - Opcode)); - - Status = AE_AML_BAD_OPCODE; - break; - } - - + AcpiUtRemoveReference (TableDesc); return_ACPI_STATUS (Status); } diff --git a/source/components/executer/exconvrt.c b/source/components/executer/exconvrt.c index 5807c890b..599df88ed 100644 --- a/source/components/executer/exconvrt.c +++ b/source/components/executer/exconvrt.c @@ -1,7 +1,7 @@ /****************************************************************************** * - * Module Name: amconvrt - Object conversion routines - * $Revision: 1.11 $ + * Module Name: exconvrt - Object conversion routines + * $Revision: 1.37 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -115,24 +115,20 @@ *****************************************************************************/ -#define __AMCONVRT_C__ +#define __EXCONVRT_C__ #include "acpi.h" -#include "acparser.h" -#include "acnamesp.h" #include "acinterp.h" -#include "acevents.h" #include "amlcode.h" -#include "acdispat.h" #define _COMPONENT ACPI_EXECUTER - MODULE_NAME ("amconvrt") + ACPI_MODULE_NAME ("exconvrt") /******************************************************************************* * - * FUNCTION: AcpiAmlConvertToInteger + * FUNCTION: AcpiExConvertToInteger * * PARAMETERS: *ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String @@ -145,59 +141,42 @@ ******************************************************************************/ ACPI_STATUS -AcpiAmlConvertToInteger ( - ACPI_OPERAND_OBJECT **ObjDesc, +AcpiExConvertToInteger ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState) { UINT32 i; ACPI_OPERAND_OBJECT *RetDesc; UINT32 Count; - char *Pointer; + UINT8 *Pointer; ACPI_INTEGER Result; - UINT32 IntegerSize = sizeof (ACPI_INTEGER); + ACPI_STATUS Status; - switch ((*ObjDesc)->Common.Type) + ACPI_FUNCTION_TRACE_PTR ("ExConvertToInteger", ObjDesc); + + + switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_INTEGER: - return (AE_OK); + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); case ACPI_TYPE_STRING: - Pointer = (*ObjDesc)->String.Pointer; - Count = (*ObjDesc)->String.Length; + Pointer = (UINT8 *) ObjDesc->String.Pointer; + Count = ObjDesc->String.Length; break; case ACPI_TYPE_BUFFER: - Pointer = (char *) (*ObjDesc)->Buffer.Pointer; - Count = (*ObjDesc)->Buffer.Length; + Pointer = ObjDesc->Buffer.Pointer; + Count = ObjDesc->Buffer.Length; break; default: - return (AE_TYPE); + return_ACPI_STATUS (AE_TYPE); } - /* - * Create a new integer - */ - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER); - if (!RetDesc) - { - return (AE_NO_MEMORY); - } - - - /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */ - - if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32) - { - /* - * We are running a method that exists in a 32-bit ACPI table. - * Truncate the value to 32 bits by zeroing out the upper 32-bit field - */ - IntegerSize = sizeof (UINT32); - } - - /* * Convert the buffer/string to an integer. Note that both buffers and * strings are treated as raw data - we don't convert ascii to hex for @@ -211,26 +190,27 @@ AcpiAmlConvertToInteger ( /* Transfer no more than an integer's worth of data */ - if (Count > IntegerSize) + if (Count > AcpiGbl_IntegerByteWidth) { - Count = IntegerSize; + Count = AcpiGbl_IntegerByteWidth; } /* * String conversion is different than Buffer conversion */ - switch ((*ObjDesc)->Common.Type) + switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_STRING: - /* TBD: Need to use 64-bit STRTOUL */ - /* * Convert string to an integer * String must be hexadecimal as per the ACPI specification */ - - Result = STRTOUL (Pointer, NULL, 16); + Status = AcpiUtStrtoul64 ((char *) Pointer, 16, &Result); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } break; @@ -249,28 +229,43 @@ AcpiAmlConvertToInteger ( */ Result |= (((ACPI_INTEGER) Pointer[i]) << (i * 8)); } - break; + + + default: + /* No other types can get here */ + break; + } + + /* + * Create a new integer + */ + RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!RetDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); } /* Save the Result, delete original descriptor, store new descriptor */ RetDesc->Integer.Value = Result; - if (WalkState->Opcode != AML_STORE_OP) + if (*ResultDesc == ObjDesc) { - AcpiCmRemoveReference (*ObjDesc); + if (WalkState->Opcode != AML_STORE_OP) + { + AcpiUtRemoveReference (ObjDesc); + } } - *ObjDesc = RetDesc; - - return (AE_OK); + *ResultDesc = RetDesc; + return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiAmlConvertToBuffer + * FUNCTION: AcpiExConvertToBuffer * * PARAMETERS: *ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String @@ -283,91 +278,189 @@ AcpiAmlConvertToInteger ( ******************************************************************************/ ACPI_STATUS -AcpiAmlConvertToBuffer ( - ACPI_OPERAND_OBJECT **ObjDesc, +AcpiExConvertToBuffer ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT *RetDesc; UINT32 i; - UINT32 IntegerSize = sizeof (ACPI_INTEGER); UINT8 *NewBuf; - switch ((*ObjDesc)->Common.Type) + ACPI_FUNCTION_TRACE_PTR ("ExConvertToBuffer", ObjDesc); + + + switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_INTEGER: /* - * Create a new Buffer + * Create a new Buffer object */ - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_BUFFER); + RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); if (!RetDesc) { - return (AE_NO_MEMORY); + return_ACPI_STATUS (AE_NO_MEMORY); } - /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */ + /* Need enough space for one integer */ - if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32) - { - /* - * We are running a method that exists in a 32-bit ACPI table. - * Truncate the value to 32 bits by zeroing out the upper - * 32-bit field - */ - IntegerSize = sizeof (UINT32); - } - - /* Need enough space for one integers */ - - RetDesc->Buffer.Length = IntegerSize; - NewBuf = AcpiCmCallocate (IntegerSize); + NewBuf = ACPI_MEM_CALLOCATE (AcpiGbl_IntegerByteWidth); if (!NewBuf) { - REPORT_ERROR - (("AmlExecDyadic2R/ConcatOp: Buffer allocation failure\n")); - AcpiCmRemoveReference (RetDesc); - return (AE_NO_MEMORY); + ACPI_REPORT_ERROR + (("ExConvertToBuffer: Buffer allocation failure\n")); + AcpiUtRemoveReference (RetDesc); + return_ACPI_STATUS (AE_NO_MEMORY); } /* Copy the integer to the buffer */ - for (i = 0; i < IntegerSize; i++) + for (i = 0; i < AcpiGbl_IntegerByteWidth; i++) { - NewBuf[i] = (UINT8) ((*ObjDesc)->Integer.Value >> (i * 8)); + NewBuf[i] = (UINT8) (ObjDesc->Integer.Value >> (i * 8)); } + + /* Complete buffer object initialization */ + + RetDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; RetDesc->Buffer.Pointer = NewBuf; + RetDesc->Buffer.Length = AcpiGbl_IntegerByteWidth; /* Return the new buffer descriptor */ - if (WalkState->Opcode != AML_STORE_OP) - { - AcpiCmRemoveReference (*ObjDesc); - } - *ObjDesc = RetDesc; + *ResultDesc = RetDesc; break; case ACPI_TYPE_STRING: + *ResultDesc = ObjDesc; break; case ACPI_TYPE_BUFFER: + *ResultDesc = ObjDesc; break; default: - return (AE_TYPE); - break; - } + return_ACPI_STATUS (AE_TYPE); + } - return (AE_OK); + /* Mark buffer initialized */ + + (*ResultDesc)->Common.Flags |= AOPOBJ_DATA_VALID; + return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiAmlConvertToString + * FUNCTION: AcpiExConvertAscii + * + * PARAMETERS: Integer + * + * RETURN: Actual string length + * + * DESCRIPTION: Convert an ACPI Integer to a hex string + * + ******************************************************************************/ + +UINT32 +AcpiExConvertToAscii ( + ACPI_INTEGER Integer, + UINT32 Base, + UINT8 *String) +{ + UINT32 i; + UINT32 j; + UINT32 k = 0; + char HexDigit; + ACPI_INTEGER Digit; + UINT32 Remainder; + UINT32 Length = sizeof (ACPI_INTEGER); + BOOLEAN LeadingZero = TRUE; + + + ACPI_FUNCTION_ENTRY (); + + + switch (Base) + { + case 10: + + Remainder = 0; + for (i = ACPI_MAX_DECIMAL_DIGITS; i > 0 ; i--) + { + /* Divide by nth factor of 10 */ + + Digit = Integer; + for (j = 1; j < i; j++) + { + (void) AcpiUtShortDivide (&Digit, 10, &Digit, &Remainder); + } + + /* Create the decimal digit */ + + if (Digit != 0) + { + LeadingZero = FALSE; + } + + if (!LeadingZero) + { + String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder); + k++; + } + } + break; + + case 16: + + /* Copy the integer to the buffer */ + + for (i = 0, j = ((Length * 2) -1); i < (Length * 2); i++, j--) + { + + HexDigit = AcpiUtHexToAsciiChar (Integer, (j * 4)); + if (HexDigit != ACPI_ASCII_ZERO) + { + LeadingZero = FALSE; + } + + if (!LeadingZero) + { + String[k] = (UINT8) HexDigit; + k++; + } + } + break; + + default: + break; + } + + /* + * Since leading zeros are supressed, we must check for the case where + * the integer equals 0. + * + * Finally, null terminate the string and return the length + */ + if (!k) + { + String [0] = ACPI_ASCII_ZERO; + k = 1; + } + String [k] = 0; + + return (k); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToString * * PARAMETERS: *ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String @@ -380,177 +473,220 @@ AcpiAmlConvertToBuffer ( ******************************************************************************/ ACPI_STATUS -AcpiAmlConvertToString ( - ACPI_OPERAND_OBJECT **ObjDesc, +AcpiExConvertToString ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + UINT32 Base, + UINT32 MaxLength, ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT *RetDesc; UINT32 i; UINT32 Index; - UINT32 IntegerSize = sizeof (ACPI_INTEGER); + UINT32 StringLength; UINT8 *NewBuf; UINT8 *Pointer; - switch ((*ObjDesc)->Common.Type) + ACPI_FUNCTION_TRACE_PTR ("ExConvertToString", ObjDesc); + + + switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_INTEGER: + StringLength = AcpiGbl_IntegerByteWidth * 2; + if (Base == 10) + { + StringLength = ACPI_MAX_DECIMAL_DIGITS; + } + /* * Create a new String */ - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING); + RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); if (!RetDesc) { - return (AE_NO_MEMORY); - } - - /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */ - - if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32) - { - /* - * We are running a method that exists in a 32-bit ACPI table. - * Truncate the value to 32 bits by zeroing out the upper - * 32-bit field - */ - IntegerSize = sizeof (UINT32); + return_ACPI_STATUS (AE_NO_MEMORY); } /* Need enough space for one ASCII integer plus null terminator */ - RetDesc->String.Length = (IntegerSize * 2) + 1; - NewBuf = AcpiCmCallocate (RetDesc->String.Length); + NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1); if (!NewBuf) { - REPORT_ERROR - (("AmlExecDyadic2R/ConcatOp: Buffer allocation failure\n")); - AcpiCmRemoveReference (RetDesc); - return (AE_NO_MEMORY); + ACPI_REPORT_ERROR + (("ExConvertToString: Buffer allocation failure\n")); + AcpiUtRemoveReference (RetDesc); + return_ACPI_STATUS (AE_NO_MEMORY); } - /* Copy the integer to the buffer */ + /* Convert */ - for (i = 0; i < (IntegerSize * 2); i++) + i = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, NewBuf); + + /* Null terminate at the correct place */ + + if (MaxLength < i) { - NewBuf[i] = AcpiGbl_HexToAscii [((*ObjDesc)->Integer.Value >> (i * 4)) & 0xF]; + NewBuf[MaxLength] = 0; + RetDesc->String.Length = MaxLength; + } + else + { + NewBuf [i] = 0; + RetDesc->String.Length = i; } - /* Null terminate */ - - NewBuf [i] = 0; RetDesc->Buffer.Pointer = NewBuf; /* Return the new buffer descriptor */ - if (WalkState->Opcode != AML_STORE_OP) + if (*ResultDesc == ObjDesc) { - AcpiCmRemoveReference (*ObjDesc); + if (WalkState->Opcode != AML_STORE_OP) + { + AcpiUtRemoveReference (ObjDesc); + } } - *ObjDesc = RetDesc; - return (AE_OK); + *ResultDesc = RetDesc; + break; case ACPI_TYPE_BUFFER: - if (((*ObjDesc)->Buffer.Length * 3) > ACPI_MAX_STRING_CONVERSION) + StringLength = ObjDesc->Buffer.Length * 3; + if (Base == 10) { - return (AE_AML_STRING_LIMIT); + StringLength = ObjDesc->Buffer.Length * 4; + } + + if (MaxLength > ACPI_MAX_STRING_CONVERSION) + { + if (StringLength > ACPI_MAX_STRING_CONVERSION) + { + return_ACPI_STATUS (AE_AML_STRING_LIMIT); + } } /* - * Create a new String + * Create a new string object */ - RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING); + RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); if (!RetDesc) { - return (AE_NO_MEMORY); + return_ACPI_STATUS (AE_NO_MEMORY); } - /* Need enough space for one ASCII integer plus null terminator */ + /* String length is the lesser of the Max or the actual length */ - RetDesc->String.Length = (*ObjDesc)->Buffer.Length * 3; - NewBuf = AcpiCmCallocate (RetDesc->String.Length + 1); + if (MaxLength < StringLength) + { + StringLength = MaxLength; + } + + NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1); if (!NewBuf) { - REPORT_ERROR - (("AmlExecDyadic2R/ConcatOp: Buffer allocation failure\n")); - AcpiCmRemoveReference (RetDesc); - return (AE_NO_MEMORY); + ACPI_REPORT_ERROR + (("ExConvertToString: Buffer allocation failure\n")); + AcpiUtRemoveReference (RetDesc); + return_ACPI_STATUS (AE_NO_MEMORY); } /* * Convert each byte of the buffer to two ASCII characters plus a space. */ - Pointer = (*ObjDesc)->Buffer.Pointer; + Pointer = ObjDesc->Buffer.Pointer; Index = 0; - for (i = 0; i < (*ObjDesc)->Buffer.Length; i++) + for (i = 0, Index = 0; i < ObjDesc->Buffer.Length; i++) { - NewBuf[Index + 0] = AcpiGbl_HexToAscii [Pointer[i] & 0x0F]; - NewBuf[Index + 1] = AcpiGbl_HexToAscii [(Pointer[i] >> 4) & 0x0F]; - NewBuf[Index + 2] = ' '; - Index += 3; + Index = AcpiExConvertToAscii ((ACPI_INTEGER) Pointer[i], Base, &NewBuf[Index]); + + NewBuf[Index] = ' '; + Index++; } /* Null terminate */ - NewBuf [Index] = 0; + NewBuf [Index-1] = 0; RetDesc->Buffer.Pointer = NewBuf; + RetDesc->String.Length = ACPI_STRLEN ((char *) NewBuf); /* Return the new buffer descriptor */ - if (WalkState->Opcode != AML_STORE_OP) + if (*ResultDesc == ObjDesc) { - AcpiCmRemoveReference (*ObjDesc); + if (WalkState->Opcode != AML_STORE_OP) + { + AcpiUtRemoveReference (ObjDesc); + } } - *ObjDesc = RetDesc; + + *ResultDesc = RetDesc; break; case ACPI_TYPE_STRING: + + if (MaxLength >= ObjDesc->String.Length) + { + *ResultDesc = ObjDesc; + } + + else + { + /* Must copy the string first and then truncate it */ + + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } break; default: - return (AE_TYPE); - break; - } + return_ACPI_STATUS (AE_TYPE); + } - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiAmlConvertToTargetType + * FUNCTION: AcpiExConvertToTargetType * - * PARAMETERS: *ObjDesc - Object to be converted. - * WalkState - Current method state + * PARAMETERS: DestinationType - Current type of the destination + * SourceDesc - Source object to be converted. + * WalkState - Current method state * * RETURN: Status * - * DESCRIPTION: + * DESCRIPTION: Implements "implicit conversion" rules for storing an object. * ******************************************************************************/ ACPI_STATUS -AcpiAmlConvertToTargetType ( - ACPI_OBJECT_TYPE8 DestinationType, - ACPI_OPERAND_OBJECT **ObjDesc, +AcpiExConvertToTargetType ( + ACPI_OBJECT_TYPE DestinationType, + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; - FUNCTION_TRACE ("AmlConvertToTargetType"); + ACPI_FUNCTION_TRACE ("ExConvertToTargetType"); + /* Default behavior */ + + *ResultDesc = SourceDesc; + /* * If required by the target, * perform implicit conversion on the source before we store it. */ - switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs)) { case ARGI_SIMPLE_TARGET: @@ -568,12 +704,12 @@ AcpiAmlConvertToTargetType ( default: /* No conversion allowed for these types */ - if (DestinationType != (*ObjDesc)->Common.Type) + if (DestinationType != ACPI_GET_OBJECT_TYPE (SourceDesc)) { - DEBUG_PRINT (ACPI_ERROR, - ("AmlConvertToTargetType: Target does not allow conversion of type %s to %s\n", - AcpiCmGetTypeName ((*ObjDesc)->Common.Type), - AcpiCmGetTypeName (DestinationType))); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Target does not allow conversion of type %s to %s\n", + AcpiUtGetObjectTypeName (SourceDesc), + AcpiUtGetTypeName (DestinationType))); Status = AE_TYPE; } } @@ -592,7 +728,7 @@ AcpiAmlConvertToTargetType ( * These types require an Integer operand. We can convert * a Buffer or a String to an Integer if necessary. */ - Status = AcpiAmlConvertToInteger (ObjDesc, WalkState); + Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, WalkState); break; @@ -602,17 +738,22 @@ AcpiAmlConvertToTargetType ( * The operand must be a String. We can convert an * Integer or Buffer if necessary */ - Status = AcpiAmlConvertToString (ObjDesc, WalkState); + Status = AcpiExConvertToString (SourceDesc, ResultDesc, 16, ACPI_UINT32_MAX, WalkState); break; case ACPI_TYPE_BUFFER: /* - * The operand must be a String. We can convert an - * Integer or Buffer if necessary + * The operand must be a Buffer. We can convert an + * Integer or String if necessary */ - Status = AcpiAmlConvertToBuffer (ObjDesc, WalkState); + Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc, WalkState); + break; + + + default: + Status = AE_AML_INTERNAL; break; } break; @@ -626,16 +767,14 @@ AcpiAmlConvertToTargetType ( default: - DEBUG_PRINT (ACPI_ERROR, - ("AmlConvertToTargetType: Unknown Target type ID 0x%X Op %s DestType %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown Target type ID 0x%X Op %s DestType %s\n", GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs), - WalkState->OpInfo->Name, - AcpiCmGetTypeName (DestinationType))); + WalkState->OpInfo->Name, AcpiUtGetTypeName (DestinationType))); Status = AE_AML_INTERNAL; } - /* * Source-to-Target conversion semantics: *