Fix for named references

date	2000.09.22.17.00.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 17:45:45 +00:00
parent 04c46e895c
commit 53650151a8

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: amresnte - AML Interpreter object resolution
* $Revision: 1.18 $
* $Revision: 1.22 $
*
*****************************************************************************/
@ -128,23 +128,24 @@
#define _COMPONENT INTERPRETER
MODULE_NAME ("amresnte");
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 an Node
*
* RETURN: Status
*
* DESCRIPTION: Resolve a ACPI_NAMED_OBJECT(nte, A.K.A. a "direct name pointer")
* DESCRIPTION: Resolve a ACPI_NAMESPACE_NODE (Node,
* A.K.A. a "direct name pointer")
*
* 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_STRING
@ -155,13 +156,13 @@
******************************************************************************/
ACPI_STATUS
AcpiAmlResolveEntryToValue (
ACPI_NAMED_OBJECT **StackPtr)
AcpiAmlResolveNodeToValue (
ACPI_NAMESPACE_NODE **StackPtr)
{
ACPI_STATUS Status = AE_OK;
ACPI_OBJECT_INTERNAL *ValDesc = NULL;
ACPI_OBJECT_INTERNAL *ObjDesc = NULL;
ACPI_NAMED_OBJECT *StackEntry;
ACPI_OPERAND_OBJECT *ValDesc = NULL;
ACPI_OPERAND_OBJECT *ObjDesc = NULL;
ACPI_NAMESPACE_NODE *Node;
UINT8 *AmlPointer = NULL;
OBJECT_TYPE_INTERNAL EntryType;
BOOLEAN Locked;
@ -173,24 +174,24 @@ AcpiAmlResolveEntryToValue (
FUNCTION_TRACE ("AmlResolveEntryToValue");
StackEntry = *StackPtr;
Node = *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.
* a ACPI_NAMESPACE_NODE (Node). Get the pointer that is attached to
* the Node.
*/
ValDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) StackEntry);
EntryType = AcpiNsGetType ((ACPI_HANDLE) StackEntry);
ValDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) 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)
*/
@ -207,12 +208,12 @@ 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 ||
@ -224,12 +225,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)
@ -253,7 +255,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);
}
@ -282,7 +285,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);
}
@ -290,10 +294,6 @@ AcpiAmlResolveEntryToValue (
ObjDesc = ValDesc;
AcpiCmAddReference (ObjDesc);
DEBUG_PRINT (TRACE_BFIELD,
("AmlResolveEntryToValue: New Buffer descriptor seq# %ld @ %p \n",
ObjDesc->Buffer.Sequence, ObjDesc));
break;
@ -320,7 +320,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);
}
@ -338,100 +339,22 @@ AcpiAmlResolveEntryToValue (
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_NUMBER != 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;
@ -472,7 +395,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);
@ -481,10 +404,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, (ACPI_HANDLE) Node,
ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length);
if (ACPI_FAILURE (Status))
{
@ -493,8 +414,7 @@ AcpiAmlResolveEntryToValue (
}
else
{
Status = AcpiAmlAccessNamedField (ACPI_READ,
(ACPI_HANDLE) StackEntry,
Status = AcpiAmlAccessNamedField (ACPI_READ, (ACPI_HANDLE) Node,
&TempVal, sizeof (TempVal));
if (ACPI_FAILURE (Status))
@ -507,8 +427,8 @@ AcpiAmlResolveEntryToValue (
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;
@ -517,16 +437,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);
}
@ -534,16 +453,15 @@ 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 */
Status = AcpiAmlAccessNamedField (ACPI_WRITE,
ValDesc->BankField.BankSelect,
&ValDesc->BankField.Value,
sizeof (ValDesc->BankField.Value));
Status = AcpiAmlAccessNamedField (ACPI_WRITE,
ValDesc->BankField.BankSelect, &ValDesc->BankField.Value,
sizeof (ValDesc->BankField.Value));
AcpiAmlReleaseGlobalLock (Locked);
@ -563,6 +481,8 @@ AcpiAmlResolveEntryToValue (
return_ACPI_STATUS (Status);
}
/* Create an object for the result */
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
if (!ObjDesc)
{
@ -577,15 +497,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);
}
@ -594,14 +514,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);
@ -612,14 +532,15 @@ 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);
}
/* Create an object for the result */
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
if (!ObjDesc)
{
@ -635,21 +556,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)
{
@ -667,7 +589,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:
@ -685,15 +607,67 @@ 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_UINT32_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_NUMBER);
if (!ObjDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
ObjDesc->Number.Value = TempVal;
break;
/* Default case is for unknown types */
@ -701,8 +675,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);