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;
This commit is contained in:
aystarik 2005-06-29 17:03:51 +00:00
parent dfdabaeca6
commit 0aa1813870
7 changed files with 1859 additions and 1234 deletions

View File

@ -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);
}

View File

@ -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);

File diff suppressed because it is too large Load Diff

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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);
}

View File

@ -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:
*