Another pass at removal of ACPI_HANDLE from low-level CA code

date	2001.03.28.22.02.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 17:42:33 +00:00
parent f2bcb8c6af
commit f1f349fd89
6 changed files with 1382 additions and 949 deletions

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: amprep - ACPI AML (p-code) execution - field prep utilities
* $Revision: 1.76 $
* $Revision: 1.77 $
*
*****************************************************************************/
@ -268,7 +268,7 @@ AcpiAmlPrepCommonFieldObject (
* FUNCTION: AcpiAmlPrepDefFieldValue
*
* PARAMETERS: Node - Owning Node
* Region - Region in which field is being defined
* RegionNode - Region in which field is being defined
* FieldFlags - Access, LockRule, or UpdateRule.
* The format of a FieldFlag is described
* in the ACPI specification
@ -285,7 +285,7 @@ AcpiAmlPrepCommonFieldObject (
ACPI_STATUS
AcpiAmlPrepDefFieldValue (
ACPI_NAMESPACE_NODE *Node,
ACPI_HANDLE Region,
ACPI_HANDLE RegionNode,
UINT8 FieldFlags,
UINT8 FieldAttribute,
UINT32 FieldPosition,
@ -301,13 +301,13 @@ AcpiAmlPrepDefFieldValue (
/* Parameter validation */
if (!Region)
if (!RegionNode)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlPrepDefFieldValue: null Region\n"));
DEBUG_PRINT (ACPI_ERROR, ("AmlPrepDefFieldValue: null RegionNode\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
Type = AcpiNsGetType (Region);
Type = AcpiNsGetType (RegionNode);
if (Type != ACPI_TYPE_REGION)
{
DEBUG_PRINT (ACPI_ERROR,
@ -329,7 +329,7 @@ AcpiAmlPrepDefFieldValue (
DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Node, IMODE_EXECUTE,
"AmlPrepDefFieldValue", 1, "case DefField");
DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Region, IMODE_EXECUTE,
DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &RegionNode, IMODE_EXECUTE,
"AmlPrepDefFieldValue", 1, "case DefField");
/* Initialize areas of the object that are common to all fields */
@ -343,11 +343,11 @@ AcpiAmlPrepDefFieldValue (
/* Initialize areas of the object that are specific to this field type */
ObjDesc->Field.Container = AcpiNsGetAttachedObject (Region);
ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (RegionNode);
/* An additional reference for the container */
AcpiCmAddReference (ObjDesc->Field.Container);
AcpiCmAddReference (ObjDesc->Field.RegionObj);
/* Debug info */
@ -362,12 +362,12 @@ AcpiAmlPrepDefFieldValue (
Node, &(Node->Name), ObjDesc));
DUMP_STACK_ENTRY (ObjDesc);
DUMP_ENTRY (Region, ACPI_INFO);
DEBUG_PRINT (ACPI_INFO, ("\t%p \n", ObjDesc->Field.Container));
DUMP_ENTRY (RegionNode, ACPI_INFO);
DEBUG_PRINT (ACPI_INFO, ("\t%p \n", ObjDesc->Field.RegionObj));
if (ObjDesc->Field.Container)
if (ObjDesc->Field.RegionObj)
{
DUMP_STACK_ENTRY (ObjDesc->Field.Container);
DUMP_STACK_ENTRY (ObjDesc->Field.RegionObj);
}
DEBUG_PRINT (ACPI_INFO,
@ -377,8 +377,7 @@ AcpiAmlPrepDefFieldValue (
* Store the constructed descriptor (ObjDesc) into the NamedObj whose
* handle is on TOS, preserving the current type of that NamedObj.
*/
Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc,
(UINT8) AcpiNsGetType ((ACPI_HANDLE) Node));
Status = AcpiNsAttachObject (Node, ObjDesc, (UINT8) AcpiNsGetType (Node));
return_ACPI_STATUS (Status);
}
@ -388,9 +387,9 @@ AcpiAmlPrepDefFieldValue (
*
* FUNCTION: AcpiAmlPrepBankFieldValue
*
* PARAMETERS: Node - Owning Node
* Region - Region in which field is being defined
* BankReg - Bank selection register
* PARAMETERS: Node - Owning Node
* RegionNode - Region in which field is being defined
* BankRegisterNode - Bank selection register node
* BankVal - Value to store in selection register
* FieldFlags - Access, LockRule, or UpdateRule
* FieldPosition - Field position
@ -398,16 +397,16 @@ AcpiAmlPrepDefFieldValue (
*
* RETURN: Status
*
* DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type BankField and
* connect it to the parent Node.
* DESCRIPTION: Construct an object of type BankField and attach it to the
* parent Node.
*
******************************************************************************/
ACPI_STATUS
AcpiAmlPrepBankFieldValue (
ACPI_NAMESPACE_NODE *Node,
ACPI_HANDLE Region,
ACPI_HANDLE BankReg,
ACPI_NAMESPACE_NODE *RegionNode,
ACPI_NAMESPACE_NODE *BankRegisterNode,
UINT32 BankVal,
UINT8 FieldFlags,
UINT8 FieldAttribute,
@ -424,13 +423,13 @@ AcpiAmlPrepBankFieldValue (
/* Parameter validation */
if (!Region)
if (!RegionNode)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlPrepBankFieldValue: null Region\n"));
DEBUG_PRINT (ACPI_ERROR, ("AmlPrepBankFieldValue: null RegionNode\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
Type = AcpiNsGetType (Region);
Type = AcpiNsGetType (RegionNode);
if (Type != ACPI_TYPE_REGION)
{
DEBUG_PRINT (ACPI_ERROR,
@ -451,7 +450,7 @@ AcpiAmlPrepBankFieldValue (
DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Node, IMODE_EXECUTE,
"AmlPrepBankFieldValue", 1, "case BankField");
DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Region, IMODE_EXECUTE,
DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &RegionNode, IMODE_EXECUTE,
"AmlPrepBankFieldValue", 1, "case BankField");
/* Initialize areas of the object that are common to all fields */
@ -465,15 +464,15 @@ AcpiAmlPrepBankFieldValue (
/* Initialize areas of the object that are specific to this field type */
ObjDesc->BankField.Value = BankVal;
ObjDesc->BankField.Container = AcpiNsGetAttachedObject (Region);
ObjDesc->BankField.BankSelect = AcpiNsGetAttachedObject (BankReg);
ObjDesc->BankField.Value = BankVal;
ObjDesc->BankField.BankRegisterNode = BankRegisterNode;
ObjDesc->BankField.BankRegisterObj = AcpiNsGetAttachedObject (BankRegisterNode);
ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject (RegionNode);
/* An additional reference for the container and bank select */
/* TBD: [Restructure] is "BankSelect" ever a real internal object?? */
/* An additional reference for the region and bankregister objects */
AcpiCmAddReference (ObjDesc->BankField.Container);
AcpiCmAddReference (ObjDesc->BankField.BankSelect);
AcpiCmAddReference (ObjDesc->BankField.RegionObj);
AcpiCmAddReference (ObjDesc->BankField.BankRegisterObj);
/* Debug info */
@ -487,17 +486,16 @@ AcpiAmlPrepBankFieldValue (
Node, &(Node->Name), ObjDesc));
DUMP_STACK_ENTRY (ObjDesc);
DUMP_ENTRY (Region, ACPI_INFO);
DUMP_ENTRY (BankReg, ACPI_INFO);
DUMP_ENTRY (RegionNode, ACPI_INFO);
DUMP_ENTRY (BankRegisterNode, ACPI_INFO);
DEBUG_PRINT (ACPI_INFO,
("============================================================\n"));
/*
* Store the constructed descriptor (ObjDesc) into the NamedObj whose
* Store the constructed descrip tor (ObjDesc) into the NamedObj whose
* handle is on TOS, preserving the current type of that NamedObj.
*/
Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc,
(UINT8) AcpiNsGetType ((ACPI_HANDLE) Node));
Status = AcpiNsAttachObject (Node, ObjDesc, (UINT8) AcpiNsGetType (Node));
return_ACPI_STATUS (Status);
}
@ -591,8 +589,7 @@ AcpiAmlPrepIndexFieldValue (
* Store the constructed descriptor (ObjDesc) into the NamedObj whose
* handle is on TOS, preserving the current type of that NamedObj.
*/
Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc,
(UINT8) AcpiNsGetType ((ACPI_HANDLE) Node));
Status = AcpiNsAttachObject (Node, ObjDesc, (UINT8) AcpiNsGetType (Node));
return_ACPI_STATUS (Status);
}

View File

@ -2,6 +2,7 @@
/******************************************************************************
*
* Module Name: amresnte - AML Interpreter object resolution
* $Revision: 1.31 $
*
*****************************************************************************/
@ -9,8 +10,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, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -126,26 +127,28 @@
#include "acevents.h"
#define _COMPONENT INTERPRETER
MODULE_NAME ("amresnte");
#define _COMPONENT ACPI_EXECUTER
MODULE_NAME ("amresnte")
/*******************************************************************************
*
* FUNCTION: AcpiAmlResolveEntryToValue
* FUNCTION: AcpiAmlResolveNodeToValue
*
* PARAMETERS: StackPtr - Pointer to a location on a stack that contains
* a ptr to an NTE
* a pointer to a Node
* WalkState - Current state
*
* RETURN: Status
*
* DESCRIPTION: Resolve a ACPI_NAMED_OBJECT(nte, A.K.A. a "direct name pointer")
* DESCRIPTION: Resolve a Namespace node (AKA a "direct name pointer") to
* a valued object
*
* Note: for some of the data types, the pointer attached to the NTE can be
* either a pointer to an actual internal object or a pointer into the AML
* stream itself. These types are currently:
* Note: for some of the data types, the pointer attached to the Node
* can be either a pointer to an actual internal object or a pointer into the
* AML stream itself. These types are currently:
*
* ACPI_TYPE_NUMBER
* ACPI_TYPE_INTEGER
* ACPI_TYPE_STRING
* ACPI_TYPE_BUFFER
* ACPI_TYPE_MUTEX
@ -154,42 +157,43 @@
******************************************************************************/
ACPI_STATUS
AcpiAmlResolveEntryToValue (
ACPI_NAMED_OBJECT **StackPtr)
AcpiAmlResolveNodeToValue (
ACPI_NAMESPACE_NODE **StackPtr,
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status = AE_OK;
ACPI_OBJECT_INTERNAL *ValDesc = NULL;
ACPI_OBJECT_INTERNAL *ObjDesc = NULL;
ACPI_NAMED_OBJECT *StackEntry;
ACPI_OPERAND_OBJECT *ValDesc;
ACPI_OPERAND_OBJECT *ObjDesc = NULL;
ACPI_NAMESPACE_NODE *Node;
UINT8 *AmlPointer = NULL;
OBJECT_TYPE_INTERNAL EntryType;
ACPI_INTEGER TempVal;
OBJECT_TYPE_INTERNAL ObjectType;
BOOLEAN Locked;
BOOLEAN AttachedAmlPointer = FALSE;
UINT8 AmlOpcode = 0;
UINT32 TempVal;
OBJECT_TYPE_INTERNAL ObjectType;
FUNCTION_TRACE ("AmlResolveEntryToValue");
StackEntry = *StackPtr;
/*
* The stack pointer is a "Direct name ptr", and points to a
* a ACPI_NAMED_OBJECT(nte). Get the pointer that is attached to
* the nte.
* The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the
* object that is attached to the Node.
*/
ValDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) StackEntry);
EntryType = AcpiNsGetType ((ACPI_HANDLE) StackEntry);
Node = *StackPtr;
ValDesc = AcpiNsGetAttachedObject (Node);
EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
DEBUG_PRINT (TRACE_EXEC,
("AmlResolveEntryToValue: Entry=%p ValDesc=%p Type=%X\n",
StackEntry, ValDesc, EntryType));
Node, ValDesc, EntryType));
/*
* The ValDesc attached to the NTE can be either:
* The ValDesc attached to the Node can be either:
* 1) An internal ACPI object
* 2) A pointer into the AML stream (into one of the ACPI system tables)
*/
@ -197,8 +201,8 @@ AcpiAmlResolveEntryToValue (
if (AcpiTbSystemTablePointer (ValDesc))
{
AttachedAmlPointer = TRUE;
AmlOpcode = *((UINT8 *) ValDesc);
AmlPointer = ((UINT8 *) ValDesc) + 1;
AmlOpcode = *((UINT8 *) ValDesc);
AmlPointer = ((UINT8 *) ValDesc) + 1;
DEBUG_PRINT (TRACE_EXEC,
("AmlResolveEntryToValue: Unparsed AML: %p Len=%X\n",
@ -206,16 +210,15 @@ AcpiAmlResolveEntryToValue (
}
/*
/*
* Several EntryTypes do not require further processing, so
* we will return immediately
*/
/* Devices rarely have an attached object, return the NTE
* and Method locals and arguments have a pseudo-NTE
/* Devices rarely have an attached object, return the Node
* and Method locals and arguments have a pseudo-Node
*/
if (EntryType == ACPI_TYPE_DEVICE ||
EntryType == INTERNAL_TYPE_METHOD_ARGUMENT ||
EntryType == INTERNAL_TYPE_METHOD_LOCAL_VAR)
(Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL)))
{
return_ACPI_STATUS (AE_OK);
}
@ -223,12 +226,13 @@ AcpiAmlResolveEntryToValue (
if (!ValDesc)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Internal error - null parameter\n"));
("AmlResolveEntryToValue: No object attached to node %p\n",
Node));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
/*
* Action is based on the type of the NTE, which indicates the type
* Action is based on the type of the Node, which indicates the type
* of the attached object or pointer
*/
switch (EntryType)
@ -252,7 +256,8 @@ AcpiAmlResolveEntryToValue (
if (ACPI_TYPE_PACKAGE != ValDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Internal error - Bad pkg value\n"));
("AmlResolveEntryToValue: Object not a package, type %X\n",
ValDesc->Common.Type));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@ -281,7 +286,8 @@ AcpiAmlResolveEntryToValue (
if (ACPI_TYPE_BUFFER != ValDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Bad buffer value\n"));
("AmlResolveEntryToValue: Object not a buffer, type %X\n",
ValDesc->Common.Type));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@ -289,10 +295,6 @@ AcpiAmlResolveEntryToValue (
ObjDesc = ValDesc;
AcpiCmAddReference (ObjDesc);
DEBUG_PRINT (TRACE_BFIELD,
("AmlResolveEntryToValue: New Buffer descriptor seq# %ld @ %p \n",
ObjDesc->Buffer.Sequence, ObjDesc));
break;
@ -311,7 +313,7 @@ AcpiAmlResolveEntryToValue (
/* Init the internal object */
ObjDesc->String.Pointer = (NATIVE_CHAR *) AmlPointer;
ObjDesc->String.Length = STRLEN (AmlPointer);
ObjDesc->String.Length = STRLEN (ObjDesc->String.Pointer);
}
else
@ -319,7 +321,8 @@ AcpiAmlResolveEntryToValue (
if (ACPI_TYPE_STRING != ValDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Internal error - Bad string value\n"));
("AmlResolveEntryToValue: Object not a string, type %X\n",
ValDesc->Common.Type));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@ -332,105 +335,27 @@ AcpiAmlResolveEntryToValue (
break;
case ACPI_TYPE_NUMBER:
case ACPI_TYPE_INTEGER:
DEBUG_PRINT (TRACE_EXEC, ("AmlResolveEntryToValue: case Number \n"));
/*
* An ACPI_TYPE_NUMBER can be either an object or an AML pointer
* The Node has an attached internal object, make sure that it's a
* number
*/
if (AttachedAmlPointer)
if (ACPI_TYPE_INTEGER != ValDesc->Common.Type)
{
/*
* The attachment points into the AML stream, get the number from
* there. The actual number is based upon the AML opcode
*
* Note: WordOp and DWordOp will not work properly if the
* processor's endianness does not match the AML's.
*/
switch (AmlOpcode)
{
case AML_ZERO_OP:
TempVal = 0;
break;
case AML_ONE_OP:
TempVal = 1;
break;
case AML_ONES_OP:
TempVal = 0xFFFFFFFF;
break;
case AML_BYTE_OP:
TempVal = (UINT32) ((UINT8 *) ValDesc)[1];
break;
case AML_WORD_OP:
MOVE_UNALIGNED16_TO_32 (&TempVal, &((UINT8 *) ValDesc)[1]);
break;
case AML_DWORD_OP:
MOVE_UNALIGNED32_TO_32 (&TempVal, &((UINT8 *) ValDesc)[1]);
break;
default:
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveToValue/Number: Internal error - expected AML number, found %02x\n",
AmlOpcode));
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
} /* switch */
/* Create and initialize a new object */
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
if (!ObjDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
ObjDesc->Number.Value = TempVal;
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveToValue: Object not a Number, type %X\n",
ValDesc->Common.Type));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
else
{
/*
* The NTE has an attached internal object, make sure that it's a
* number
*/
if (ACPI_TYPE_NUMBER != ValDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveToValue/Number: Attached obj %p not a Number, type 0x%X\n", ValDesc, ValDesc->Common.Type));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/* Return an additional reference to the object */
ObjDesc = ValDesc;
AcpiCmAddReference (ObjDesc);
}
/* Return an additional reference to the object */
ObjDesc = ValDesc;
AcpiCmAddReference (ObjDesc);
break;
@ -454,7 +379,7 @@ AcpiAmlResolveEntryToValue (
}
else
{
ObjectType = ACPI_TYPE_NUMBER;
ObjectType = ACPI_TYPE_INTEGER;
}
/*
@ -471,7 +396,7 @@ AcpiAmlResolveEntryToValue (
*/
if (ACPI_TYPE_BUFFER == ObjectType)
{
ObjDesc->Buffer.Pointer = AcpiCmCallocate(ValDesc->Field.Length);
ObjDesc->Buffer.Pointer = AcpiCmCallocate (ValDesc->Field.Length);
if (!ObjDesc->Buffer.Pointer)
{
AcpiCmRemoveReference(ObjDesc);
@ -480,10 +405,8 @@ AcpiAmlResolveEntryToValue (
ObjDesc->Buffer.Length = ValDesc->Field.Length;
Status = AcpiAmlAccessNamedField (ACPI_READ,
(ACPI_HANDLE) StackEntry,
ObjDesc->Buffer.Pointer,
ObjDesc->Buffer.Length);
Status = AcpiAmlAccessNamedField (ACPI_READ, Node,
ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length);
if (ACPI_FAILURE (Status))
{
@ -492,8 +415,7 @@ AcpiAmlResolveEntryToValue (
}
else
{
Status = AcpiAmlAccessNamedField (ACPI_READ,
(ACPI_HANDLE) StackEntry,
Status = AcpiAmlAccessNamedField (ACPI_READ, Node,
&TempVal, sizeof (TempVal));
if (ACPI_FAILURE (Status))
@ -501,13 +423,13 @@ AcpiAmlResolveEntryToValue (
return_ACPI_STATUS (Status);
}
ObjDesc->Number.Value = TempVal;
ObjDesc->Integer.Value = TempVal;
}
DEBUG_PRINT (TRACE_EXEC,
("AmlResolveEntryToValue: at DefField Entry=%p ValDesc=%p Type=%X\n",
StackEntry, ValDesc, EntryType));
("AmlResolveEntryToValue: DefField Entry=%p ValDesc=%p Type=%X\n",
Node, ValDesc, EntryType));
break;
@ -516,16 +438,15 @@ AcpiAmlResolveEntryToValue (
if (AttachedAmlPointer)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Internal error - BankField cannot be an AcpiAml ptr\n"));
("AmlResolveEntryToValue: BankField cannot be an Aml ptr\n"));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
if (INTERNAL_TYPE_BANK_FIELD != ValDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR, (
"AmlResolveToValue/BankField:Internal error - Name %4.4s type %d does not match value-type %d at %p\n",
&(((ACPI_NAMED_OBJECT*) (*StackPtr))->Name),
INTERNAL_TYPE_BANK_FIELD, ValDesc->Common.Type, ValDesc));
"AmlResolveToValue: Object not a BankField, type %X\n",
ValDesc->Common.Type));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@ -533,16 +454,16 @@ AcpiAmlResolveEntryToValue (
/* Get the global lock if needed */
ObjDesc = (ACPI_OBJECT_INTERNAL *) *StackPtr;
ObjDesc = (ACPI_OPERAND_OBJECT *) *StackPtr;
Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule);
/* Set Index value to select proper Data register */
/* perform the update */
/*
* Set the bank register and perform the update
*/
Status = AcpiAmlAccessNamedField (ACPI_WRITE,
ValDesc->BankField.BankSelect,
&ValDesc->BankField.Value,
sizeof (ValDesc->BankField.Value));
ValDesc->BankField.BankRegisterNode,
&ValDesc->BankField.Value,
sizeof (ValDesc->BankField.Value));
AcpiAmlReleaseGlobalLock (Locked);
@ -554,21 +475,25 @@ AcpiAmlResolveEntryToValue (
/* Read Data value */
/* TBD: [bug] - this read is probably wrong! */
Status = AcpiAmlAccessNamedField (ACPI_READ,
(ACPI_HANDLE) ValDesc->BankField.Container,
ValDesc->BankField.BankRegisterNode,
&TempVal, sizeof (TempVal));
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
/* Create an object for the result */
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER);
if (!ObjDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
ObjDesc->Number.Value = TempVal;
ObjDesc->Integer.Value = TempVal;
break;
@ -576,15 +501,15 @@ AcpiAmlResolveEntryToValue (
if (AttachedAmlPointer)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal error - IndexField cannot be an AcpiAml ptr\n"));
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal - IndexField cannot be an Aml ptr\n"));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
if (INTERNAL_TYPE_INDEX_FIELD != ValDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR, (
"AmlResolveToValue/IndexField: Internal error - Name %4.4s type %d does not match value-type %d at %p\n",
&(((ACPI_NAMED_OBJECT*) (*StackPtr))->Name), INTERNAL_TYPE_INDEX_FIELD, ValDesc->Common.Type, ValDesc));
"AmlResolveToValue: Object not an IndexField, type %X\n",
ValDesc->Common.Type));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@ -593,14 +518,14 @@ AcpiAmlResolveEntryToValue (
/* Set Index value to select proper Data register */
/* Get the global lock if needed */
ObjDesc = (ACPI_OBJECT_INTERNAL *) *StackPtr;
ObjDesc = (ACPI_OPERAND_OBJECT *) *StackPtr;
Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule);
/* Perform the update */
Status = AcpiAmlAccessNamedField (ACPI_WRITE,
ValDesc->IndexField.Index,
&ValDesc->IndexField.Value,
sizeof (ValDesc->IndexField.Value));
Status = AcpiAmlAccessNamedField (ACPI_WRITE,
ValDesc->IndexField.Index, &ValDesc->IndexField.Value,
sizeof (ValDesc->IndexField.Value));
AcpiAmlReleaseGlobalLock (Locked);
@ -611,21 +536,22 @@ AcpiAmlResolveEntryToValue (
/* Read Data value */
Status = AcpiAmlAccessNamedField (ACPI_READ,
ValDesc->IndexField.Data,
&TempVal, sizeof (TempVal));
Status = AcpiAmlAccessNamedField (ACPI_READ, ValDesc->IndexField.Data,
&TempVal, sizeof (TempVal));
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
/* Create an object for the result */
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER);
if (!ObjDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
ObjDesc->Number.Value = TempVal;
ObjDesc->Integer.Value = TempVal;
break;
@ -634,21 +560,22 @@ AcpiAmlResolveEntryToValue (
if (AttachedAmlPointer)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Internal error - FieldUnit cannot be an AcpiAml ptr\n"));
("AmlResolveEntryToValue: FieldUnit cannot be an Aml ptr\n"));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
if (ValDesc->Common.Type != (UINT8) EntryType)
{
DEBUG_PRINT (ACPI_ERROR, (
"AmlResolveToValue/FieldUnit: Internal error - Name %4.4s type %d does not match value-type %d at %p\n",
&(((ACPI_NAMED_OBJECT*) (*StackPtr))->Name), EntryType,
ValDesc->Common.Type, ValDesc));
"AmlResolveToValue: Object type %X not same as EntryType %X\n",
ValDesc->Common.Type, EntryType));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
break;
}
/* Create object for result */
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY);
if (!ObjDesc)
{
@ -666,7 +593,7 @@ AcpiAmlResolveEntryToValue (
/*
* For these objects, just return the object attached to the NTE
* For these objects, just return the object attached to the Node
*/
case ACPI_TYPE_MUTEX:
@ -684,15 +611,70 @@ AcpiAmlResolveEntryToValue (
AcpiCmAddReference (ObjDesc);
break;
/* TYPE_Any is untyped, and thus there is no object associated with it */
case ACPI_TYPE_ANY:
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Untyped entry %p - has no Rvalue\n",
StackEntry));
("AmlResolveEntryToValue: Untyped entry %p, no attached object!\n",
Node));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
break;
/*
* The only named references allowed are named constants
*
* e.g. Name (\OSFL, Ones)
*/
case INTERNAL_TYPE_REFERENCE:
switch (ValDesc->Reference.Opcode)
{
case AML_ZERO_OP:
TempVal = 0;
break;
case AML_ONE_OP:
TempVal = 1;
break;
case AML_ONES_OP:
TempVal = ACPI_INTEGER_MAX;
break;
default:
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveToValue/Number: Unsupported reference opcode %X\n",
ValDesc->Reference.Opcode));
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
}
/* Create object for result */
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER);
if (!ObjDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
ObjDesc->Integer.Value = TempVal;
/* Truncate value if we are executing from a 32-bit ACPI table */
AcpiAmlTruncateFor32bitTable (ObjDesc, WalkState);
break;
/* Default case is for unknown types */
@ -700,8 +682,8 @@ AcpiAmlResolveEntryToValue (
default:
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Entry %p - Unknown object type %d\n",
StackEntry, EntryType));
("AmlResolveEntryToValue: Node %p - Unknown object type %X\n",
Node, EntryType));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);

View File

@ -1,8 +1,8 @@
/******************************************************************************
*
* Module Name: exresolv - AML Interpreter object resolution
* $Revision: 1.114 $
* Module Name: amresolv - AML Interpreter object resolution
* $Revision: 1.88 $
*
*****************************************************************************/
@ -10,7 +10,7 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
@ -115,21 +115,151 @@
*
*****************************************************************************/
#define __EXRESOLV_C__
#define __AMRESOLV_C__
#include "acpi.h"
#include "amlcode.h"
#include "acparser.h"
#include "acdispat.h"
#include "acinterp.h"
#include "acnamesp.h"
#include "actables.h"
#include "acevents.h"
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exresolv")
MODULE_NAME ("amresolv")
/*******************************************************************************
*
* FUNCTION: AcpiExResolveToValue
* FUNCTION: AcpiAmlGetFieldUnitValue
*
* PARAMETERS: *FieldDesc - Pointer to a FieldUnit
* *ResultDesc - Pointer to an empty descriptor which will
* become an Integer with the field's value
*
* RETURN: Status
*
* DESCRIPTION: Retrieve the value from a FieldUnit
*
******************************************************************************/
ACPI_STATUS
AcpiAmlGetFieldUnitValue (
ACPI_OPERAND_OBJECT *FieldDesc,
ACPI_OPERAND_OBJECT *ResultDesc)
{
ACPI_STATUS Status;
UINT32 Mask;
UINT8 *Location;
BOOLEAN Locked;
FUNCTION_TRACE ("AmlGetFieldUnitValue");
/*
* Parameter validation
*/
if (!FieldDesc)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlGetFieldUnitValue: Internal error - null field pointer\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
if (!(FieldDesc->Common.Flags & AOPOBJ_DATA_VALID))
{
Status = AcpiDsGetFieldUnitArguments (FieldDesc);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
if (!FieldDesc->FieldUnit.ContainerObj)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlGetFieldUnitValue: Internal error - null container pointer\n"));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
if (ACPI_TYPE_BUFFER != FieldDesc->FieldUnit.ContainerObj->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlGetFieldUnitValue: Internal error - container is not a Buffer\n"));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
if (!ResultDesc)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlGetFieldUnitValue: Internal error - null result pointer\n"));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
/* Get the global lock if needed */
Locked = AcpiAmlAcquireGlobalLock (FieldDesc->FieldUnit.LockRule);
/* Field location is (base of buffer) + (byte offset) */
Location = FieldDesc->FieldUnit.ContainerObj->Buffer.Pointer
+ FieldDesc->FieldUnit.Offset;
/*
* Construct Mask with as many 1 bits as the field width
*
* NOTE: Only the bottom 5 bits are valid for a shift operation, so
* special care must be taken for any shift greater than 31 bits.
*
* TBD: [Unhandled] Fields greater than 32 bits will not work.
*/
if (FieldDesc->FieldUnit.Length < 32)
{
Mask = ((UINT32) 1 << FieldDesc->FieldUnit.Length) - (UINT32) 1;
}
else
{
Mask = ACPI_UINT32_MAX;
}
ResultDesc->Integer.Type = (UINT8) ACPI_TYPE_INTEGER;
/* Get the 32 bit value at the location */
MOVE_UNALIGNED32_TO_32 (&ResultDesc->Integer.Value, Location);
/*
* Shift the 32-bit word containing the field, and mask off the
* resulting value
*/
ResultDesc->Integer.Value =
(ResultDesc->Integer.Value >> FieldDesc->FieldUnit.BitOffset) & Mask;
DEBUG_PRINT (ACPI_INFO,
("** Read from buffer %p byte %ld bit %d width %d addr %p mask %08lx val %08lx\n",
FieldDesc->FieldUnit.ContainerObj->Buffer.Pointer,
FieldDesc->FieldUnit.Offset,
FieldDesc->FieldUnit.BitOffset,
FieldDesc->FieldUnit.Length,
Location, Mask, ResultDesc->Integer.Value));
/* Release global lock if we acquired it earlier */
AcpiAmlReleaseGlobalLock (Locked);
return_ACPI_STATUS (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlResolveToValue
*
* PARAMETERS: **StackPtr - Points to entry on ObjStack, which can
* be either an (ACPI_OPERAND_OBJECT *)
@ -143,30 +273,33 @@
******************************************************************************/
ACPI_STATUS
AcpiExResolveToValue (
AcpiAmlResolveToValue (
ACPI_OPERAND_OBJECT **StackPtr,
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE_PTR ("ExResolveToValue", StackPtr);
FUNCTION_TRACE_PTR ("AmlResolveToValue", StackPtr);
if (!StackPtr || !*StackPtr)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n"));
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveToValue: Internal error - null pointer\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
/*
* The entity pointed to by the StackPtr can be either
* 1) A valid ACPI_OPERAND_OBJECT, or
* 2) A ACPI_NAMESPACE_NODE (NamedObj)
*/
if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND)
if (VALID_DESCRIPTOR_TYPE (*StackPtr, ACPI_DESC_TYPE_INTERNAL))
{
Status = AcpiExResolveObjectToValue (StackPtr, WalkState);
Status = AcpiAmlResolveObjectToValue (StackPtr, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
@ -174,13 +307,13 @@ AcpiExResolveToValue (
}
/*
* Object on the stack may have changed if AcpiExResolveObjectToValue()
* Object on the stack may have changed if AcpiAmlResolveObjectToValue()
* was called (i.e., we can't use an _else_ here.)
*/
if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED)
if (VALID_DESCRIPTOR_TYPE (*StackPtr, ACPI_DESC_TYPE_NAMED))
{
Status = AcpiExResolveNodeToValue (
ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr),
Status = AcpiAmlResolveNodeToValue ((ACPI_NAMESPACE_NODE **) StackPtr,
WalkState);
if (ACPI_FAILURE (Status))
{
@ -188,14 +321,17 @@ AcpiExResolveToValue (
}
}
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr));
DEBUG_PRINT (ACPI_INFO,
("AmlResolveToValue: Returning resolved object %p\n", *StackPtr));
return_ACPI_STATUS (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiExResolveObjectToValue
* FUNCTION: AcpiAmlResolveObjectToValue
*
* PARAMETERS: StackPtr - Pointer to a stack location that contains a
* ptr to an internal object.
@ -209,7 +345,7 @@ AcpiExResolveToValue (
******************************************************************************/
ACPI_STATUS
AcpiExResolveObjectToValue (
AcpiAmlResolveObjectToValue (
ACPI_OPERAND_OBJECT **StackPtr,
ACPI_WALK_STATE *WalkState)
{
@ -220,32 +356,35 @@ AcpiExResolveObjectToValue (
UINT16 Opcode;
ACPI_FUNCTION_TRACE ("ExResolveObjectToValue");
FUNCTION_TRACE ("AmlResolveObjectToValue");
StackDesc = *StackPtr;
/* This is an ACPI_OPERAND_OBJECT */
switch (ACPI_GET_OBJECT_TYPE (StackDesc))
switch (StackDesc->Common.Type)
{
case INTERNAL_TYPE_REFERENCE:
Opcode = StackDesc->Reference.Opcode;
switch (Opcode)
{
case AML_NAME_OP:
/*
* Convert indirect name ptr to a direct name ptr.
* Then, AcpiExResolveNodeToValue can be used to get the value
* Then, AcpiAmlResolveNodeToValue can be used to get the value
*/
TempNode = StackDesc->Reference.Object;
/* Delete the Reference Object */
AcpiUtRemoveReference (StackDesc);
AcpiCmRemoveReference (StackDesc);
/* Put direct name pointer onto stack and exit */
@ -260,7 +399,8 @@ AcpiExResolveObjectToValue (
* Get the local from the method's state info
* Note: this increments the local's object reference count
*/
Status = AcpiDsMethodDataGetValue (Opcode,
Status = AcpiDsMethodDataGetValue (Opcode,
StackDesc->Reference.Offset, WalkState, &ObjDesc);
if (ACPI_FAILURE (Status))
{
@ -271,14 +411,46 @@ AcpiExResolveObjectToValue (
* Now we can delete the original Reference Object and
* replace it with the resolve value
*/
AcpiUtRemoveReference (StackDesc);
AcpiCmRemoveReference (StackDesc);
*StackPtr = ObjDesc;
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %d] ValueObj is %p\n",
DEBUG_PRINT (ACPI_INFO,
("AmlResolveObjectToValue: [Arg/Local %d] ValueObj is %p\n",
StackDesc->Reference.Offset, ObjDesc));
break;
/*
* TBD: [Restructure] These next three opcodes change the type of
* the object, which is actually a no-no.
*/
case AML_ZERO_OP:
StackDesc->Common.Type = (UINT8) ACPI_TYPE_INTEGER;
StackDesc->Integer.Value = 0;
break;
case AML_ONE_OP:
StackDesc->Common.Type = (UINT8) ACPI_TYPE_INTEGER;
StackDesc->Integer.Value = 1;
break;
case AML_ONES_OP:
StackDesc->Common.Type = (UINT8) ACPI_TYPE_INTEGER;
StackDesc->Integer.Value = ACPI_INTEGER_MAX;
/* Truncate value if we are executing from a 32-bit ACPI table */
AcpiAmlTruncateFor32bitTable (StackDesc, WalkState);
break;
case AML_INDEX_OP:
switch (StackDesc->Reference.TargetType)
@ -290,7 +462,6 @@ AcpiExResolveObjectToValue (
case ACPI_TYPE_PACKAGE:
ObjDesc = *StackDesc->Reference.Where;
if (ObjDesc)
{
@ -299,34 +470,34 @@ AcpiExResolveObjectToValue (
* (i.e., dereference the package index)
* Delete the ref object, increment the returned object
*/
AcpiUtRemoveReference (StackDesc);
AcpiUtAddReference (ObjDesc);
AcpiCmRemoveReference (StackDesc);
AcpiCmAddReference (ObjDesc);
*StackPtr = ObjDesc;
}
else
{
/*
* A NULL object descriptor means an unitialized element of
* the package, can't dereference it
*/
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Attempt to deref an Index to NULL pkg element Idx=%p\n",
StackDesc));
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveObjectToValue: Attempt to deref an Index to NULL pkg element Idx=%p\n", StackDesc));
Status = AE_AML_UNINITIALIZED_ELEMENT;
}
break;
default:
/* Invalid reference object */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unknown TargetType %X in Index/Reference obj %p\n",
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveObjectToValue: Unknown TargetType %X in Index/Reference obj %p\n",
StackDesc->Reference.TargetType, StackDesc));
Status = AE_AML_INTERNAL;
break;
}
break;
@ -338,44 +509,63 @@ AcpiExResolveObjectToValue (
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference opcode %X in %p\n",
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveObjectToValue: Unknown Reference object subtype %02X in %p\n",
Opcode, StackDesc));
Status = AE_AML_INTERNAL;
break;
} /* switch (Opcode) */
break; /* case INTERNAL_TYPE_REFERENCE */
case ACPI_TYPE_FIELD_UNIT:
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY);
if (!ObjDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
break;
Status = AcpiAmlGetFieldUnitValue (StackDesc, ObjDesc);
if (ACPI_FAILURE (Status))
{
AcpiCmRemoveReference (ObjDesc);
ObjDesc = NULL;
}
case ACPI_TYPE_BUFFER:
Status = AcpiDsGetBufferArguments (StackDesc);
break;
case ACPI_TYPE_PACKAGE:
Status = AcpiDsGetPackageArguments (StackDesc);
break;
/*
* These cases may never happen here, but just in case..
*/
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, "FieldRead SourceDesc=%p Type=%X\n",
StackDesc, ACPI_GET_OBJECT_TYPE (StackDesc)));
Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc);
*StackPtr = (void *) ObjDesc;
break;
default:
case INTERNAL_TYPE_BANK_FIELD:
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY);
if (!ObjDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
Status = AcpiAmlGetFieldUnitValue (StackDesc, ObjDesc);
if (ACPI_FAILURE (Status))
{
AcpiCmRemoveReference (ObjDesc);
ObjDesc = NULL;
}
*StackPtr = (void *) ObjDesc;
break;
}
/* TBD: [Future] - may need to handle IndexField, and DefField someday */
default:
break;
} /* switch (StackDesc->Common.Type) */
return_ACPI_STATUS (Status);
}

View File

@ -1,8 +1,8 @@
/******************************************************************************
*
* Module Name: exresop - AML Interpreter operand/object resolution
* $Revision: 1.55 $
* Module Name: amresop - AML Interpreter operand/object resolution
* $Revision: 1.25 $
*
*****************************************************************************/
@ -10,7 +10,7 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
@ -115,22 +115,25 @@
*
*****************************************************************************/
#define __EXRESOP_C__
#define __AMRESOP_C__
#include "acpi.h"
#include "amlcode.h"
#include "acparser.h"
#include "acdispat.h"
#include "acinterp.h"
#include "acnamesp.h"
#include "actables.h"
#include "acevents.h"
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exresop")
MODULE_NAME ("amresop")
/*******************************************************************************
*
* FUNCTION: AcpiExCheckObjectType
* FUNCTION: AcpiAmlCheckObjectType
*
* PARAMETERS: TypeNeeded Object type needed
* ThisType Actual object type
@ -143,12 +146,11 @@
******************************************************************************/
ACPI_STATUS
AcpiExCheckObjectType (
AcpiAmlCheckObjectType (
ACPI_OBJECT_TYPE TypeNeeded,
ACPI_OBJECT_TYPE ThisType,
void *Object)
{
ACPI_FUNCTION_NAME ("ExCheckObjectType");
if (TypeNeeded == ACPI_TYPE_ANY)
@ -158,57 +160,43 @@ AcpiExCheckObjectType (
return (AE_OK);
}
if (TypeNeeded == INTERNAL_TYPE_REFERENCE)
{
/*
* Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference
* objects and thus allow them to be targets. (As per the ACPI
* specification, a store to a constant is a noop.)
*/
if ((ThisType == ACPI_TYPE_INTEGER) &&
(((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT))
{
return (AE_OK);
}
}
if (TypeNeeded != ThisType)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [%s], found [%s] %p\n",
AcpiUtGetTypeName (TypeNeeded),
AcpiUtGetTypeName (ThisType), Object));
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed [%s], found [%s] %p\n",
AcpiCmGetTypeName (TypeNeeded),
AcpiCmGetTypeName (ThisType), Object));
return (AE_AML_OPERAND_TYPE);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiExResolveOperands
* FUNCTION: AcpiAmlResolveOperands
*
* PARAMETERS: Opcode - Opcode being interpreted
* StackPtr - Pointer to the operand stack to be
* resolved
* WalkState - Current state
* PARAMETERS: Opcode Opcode being interpreted
* StackPtr Top of operand stack
*
* RETURN: Status
*
* DESCRIPTION: Convert multiple input operands to the types required by the
* target operator.
* DESCRIPTION: Convert stack entries to required types
*
* Each 5-bit group in ArgTypes represents one required
* operand and indicates the required Type. The corresponding operand
* will be converted to the required type if possible, otherwise we
* abort with an exception.
* Each nibble in ArgTypes represents one required operand
* and indicates the required Type:
*
* The corresponding stack entry will be converted to the
* required type if possible, else return an exception
*
******************************************************************************/
ACPI_STATUS
AcpiExResolveOperands (
AcpiAmlResolveOperands (
UINT16 Opcode,
ACPI_OPERAND_OBJECT **StackPtr,
ACPI_WALK_STATE *WalkState)
@ -218,45 +206,49 @@ AcpiExResolveOperands (
UINT8 ObjectType;
void *TempNode;
UINT32 ArgTypes;
const ACPI_OPCODE_INFO *OpInfo;
ACPI_OPCODE_INFO *OpInfo;
UINT32 ThisArgType;
ACPI_OBJECT_TYPE TypeNeeded;
ACPI_FUNCTION_TRACE_U32 ("ExResolveOperands", Opcode);
FUNCTION_TRACE_U32 ("AmlResolveOperands", Opcode);
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
if (OpInfo->Class == AML_CLASS_UNKNOWN)
if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE)
{
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
}
ArgTypes = OpInfo->RuntimeArgs;
if (ArgTypes == ARGI_INVALID_OPCODE)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - %X is not a valid AML opcode\n",
Opcode));
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveOperands: Internal error - %X is not a valid AML opcode\n", Opcode));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X [%s] OperandTypes=%X \n",
Opcode, OpInfo->Name, ArgTypes));
DEBUG_PRINT (TRACE_EXEC,
("AmlResolveOperands: Opcode %X OperandTypes=%X \n",
Opcode, ArgTypes));
/*
* Normal exit is with (ArgTypes == 0) at end of argument list.
/*
* Normal exit is with *Types == '\0' at end of string.
* Function will return an exception from within the loop upon
* finding an entry which is not (or cannot be converted
* to) the required type; if stack underflows; or upon
* finding a NULL stack entry (which should not happen).
* finding an entry which is not, and cannot be converted
* to, the required type; if stack underflows; or upon
* finding a NULL stack entry (which "should never happen").
*/
while (GET_CURRENT_ARG_TYPE (ArgTypes))
{
if (!StackPtr || !*StackPtr)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null stack entry at %p\n",
StackPtr));
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveOperands: Internal error - null stack entry at %X\n", StackPtr));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
@ -267,27 +259,25 @@ AcpiExResolveOperands (
/* Decode the descriptor type */
switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
{
case ACPI_DESC_TYPE_NAMED:
/* Node */
ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
break;
case ACPI_DESC_TYPE_OPERAND:
}
else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL))
{
/* ACPI internal object */
ObjectType = ACPI_GET_OBJECT_TYPE (ObjDesc);
ObjectType = ObjDesc->Common.Type;
/* Check for bad ACPI_OBJECT_TYPE */
if (!AcpiExValidateObjectType (ObjectType))
if (!AcpiAmlValidateObjectType (ObjectType))
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad operand object type [%X]\n",
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveOperands: Bad operand object type [%X]\n",
ObjectType));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
@ -298,43 +288,47 @@ AcpiExResolveOperands (
/*
* Decode the Reference
*/
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
if (OpInfo->Class == AML_CLASS_UNKNOWN)
if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE)
{
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
}
switch (ObjDesc->Reference.Opcode)
{
case AML_ZERO_OP:
case AML_ONE_OP:
case AML_ONES_OP:
case AML_DEBUG_OP:
case AML_NAME_OP:
case AML_INDEX_OP:
case AML_REF_OF_OP:
case AML_ARG_OP:
case AML_LOCAL_OP:
ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Reference Opcode: %s\n", OpInfo->Name)));
DEBUG_ONLY_MEMBERS (DEBUG_PRINT (ACPI_INFO,
("Reference Opcode: %s\n", OpInfo->Name)));
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unknown Reference Opcode %X\n",
DEBUG_PRINT (ACPI_INFO,
("Reference Opcode: Unknown [%02x]\n",
ObjDesc->Reference.Opcode));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
break;
}
}
break;
default:
}
else
{
/* Invalid descriptor */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Bad descriptor type %X in Obj %p\n",
ACPI_GET_DESCRIPTOR_TYPE (ObjDesc), ObjDesc));
DEBUG_PRINT (ACPI_ERROR,
("Bad descriptor type %X in Obj %p\n",
ObjDesc->Common.DataType, ObjDesc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@ -343,63 +337,56 @@ AcpiExResolveOperands (
/*
* Get one argument type, point to the next
*/
ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes);
INCREMENT_ARG_LIST (ArgTypes);
/*
* Handle cases where the object does not need to be
* resolved to a value
*/
switch (ThisArgType)
{
case ARGI_REF_OR_STRING: /* Can be a String or Reference */
if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) &&
(ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_STRING))
{
/*
* String found - the string references a named object and must be
* resolved to a node
*/
goto NextOperand;
}
/* Else not a string - fall through to the normal Reference case below */
/*lint -fallthrough */
case ARGI_REFERENCE: /* References: */
case ARGI_REFERENCE: /* References */
case ARGI_INTEGER_REF:
case ARGI_OBJECT_REF:
case ARGI_DEVICE_REF:
case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
case ARGI_TARGETREF: /* TBD: must implement implicit conversion rules before store */
case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
/* Need an operand of type INTERNAL_TYPE_REFERENCE */
if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) /* Node (name) ptr OK as-is */
if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) /* direct name ptr OK as-is */
{
goto NextOperand;
}
Status = AcpiExCheckObjectType (INTERNAL_TYPE_REFERENCE,
Status = AcpiAmlCheckObjectType (INTERNAL_TYPE_REFERENCE,
ObjectType, ObjDesc);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
if (AML_NAME_OP == ObjDesc->Reference.Opcode)
{
/*
* Convert an indirect name ptr to direct name ptr and put
* it on the stack
*/
TempNode = ObjDesc->Reference.Object;
AcpiUtRemoveReference (ObjDesc);
AcpiCmRemoveReference (ObjDesc);
(*StackPtr) = TempNode;
}
goto NextOperand;
break;
case ARGI_ANYTYPE:
@ -410,29 +397,28 @@ AcpiExResolveOperands (
* Instead, we just want to store the reference object.
* -- All others must be resolved below.
*/
if ((Opcode == AML_STORE_OP) &&
(ACPI_GET_OBJECT_TYPE (*StackPtr) == INTERNAL_TYPE_REFERENCE) &&
((*StackPtr)->Common.Type == INTERNAL_TYPE_REFERENCE) &&
((*StackPtr)->Reference.Opcode == AML_INDEX_OP))
{
goto NextOperand;
}
break;
default:
/* All cases covered above */
break;
}
/*
* Resolve this object to a value
*/
Status = AcpiExResolveToValue (StackPtr, WalkState);
Status = AcpiAmlResolveToValue (StackPtr, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/*
* Check the resulting object (value) type
*/
@ -488,27 +474,30 @@ AcpiExResolveOperands (
/*
* The more complex cases allow multiple resolved object types
*/
case ARGI_INTEGER: /* Number */
/*
* Need an operand of type ACPI_TYPE_INTEGER,
* But we can implicitly convert from a STRING or BUFFER
*/
Status = AcpiExConvertToInteger (*StackPtr, StackPtr, WalkState);
Status = AcpiAmlConvertToInteger (StackPtr, WalkState);
if (ACPI_FAILURE (Status))
{
if (Status == AE_TYPE)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiUtGetObjectTypeName (*StackPtr), *StackPtr));
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiCmGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
return_ACPI_STATUS (Status);
}
goto NextOperand;
break;
case ARGI_BUFFER:
@ -517,21 +506,23 @@ AcpiExResolveOperands (
* Need an operand of type ACPI_TYPE_BUFFER,
* But we can implicitly convert from a STRING or INTEGER
*/
Status = AcpiExConvertToBuffer (*StackPtr, StackPtr, WalkState);
Status = AcpiAmlConvertToBuffer (StackPtr, WalkState);
if (ACPI_FAILURE (Status))
{
if (Status == AE_TYPE)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiUtGetObjectTypeName (*StackPtr), *StackPtr));
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiCmGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
return_ACPI_STATUS (Status);
}
goto NextOperand;
break;
case ARGI_STRING:
@ -540,153 +531,126 @@ AcpiExResolveOperands (
* Need an operand of type ACPI_TYPE_STRING,
* But we can implicitly convert from a BUFFER or INTEGER
*/
Status = AcpiExConvertToString (*StackPtr, StackPtr, 16, ACPI_UINT32_MAX, WalkState);
Status = AcpiAmlConvertToString (StackPtr, WalkState);
if (ACPI_FAILURE (Status))
{
if (Status == AE_TYPE)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiUtGetObjectTypeName (*StackPtr), *StackPtr));
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiCmGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
return_ACPI_STATUS (Status);
}
goto NextOperand;
break;
case ARGI_COMPUTEDATA:
/* Need an operand of type INTEGER, STRING or BUFFER */
switch (ACPI_GET_OBJECT_TYPE (*StackPtr))
if ((ACPI_TYPE_INTEGER != (*StackPtr)->Common.Type) &&
(ACPI_TYPE_STRING != (*StackPtr)->Common.Type) &&
(ACPI_TYPE_BUFFER != (*StackPtr)->Common.Type))
{
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/* Valid operand */
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiUtGetObjectTypeName (*StackPtr), *StackPtr));
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiCmGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
goto NextOperand;
break;
case ARGI_DATAOBJECT:
/*
* ARGI_DATAOBJECT is only used by the SizeOf operator.
* Need a buffer, string, package, or Node reference.
*
* The only reference allowed here is a direct reference to
* a namespace node.
* The ACPI specification allows SizeOf to return the size of
* a Buffer, String or Package. However, the MS ACPI.SYS AML
* Interpreter also allows an Node reference to return without
* error with a size of 4.
*/
if (ACPI_GET_OBJECT_TYPE (*StackPtr) == INTERNAL_TYPE_REFERENCE)
/* Need a buffer, string, package or Node reference */
if (((*StackPtr)->Common.Type != ACPI_TYPE_BUFFER) &&
((*StackPtr)->Common.Type != ACPI_TYPE_STRING) &&
((*StackPtr)->Common.Type != ACPI_TYPE_PACKAGE) &&
((*StackPtr)->Common.Type != INTERNAL_TYPE_REFERENCE))
{
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed [Buf/Str/Pkg/Ref], found [%s] %p\n",
AcpiCmGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/*
* If this is a reference, only allow a reference to an Node.
*/
if ((*StackPtr)->Common.Type == INTERNAL_TYPE_REFERENCE)
{
if (!(*StackPtr)->Reference.Node)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Node Reference], found [%p]\n",
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed [Node Reference], found [%p]\n",
*StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/* Get the object attached to the node */
TempNode = AcpiNsGetAttachedObject ((*StackPtr)->Reference.Node);
if (!TempNode)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Node [%p] has no attached object\n",
(*StackPtr)->Reference.Node));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/*
* Swap the reference object with the node's object. Must add
* a reference to the node object, and remove a reference from
* the original reference object.
*/
AcpiUtAddReference (TempNode);
AcpiUtRemoveReference (*StackPtr);
(*StackPtr) = TempNode;
}
/* Need a buffer, string, package */
switch (ACPI_GET_OBJECT_TYPE (*StackPtr))
{
case ACPI_TYPE_PACKAGE:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/* Valid operand */
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Buf/Str/Pkg], found [%s] %p\n",
AcpiUtGetObjectTypeName (*StackPtr), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
goto NextOperand;
break;
case ARGI_COMPLEXOBJ:
/* Need a buffer or package or (ACPI 2.0) String */
/* Need a buffer or package */
switch (ACPI_GET_OBJECT_TYPE (*StackPtr))
if (((*StackPtr)->Common.Type != ACPI_TYPE_BUFFER) &&
((*StackPtr)->Common.Type != ACPI_TYPE_PACKAGE))
{
case ACPI_TYPE_PACKAGE:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/* Valid operand */
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Buf/Str/Pkg], found [%s] %p\n",
AcpiUtGetObjectTypeName (*StackPtr), *StackPtr));
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed [Buf/Pkg], found [%s] %p\n",
AcpiCmGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
goto NextOperand;
break;
default:
/* Unknown type */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Internal - Unknown ARGI type %X\n",
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveOperands: Internal error - Unknown ARGI type %X\n",
ThisArgType));
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
/*
* Make sure that the original object was resolved to the
* required object type (Simple cases only).
*/
Status = AcpiExCheckObjectType (TypeNeeded,
ACPI_GET_OBJECT_TYPE (*StackPtr), *StackPtr);
Status = AcpiAmlCheckObjectType (TypeNeeded,
(*StackPtr)->Common.Type, *StackPtr);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
NextOperand:
/*
* If more operands needed, decrement StackPtr to point
@ -699,6 +663,7 @@ NextOperand:
} /* while (*Types) */
return_ACPI_STATUS (Status);
}

View File

@ -1,8 +1,8 @@
/******************************************************************************
*
* Module Name: exstore - AML Interpreter object store support
* $Revision: 1.169 $
* Module Name: amstore - AML Interpreter object store support
* $Revision: 1.130 $
*
*****************************************************************************/
@ -10,7 +10,7 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
@ -115,42 +115,43 @@
*
*****************************************************************************/
#define __EXSTORE_C__
#define __AMSTORE_C__
#include "acpi.h"
#include "acparser.h"
#include "acdispat.h"
#include "acinterp.h"
#include "amlcode.h"
#include "acnamesp.h"
#include "actables.h"
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exstore")
MODULE_NAME ("amstore")
/*******************************************************************************
*
* FUNCTION: AcpiExStore
* FUNCTION: AcpiAmlExecStore
*
* PARAMETERS: *SourceDesc - Value to be stored
* PARAMETERS: *ValDesc - Value to be stored
* *DestDesc - Where to store it. Must be an NS node
* or an ACPI_OPERAND_OBJECT of type
* Reference;
* WalkState - Current walk state
* Reference; if the latter the descriptor
* will be either reused or deleted.
*
* RETURN: Status
*
* DESCRIPTION: Store the value described by SourceDesc into the location
* DESCRIPTION: Store the value described by ValDesc into the location
* described by DestDesc. Called by various interpreter
* functions to store the result of an operation into
* the destination operand -- not just simply the actual "Store"
* ASL operator.
* the destination operand.
*
******************************************************************************/
ACPI_STATUS
AcpiExStore (
ACPI_OPERAND_OBJECT *SourceDesc,
AcpiAmlExecStore (
ACPI_OPERAND_OBJECT *ValDesc,
ACPI_OPERAND_OBJECT *DestDesc,
ACPI_WALK_STATE *WalkState)
{
@ -158,64 +159,53 @@ AcpiExStore (
ACPI_OPERAND_OBJECT *RefDesc = DestDesc;
ACPI_FUNCTION_TRACE_PTR ("ExStore", DestDesc);
FUNCTION_TRACE_PTR ("AmlExecStore", DestDesc);
/* Validate parameters */
if (!SourceDesc || !DestDesc)
if (!ValDesc || !DestDesc)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null parameter\n"));
DEBUG_PRINT (ACPI_ERROR,
("AmlExecStore: Internal error - null pointer\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
/* DestDesc can be either a namespace node or an ACPI object */
if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED)
if (VALID_DESCRIPTOR_TYPE (DestDesc, ACPI_DESC_TYPE_NAMED))
{
/*
* Dest is a namespace node,
* Storing an object into a Name "container"
*/
Status = AcpiExStoreObjectToNode (SourceDesc,
Status = AcpiAmlStoreObjectToNode (ValDesc,
(ACPI_NAMESPACE_NODE *) DestDesc, WalkState);
/* All done, that's it */
return_ACPI_STATUS (Status);
}
/* Destination object must be a Reference or a Constant object */
switch (ACPI_GET_OBJECT_TYPE (DestDesc))
/* Destination object must be an object of type Reference */
if (DestDesc->Common.Type != INTERNAL_TYPE_REFERENCE)
{
case INTERNAL_TYPE_REFERENCE:
break;
case ACPI_TYPE_INTEGER:
/* Allow stores to Constants -- a Noop as per ACPI spec */
if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT)
{
return_ACPI_STATUS (AE_OK);
}
/*lint: -fallthrough */
default:
/* Destination is not an Reference */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Destination is not a Reference or Constant object [%p]\n", DestDesc));
DEBUG_PRINT (ACPI_ERROR,
("AmlExecStore: Destination is not a ReferenceObj [%p]\n", DestDesc));
ACPI_DUMP_STACK_ENTRY (SourceDesc);
ACPI_DUMP_STACK_ENTRY (DestDesc);
ACPI_DUMP_OPERANDS (&DestDesc, ACPI_IMODE_EXECUTE, "ExStore",
2, "Target is not a Reference or Constant object");
DUMP_STACK_ENTRY (ValDesc);
DUMP_STACK_ENTRY (DestDesc);
DUMP_OPERANDS (&DestDesc, IMODE_EXECUTE, "AmlExecStore",
2, "Target is not a ReferenceObj");
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/*
* Examine the Reference opcode. These cases are handled:
*
@ -223,15 +213,17 @@ AcpiExStore (
* 2) Store to an indexed area of a Buffer or Package
* 3) Store to a Method Local or Arg
* 4) Store to the debug object
* 5) Store to a constant -- a noop
*/
switch (RefDesc->Reference.Opcode)
{
case AML_NAME_OP:
case AML_REF_OF_OP:
/* Storing an object into a Name "container" */
Status = AcpiExStoreObjectToNode (SourceDesc, RefDesc->Reference.Object,
Status = AcpiAmlStoreObjectToNode (ValDesc, RefDesc->Reference.Object,
WalkState);
break;
@ -240,7 +232,7 @@ AcpiExStore (
/* Storing to an Index (pointer into a packager or buffer) */
Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState);
Status = AcpiAmlStoreObjectToIndex (ValDesc, RefDesc, WalkState);
break;
@ -250,7 +242,7 @@ AcpiExStore (
/* Store to a method local/arg */
Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Opcode,
RefDesc->Reference.Offset, SourceDesc, WalkState);
RefDesc->Reference.Offset, ValDesc, WalkState);
break;
@ -259,61 +251,55 @@ AcpiExStore (
/*
* Storing to the Debug object causes the value stored to be
* displayed and otherwise has no effect -- see ACPI Specification
*
* TBD: print known object types "prettier".
*/
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Write to Debug Object: ****:\n\n"));
DEBUG_PRINT (ACPI_INFO, ("**** Write to Debug Object: ****: \n"));
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %s: ",
AcpiUtGetObjectTypeName (SourceDesc)));
switch (ACPI_GET_OBJECT_TYPE (SourceDesc))
if (ValDesc->Common.Type == ACPI_TYPE_STRING)
{
case ACPI_TYPE_INTEGER:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%8.8X%8.8X\n",
ACPI_HIWORD (SourceDesc->Integer.Value),
ACPI_LOWORD (SourceDesc->Integer.Value)));
break;
case ACPI_TYPE_BUFFER:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length %.2X\n",
(UINT32) SourceDesc->Buffer.Length));
break;
case ACPI_TYPE_STRING:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s\n", SourceDesc->String.Pointer));
break;
case ACPI_TYPE_PACKAGE:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements Ptr - %p\n",
SourceDesc->Package.Elements));
break;
default:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Type %s %p\n",
AcpiUtGetObjectTypeName (SourceDesc), SourceDesc));
break;
DEBUG_PRINT (ACPI_INFO, ("%s\n", ValDesc->String.Pointer));
}
else
{
DUMP_STACK_ENTRY (ValDesc);
}
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
break;
case AML_ZERO_OP:
case AML_ONE_OP:
case AML_ONES_OP:
/*
* Storing to a constant is a no-op -- see ACPI Specification
* Delete the reference descriptor, however
*/
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference opcode %X\n",
DEBUG_PRINT (ACPI_ERROR,
("AmlExecStore: Internal error - Unknown Reference subtype %02x\n",
RefDesc->Reference.Opcode));
ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_ERROR);
/* TBD: [Restructure] use object dump routine !! */
DUMP_BUFFER (RefDesc, sizeof (ACPI_OPERAND_OBJECT));
Status = AE_AML_INTERNAL;
break;
} /* switch (RefDesc->Reference.Opcode) */
/* Always delete the reference descriptor object */
if (RefDesc)
{
AcpiCmRemoveReference (RefDesc);
}
return_ACPI_STATUS (Status);
@ -322,38 +308,39 @@ AcpiExStore (
/*******************************************************************************
*
* FUNCTION: AcpiExStoreObjectToIndex
* FUNCTION: AcpiAmlStoreObjectToIndex
*
* PARAMETERS: *SourceDesc - Value to be stored
* *DestDesc - Named object to receive the value
* WalkState - Current walk state
* PARAMETERS: *ValDesc - Value to be stored
* *Node - Named object to receive the value
*
* RETURN: Status
*
* DESCRIPTION: Store the object to indexed Buffer or Package element
* DESCRIPTION: Store the object to the named object.
*
******************************************************************************/
ACPI_STATUS
AcpiExStoreObjectToIndex (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OPERAND_OBJECT *IndexDesc,
AcpiAmlStoreObjectToIndex (
ACPI_OPERAND_OBJECT *ValDesc,
ACPI_OPERAND_OBJECT *DestDesc,
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status = AE_OK;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_OPERAND_OBJECT *NewDesc;
UINT32 Length;
UINT32 i;
UINT8 Value = 0;
ACPI_FUNCTION_TRACE ("ExStoreObjectToIndex");
FUNCTION_TRACE ("AcpiAmlStoreObjectToIndex");
/*
* Destination must be a reference pointer, and
* must point to either a buffer or a package
*/
switch (IndexDesc->Reference.TargetType)
switch (DestDesc->Reference.TargetType)
{
case ACPI_TYPE_PACKAGE:
/*
@ -362,51 +349,110 @@ AcpiExStoreObjectToIndex (
* source is copied into the destination - we can't just point to the
* source object.
*/
/*
* The object at *(IndexDesc->Reference.Where) is the
* element within the package that is to be modified.
*/
ObjDesc = *(IndexDesc->Reference.Where);
/* Do the conversion/store */
Status = AcpiExStoreObjectToObject (SourceDesc, ObjDesc, &NewDesc,
WalkState);
if (ACPI_FAILURE (Status))
if (DestDesc->Reference.TargetType == ACPI_TYPE_PACKAGE)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Could not store object to indexed package element\n"));
return_ACPI_STATUS (Status);
}
/*
* The object at *(DestDesc->Reference.Where) is the
* element within the package that is to be modified.
*/
ObjDesc = *(DestDesc->Reference.Where);
if (ObjDesc)
{
/*
* If the Destination element is a package, we will delete
* that object and construct a new one.
*
* TBD: [Investigate] Should both the src and dest be required
* to be packages?
* && (ValDesc->Common.Type == ACPI_TYPE_PACKAGE)
*/
if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
{
/*
* Take away the reference for being part of a package and
* delete
*/
AcpiCmRemoveReference (ObjDesc);
AcpiCmRemoveReference (ObjDesc);
/*
* If a new object was created, we must install it as the new
* package element
*/
if (NewDesc != ObjDesc)
{
AcpiUtRemoveReference (ObjDesc);
*(IndexDesc->Reference.Where) = NewDesc;
ObjDesc = NULL;
}
}
if (!ObjDesc)
{
/*
* If the ObjDesc is NULL, it means that an uninitialized package
* element has been used as a destination (this is OK), therefore,
* we must create the destination element to match the type of the
* source element NOTE: ValDesc can be of any type.
*/
ObjDesc = AcpiCmCreateInternalObject (ValDesc->Common.Type);
if (!ObjDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
/*
* If the source is a package, copy the source to the new dest
*/
if (ACPI_TYPE_PACKAGE == ObjDesc->Common.Type)
{
Status = AcpiCmCopyIpackageToIpackage (ValDesc, ObjDesc, WalkState);
if (ACPI_FAILURE (Status))
{
AcpiCmRemoveReference (ObjDesc);
return_ACPI_STATUS (Status);
}
}
/*
* Install the new descriptor into the package and add a
* reference to the newly created descriptor for now being
* part of the parent package
*/
*(DestDesc->Reference.Where) = ObjDesc;
AcpiCmAddReference (ObjDesc);
}
if (ACPI_TYPE_PACKAGE != ObjDesc->Common.Type)
{
/*
* The destination element is not a package, so we need to
* convert the contents of the source (ValDesc) and copy into
* the destination (ObjDesc)
*/
Status = AcpiAmlStoreObjectToObject (ValDesc, ObjDesc,
WalkState);
if (ACPI_FAILURE (Status))
{
/*
* An error occurrered when copying the internal object
* so delete the reference.
*/
DEBUG_PRINT (ACPI_ERROR,
("AmlExecStore/Index: Unable to copy the internal object\n"));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
}
}
break;
case ACPI_TYPE_BUFFER_FIELD:
/*
* Store into a Buffer (not actually a real BufferField) at a
* location defined by an Index.
* Storing into a buffer at a location defined by an Index.
*
* The first 8-bit element of the source object is written to the
* 8-bit Buffer location defined by the Index destination object,
* according to the ACPI 2.0 specification.
* Each 8-bit element of the source object is written to the
* 8-bit Buffer Field of the Index destination object.
*/
/*
* Make sure the target is a Buffer
* Set the ObjDesc to the destination object and type check.
*/
ObjDesc = IndexDesc->Reference.Object;
if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_BUFFER)
ObjDesc = DestDesc->Reference.Object;
if (ObjDesc->Common.Type != ACPI_TYPE_BUFFER)
{
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@ -415,66 +461,87 @@ AcpiExStoreObjectToIndex (
* The assignment of the individual elements will be slightly
* different for each source type.
*/
switch (ACPI_GET_OBJECT_TYPE (SourceDesc))
switch (ValDesc->Common.Type)
{
/*
* If the type is Integer, assign bytewise
* This loop to assign each of the elements is somewhat
* backward because of the Big Endian-ness of IA-64
*/
case ACPI_TYPE_INTEGER:
/* Use the least-significant byte of the integer */
Value = (UINT8) (SourceDesc->Integer.Value);
Length = sizeof (ACPI_INTEGER);
for (i = Length; i != 0; i--)
{
Value = (UINT8)(ValDesc->Integer.Value >> (MUL_8 (i - 1)));
ObjDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value;
}
break;
/*
* If the type is Buffer, the Length is in the structure.
* Just loop through the elements and assign each one in turn.
*/
case ACPI_TYPE_BUFFER:
Value = SourceDesc->Buffer.Pointer[0];
Length = ValDesc->Buffer.Length;
for (i = 0; i < Length; i++)
{
Value = *(ValDesc->Buffer.Pointer + i);
ObjDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value;
}
break;
/*
* If the type is String, the Length is in the structure.
* Just loop through the elements and assign each one in turn.
*/
case ACPI_TYPE_STRING:
Value = (UINT8) SourceDesc->String.Pointer[0];
Length = ValDesc->String.Length;
for (i = 0; i < Length; i++)
{
Value = *(ValDesc->String.Pointer + i);
ObjDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value;
}
break;
/*
* If source is not a valid type so return an error.
*/
default:
/* All other types are invalid */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Source must be Integer/Buffer/String type, not %s\n",
AcpiUtGetObjectTypeName (SourceDesc)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
DEBUG_PRINT (ACPI_ERROR,
("AmlExecStore/Index: Source must be Number/Buffer/String type, not %X\n",
ValDesc->Common.Type));
Status = AE_AML_OPERAND_TYPE;
break;
}
/* Store the source value into the target buffer byte */
ObjDesc->Buffer.Pointer[IndexDesc->Reference.Offset] = Value;
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Target is not a Package or BufferField\n"));
DEBUG_PRINT (ACPI_ERROR,
("AmlExecStoreIndex: Target is not a Package or BufferField\n"));
Status = AE_AML_OPERAND_TYPE;
break;
}
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiExStoreObjectToNode
* FUNCTION: AcpiAmlStoreObjectToNode
*
* PARAMETERS: SourceDesc - Value to be stored
* Node - Named object to receive the value
* WalkState - Current walk state
* PARAMETERS: *SourceDesc - Value to be stored
* *Node - Named object to receive the value
*
* RETURN: Status
*
* DESCRIPTION: Store the object to the named object.
*
* The Assignment of an object to a named object is handled here
* The value passed in will replace the current value (if any)
* The val passed in will replace the current value (if any)
* with the input value.
*
* When storing into an object the data is converted to the
@ -482,23 +549,30 @@ AcpiExStoreObjectToIndex (
* that the target object type (for an initialized target) will
* not be changed by a store operation.
*
* Assumes parameters are already validated.
* NOTE: the global lock is acquired early. This will result
* in the global lock being held a bit longer. Also, if the
* function fails during set up we may get the lock when we
* don't really need it. I don't think we care.
*
******************************************************************************/
ACPI_STATUS
AcpiExStoreObjectToNode (
AcpiAmlStoreObjectToNode (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_NAMESPACE_NODE *Node,
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status = AE_OK;
ACPI_OPERAND_OBJECT *TargetDesc;
ACPI_OPERAND_OBJECT *NewDesc;
ACPI_OBJECT_TYPE TargetType;
OBJECT_TYPE_INTERNAL TargetType = ACPI_TYPE_ANY;
ACPI_FUNCTION_TRACE_PTR ("ExStoreObjectToNode", SourceDesc);
FUNCTION_TRACE ("AmlStoreObjectToNode");
/*
* Assuming the parameters were already validated
*/
ACPI_ASSERT((Node) && (SourceDesc));
/*
@ -507,40 +581,41 @@ AcpiExStoreObjectToNode (
TargetType = AcpiNsGetType (Node);
TargetDesc = AcpiNsGetAttachedObject (Node);
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
SourceDesc, AcpiUtGetObjectTypeName (SourceDesc),
Node, AcpiUtGetTypeName (TargetType)));
DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToNode: Storing %p(%s) into node %p(%s)\n",
Node, AcpiCmGetTypeName (SourceDesc->Common.Type),
SourceDesc, AcpiCmGetTypeName (TargetType)));
/*
* Resolve the source object to an actual value
* (If it is a reference object)
*/
Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState);
Status = AcpiAmlResolveObject (&SourceDesc, TargetType, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/*
* Do the actual store operation
*/
switch (TargetType)
{
case ACPI_TYPE_BUFFER_FIELD:
case INTERNAL_TYPE_REGION_FIELD:
case INTERNAL_TYPE_BANK_FIELD:
case INTERNAL_TYPE_INDEX_FIELD:
case INTERNAL_TYPE_DEF_FIELD:
/*
* For fields, copy the source data to the target field.
*/
Status = AcpiExWriteDataToField (SourceDesc, TargetDesc);
/* Raw data copy for target types Integer/String/Buffer */
Status = AcpiAmlCopyDataToNamedField (SourceDesc, Node);
break;
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
case INTERNAL_TYPE_BANK_FIELD:
case INTERNAL_TYPE_INDEX_FIELD:
case ACPI_TYPE_FIELD_UNIT:
/*
* These target types are all of type Integer/String/Buffer, and
@ -548,42 +623,128 @@ AcpiExStoreObjectToNode (
*
* Copy and/or convert the source object to a new target object
*/
Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, &NewDesc, WalkState);
Status = AcpiAmlStoreObject (SourceDesc, TargetType, &TargetDesc, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
if (NewDesc != TargetDesc)
{
/*
* Store the new NewDesc as the new value of the Name, and set
* the Name's type to that of the value being stored in it.
* SourceDesc reference count is incremented by AttachObject.
*/
Status = AcpiNsAttachObject (Node, NewDesc, TargetType);
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Store %s into %s via Convert/Attach\n",
AcpiUtGetObjectTypeName (SourceDesc),
AcpiUtGetObjectTypeName (NewDesc)));
}
/*
* Store the new TargetDesc as the new value of the Name, and set
* the Name's type to that of the value being stored in it.
* SourceDesc reference count is incremented by AttachObject.
*/
Status = AcpiNsAttachObject (Node, TargetDesc, TargetType);
DEBUG_PRINT (ACPI_INFO,
("AmlStoreObjectToNode: Store %s into %s via Convert/Attach\n",
AcpiCmGetTypeName (TargetDesc->Common.Type),
AcpiCmGetTypeName (TargetType)));
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Storing %s (%p) directly into node (%p), no implicit conversion\n",
AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node));
/* No conversions for all other types. Just attach the source object */
Status = AcpiNsAttachObject (Node, SourceDesc, ACPI_GET_OBJECT_TYPE (SourceDesc));
Status = AcpiNsAttachObject (Node, SourceDesc, SourceDesc->Common.Type);
DEBUG_PRINT (ACPI_INFO,
("AmlStoreObjectToNode: Store %s into %s via Attach only\n",
AcpiCmGetTypeName (SourceDesc->Common.Type),
AcpiCmGetTypeName (SourceDesc->Common.Type)));
break;
}
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlStoreObjectToObject
*
* PARAMETERS: *SourceDesc - Value to be stored
* *DestDesc - Object to receive the value
*
* RETURN: Status
*
* DESCRIPTION: Store an object to another object.
*
* The Assignment of an object to another (not named) object
* is handled here.
* The val passed in will replace the current value (if any)
* with the input value.
*
* When storing into an object the data is converted to the
* target object type then stored in the object. This means
* that the target object type (for an initialized target) will
* not be changed by a store operation.
*
* This module allows destination types of Number, String,
* and Buffer.
*
******************************************************************************/
ACPI_STATUS
AcpiAmlStoreObjectToObject (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OPERAND_OBJECT *DestDesc,
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status = AE_OK;
OBJECT_TYPE_INTERNAL DestinationType = DestDesc->Common.Type;
FUNCTION_TRACE ("AmlStoreObjectToObject");
/*
* Assuming the parameters are valid!
*/
ACPI_ASSERT((DestDesc) && (SourceDesc));
DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToObject: Storing %p(%s) to %p(%s)\n",
SourceDesc, AcpiCmGetTypeName (SourceDesc->Common.Type),
DestDesc, AcpiCmGetTypeName (DestDesc->Common.Type)));
/*
* From this interface, we only support Integers/Strings/Buffers
*/
switch (DestinationType)
{
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
break;
default:
DEBUG_PRINT (ACPI_WARN,
("AmlStoreObjectToObject: Store into %s not implemented\n",
AcpiCmGetTypeName (DestDesc->Common.Type)));
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
}
/*
* Resolve the source object to an actual value
* (If it is a reference object)
*/
Status = AcpiAmlResolveObject (&SourceDesc, DestinationType, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/*
* Copy and/or convert the source object to the destination object
*/
Status = AcpiAmlStoreObject (SourceDesc, DestinationType, &DestDesc, WalkState);
return_ACPI_STATUS (Status);
}

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: amstorob - AML Interpreter object store support, store to object
* $Revision: 1.18 $
* $Revision: 1.29 $
*
*****************************************************************************/
@ -10,8 +10,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, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -126,321 +126,459 @@
#include "actables.h"
#define _COMPONENT INTERPRETER
#define _COMPONENT ACPI_EXECUTER
MODULE_NAME ("amstorob")
/*******************************************************************************
*
* FUNCTION: AcpiAmlStoreObjectToObject
* FUNCTION: AcpiAmlCopyBufferToBuffer
*
* PARAMETERS: *ValDesc - Value to be stored
* *DestDesc - Object to receive the value
* PARAMETERS: SourceDesc - Source object to copy
* TargetDesc - Destination object of the copy
*
* RETURN: Status
*
* DESCRIPTION: Store an object to another object.
*
* The Assignment of an object to another (not named) object
* is handled here.
* The val passed in will replace the current value (if any)
* with the input value.
*
* When storing into an object the data is converted to the
* target object type then stored in the object. This means
* that the target object type (for an initialized target) will
* not be changed by a store operation.
*
* This module allows destination types of Number, String,
* and Buffer.
* DESCRIPTION: Copy a buffer object to another buffer object.
*
******************************************************************************/
ACPI_STATUS
AcpiAmlStoreObjectToObject (
ACPI_OPERAND_OBJECT *ValDesc,
ACPI_OPERAND_OBJECT *DestDesc,
ACPI_WALK_STATE *WalkState)
AcpiAmlCopyBufferToBuffer (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OPERAND_OBJECT *TargetDesc)
{
ACPI_STATUS Status = AE_OK;
UINT8 *Buffer = NULL;
UINT32 Length = 0;
OBJECT_TYPE_INTERNAL DestinationType = DestDesc->Common.Type;
UINT32 Length;
UINT8 *Buffer;
FUNCTION_TRACE ("AmlStoreObjectToObject");
DEBUG_PRINT (ACPI_INFO,
("entered AcpiAmlStoreObjectToObject: Dest=%p, Val=%p\n",
DestDesc, ValDesc));
/*
* Assuming the parameters are valid!!!
* We know that SourceDesc is a buffer by now
*/
ACPI_ASSERT((DestDesc) && (ValDesc));
DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToObject: Storing %s into %s\n",
AcpiCmGetTypeName (ValDesc->Common.Type),
AcpiCmGetTypeName (DestDesc->Common.Type)));
Buffer = (UINT8 *) SourceDesc->Buffer.Pointer;
Length = SourceDesc->Buffer.Length;
/*
* First ensure we have a value that can be stored in the target
* If target is a buffer of length zero, allocate a new
* buffer of the proper length
*/
switch (DestinationType)
if (TargetDesc->Buffer.Length == 0)
{
/* Type of Name's existing value */
case ACPI_TYPE_NUMBER:
/*
* These cases all require only number values or values that
* can be converted to numbers.
*
* If value is not a Number, try to resolve it to one.
*/
if (ValDesc->Common.Type != ACPI_TYPE_NUMBER)
TargetDesc->Buffer.Pointer = AcpiCmAllocate (Length);
if (!TargetDesc->Buffer.Pointer)
{
/*
* Initially not a number, convert
*/
Status = AcpiAmlResolveToValue (&ValDesc, WalkState);
if (ACPI_SUCCESS (Status) &&
(ValDesc->Common.Type != ACPI_TYPE_NUMBER))
{
/*
* Conversion successful but still not a number
*/
DEBUG_PRINT (ACPI_ERROR,
("AmlStoreObjectToObject: Value assigned to %s must be Number, not %s\n",
AcpiCmGetTypeName (DestinationType),
AcpiCmGetTypeName (ValDesc->Common.Type)));
Status = AE_AML_OPERAND_TYPE;
}
return (AE_NO_MEMORY);
}
break;
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/*
* Storing into a Field in a region or into a buffer or into
* a string all is essentially the same.
*
* If value is not a valid type, try to resolve it to one.
*/
if ((ValDesc->Common.Type != ACPI_TYPE_NUMBER) &&
(ValDesc->Common.Type != ACPI_TYPE_BUFFER) &&
(ValDesc->Common.Type != ACPI_TYPE_STRING))
{
/*
* Initially not a valid type, convert
*/
Status = AcpiAmlResolveToValue (&ValDesc, WalkState);
if (ACPI_SUCCESS (Status) &&
(ValDesc->Common.Type != ACPI_TYPE_NUMBER) &&
(ValDesc->Common.Type != ACPI_TYPE_BUFFER) &&
(ValDesc->Common.Type != ACPI_TYPE_STRING))
{
/*
* Conversion successful but still not a valid type
*/
DEBUG_PRINT (ACPI_ERROR,
("AmlStoreObjectToObject: Assign wrong type %s to %s (must be type Num/Str/Buf)\n",
AcpiCmGetTypeName (ValDesc->Common.Type),
AcpiCmGetTypeName (DestinationType)));
Status = AE_AML_OPERAND_TYPE;
}
}
break;
default:
/*
* TBD: [Unhandled] What other combinations must be implemented?
*/
Status = AE_NOT_IMPLEMENTED;
break;
}
/* Exit now if failure above */
if (ACPI_FAILURE (Status))
{
goto CleanUpAndBailOut;
TargetDesc->Buffer.Length = Length;
}
/*
* AcpiEverything is ready to execute now, We have
* a value we can handle, just perform the update
* Buffer is a static allocation,
* only place what will fit in the buffer.
*/
switch (DestinationType)
if (Length <= TargetDesc->Buffer.Length)
{
/* Clear existing buffer and copy in the new one */
case ACPI_TYPE_STRING:
/*
* Perform the update
*/
switch (ValDesc->Common.Type)
{
case ACPI_TYPE_NUMBER:
Buffer = (UINT8 *) &ValDesc->Number.Value;
Length = sizeof (ValDesc->Number.Value);
break;
case ACPI_TYPE_BUFFER:
Buffer = (UINT8 *) ValDesc->Buffer.Pointer;
Length = ValDesc->Buffer.Length;
break;
case ACPI_TYPE_STRING:
Buffer = (UINT8 *) ValDesc->String.Pointer;
Length = ValDesc->String.Length;
break;
}
/*
* Setting a string value replaces the old string
*/
if (Length < DestDesc->String.Length)
{
/*
* Zero fill, not willing to do pointer arithmetic for
* architecture independence. Just clear the whole thing
*/
MEMSET(DestDesc->String.Pointer, 0, DestDesc->String.Length);
MEMCPY(DestDesc->String.Pointer, Buffer, Length);
}
else
{
/*
* Free the current buffer, then allocate a buffer
* large enough to hold the value
*/
if ( DestDesc->String.Pointer &&
!AcpiTbSystemTablePointer (DestDesc->String.Pointer))
{
/*
* Only free if not a pointer into the DSDT
*/
AcpiCmFree(DestDesc->String.Pointer);
}
DestDesc->String.Pointer = AcpiCmAllocate (Length + 1);
DestDesc->String.Length = Length;
if (!DestDesc->String.Pointer)
{
Status = AE_NO_MEMORY;
goto CleanUpAndBailOut;
}
MEMCPY(DestDesc->String.Pointer, Buffer, Length);
}
break;
case ACPI_TYPE_BUFFER:
/*
* Perform the update to the buffer
*/
switch (ValDesc->Common.Type)
{
case ACPI_TYPE_NUMBER:
Buffer = (UINT8 *) &ValDesc->Number.Value;
Length = sizeof (ValDesc->Number.Value);
break;
case ACPI_TYPE_BUFFER:
Buffer = (UINT8 *) ValDesc->Buffer.Pointer;
Length = ValDesc->Buffer.Length;
break;
case ACPI_TYPE_STRING:
Buffer = (UINT8 *) ValDesc->String.Pointer;
Length = ValDesc->String.Length;
break;
}
/*
* If the buffer is uninitialized,
* memory needs to be allocated for the copy.
*/
if(0 == DestDesc->Buffer.Length)
{
DestDesc->Buffer.Pointer = AcpiCmCallocate(Length);
DestDesc->Buffer.Length = Length;
if (!DestDesc->Buffer.Pointer)
{
Status = AE_NO_MEMORY;
goto CleanUpAndBailOut;
}
}
/*
* Buffer is a static allocation,
* only place what will fit in the buffer.
*/
if (Length <= DestDesc->Buffer.Length)
{
/*
* Zero fill first, not willing to do pointer arithmetic for
* architecture independence. Just clear the whole thing
*/
MEMSET(DestDesc->Buffer.Pointer, 0, DestDesc->Buffer.Length);
MEMCPY(DestDesc->Buffer.Pointer, Buffer, Length);
}
else
{
/*
* truncate, copy only what will fit
*/
MEMCPY(DestDesc->Buffer.Pointer, Buffer, DestDesc->Buffer.Length);
DEBUG_PRINT (ACPI_INFO,
("AmlStoreObjectToObject: Truncating src buffer from %X to %X\n",
Length, DestDesc->Buffer.Length));
}
break;
case ACPI_TYPE_NUMBER:
DestDesc->Number.Value = ValDesc->Number.Value;
/* Truncate value if we are executing from a 32-bit ACPI table */
AcpiAmlTruncateFor32bitTable (DestDesc, WalkState);
break;
default:
/*
* All other types than Alias and the various Fields come here.
* Store ValDesc as the new value of the Name, and set
* the Name's type to that of the value being stored in it.
* ValDesc reference count is incremented by AttachObject.
*/
DEBUG_PRINT (ACPI_WARN,
("AmlStoreObjectToObject: Store into %s not implemented\n",
AcpiCmGetTypeName (DestDesc->Common.Type)));
Status = AE_NOT_IMPLEMENTED;
break;
MEMSET(TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length);
MEMCPY(TargetDesc->Buffer.Pointer, Buffer, Length);
}
CleanUpAndBailOut:
else
{
/*
* Truncate the source, copy only what will fit
*/
MEMCPY(TargetDesc->Buffer.Pointer, Buffer, TargetDesc->Buffer.Length);
return_ACPI_STATUS (Status);
DEBUG_PRINT (ACPI_INFO,
("AmlCopyBufferToBuffer: Truncating src buffer from %X to %X\n",
Length, TargetDesc->Buffer.Length));
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlCopyStringToString
*
* PARAMETERS: SourceDesc - Source object to copy
* TargetDesc - Destination object of the copy
*
* RETURN: Status
*
* DESCRIPTION: Copy a String object to another String object
*
******************************************************************************/
ACPI_STATUS
AcpiAmlCopyStringToString (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OPERAND_OBJECT *TargetDesc)
{
UINT32 Length;
UINT8 *Buffer;
/*
* We know that SourceDesc is a string by now.
*/
Buffer = (UINT8 *) SourceDesc->String.Pointer;
Length = SourceDesc->String.Length;
/*
* Setting a string value replaces the old string
*/
if (Length < TargetDesc->String.Length)
{
/* Clear old string and copy in the new one */
MEMSET(TargetDesc->String.Pointer, 0, TargetDesc->String.Length);
MEMCPY(TargetDesc->String.Pointer, Buffer, Length);
}
else
{
/*
* Free the current buffer, then allocate a buffer
* large enough to hold the value
*/
if (TargetDesc->String.Pointer &&
!AcpiTbSystemTablePointer (TargetDesc->String.Pointer))
{
/*
* Only free if not a pointer into the DSDT
*/
AcpiCmFree(TargetDesc->String.Pointer);
}
TargetDesc->String.Pointer = AcpiCmAllocate (Length + 1);
if (!TargetDesc->String.Pointer)
{
return (AE_NO_MEMORY);
}
TargetDesc->String.Length = Length;
MEMCPY(TargetDesc->String.Pointer, Buffer, Length);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlCopyIntegerToIndexField
*
* PARAMETERS: SourceDesc - Source object to copy
* TargetDesc - Destination object of the copy
*
* RETURN: Status
*
* DESCRIPTION: Write an Integer to an Index Field
*
******************************************************************************/
ACPI_STATUS
AcpiAmlCopyIntegerToIndexField (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OPERAND_OBJECT *TargetDesc)
{
ACPI_STATUS Status;
BOOLEAN Locked;
/*
* Get the global lock if needed
*/
Locked = AcpiAmlAcquireGlobalLock (TargetDesc->IndexField.LockRule);
/*
* Set Index value to select proper Data register
* perform the update (Set index)
*/
Status = AcpiAmlAccessNamedField (ACPI_WRITE,
TargetDesc->IndexField.Index,
&TargetDesc->IndexField.Value,
sizeof (TargetDesc->IndexField.Value));
if (ACPI_SUCCESS (Status))
{
/* SetIndex was successful, next set Data value */
Status = AcpiAmlAccessNamedField (ACPI_WRITE,
TargetDesc->IndexField.Data,
&SourceDesc->Integer.Value,
sizeof (SourceDesc->Integer.Value));
DEBUG_PRINT (ACPI_INFO,
("AmlCopyIntegerToIndexField: IndexField: set data returned %s\n",
AcpiCmFormatException (Status)));
}
else
{
DEBUG_PRINT (ACPI_INFO,
("AmlCopyIntegerToIndexField: IndexField: set index returned %s\n",
AcpiCmFormatException (Status)));
}
/*
* Release global lock if we acquired it earlier
*/
AcpiAmlReleaseGlobalLock (Locked);
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlCopyIntegerToBankField
*
* PARAMETERS: SourceDesc - Source object to copy
* TargetDesc - Destination object of the copy
*
* RETURN: Status
*
* DESCRIPTION: Write an Integer to a Bank Field
*
******************************************************************************/
ACPI_STATUS
AcpiAmlCopyIntegerToBankField (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OPERAND_OBJECT *TargetDesc)
{
ACPI_STATUS Status;
BOOLEAN Locked;
/*
* Get the global lock if needed
*/
Locked = AcpiAmlAcquireGlobalLock (TargetDesc->IndexField.LockRule);
/*
* Set Bank value to select proper Bank
* Perform the update (Set Bank Select)
*/
Status = AcpiAmlAccessNamedField (ACPI_WRITE,
TargetDesc->BankField.BankRegisterNode,
&TargetDesc->BankField.Value,
sizeof (TargetDesc->BankField.Value));
if (ACPI_SUCCESS (Status))
{
/* Set bank select successful, set data value */
Status = AcpiAmlAccessNamedField (ACPI_WRITE,
TargetDesc->BankField.BankRegisterNode,
&SourceDesc->BankField.Value,
sizeof (SourceDesc->BankField.Value));
}
else
{
DEBUG_PRINT (ACPI_INFO,
("AmlCopyIntegerToBankField: set bank failed: %s\n",
AcpiCmFormatException (Status)));
}
/*
* Release global lock if we acquired it earlier
*/
AcpiAmlReleaseGlobalLock (Locked);
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlCopyDataToNamedField
*
* PARAMETERS: SourceDesc - Source object to copy
* Node - Destination Namespace node
*
* RETURN: Status
*
* DESCRIPTION: Copy raw data to a Named Field. No implicit conversion
* is performed on the source object
*
******************************************************************************/
ACPI_STATUS
AcpiAmlCopyDataToNamedField (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_NAMESPACE_NODE *Node)
{
ACPI_STATUS Status;
BOOLEAN Locked;
UINT32 Length;
UINT8 *Buffer;
/*
* Named fields (CreateXxxField) - We don't perform any conversions on the
* source operand, just use the raw data
*/
switch (SourceDesc->Common.Type)
{
case ACPI_TYPE_INTEGER:
Buffer = (UINT8 *) &SourceDesc->Integer.Value;
Length = sizeof (SourceDesc->Integer.Value);
break;
case ACPI_TYPE_BUFFER:
Buffer = (UINT8 *) SourceDesc->Buffer.Pointer;
Length = SourceDesc->Buffer.Length;
break;
case ACPI_TYPE_STRING:
Buffer = (UINT8 *) SourceDesc->String.Pointer;
Length = SourceDesc->String.Length;
break;
default:
return (AE_TYPE);
}
/*
* Get the global lock if needed before the update
* TBD: not needed!
*/
Locked = AcpiAmlAcquireGlobalLock (SourceDesc->Field.LockRule);
Status = AcpiAmlAccessNamedField (ACPI_WRITE,
Node, Buffer, Length);
AcpiAmlReleaseGlobalLock (Locked);
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlCopyIntegerToFieldUnit
*
* PARAMETERS: SourceDesc - Source object to copy
* TargetDesc - Destination object of the copy
*
* RETURN: Status
*
* DESCRIPTION: Write an Integer to a Field Unit.
*
******************************************************************************/
ACPI_STATUS
AcpiAmlCopyIntegerToFieldUnit (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OPERAND_OBJECT *TargetDesc)
{
ACPI_STATUS Status = AE_OK;
UINT8 *Location = NULL;
UINT32 Mask;
UINT32 NewValue;
BOOLEAN Locked = FALSE;
FUNCTION_TRACE ("AmlCopyIntegerToFieldUnit");
/*
* If the Field Buffer and Index have not been previously evaluated,
* evaluate them and save the results.
*/
if (!(TargetDesc->Common.Flags & AOPOBJ_DATA_VALID))
{
Status = AcpiDsGetFieldUnitArguments (TargetDesc);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
if ((!TargetDesc->FieldUnit.ContainerObj ||
ACPI_TYPE_BUFFER != TargetDesc->FieldUnit.ContainerObj->Common.Type))
{
DEBUG_PRINT (ACPI_ERROR,
("Null Container or wrong type: %p",
TargetDesc->FieldUnit.ContainerObj));
if (TargetDesc->FieldUnit.ContainerObj)
{
DEBUG_PRINT_RAW (ACPI_ERROR, (" Type %X",
TargetDesc->FieldUnit.ContainerObj->Common.Type));
}
DEBUG_PRINT_RAW (ACPI_ERROR, ("\n"));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
/*
* Get the global lock if needed
*/
Locked = AcpiAmlAcquireGlobalLock (TargetDesc->FieldUnit.LockRule);
/*
* TBD: [Unhandled] REMOVE this limitation
* Make sure the operation is within the limits of our implementation
* this is not a Spec limitation!!
*/
if (TargetDesc->FieldUnit.Length + TargetDesc->FieldUnit.BitOffset > 32)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlCopyIntegerToFieldUnit: FieldUnit: Implementation limitation - Field exceeds UINT32\n"));
AcpiAmlReleaseGlobalLock (Locked);
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
}
/* Field location is (base of buffer) + (byte offset) */
Location = TargetDesc->FieldUnit.ContainerObj->Buffer.Pointer
+ TargetDesc->FieldUnit.Offset;
/*
* Construct Mask with 1 bits where the field is,
* 0 bits elsewhere
*/
Mask = ((UINT32) 1 << TargetDesc->FieldUnit.Length) - ((UINT32)1
<< TargetDesc->FieldUnit.BitOffset);
DEBUG_PRINT (TRACE_EXEC,
("** Store %lx in buffer %p byte %ld bit %X width %d addr %p mask %08lx\n",
SourceDesc->Integer.Value,
TargetDesc->FieldUnit.ContainerObj->Buffer.Pointer,
TargetDesc->FieldUnit.Offset, TargetDesc->FieldUnit.BitOffset,
TargetDesc->FieldUnit.Length,Location, Mask));
/* Zero out the field in the buffer */
MOVE_UNALIGNED32_TO_32 (&NewValue, Location);
NewValue &= ~Mask;
/*
* Shift and mask the new value into position,
* and or it into the buffer.
*/
NewValue |= (SourceDesc->Integer.Value << TargetDesc->FieldUnit.BitOffset) &
Mask;
/* Store back the value */
MOVE_UNALIGNED32_TO_32 (Location, &NewValue);
AcpiAmlReleaseGlobalLock (Locked);
DEBUG_PRINT (TRACE_EXEC, ("New Field value %08lx\n", NewValue));
return_ACPI_STATUS (AE_OK);
}