Global rename of identifiers and constants

date	2000.06.13.18.19.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 17:26:35 +00:00
parent e67d0febfb
commit fd3818138b
8 changed files with 1167 additions and 1533 deletions

View File

@ -116,13 +116,13 @@
#define __IEFIELD_C__
#include <acpi.h>
#include <dispatch.h>
#include <interp.h>
#include <amlcode.h>
#include <namesp.h>
#include <hardware.h>
#include <events.h>
#include "acpi.h"
#include "dispatch.h"
#include "interp.h"
#include "amlcode.h"
#include "namesp.h"
#include "hardware.h"
#include "events.h"
#define _COMPONENT INTERPRETER
@ -133,7 +133,7 @@
/*****************************************************************************
*
* FUNCTION: AmlSetupField
* FUNCTION: AcpiAmlSetupField
*
* PARAMETERS: *ObjDesc - Field to be read or written
* *RgnDesc - Region containing field
@ -141,7 +141,7 @@
*
* RETURN: Status
*
* DESCRIPTION: Common processing for AmlReadField and AmlWriteField
* DESCRIPTION: Common processing for AcpiAmlReadField and AcpiAmlWriteField
*
* ACPI SPECIFICATION REFERENCES:
* 16.2.4.3 Each of the Type1Opcodes is defined as specified in in-line
@ -160,7 +160,7 @@
****************************************************************************/
ACPI_STATUS
AmlSetupField (
AcpiAmlSetupField (
ACPI_OBJECT_INTERNAL *ObjDesc,
ACPI_OBJECT_INTERNAL *RgnDesc,
INT32 FieldBitWidth)
@ -180,10 +180,10 @@ AmlSetupField (
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
if (ACPI_TYPE_Region != RgnDesc->Common.Type)
if (ACPI_TYPE_REGION != RgnDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlSetupField: Needed Region, found type %x %s\n",
RgnDesc->Common.Type, CmGetTypeName (RgnDesc->Common.Type)));
RgnDesc->Common.Type, AcpiCmGetTypeName (RgnDesc->Common.Type)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@ -208,7 +208,7 @@ AmlSetupField (
if (!(RgnDesc->Region.RegionFlags & REGION_AGRUMENT_DATA_VALID))
{
Status = DsGetRegionArguments (RgnDesc);
Status = AcpiDsGetRegionArguments (RgnDesc);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
@ -245,7 +245,7 @@ AmlSetupField (
/*****************************************************************************
*
* FUNCTION: AmlAccessNamedField
* FUNCTION: AcpiAmlAccessNamedField
*
* PARAMETERS: Mode - ACPI_READ or ACPI_WRITE
* NamedField - Handle for field to be accessed
@ -259,7 +259,7 @@ AmlSetupField (
****************************************************************************/
ACPI_STATUS
AmlAccessNamedField (
AcpiAmlAccessNamedField (
INT32 Mode,
ACPI_HANDLE NamedField,
void *Buffer,
@ -280,7 +280,7 @@ AmlAccessNamedField (
/* Get the attached field object */
ObjDesc = NsGetAttachedObject (NamedField);
ObjDesc = AcpiNsGetAttachedObject (NamedField);
if (!ObjDesc)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlAccessNamedField: Internal error - null value pointer\n"));
@ -289,10 +289,10 @@ AmlAccessNamedField (
/* Check the type */
if (INTERNAL_TYPE_DefField != NsGetType (NamedField))
if (INTERNAL_TYPE_DEF_FIELD != AcpiNsGetType (NamedField))
{
DEBUG_PRINT (ACPI_ERROR, ("AmlAccessNamedField: Name %4.4s type %x is not a defined field\n",
&(((NAME_TABLE_ENTRY *) NamedField)->Name), NsGetType (NamedField)));
&(((NAME_TABLE_ENTRY *) NamedField)->Name), AcpiNsGetType (NamedField)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@ -307,11 +307,11 @@ AmlAccessNamedField (
/* Double-check that the attached object is also a field */
if (INTERNAL_TYPE_DefField != ObjDesc->Common.Type)
if (INTERNAL_TYPE_DEF_FIELD != ObjDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR, (
"AmlAccessNamedField: Internal error - Name %4.4s type %x does not match value-type %x at %p\n",
&(((NAME_TABLE_ENTRY *) NamedField)->Name), NsGetType (NamedField), ObjDesc->Common.Type, ObjDesc));
&(((NAME_TABLE_ENTRY *) NamedField)->Name), AcpiNsGetType (NamedField), ObjDesc->Common.Type, ObjDesc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@ -323,7 +323,7 @@ AmlAccessNamedField (
/* Check if request is too large for the field, and silently truncate if necessary */
/* TBD: should an error be returned in this case? */
/* TBD: [Errors] should an error be returned in this case? */
ByteFieldLength = (UINT32) DIV_8 (ObjDesc->FieldUnit.Length + 7);
@ -348,7 +348,7 @@ AmlAccessNamedField (
/* Get the global lock if needed */
Locked = AmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule);
Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule);
/* Perform the actual read or write of the buffer */
@ -357,14 +357,14 @@ AmlAccessNamedField (
{
case ACPI_READ:
Status = AmlReadField (ObjDesc, Buffer, BufferLength, ActualByteLength, DatumLength,
Status = AcpiAmlReadField (ObjDesc, Buffer, BufferLength, ActualByteLength, DatumLength,
BitGranularity, ByteGranularity);
break;
case ACPI_WRITE:
Status = AmlWriteField (ObjDesc, Buffer, BufferLength, ActualByteLength, DatumLength,
Status = AcpiAmlWriteField (ObjDesc, Buffer, BufferLength, ActualByteLength, DatumLength,
BitGranularity, ByteGranularity);
break;
@ -380,7 +380,7 @@ AmlAccessNamedField (
/* Release global lock if we acquired it earlier */
AmlReleaseGlobalLock (Locked);
AcpiAmlReleaseGlobalLock (Locked);
return_ACPI_STATUS (Status);
}
@ -388,7 +388,7 @@ AmlAccessNamedField (
/*****************************************************************************
*
* FUNCTION: AmlSetNamedFieldValue
* FUNCTION: AcpiAmlSetNamedFieldValue
*
* PARAMETERS: NamedField - Handle for field to be set
* Buffer - Bytes to be stored
@ -401,7 +401,7 @@ AmlAccessNamedField (
****************************************************************************/
ACPI_STATUS
AmlSetNamedFieldValue (
AcpiAmlSetNamedFieldValue (
ACPI_HANDLE NamedField,
void *Buffer,
UINT32 BufferLength)
@ -418,14 +418,14 @@ AmlSetNamedFieldValue (
return_ACPI_STATUS (AE_AML_INTERNAL);
}
Status = AmlAccessNamedField (ACPI_WRITE, NamedField, Buffer, BufferLength);
Status = AcpiAmlAccessNamedField (ACPI_WRITE, NamedField, Buffer, BufferLength);
return_ACPI_STATUS (Status);
}
/*****************************************************************************
*
* FUNCTION: AmlGetNamedFieldValue
* FUNCTION: AcpiAmlGetNamedFieldValue
*
* PARAMETERS: NamedField - Handle for field to be read
* *Buffer - Where to store value read from field
@ -438,7 +438,7 @@ AmlSetNamedFieldValue (
****************************************************************************/
ACPI_STATUS
AmlGetNamedFieldValue (
AcpiAmlGetNamedFieldValue (
ACPI_HANDLE NamedField,
void *Buffer,
UINT32 BufferLength)
@ -455,7 +455,7 @@ AmlGetNamedFieldValue (
return_ACPI_STATUS (AE_AML_INTERNAL);
}
Status = AmlAccessNamedField (ACPI_READ, NamedField, Buffer, BufferLength);
Status = AcpiAmlAccessNamedField (ACPI_READ, NamedField, Buffer, BufferLength);
return_ACPI_STATUS (Status);
}

View File

@ -116,12 +116,12 @@
#define __IEFREAD_C__
#include <acpi.h>
#include <interp.h>
#include <amlcode.h>
#include <namesp.h>
#include <hardware.h>
#include <events.h>
#include "acpi.h"
#include "interp.h"
#include "amlcode.h"
#include "namesp.h"
#include "hardware.h"
#include "events.h"
#define _COMPONENT INTERPRETER
@ -130,7 +130,7 @@
/*****************************************************************************
*
* FUNCTION: AmlReadFieldData
* FUNCTION: AcpiAmlReadFieldData
*
* PARAMETERS: *ObjDesc - Field to be read
* *Value - Where to store value
@ -143,7 +143,7 @@
****************************************************************************/
ACPI_STATUS
AmlReadFieldData (
AcpiAmlReadFieldData (
ACPI_OBJECT_INTERNAL *ObjDesc,
UINT32 FieldByteOffset,
UINT32 FieldBitWidth,
@ -168,7 +168,7 @@ AmlReadFieldData (
FieldByteWidth = DIV_8 (FieldBitWidth);
Status = AmlSetupField (ObjDesc, RgnDesc, FieldBitWidth);
Status = AcpiAmlSetupField (ObjDesc, RgnDesc, FieldBitWidth);
if (AE_OK != Status)
{
return_ACPI_STATUS (Status);
@ -202,19 +202,19 @@ AmlReadFieldData (
{
DEBUG_PRINT (TRACE_OPREGION,
("AmlReadFieldData: OpRegion %s at %08lx width %d\n",
Gbl_RegionTypes[RgnDesc->Region.SpaceId], Address, FieldBitWidth));
Acpi_GblRegionTypes[RgnDesc->Region.SpaceId], Address, FieldBitWidth));
}
/* Invoke the appropriate AddressSpace/OpRegion handler */
Status = EvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ,
Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ,
Address, FieldBitWidth, Value);
if (Status == AE_NOT_IMPLEMENTED)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlReadFieldData: **** OpRegion type %s not implemented\n",
Gbl_RegionTypes[RgnDesc->Region.SpaceId]));
Acpi_GblRegionTypes[RgnDesc->Region.SpaceId]));
}
else if (Status == AE_EXIST)
@ -231,7 +231,7 @@ AmlReadFieldData (
/*****************************************************************************
*
* FUNCTION: AmlReadField
* FUNCTION: AcpiAmlReadField
*
* PARAMETERS: *ObjDesc - Field to be read
* *Value - Where to store value
@ -244,7 +244,7 @@ AmlReadFieldData (
****************************************************************************/
ACPI_STATUS
AmlReadField (
AcpiAmlReadField (
ACPI_OBJECT_INTERNAL *ObjDesc,
void *Buffer,
UINT32 BufferLength,
@ -279,7 +279,7 @@ AmlReadField (
ThisFieldByteOffset = 0;
ThisFieldDatumOffset= 0;
Status = AmlReadFieldData (ObjDesc, ThisFieldByteOffset, BitGranularity, &PreviousRawDatum);
Status = AcpiAmlReadFieldData (ObjDesc, ThisFieldByteOffset, BitGranularity, &PreviousRawDatum);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
@ -329,7 +329,7 @@ AmlReadField (
{
/* Get the next raw datum, it contains bits of the current field datum... */
Status = AmlReadFieldData (ObjDesc, ThisFieldByteOffset + ByteGranularity,
Status = AcpiAmlReadFieldData (ObjDesc, ThisFieldByteOffset + ByteGranularity,
BitGranularity, &ThisRawDatum);
if (ACPI_FAILURE (Status))
{

View File

@ -117,10 +117,11 @@
#define __IEOPEXEC_C__
#include <acpi.h>
#include <parser.h>
#include <interp.h>
#include <amlcode.h>
#include "acpi.h"
#include "parser.h"
#include "interp.h"
#include "amlcode.h"
#include "dispatch.h"
#define _COMPONENT INTERPRETER
@ -130,7 +131,7 @@
/*****************************************************************************
*
* FUNCTION: AmlExecFatal
* FUNCTION: AcpiAmlExecFatal
*
* PARAMETERS: none
*
@ -148,8 +149,8 @@
****************************************************************************/
ACPI_STATUS
AmlExecFatal (
ACPI_OBJECT_INTERNAL **Operands)
AcpiAmlExecFatal (
ACPI_WALK_STATE *WalkState)
{
ACPI_OBJECT_INTERNAL *TypeDesc;
ACPI_OBJECT_INTERNAL *CodeDesc;
@ -160,39 +161,43 @@ AmlExecFatal (
FUNCTION_TRACE ("AmlExecFatal");
Status = AmlPrepOperands ("nnn", Operands);
/* Resolve operands */
Status = AcpiAmlResolveOperands (AML_FATAL_OP, WALK_OPERANDS);
DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (AML_FATAL_OP), 3, "after AcpiAmlResolveOperands");
/* Get operands */
Status |= AcpiDsObjStackPopObject (&ArgDesc, WalkState);
Status |= AcpiDsObjStackPopObject (&CodeDesc, WalkState);
Status |= AcpiDsObjStackPopObject (&TypeDesc, WalkState);
if (Status != AE_OK)
{
/* invalid parameters on object stack */
AmlAppendOperandDiag (_THIS_MODULE, __LINE__, (UINT16) AML_FatalOp, Operands, 3);
AcpiAmlAppendOperandDiag (_THIS_MODULE, __LINE__, (UINT16) AML_FATAL_OP, WALK_OPERANDS, 3);
goto Cleanup;
}
DUMP_OPERANDS (Operands, IMODE_Execute, PsGetOpcodeName (AML_FatalOp), 3, "after AmlPrepOperands");
/* DefFatal := FatalOp FatalType FatalCode FatalArg */
ArgDesc = Operands[0];
CodeDesc = Operands[-1];
TypeDesc = Operands[-2];
DEBUG_PRINT (ACPI_INFO, ("FatalOp: Type %x Code %x Arg %x <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
TypeDesc->Number.Value, CodeDesc->Number.Value, ArgDesc->Number.Value));
/* TBD: call OSD interface to notify OS of fatal error requiring shutdown! */
/* TBD: [Unhandled] call OSD interface to notify OS of fatal error requiring shutdown! */
Cleanup:
/* Free the operands */
CmDeleteOperand (&Operands[0]);
CmDeleteOperand (&Operands[-1]);
CmDeleteOperand (&Operands[-2]);
AcpiCmRemoveReference (ArgDesc);
AcpiCmRemoveReference (CodeDesc);
AcpiCmRemoveReference (TypeDesc);
/* If we get back from the OS call, we might as well keep going. */
@ -204,7 +209,7 @@ Cleanup:
/*****************************************************************************
*
* FUNCTION: AmlExecIndex
* FUNCTION: AcpiAmlExecIndex
*
* PARAMETERS: none
*
@ -225,8 +230,8 @@ Cleanup:
****************************************************************************/
ACPI_STATUS
AmlExecIndex (
ACPI_OBJECT_INTERNAL **Operands,
AcpiAmlExecIndex (
ACPI_WALK_STATE *WalkState,
ACPI_OBJECT_INTERNAL **ReturnDesc)
{
ACPI_OBJECT_INTERNAL *ObjDesc;
@ -240,31 +245,29 @@ AmlExecIndex (
FUNCTION_TRACE ("AmlExecIndex");
/* Resolve operands */
/* First operand can be either a package or a buffer */
Status = AmlPrepOperands ("lnp", Operands);
Status = AcpiAmlResolveOperands (AML_INDEX_OP, WALK_OPERANDS);
DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (AML_INDEX_OP), 3, "after AcpiAmlResolveOperands");
if (Status == AE_TYPE)
{
Status = AmlPrepOperands ("lnb", Operands);
}
/* Get all operands */
Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState);
Status |= AcpiDsObjStackPopObject (&IdxDesc, WalkState);
Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState);
if (Status != AE_OK)
{
/* invalid parameters on object stack */
/* Invalid parameters on object stack */
AmlAppendOperandDiag (_THIS_MODULE, __LINE__, (UINT16) AML_IndexOp, Operands, 3);
AcpiAmlAppendOperandDiag (_THIS_MODULE, __LINE__, (UINT16) AML_INDEX_OP, WALK_OPERANDS, 3);
goto Cleanup;
}
DUMP_OPERANDS (Operands, IMODE_Execute, PsGetOpcodeName (AML_IndexOp), 3, "after AmlPrepOperands");
ResDesc = Operands[0];
IdxDesc = Operands[-1];
ObjDesc = Operands[-2];
/* Create the internal return object */
RetDesc = CmCreateInternalObject (INTERNAL_TYPE_Lvalue);
RetDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE);
if (!RetDesc)
{
Status = AE_NO_MEMORY;
@ -276,7 +279,7 @@ AmlExecIndex (
* At this point, the ObjDesc operand is either a Package or a Buffer
*/
if (ObjDesc->Common.Type == ACPI_TYPE_Package)
if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
{
/* Object to be indexed is a Package */
@ -287,45 +290,40 @@ AmlExecIndex (
goto Cleanup;
}
if ((ResDesc->Common.Type == INTERNAL_TYPE_Lvalue) &&
(ResDesc->Lvalue.OpCode == AML_ZeroOp))
if ((ResDesc->Common.Type == INTERNAL_TYPE_REFERENCE) &&
(ResDesc->Reference.OpCode == AML_ZERO_OP))
{
/*
* There is no actual result descriptor (the ZeroOp Result descriptor is a placeholder),
* so just delete the placeholder and return a reference to the package element
*/
CmDeleteInternalObject (ResDesc);
AcpiCmRemoveReference (ResDesc);
}
else
{
/*
* TBD - possible dangling reference: if the package vector changes
* TBD - before this pointer is used, the results may be surprising.
*/
/*
* Each element of the package is an internal object. Get the one
* we are after.
*/
TmpDesc = ObjDesc->Package.Elements[IdxDesc->Number.Value];
RetDesc->Lvalue.OpCode = AML_IndexOp;
RetDesc->Lvalue.TargetType = TmpDesc->Common.Type;
RetDesc->Lvalue.Object = TmpDesc;
TmpDesc = ObjDesc->Package.Elements[IdxDesc->Number.Value];
RetDesc->Reference.OpCode = AML_INDEX_OP;
RetDesc->Reference.TargetType = TmpDesc->Common.Type;
RetDesc->Reference.Object = TmpDesc;
Status = AmlExecStore (RetDesc, ResDesc);
RetDesc->Lvalue.Object = NULL;
Status = AcpiAmlExecStore (RetDesc, ResDesc);
RetDesc->Reference.Object = NULL;
}
/*
* The local return object must always be a reference to the package element,
* not the element itself.
*/
RetDesc->Lvalue.OpCode = AML_IndexOp;
RetDesc->Lvalue.TargetType = ACPI_TYPE_Package;
RetDesc->Lvalue.Where = &ObjDesc->Package.Elements[IdxDesc->Number.Value];
RetDesc->Reference.OpCode = AML_INDEX_OP;
RetDesc->Reference.TargetType = ACPI_TYPE_PACKAGE;
RetDesc->Reference.Where = &ObjDesc->Package.Elements[IdxDesc->Number.Value];
}
else
@ -339,16 +337,12 @@ AmlExecIndex (
goto Cleanup;
}
/*
* TBD - possible dangling reference: if the package vector changes
* TBD - before this pointer is used, the results may be surprising.
*/
RetDesc->Lvalue.OpCode = AML_IndexOp;
RetDesc->Lvalue.TargetType = ACPI_TYPE_Buffer;
RetDesc->Lvalue.Object = ObjDesc;
RetDesc->Lvalue.Offset = IdxDesc->Number.Value;
RetDesc->Reference.OpCode = AML_INDEX_OP;
RetDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
RetDesc->Reference.Object = ObjDesc;
RetDesc->Reference.Offset = IdxDesc->Number.Value;
Status = AmlExecStore (RetDesc, ResDesc);
Status = AcpiAmlExecStore (RetDesc, ResDesc);
}
@ -356,18 +350,21 @@ Cleanup:
/* Always delete operands */
CmDeleteOperand (&Operands[-1]);
CmDeleteOperand (&Operands[-2]);
AcpiCmRemoveReference (ObjDesc);
AcpiCmRemoveReference (IdxDesc);
/* Delete return object on error */
if (ACPI_FAILURE (Status) &&
(RetDesc))
if (ACPI_FAILURE (Status))
{
CmDeleteInternalObject (RetDesc);
RetDesc = NULL;
}
AcpiCmRemoveReference (ResDesc);
if (RetDesc)
{
AcpiCmRemoveReference (RetDesc);
RetDesc = NULL;
}
}
/* Set the return object and exit */
@ -378,7 +375,7 @@ Cleanup:
/*****************************************************************************
*
* FUNCTION: AmlExecMatch
* FUNCTION: AcpiAmlExecMatch
*
* PARAMETERS: none
*
@ -401,8 +398,8 @@ Cleanup:
****************************************************************************/
ACPI_STATUS
AmlExecMatch (
ACPI_OBJECT_INTERNAL **Operands,
AcpiAmlExecMatch (
ACPI_WALK_STATE *WalkState,
ACPI_OBJECT_INTERNAL **ReturnDesc)
{
ACPI_OBJECT_INTERNAL *PkgDesc;
@ -420,28 +417,28 @@ AmlExecMatch (
FUNCTION_TRACE ("AmlExecMatch");
Status = AmlPrepOperands ("nnnnnp", Operands);
/* Resolve all operands */
Status = AcpiAmlResolveOperands (AML_MATCH_OP, WALK_OPERANDS);
DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (AML_MATCH_OP), 6, "after AcpiAmlResolveOperands");
/* Get all operands */
Status |= AcpiDsObjStackPopObject (&StartDesc, WalkState);
Status |= AcpiDsObjStackPopObject (&V2Desc, WalkState);
Status |= AcpiDsObjStackPopObject (&Op2Desc, WalkState);
Status |= AcpiDsObjStackPopObject (&V1Desc, WalkState);
Status |= AcpiDsObjStackPopObject (&Op1Desc, WalkState);
Status |= AcpiDsObjStackPopObject (&PkgDesc, WalkState);
if (Status != AE_OK)
{
/* invalid parameters on object stack */
AmlAppendOperandDiag (_THIS_MODULE, __LINE__, (UINT16) AML_MatchOp, Operands, 6);
AcpiAmlAppendOperandDiag (_THIS_MODULE, __LINE__, (UINT16) AML_MATCH_OP, WALK_OPERANDS, 6);
goto Cleanup;
}
/* Get the parameters from the object stack */
DUMP_OPERANDS (Operands, IMODE_Execute, PsGetOpcodeName (AML_MatchOp), 6, "after AmlPrepOperands");
StartDesc = Operands[0];
V2Desc = Operands[-1];
Op2Desc = Operands[-2];
V1Desc = Operands[-3];
Op1Desc = Operands[-4];
PkgDesc = Operands[-5];
/* Validate match comparison sub-opcodes */
if ((Op1Desc->Number.Value > MAX_MATCH_OPERATOR) ||
@ -460,7 +457,7 @@ AmlExecMatch (
goto Cleanup;
}
RetDesc = CmCreateInternalObject (ACPI_TYPE_Number);
RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
if (!RetDesc)
{
Status = AE_NO_MEMORY;
@ -485,7 +482,7 @@ AmlExecMatch (
* XXX - if an element is a Name, should we examine its value?
*/
if (!PkgDesc->Package.Elements[Index] ||
ACPI_TYPE_Number != PkgDesc->Package.Elements[Index]->Common.Type)
ACPI_TYPE_NUMBER != PkgDesc->Package.Elements[Index]->Common.Type)
{
continue;
}
@ -638,19 +635,20 @@ Cleanup:
/* Free the operands */
CmDeleteOperand (&Operands[0]);
CmDeleteOperand (&Operands[-1]);
CmDeleteOperand (&Operands[-2]);
CmDeleteOperand (&Operands[-3]);
CmDeleteOperand (&Operands[-4]);
CmDeleteOperand (&Operands[-5]);
AcpiCmRemoveReference (StartDesc);
AcpiCmRemoveReference (V2Desc);
AcpiCmRemoveReference (Op2Desc);
AcpiCmRemoveReference (V1Desc);
AcpiCmRemoveReference (Op1Desc);
AcpiCmRemoveReference (PkgDesc);
/* Delete return object on error */
if (ACPI_FAILURE (Status) &&
(RetDesc))
{
CmDeleteInternalObject (RetDesc);
AcpiCmRemoveReference (RetDesc);
RetDesc = NULL;
}

File diff suppressed because it is too large Load Diff

View File

@ -117,12 +117,13 @@
#define __IEDYAD_C__
#include <acpi.h>
#include <parser.h>
#include <namesp.h>
#include <interp.h>
#include <events.h>
#include <amlcode.h>
#include "acpi.h"
#include "parser.h"
#include "namesp.h"
#include "interp.h"
#include "events.h"
#include "amlcode.h"
#include "dispatch.h"
#define _COMPONENT INTERPRETER
@ -131,7 +132,7 @@
/*****************************************************************************
*
* FUNCTION: AmlExecDyadic1
* FUNCTION: AcpiAmlExecDyadic1
*
* PARAMETERS: Opcode - The opcode to be executed
*
@ -145,9 +146,9 @@
****************************************************************************/
ACPI_STATUS
AmlExecDyadic1 (
AcpiAmlExecDyadic1 (
UINT16 Opcode,
ACPI_OBJECT_INTERNAL **Operands)
ACPI_WALK_STATE *WalkState)
{
ACPI_OBJECT_INTERNAL *ObjDesc = NULL;
ACPI_OBJECT_INTERNAL *ValDesc = NULL;
@ -155,25 +156,26 @@ AmlExecDyadic1 (
ACPI_STATUS Status = AE_OK;
FUNCTION_TRACE_PTR ("AmlExecDyadic1", Operands);
FUNCTION_TRACE_PTR ("AmlExecDyadic1", WALK_OPERANDS);
Status = AmlPrepOperands ("nl", Operands);
/* Resolve all operands */
if (Status != AE_OK)
{
/* Invalid parameters on object stack */
AmlAppendOperandDiag (_THIS_MODULE, __LINE__, Opcode, Operands, 2);
goto Cleanup;
}
DUMP_OPERANDS (Operands, IMODE_Execute, PsGetOpcodeName (Opcode), 2, "after AmlPrepOperands");
Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS);
DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), 2, "after AcpiAmlResolveOperands");
/* Get the operands */
ValDesc = Operands[0];
ObjDesc = Operands[-1];
Status |= AcpiDsObjStackPopObject (&ValDesc, WalkState);
Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState);
if (ACPI_FAILURE (Status))
{
/* Invalid parameters on object stack */
AcpiAmlAppendOperandDiag (_THIS_MODULE, __LINE__, Opcode, WALK_OPERANDS, 2);
goto Cleanup;
}
/* Examine the opcode */
@ -183,7 +185,7 @@ AmlExecDyadic1 (
/* DefNotify := NotifyOp NotifyObject NotifyValue */
case AML_NotifyOp:
case AML_NOTIFY_OP:
/* The ObjDesc is actually an NTE */
@ -196,14 +198,14 @@ AmlExecDyadic1 (
{
switch (Entry->Type)
{
case ACPI_TYPE_Device:
case ACPI_TYPE_Thermal:
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_THERMAL:
/* Requires that Device and ThermalZone be compatible mappings */
/* Dispatch the notify to the appropriate handler */
EvNotifyDispatch (Entry, ValDesc->Number.Value);
AcpiEvNotifyDispatch (Entry, ValDesc->Number.Value);
break;
default:
@ -225,8 +227,8 @@ Cleanup:
/* Always delete both operands */
CmDeleteOperand (&Operands[0]);
CmDeleteOperand (&Operands[-1]);
AcpiCmRemoveReference (ValDesc);
AcpiCmRemoveReference (ObjDesc);
return_ACPI_STATUS (Status);
@ -235,7 +237,7 @@ Cleanup:
/*****************************************************************************
*
* FUNCTION: AmlExecDyadic2R
* FUNCTION: AcpiAmlExecDyadic2R
*
* PARAMETERS: Opcode - The opcode to be executed
*
@ -249,103 +251,68 @@ Cleanup:
****************************************************************************/
ACPI_STATUS
AmlExecDyadic2R (
AcpiAmlExecDyadic2R (
UINT16 Opcode,
ACPI_OBJECT_INTERNAL **Operands,
ACPI_WALK_STATE *WalkState,
ACPI_OBJECT_INTERNAL **ReturnDesc)
{
ACPI_OBJECT_INTERNAL *ObjDesc;
ACPI_OBJECT_INTERNAL *ObjDesc2;
ACPI_OBJECT_INTERNAL *ResDesc = NULL;
ACPI_OBJECT_INTERNAL *ResDesc2 = NULL;
ACPI_OBJECT_INTERNAL *RetDesc = NULL;
ACPI_OBJECT_INTERNAL *RetDesc2 = NULL;
ACPI_STATUS Status;
ACPI_OBJECT_INTERNAL *ObjDesc = NULL;
ACPI_OBJECT_INTERNAL *ObjDesc2 = NULL;
ACPI_OBJECT_INTERNAL *ResDesc = NULL;
ACPI_OBJECT_INTERNAL *ResDesc2 = NULL;
ACPI_OBJECT_INTERNAL *RetDesc = NULL;
ACPI_OBJECT_INTERNAL *RetDesc2 = NULL;
ACPI_STATUS Status = AE_OK;
UINT32 Remainder;
INT32 NumOperands;
INT32 NumOperands = 3;
char *NewBuf;
FUNCTION_TRACE_PTR ("AmlExecDyadic2R", Operands);
FUNCTION_TRACE_U32 ("AmlExecDyadic2R", Opcode);
/* Examine the opcode */
/* Resolve all operands */
switch (Opcode)
Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS);
DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), NumOperands, "after AcpiAmlResolveOperands");
/* Get all operands */
if (AML_DIVIDE_OP == Opcode)
{
/* DefConcat := ConcatOp Data1 Data2 Result */
case AML_ConcatOp:
Status = AmlPrepOperands ("lss", Operands);
NumOperands = 3;
break;
/* DefDivide := DivideOp Dividend Divisor Remainder Quotient */
case AML_DivideOp:
Status = AmlPrepOperands ("llnn", Operands);
NumOperands = 4;
break;
/* DefX := XOp Operand1 Operand2 Result */
default:
Status = AmlPrepOperands ("lnn", Operands);
NumOperands = 3;
break;
Status |= AcpiDsObjStackPopObject (&ResDesc2, WalkState);
}
Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState);
Status |= AcpiDsObjStackPopObject (&ObjDesc2, WalkState);
Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState);
if (Status != AE_OK)
{
AmlAppendOperandDiag (_THIS_MODULE, __LINE__, Opcode, Operands, NumOperands);
AcpiAmlAppendOperandDiag (_THIS_MODULE, __LINE__, Opcode, &(WalkState->Operands [WalkState->NumOperands -1]), NumOperands);
goto Cleanup;
}
DUMP_OPERANDS (Operands, IMODE_Execute, PsGetOpcodeName (Opcode), NumOperands, "after AmlPrepOperands");
/* Get all operand and result objects from the stack */
if (AML_DivideOp == Opcode)
{
ResDesc2 = Operands[0];
ResDesc = Operands[-1];
ObjDesc2 = Operands[-2];
ObjDesc = Operands[-3];
}
else
{
ResDesc = Operands[0];
ObjDesc2 = Operands[-1];
ObjDesc = Operands[-2];
}
/* Create an internal return object if necessary */
switch (Opcode)
{
case AML_AddOp:
case AML_BitAndOp:
case AML_BitNandOp:
case AML_BitOrOp:
case AML_BitNorOp:
case AML_BitXorOp:
case AML_DivideOp:
case AML_MultiplyOp:
case AML_ShiftLeftOp:
case AML_ShiftRightOp:
case AML_SubtractOp:
case AML_ADD_OP:
case AML_BIT_AND_OP:
case AML_BIT_NAND_OP:
case AML_BIT_OR_OP:
case AML_BIT_NOR_OP:
case AML_BIT_XOR_OP:
case AML_DIVIDE_OP:
case AML_MULTIPLY_OP:
case AML_SHIFT_LEFT_OP:
case AML_SHIFT_RIGHT_OP:
case AML_SUBTRACT_OP:
RetDesc = CmCreateInternalObject (ACPI_TYPE_Number);
RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
if (!RetDesc)
{
Status = AE_NO_MEMORY;
@ -365,7 +332,7 @@ AmlExecDyadic2R (
/* DefAdd := AddOp Operand1 Operand2 Result */
case AML_AddOp:
case AML_ADD_OP:
RetDesc->Number.Value = ObjDesc->Number.Value + ObjDesc2->Number.Value;
break;
@ -373,7 +340,7 @@ AmlExecDyadic2R (
/* DefAnd := AndOp Operand1 Operand2 Result */
case AML_BitAndOp:
case AML_BIT_AND_OP:
RetDesc->Number.Value = ObjDesc->Number.Value & ObjDesc2->Number.Value;
break;
@ -381,7 +348,7 @@ AmlExecDyadic2R (
/* DefNAnd := NAndOp Operand1 Operand2 Result */
case AML_BitNandOp:
case AML_BIT_NAND_OP:
RetDesc->Number.Value = ~(ObjDesc->Number.Value & ObjDesc2->Number.Value);
break;
@ -389,7 +356,7 @@ AmlExecDyadic2R (
/* DefOr := OrOp Operand1 Operand2 Result */
case AML_BitOrOp:
case AML_BIT_OR_OP:
RetDesc->Number.Value = ObjDesc->Number.Value | ObjDesc2->Number.Value;
break;
@ -397,7 +364,7 @@ AmlExecDyadic2R (
/* DefNOr := NOrOp Operand1 Operand2 Result */
case AML_BitNorOp:
case AML_BIT_NOR_OP:
RetDesc->Number.Value = ~(ObjDesc->Number.Value | ObjDesc2->Number.Value);
break;
@ -405,7 +372,7 @@ AmlExecDyadic2R (
/* DefXOr := XOrOp Operand1 Operand2 Result */
case AML_BitXorOp:
case AML_BIT_XOR_OP:
RetDesc->Number.Value = ObjDesc->Number.Value ^ ObjDesc2->Number.Value;
break;
@ -413,17 +380,18 @@ AmlExecDyadic2R (
/* DefDivide := DivideOp Dividend Divisor Remainder Quotient */
case AML_DivideOp:
case AML_DIVIDE_OP:
if ((UINT32) 0 == ObjDesc2->Number.Value)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlExecDyadic2R/DivideOp: Divide by zero\n"));
REPORT_ERROR ("AmlExecDyadic2R/DivideOp: Divide by zero");
Status = AE_AML_DIVIDE_BY_ZERO;
goto Cleanup;
}
RetDesc2 = CmCreateInternalObject (ACPI_TYPE_Number);
RetDesc2 = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
if (!RetDesc2)
{
Status = AE_NO_MEMORY;
@ -431,14 +399,14 @@ AmlExecDyadic2R (
}
Remainder = ObjDesc->Number.Value % ObjDesc2->Number.Value;
RetDesc->Number.Value = ObjDesc->Number.Value / ObjDesc2->Number.Value; /* Result (what we used to call the quotient) */
RetDesc2->Number.Value = Remainder; /* Remainder */
RetDesc2->Number.Value = ObjDesc->Number.Value / ObjDesc2->Number.Value; /* Result (what we used to call the quotient) */
RetDesc->Number.Value = Remainder; /* Remainder */
break;
/* DefMultiply := MultiplyOp Operand1 Operand2 Result */
case AML_MultiplyOp:
case AML_MULTIPLY_OP:
RetDesc->Number.Value = ObjDesc->Number.Value * ObjDesc2->Number.Value;
break;
@ -446,7 +414,7 @@ AmlExecDyadic2R (
/* DefShiftLeft := ShiftLeftOp Operand ShiftCount Result */
case AML_ShiftLeftOp:
case AML_SHIFT_LEFT_OP:
RetDesc->Number.Value = ObjDesc->Number.Value << ObjDesc2->Number.Value;
break;
@ -454,7 +422,7 @@ AmlExecDyadic2R (
/* DefShiftRight := ShiftRightOp Operand ShiftCount Result */
case AML_ShiftRightOp:
case AML_SHIFT_RIGHT_OP:
RetDesc->Number.Value = ObjDesc->Number.Value >> ObjDesc2->Number.Value;
break;
@ -462,7 +430,7 @@ AmlExecDyadic2R (
/* DefSubtract := SubtractOp Operand1 Operand2 Result */
case AML_SubtractOp:
case AML_SUBTRACT_OP:
RetDesc->Number.Value = ObjDesc->Number.Value - ObjDesc2->Number.Value;
break;
@ -470,7 +438,7 @@ AmlExecDyadic2R (
/* DefConcat := ConcatOp Data1 Data2 Result */
case AML_ConcatOp:
case AML_CONCAT_OP:
if (ObjDesc2->Common.Type != ObjDesc->Common.Type)
{
@ -482,9 +450,9 @@ AmlExecDyadic2R (
/* Both operands are now known to be the same */
if (ACPI_TYPE_String == ObjDesc->Common.Type)
if (ACPI_TYPE_STRING == ObjDesc->Common.Type)
{
RetDesc = CmCreateInternalObject (ACPI_TYPE_String);
RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING);
if (!RetDesc)
{
Status = AE_NO_MEMORY;
@ -493,7 +461,7 @@ AmlExecDyadic2R (
/* Operand1 is string */
NewBuf = CmAllocate ((ACPI_SIZE) (ObjDesc->String.Length
NewBuf = AcpiCmAllocate ((ACPI_SIZE) (ObjDesc->String.Length
+ ObjDesc2->String.Length + 1));
if (!NewBuf)
{
@ -515,20 +483,20 @@ AmlExecDyadic2R (
{
/* Operand1 is not a string ==> must be a buffer */
RetDesc = CmCreateInternalObject (ACPI_TYPE_Buffer);
RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_BUFFER);
if (!RetDesc)
{
Status = AE_NO_MEMORY;
goto Cleanup;
}
NewBuf = CmAllocate ((ACPI_SIZE) (ObjDesc->Buffer.Length
NewBuf = AcpiCmAllocate ((ACPI_SIZE) (ObjDesc->Buffer.Length
+ ObjDesc2->Buffer.Length));
if (!NewBuf)
{
/* Only bail out if the buffer is small */
/* TBD: what is the point of this code? */
/* TBD: [Investigate] what is the point of this code? */
if (ObjDesc->Buffer.Length + ObjDesc2->Buffer.Length < 1024)
{
@ -572,31 +540,21 @@ AmlExecDyadic2R (
* descriptor (ResDesc).
*/
if ((Status = AmlExecStore (RetDesc, ResDesc)) != AE_OK)
if ((Status = AcpiAmlExecStore (RetDesc, ResDesc)) != AE_OK)
{
goto Cleanup;
}
if (AML_DivideOp == Opcode)
if (AML_DIVIDE_OP == Opcode)
{
Status = AmlExecStore (RetDesc2, ResDesc2);
Status = AcpiAmlExecStore (RetDesc2, ResDesc2);
/*
* Since the remainder is not returned, check now if it should
* be deleted (isn't being referenced)
* Since the remainder is not returned, remove a reference to
* the object we created earlier
*/
if (RetDesc2->Common.ReferenceCount == 1)
{
CmDeleteInternalObject (RetDesc2);
}
}
if (RetDesc->Common.ReferenceCount > 1)
{
DEBUG_PRINT (TRACE_EXEC, ("AmlExecDyadic2R: Return Obj %p has other refs, incrementing\n",
RetDesc));
CmUpdateObjectReference (RetDesc, REF_INCREMENT);
AcpiCmRemoveReference (RetDesc2);
}
@ -604,42 +562,27 @@ Cleanup:
/* Always delete the operands */
if (AML_DivideOp == Opcode)
{
CmDeleteOperand (&Operands[-2]);
CmDeleteOperand (&Operands[-3]);
AcpiCmRemoveReference (ObjDesc);
AcpiCmRemoveReference (ObjDesc2);
/* On failure, delete the result ops */
if (ACPI_FAILURE (Status))
{
CmDeleteOperand (&Operands[-1]);
CmDeleteOperand (&Operands[0]);
}
}
else
{
CmDeleteOperand (&Operands[-1]);
CmDeleteOperand (&Operands[-2]);
/* On failure, delete the result op */
if (ACPI_FAILURE (Status))
{
CmDeleteOperand (&Operands[0]);
}
}
/* Delete return object on error */
if (ACPI_FAILURE (Status) &&
(RetDesc))
if (ACPI_FAILURE (Status))
{
CmDeleteInternalObject (RetDesc);
RetDesc = NULL;
}
/* On failure, delete the result ops */
AcpiCmRemoveReference (ResDesc);
AcpiCmRemoveReference (ResDesc2);
if (RetDesc)
{
/* And delete the internal return object */
AcpiCmRemoveReference (RetDesc);
RetDesc = NULL;
}
}
/* Set the return object and exit */
@ -650,7 +593,7 @@ Cleanup:
/*****************************************************************************
*
* FUNCTION: AmlExecDyadic2S
* FUNCTION: AcpiAmlExecDyadic2S
*
* PARAMETERS: Opcode - The opcode to be executed
*
@ -663,82 +606,48 @@ Cleanup:
****************************************************************************/
ACPI_STATUS
AmlExecDyadic2S (
AcpiAmlExecDyadic2S (
UINT16 Opcode,
ACPI_OBJECT_INTERNAL **Operands,
ACPI_WALK_STATE *WalkState,
ACPI_OBJECT_INTERNAL **ReturnDesc)
{
ACPI_OBJECT_INTERNAL *ObjDesc;
ACPI_OBJECT_INTERNAL *TimeDesc;
ACPI_OBJECT_INTERNAL *RetDesc = NULL;
NAME_TABLE_ENTRY *ThisEntry;
ACPI_STATUS Status;
FUNCTION_TRACE_PTR ("AmlExecDyadic2S", Operands);
FUNCTION_TRACE_PTR ("AmlExecDyadic2S", WALK_OPERANDS);
Status = AmlPrepOperands ("nl", Operands);
/* Resolve all operands */
Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS);
DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), 2, "after AcpiAmlResolveOperands");
/* Get all operands */
Status |= AcpiDsObjStackPopObject (&TimeDesc, WalkState);
Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState);
if (Status != AE_OK)
{
/* Invalid parameters on object stack */
AmlAppendOperandDiag (_THIS_MODULE, __LINE__, Opcode, Operands, 2);
AcpiAmlAppendOperandDiag (_THIS_MODULE, __LINE__, Opcode, WALK_OPERANDS, 2);
goto Cleanup;
}
/* Get the operands and validate them */
DUMP_OPERANDS (Operands, IMODE_Execute, PsGetOpcodeName (Opcode), 2, "after AmlPrepOperands");
TimeDesc = Operands[0];
ObjDesc = Operands[-1];
if (!TimeDesc || !ObjDesc)
{
Status = AE_AML_NO_OPERAND;
goto Cleanup;
}
/* ObjDesc can be an NTE */
if (VALID_DESCRIPTOR_TYPE (ObjDesc, DESC_TYPE_NTE))
{
ThisEntry = (NAME_TABLE_ENTRY *) ObjDesc;
ObjDesc = NsGetAttachedObject ((ACPI_HANDLE) ThisEntry);
if (!ObjDesc)
{
/* No object present, create a Mutex object */
ObjDesc = CmCreateInternalObject (ACPI_TYPE_Mutex);
if (!ObjDesc)
{
Status = AE_NO_MEMORY;
goto Cleanup;
}
/* Initialize the new object and install it in the NTE */
ObjDesc->Mutex.SyncLevel = 0;
ObjDesc->Mutex.Semaphore = 0;
ObjDesc->Mutex.LockCount = 0;
ObjDesc->Mutex.ThreadId = 0;
NsAttachObject ((ACPI_HANDLE) ThisEntry, ObjDesc, ACPI_TYPE_Mutex);
}
}
/* Create the internal return object */
RetDesc = CmCreateInternalObject (ACPI_TYPE_Number);
RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
if (!RetDesc)
{
Status = AE_NO_MEMORY;
goto Cleanup;
}
RetDesc->Number.Value = 0; /* Default return value is FALSE, operation did not time out */
/* Examine the opcode */
@ -748,31 +657,15 @@ AmlExecDyadic2S (
/* DefAcquire := AcquireOp MutexObject Timeout */
case AML_AcquireOp:
if (ACPI_TYPE_Mutex != ObjDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlExecDyadic2S/AcquireOp: Needed Mutex, found %d\n",
ObjDesc->Common.Type));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
case AML_ACQUIRE_OP:
Status = OsAcquireMutex (TimeDesc, ObjDesc);
break;
/* DefWait := WaitOp EventObject Timeout */
/* DefWait := WaitOp AcpiEventObject Timeout */
case AML_WaitOp:
if (ACPI_TYPE_Event != ObjDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlExecDyadic2S/WaitOp: Needed Event, found %d\n",
ObjDesc->Common.Type));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
case AML_WAIT_OP:
Status = OsWaitEvent (TimeDesc, ObjDesc);
break;
@ -792,11 +685,7 @@ AmlExecDyadic2S (
if (Status == AE_TIME)
{
RetDesc->Number.Value = (UINT32)(-1); /* TRUE, operation timed out */
}
else
{
RetDesc->Number.Value = 0; /* FALSE, operation did not time out */
Status = AE_OK;
}
@ -805,15 +694,15 @@ Cleanup:
/* Delete params */
CmDeleteOperand (&Operands[0]);
CmDeleteOperand (&Operands[-1]);
AcpiCmRemoveReference (TimeDesc);
AcpiCmRemoveReference (ObjDesc);
/* Delete return object on error */
if (ACPI_FAILURE (Status) &&
(RetDesc))
{
CmDeleteInternalObject (RetDesc);
AcpiCmRemoveReference (RetDesc);
RetDesc = NULL;
}
@ -827,7 +716,7 @@ Cleanup:
/*****************************************************************************
*
* FUNCTION: AmlExecDyadic2
* FUNCTION: AcpiAmlExecDyadic2
*
* PARAMETERS: Opcode - The opcode to be executed
*
@ -842,9 +731,9 @@ Cleanup:
****************************************************************************/
ACPI_STATUS
AmlExecDyadic2 (
AcpiAmlExecDyadic2 (
UINT16 Opcode,
ACPI_OBJECT_INTERNAL **Operands,
ACPI_WALK_STATE *WalkState,
ACPI_OBJECT_INTERNAL **ReturnDesc)
{
ACPI_OBJECT_INTERNAL *ObjDesc;
@ -854,27 +743,32 @@ AmlExecDyadic2 (
BOOLEAN Lboolean;
FUNCTION_TRACE_PTR ("AmlExecDyadic2", Operands);
FUNCTION_TRACE_PTR ("AmlExecDyadic2", WALK_OPERANDS);
Status = AmlPrepOperands ("nn", Operands);
/* Resolve all operands */
Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS);
DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), 2, "after AcpiAmlResolveOperands");
/* Get all operands */
Status |= AcpiDsObjStackPopObject (&ObjDesc2, WalkState);
Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState);
if (Status != AE_OK)
{
/* Invalid parameters on object stack */
AmlAppendOperandDiag (_THIS_MODULE, __LINE__, Opcode, Operands, 2);
AcpiAmlAppendOperandDiag (_THIS_MODULE, __LINE__, Opcode, WALK_OPERANDS, 2);
goto Cleanup;
}
DUMP_OPERANDS (Operands, IMODE_Execute, PsGetOpcodeName (Opcode), 2, "after AmlPrepOperands");
ObjDesc2 = Operands[0];
ObjDesc = Operands[-1];
/* Create the internal return object */
RetDesc = CmCreateInternalObject (ACPI_TYPE_Number);
RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
if (!RetDesc)
{
Status = AE_NO_MEMORY;
@ -885,12 +779,13 @@ AmlExecDyadic2 (
* Execute the Opcode
*/
Lboolean = FALSE;
switch (Opcode)
{
/* DefLAnd := LAndOp Operand1 Operand2 */
case AML_LAndOp:
case AML_LAND_OP:
Lboolean = (BOOLEAN) (ObjDesc->Number.Value && ObjDesc2->Number.Value);
break;
@ -898,7 +793,7 @@ AmlExecDyadic2 (
/* DefLEqual := LEqualOp Operand1 Operand2 */
case AML_LEqualOp:
case AML_LEQUAL_OP:
Lboolean = (BOOLEAN) (ObjDesc->Number.Value == ObjDesc2->Number.Value);
break;
@ -906,7 +801,7 @@ AmlExecDyadic2 (
/* DefLGreater := LGreaterOp Operand1 Operand2 */
case AML_LGreaterOp:
case AML_LGREATER_OP:
Lboolean = (BOOLEAN) (ObjDesc->Number.Value > ObjDesc2->Number.Value);
break;
@ -914,7 +809,7 @@ AmlExecDyadic2 (
/* DefLLess := LLessOp Operand1 Operand2 */
case AML_LLessOp:
case AML_LLESS_OP:
Lboolean = (BOOLEAN) (ObjDesc->Number.Value < ObjDesc2->Number.Value);
break;
@ -922,7 +817,7 @@ AmlExecDyadic2 (
/* DefLOr := LOrOp Operand1 Operand2 */
case AML_LOrOp:
case AML_LOR_OP:
Lboolean = (BOOLEAN) (ObjDesc->Number.Value || ObjDesc2->Number.Value);
break;
@ -953,8 +848,8 @@ Cleanup:
/* Always delete operands */
CmDeleteOperand (&Operands[0]);
CmDeleteOperand (&Operands[-1]);
AcpiCmRemoveReference (ObjDesc);
AcpiCmRemoveReference (ObjDesc2);
/* Delete return object on error */
@ -962,7 +857,7 @@ Cleanup:
if (ACPI_FAILURE (Status) &&
(RetDesc))
{
CmDeleteInternalObject (RetDesc);
AcpiCmRemoveReference (RetDesc);
RetDesc = NULL;
}

View File

@ -116,10 +116,11 @@
#define __IEPREP_C__
#include <acpi.h>
#include <interp.h>
#include <amlcode.h>
#include <namesp.h>
#include "acpi.h"
#include "interp.h"
#include "amlcode.h"
#include "namesp.h"
#include "parser.h"
#define _COMPONENT INTERPRETER
@ -129,343 +130,7 @@
/*****************************************************************************
*
* FUNCTION: AmlPrepOperands
*
* PARAMETERS: *Types - String giving operand types needed,
* each a single char, as per below.
*
* RETURN: Status
*
* DESCRIPTION: Convert stack entries to required types
*
* Each character in Types represents one required operand
* and indicates the required Type:
*
* l => Lvalue, also accepts a name table entry which is an
* ACPI_HANDLE instead of an (ACPI_OBJECT_INTERNAL *))
*
* n => Number (Must be ACPI_OBJECT_INTERNAL)
* s => String or Buffer (Must be ACPI_OBJECT_INTERNAL)
* b => Buffer (Must be ACPI_OBJECT_INTERNAL)
* i => If (Must be ACPI_OBJECT_INTERNAL)
* p => Package (Must be ACPI_OBJECT_INTERNAL)
*
* The corresponding stack entry will be converted to the
* required type if possible, else return an exception
*
****************************************************************************/
ACPI_STATUS
AmlPrepOperands (
char *Types,
ACPI_OBJECT_INTERNAL **StackPtr)
{
ACPI_OBJECT_INTERNAL *ObjDesc;
ACPI_STATUS Status = AE_OK;
UINT8 ObjectType;
ACPI_HANDLE TempHandle;
char *ObjectTypeName = NULL;
FUNCTION_TRACE_PTR ("AmlPrepOperands", StackPtr);
DEBUG_PRINT (TRACE_EXEC, ("AmlPrepOperands: NumOperands=%d Types=%s \n",
STRLEN (Types), Types));
/*
* Ensure room on stack for AmlGetRvalue() to operate
* without clobbering top existing entry.
*/
/*
OBSOLETE!
Status = AmlObjStackPush ();
if (AE_OK != Status)
{
return_ACPI_STATUS (Status);
}
*/
/*
* 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, and cannot be converted
* to, the required type; if stack underflows; or upon
* finding a NULL stack entry (which "should never happen").
*/
while (*Types)
{
if (!StackPtr || !*StackPtr)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlPrepOperands: Internal error - null stack entry at %X\n", StackPtr));
Status = AE_AML_INTERNAL;
goto Cleanup;
}
/* Extract useful items */
ObjDesc = *StackPtr;
/* Decode the descriptor type */
if (VALID_DESCRIPTOR_TYPE (ObjDesc, DESC_TYPE_NTE))
{
/* NTE */
ObjectType = ((NAME_TABLE_ENTRY *) ObjDesc)->Type;
DEBUG_EXEC (ObjectTypeName = "[NTE]");
}
else if (VALID_DESCRIPTOR_TYPE (ObjDesc, DESC_TYPE_ACPI_OBJ))
{
/* ACPI internal object */
ObjectType = ObjDesc->Common.Type;
/* Check for bad ACPI_OBJECT_TYPE */
if (!AmlValidateObjectType (ObjectType))
{
DEBUG_PRINT (ACPI_ERROR, ("AmlPrepOperands: Bad operand object type [0x%x]\n", ObjectType));
DEBUG_EXEC (ObjectTypeName = "***Bad object type***");
}
else if (ObjectType == (UINT8) INTERNAL_TYPE_Lvalue)
{
/*
* Decode the Lvalue
*/
switch (ObjDesc->Lvalue.OpCode)
{
case AML_ZeroOp:
DEBUG_PRINT (ACPI_INFO, ("Lvalue Opcode: Zero\n"));
DEBUG_EXEC (ObjectTypeName = "Lvalue Zero");
break;
case AML_OneOp:
DEBUG_PRINT (ACPI_INFO, ("Lvalue Opcode: One\n"));
DEBUG_EXEC (ObjectTypeName = "Lvalue One");
break;
case AML_OnesOp:
DEBUG_PRINT (ACPI_INFO, ("Lvalue Opcode: Ones\n"));
DEBUG_EXEC (ObjectTypeName = "Lvalue Ones");
break;
case AML_DebugOp:
DEBUG_PRINT (ACPI_INFO, ("Lvalue Opcode: DebugObj\n"));
DEBUG_EXEC (ObjectTypeName = "Lvalue DebugObj");
break;
case AML_NameOp:
DEBUG_PRINT (ACPI_INFO, ("Lvalue Opcode: Name\n"));
DEBUG_EXEC (ObjectTypeName = "Lvalue Name");
break;
case AML_IndexOp:
DEBUG_PRINT (ACPI_INFO, ("Lvalue Opcode: Index %p\n", ObjDesc->Lvalue.Object));
DEBUG_EXEC (ObjectTypeName = "Lvalue Index");
break;
case AML_ArgOp:
DEBUG_PRINT (ACPI_INFO, ("Lvalue Opcode: Arg%d\n", ObjDesc->Lvalue.Offset));
DEBUG_EXEC (ObjectTypeName = "Lvalue Argument");
break;
case AML_LocalOp:
DEBUG_PRINT (ACPI_INFO, ("Lvalue Opcode: Local%d\n", ObjDesc->Lvalue.Offset));
DEBUG_EXEC (ObjectTypeName = "Lvalue Local");
break;
default:
DEBUG_PRINT (ACPI_INFO, ("Lvalue Opcode: Unknown [%02x]\n", ObjDesc->Lvalue.OpCode));
DEBUG_EXEC (ObjectTypeName = "Lvalue [Unknown]");
Status = AE_TYPE;
goto Cleanup;
break;
}
}
else
{
DEBUG_EXEC (ObjectTypeName = CmGetTypeName (ObjectType));
}
}
else
{
/* Invalid descriptor */
DEBUG_PRINT (ACPI_ERROR, ("Bad descriptor type: %x\n", ObjDesc->Common.DataType));
Status = AE_TYPE;
goto Cleanup;
}
/*
* Decode a character from the type string
*/
switch (*Types++)
{
case 'l': /* Lvalue */
/* Need an operand of type INTERNAL_TYPE_Lvalue */
if (VALID_DESCRIPTOR_TYPE (ObjDesc, DESC_TYPE_NTE)) /* direct name ptr OK as-is */
{
break;
}
if (INTERNAL_TYPE_Lvalue != ObjectType)
{
DEBUG_PRINT (ACPI_INFO, ("AmlPrepOperands: Needed Lvalue, found %s Obj=%p\n",
ObjectTypeName, *StackPtr));
Status = AE_TYPE;
goto Cleanup;
}
if (AML_NameOp == ObjDesc->Lvalue.OpCode)
{
/* Convert an indirect name ptr to direct name ptr and put it on the stack */
TempHandle = ObjDesc->Lvalue.Object;
CmDeleteInternalObject (ObjDesc);
(*StackPtr) = TempHandle;
}
break;
case 'n': /* Number */
/* Need an operand of type ACPI_TYPE_Number */
if ((Status = AmlGetRvalue (StackPtr)) != AE_OK)
{
goto Cleanup;
}
if (ACPI_TYPE_Number != (*StackPtr)->Common.Type)
{
DEBUG_PRINT (ACPI_INFO, ("AmlPrepOperands: Needed Number, found %s Obj=%p\n",
ObjectTypeName, *StackPtr));
Status = AE_TYPE;
goto Cleanup;
}
break;
case 's': /* String */
/* Need an operand of type ACPI_TYPE_String or ACPI_TYPE_Buffer */
if ((Status = AmlGetRvalue (StackPtr)) != AE_OK)
{
goto Cleanup;
}
if ((ACPI_TYPE_String != (*StackPtr)->Common.Type) &&
(ACPI_TYPE_Buffer != (*StackPtr)->Common.Type))
{
DEBUG_PRINT (ACPI_INFO, ("AmlPrepOperands: Needed String or Buffer, found %s Obj=%p\n",
ObjectTypeName, *StackPtr));
Status = AE_TYPE;
goto Cleanup;
}
break;
case 'b': /* Buffer */
/* Need an operand of type ACPI_TYPE_Buffer */
if ((Status = AmlGetRvalue(StackPtr)) != AE_OK)
{
goto Cleanup;
}
if (ACPI_TYPE_Buffer != (*StackPtr)->Common.Type)
{
DEBUG_PRINT (ACPI_INFO, ("AmlPrepOperands: Needed Buffer, found %s Obj=%p\n",
ObjectTypeName, *StackPtr));
Status = AE_TYPE;
goto Cleanup;
}
break;
case 'i': /* If */
/* Need an operand of type INTERNAL_TYPE_If */
if (INTERNAL_TYPE_If != (*StackPtr)->Common.Type)
{
DEBUG_PRINT (ACPI_INFO, ("AmlPrepOperands: Needed If, found %s Obj=%p\n",
ObjectTypeName, *StackPtr));
Status = AE_TYPE;
goto Cleanup;
}
break;
case 'p': /* Package */
/* Need an operand of type ACPI_TYPE_Package */
if ((Status = AmlGetRvalue (StackPtr)) != AE_OK)
{
goto Cleanup;
}
if (ACPI_TYPE_Package != (*StackPtr)->Common.Type)
{
DEBUG_PRINT (ACPI_INFO, ("AmlPrepOperands: Needed Package, found %s Obj=%p\n",
ObjectTypeName, *StackPtr));
Status = AE_TYPE;
goto Cleanup;
}
break;
/* Unknown abbreviation passed in */
default:
DEBUG_PRINT (ACPI_ERROR, ("AmlPrepOperands: Internal error - Unknown type flag %02x\n",
*--Types));
Status = AE_BAD_PARAMETER;
goto Cleanup;
} /* switch (*Types++) */
/*
* If more operands needed, decrement StackPtr to point
* to next operand on stack (after checking for underflow).
*/
if (*Types)
{
StackPtr--;
}
} /* while (*Types) */
Cleanup:
return_ACPI_STATUS (Status);
}
/*****************************************************************************
*
* FUNCTION: AmlDecodeFieldAccessType
* FUNCTION: AcpiAmlDecodeFieldAccessType
*
* PARAMETERS: Access - Encoded field access bits
*
@ -476,25 +141,25 @@ Cleanup:
****************************************************************************/
UINT32
AmlDecodeFieldAccessType (
AcpiAmlDecodeFieldAccessType (
UINT32 Access)
{
switch (Access)
{
case ACCESS_AnyAcc:
case ACCESS_ANY_ACC:
return 8;
break;
case ACCESS_ByteAcc:
case ACCESS_BYTE_ACC:
return 8;
break;
case ACCESS_WordAcc:
case ACCESS_WORD_ACC:
return 16;
break;
case ACCESS_DWordAcc:
case ACCESS_DWORD_ACC:
return 32;
break;
@ -508,102 +173,163 @@ AmlDecodeFieldAccessType (
}
/*****************************************************************************
*
* FUNCTION: AmlPrepDefFieldValue
* FUNCTION: AcpiAmlPrepCommonFieldObjec
*
* PARAMETERS: Region - Region in which field is being defined
* FldFlg - Access, LockRule, or UpdateRule.
* PARAMETERS: ObjDesc - The field object
* FieldFlags - Access, LockRule, or UpdateRule.
* The format of a FieldFlag is described
* in the ACPI specification and in <aml.h>
* FldPos - Field position
* FldLen - Field length
* FieldPosition - Field position
* FieldLength - Field length
*
* RETURN: Status
*
* DESCRIPTION: Construct an ACPI_OBJECT_INTERNAL of type DefField and connect
* it to the nte whose handle is at the object stack top.
* DESCRIPTION: Initialize the areas of the field object that are common
* to the various types of fields.
*
****************************************************************************/
ACPI_STATUS
AmlPrepDefFieldValue (
AcpiAmlPrepCommonFieldObject (
ACPI_OBJECT_INTERNAL *ObjDesc,
UINT8 FieldFlags,
UINT8 FieldAttribute,
UINT32 FieldPosition,
UINT32 FieldLength)
{
UINT32 Granularity;
FUNCTION_TRACE ("AmlPrepCommonFieldObject");
/*
* Note: the structure being initialized is the
* ACPI_COMMON_FIELD_INFO; Therefore, we can just use the Field union to
* access this common area. No structure fields outside of the common area
* are initialized by this procedure.
*/
/* Decode the FieldFlags */
ObjDesc->Field.Access = (UINT8) ((FieldFlags & ACCESS_TYPE_MASK) >> ACCESS_TYPE_SHIFT);
ObjDesc->Field.LockRule = (UINT8) ((FieldFlags & LOCK_RULE_MASK) >> LOCK_RULE_SHIFT);
ObjDesc->Field.UpdateRule = (UINT8) ((FieldFlags & UPDATE_RULE_MASK) >> UPDATE_RULE_SHIFT);
/* Other misc fields */
ObjDesc->Field.Length = (UINT16) FieldLength;
ObjDesc->Field.AccessAttribute = FieldAttribute;
/* Decode the access type so we can compute offsets */
Granularity = AcpiAmlDecodeFieldAccessType (ObjDesc->Field.Access);
if (!Granularity)
{
return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
}
/* Access granularity based fields */
ObjDesc->Field.Granularity = (UINT8) Granularity;
ObjDesc->Field.BitOffset = (UINT8) (FieldPosition % Granularity);
ObjDesc->Field.Offset = (UINT32) FieldPosition / Granularity;
return_ACPI_STATUS (AE_OK);
}
/*****************************************************************************
*
* FUNCTION: AcpiAmlPrepDefFieldValue
*
* PARAMETERS: ThisEntry - Owning NTE
* Region - Region in which field is being defined
* FieldFlags - Access, LockRule, or UpdateRule.
* The format of a FieldFlag is described
* in the ACPI specification and in <aml.h>
* FieldPosition - Field position
* FieldLength - Field length
*
* RETURN: Status
*
* DESCRIPTION: Construct an ACPI_OBJECT_INTERNAL of type DefField and
* connect it to the parent NTE.
*
****************************************************************************/
ACPI_STATUS
AcpiAmlPrepDefFieldValue (
NAME_TABLE_ENTRY *ThisEntry,
ACPI_HANDLE Region,
UINT8 FldFlg,
INT32 FldPos,
INT32 FldLen)
UINT8 FieldFlags,
UINT8 FieldAttribute,
UINT32 FieldPosition,
UINT32 FieldLength)
{
ACPI_OBJECT_INTERNAL *ObjDesc = NULL;
ACPI_OBJECT_INTERNAL *ObjDesc;
INT32 Type;
UINT32 Granularity;
ACPI_STATUS Status;
FUNCTION_TRACE ("AmlPrepDefFieldValue");
/* Parameter validation */
if (!Region)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlPrepDefFieldValue: null Region\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
/* Region typecheck */
if (ACPI_TYPE_Region != (Type = NsGetType (Region)))
Type = AcpiNsGetType (Region);
if (Type != ACPI_TYPE_REGION)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlPrepDefFieldValue: Needed Region, found %d %s\n",
Type, CmGetTypeName (Type)));
Type, AcpiCmGetTypeName (Type)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/* Allocate a new object */
ObjDesc = CmCreateInternalObject (INTERNAL_TYPE_DefField);
ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_DEF_FIELD);
if (!ObjDesc)
{
/* Unable to allocate new object descriptor */
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* ObjDesc and Region valid */
DUMP_OPERANDS ((ACPI_OBJECT_INTERNAL **) &ThisEntry, IMODE_Execute, "AmlPrepDefFieldValue", 1, "case DefField");
DUMP_OPERANDS ((ACPI_OBJECT_INTERNAL **) &Region, IMODE_Execute, "AmlPrepDefFieldValue", 1, "case DefField");
DUMP_OPERANDS ((ACPI_OBJECT_INTERNAL **) &ThisEntry, IMODE_EXECUTE, "AmlPrepDefFieldValue", 1, "case DefField");
DUMP_OPERANDS ((ACPI_OBJECT_INTERNAL **) &Region, IMODE_EXECUTE, "AmlPrepDefFieldValue", 1, "case DefField");
/* ObjDesc, Region, and ObjDesc->Field.Type valid */
/* Initialize areas of the object that are common to all fields */
ObjDesc->Field.Length = (UINT16) FldLen;
ObjDesc->Field.UpdateRule = (UINT8) ((FldFlg & UPDATE_RULE_MASK) >> UPDATE_RULE_SHIFT);
ObjDesc->Field.LockRule = (UINT8) ((FldFlg & LOCK_RULE_MASK) >> LOCK_RULE_SHIFT);
ObjDesc->Field.Access = (UINT8) ((FldFlg & ACCESS_TYPE_MASK) >> ACCESS_TYPE_SHIFT);
/* Decode the access type so we can compute offsets */
Granularity = AmlDecodeFieldAccessType (ObjDesc->Field.Access);
if (!Granularity)
Status = AcpiAmlPrepCommonFieldObject (ObjDesc, FieldFlags, FieldAttribute, FieldPosition, FieldLength);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
return_ACPI_STATUS (Status);
}
/* Compute field offset and bit offset within the minimum read/write data unit */
/* Initialize areas of the object that are specific to this field type */
ObjDesc->Field.Granularity = (UINT8) Granularity;
ObjDesc->Field.BitOffset = (UINT8) (FldPos % Granularity);
ObjDesc->Field.Offset = (UINT32) FldPos / Granularity;
ObjDesc->Field.Container = NsGetAttachedObject (Region);
ObjDesc->Field.Container = AcpiNsGetAttachedObject (Region);
/* An additional reference for the container */
CmUpdateObjectReference (ObjDesc->Field.Container, REF_INCREMENT);
AcpiCmAddReference (ObjDesc->Field.Container);
/* Debug output only */
/* Debug info */
DEBUG_PRINT (ACPI_INFO, ("AmlPrepDefFieldValue: bitoff=%X off=%X gran=%X\n",
ObjDesc->Field.BitOffset, ObjDesc->Field.Offset, Granularity));
ObjDesc->Field.BitOffset, ObjDesc->Field.Offset, ObjDesc->Field.Granularity));
DEBUG_PRINT (ACPI_INFO, ("AmlPrepDefFieldValue: set nte %p (%4.4s) val = %p\n",
ThisEntry, &(ThisEntry->Name), ObjDesc));
@ -611,121 +337,114 @@ AmlPrepDefFieldValue (
DUMP_STACK_ENTRY (ObjDesc);
DUMP_ENTRY (Region, ACPI_INFO);
DEBUG_PRINT (ACPI_INFO, ("\t%p \n", ObjDesc->Field.Container));
if (ObjDesc->Field.Container)
{
DUMP_STACK_ENTRY (ObjDesc->Field.Container);
}
DEBUG_PRINT (ACPI_INFO,
("============================================================\n"));
DEBUG_PRINT (ACPI_INFO, ("============================================================\n"));
/*
* Store the constructed descriptor (ObjDesc) into the nte whose
* handle is on TOS, preserving the current type of that nte.
*/
NsAttachObject ((ACPI_HANDLE) ThisEntry, ObjDesc,
(UINT8) NsGetType ((ACPI_HANDLE) ThisEntry));
Status = AcpiNsAttachObject ((ACPI_HANDLE) ThisEntry, ObjDesc,
(UINT8) AcpiNsGetType ((ACPI_HANDLE) ThisEntry));
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS (Status);
}
/*****************************************************************************
*
* FUNCTION: AmlPrepBankFieldValue
* FUNCTION: AcpiAmlPrepBankFieldValue
*
* PARAMETERS: Region - Region in which field is being defined
* PARAMETERS: ThisEntry - Owning NTE
* Region - Region in which field is being defined
* BankReg - Bank selection register
* BankVal - Value to store in selection register
* FldFlg - Access, LockRule, or UpdateRule
* FldPos - Field position
* FldLen - Field length
* FieldFlags - Access, LockRule, or UpdateRule
* FieldPosition - Field position
* FieldLength - Field length
*
* RETURN: Status
*
* DESCRIPTION: Construct an ACPI_OBJECT_INTERNAL of type BankField and connect
* it to the nte whose handle is at the object stack top
* DESCRIPTION: Construct an ACPI_OBJECT_INTERNAL of type BankField and
* connect it to the parent NTE.
*
****************************************************************************/
ACPI_STATUS
AmlPrepBankFieldValue (
AcpiAmlPrepBankFieldValue (
NAME_TABLE_ENTRY *ThisEntry,
ACPI_HANDLE Region,
ACPI_HANDLE BankReg,
UINT32 BankVal,
UINT8 FldFlg,
INT32 FldPos,
INT32 FldLen)
UINT8 FieldFlags,
UINT8 FieldAttribute,
UINT32 FieldPosition,
UINT32 FieldLength)
{
ACPI_OBJECT_INTERNAL *ObjDesc = NULL;
ACPI_OBJECT_INTERNAL *ObjDesc;
INT32 Type;
UINT32 Granularity;
ACPI_STATUS Status;
FUNCTION_TRACE ("AmlPrepBankFieldValue");
/* Parameter validation */
if (!Region)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlPrepBankFieldValue: null Region\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
Type = NsGetType (Region);
if (Type != ACPI_TYPE_Region)
Type = AcpiNsGetType (Region);
if (Type != ACPI_TYPE_REGION)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlPrepBankFieldValue: Needed Region, found %d %s\n",
Type, CmGetTypeName (Type)));
Type, AcpiCmGetTypeName (Type)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/* Allocate a new object */
ObjDesc = CmCreateInternalObject (INTERNAL_TYPE_BankField);
ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_BANK_FIELD);
if (!ObjDesc)
{
/* Unable to allocate new object descriptor */
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* ObjDesc and Region valid */
DUMP_OPERANDS ((ACPI_OBJECT_INTERNAL **) &ThisEntry, IMODE_Execute, "AmlPrepBankFieldValue", 1, "case BankField");
DUMP_OPERANDS ((ACPI_OBJECT_INTERNAL **) &Region, IMODE_Execute, "AmlPrepBankFieldValue", 1, "case BankField");
DUMP_OPERANDS ((ACPI_OBJECT_INTERNAL **) &ThisEntry, IMODE_EXECUTE, "AmlPrepBankFieldValue", 1, "case BankField");
DUMP_OPERANDS ((ACPI_OBJECT_INTERNAL **) &Region, IMODE_EXECUTE, "AmlPrepBankFieldValue", 1, "case BankField");
/* ObjDesc, Region, and ObjDesc->BankField.ValTyp valid */
/* Initialize areas of the object that are common to all fields */
ObjDesc->BankField.Access = (UINT8) ((FldFlg & ACCESS_TYPE_MASK) >> ACCESS_TYPE_SHIFT);
ObjDesc->BankField.LockRule = (UINT8) ((FldFlg & LOCK_RULE_MASK) >> LOCK_RULE_SHIFT);
ObjDesc->BankField.UpdateRule = (UINT8) ((FldFlg & UPDATE_RULE_MASK) >> UPDATE_RULE_SHIFT);
ObjDesc->BankField.Length = (UINT16) FldLen;
/* Decode the access type so we can compute offsets */
Granularity = AmlDecodeFieldAccessType (ObjDesc->Field.Access);
if (!Granularity)
Status = AcpiAmlPrepCommonFieldObject (ObjDesc, FieldFlags, FieldAttribute, FieldPosition, FieldLength);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
return_ACPI_STATUS (Status);
}
ObjDesc->Field.Granularity = (UINT8) Granularity;
ObjDesc->BankField.BitOffset = (UINT8) (FldPos % Granularity);
ObjDesc->BankField.Offset = (UINT32) (FldPos / Granularity);
/* Initialize areas of the object that are specific to this field type */
ObjDesc->BankField.Value = BankVal;
ObjDesc->BankField.Container = NsGetAttachedObject (Region);
ObjDesc->BankField.BankSelect = NsGetAttachedObject (BankReg);
ObjDesc->BankField.Container = AcpiNsGetAttachedObject (Region);
ObjDesc->BankField.BankSelect = AcpiNsGetAttachedObject (BankReg);
/* An additional reference for the container and bank select */
/* TBD: is "BankSelect" ever a real internal object?? */
/* TBD: [Restructure] is "BankSelect" ever a real internal object?? */
CmUpdateObjectReference (ObjDesc->BankField.Container, REF_INCREMENT);
CmUpdateObjectReference (ObjDesc->BankField.BankSelect, REF_INCREMENT);
AcpiCmAddReference (ObjDesc->BankField.Container);
AcpiCmAddReference (ObjDesc->BankField.BankSelect);
/* Debug info */
DEBUG_PRINT (ACPI_INFO, ("AmlPrepBankFieldValue: bitoff=%X off=%X gran=%X\n",
ObjDesc->BankField.BitOffset, ObjDesc->BankField.Offset, Granularity));
ObjDesc->BankField.BitOffset, ObjDesc->BankField.Offset, ObjDesc->Field.Granularity));
DEBUG_PRINT (ACPI_INFO, ("AmlPrepBankFieldValue: set nte %p (%4.4s) val = %p\n",
ThisEntry, &(ThisEntry->Name), ObjDesc));
@ -733,55 +452,56 @@ AmlPrepBankFieldValue (
DUMP_STACK_ENTRY (ObjDesc);
DUMP_ENTRY (Region, ACPI_INFO);
DUMP_ENTRY (BankReg, ACPI_INFO);
DEBUG_PRINT (ACPI_INFO,
("============================================================\n"));
DEBUG_PRINT (ACPI_INFO, ("============================================================\n"));
/*
* Store the constructed descriptor (ObjDesc) into the nte whose
* handle is on TOS, preserving the current type of that nte.
*/
NsAttachObject ((ACPI_HANDLE) ThisEntry, ObjDesc,
(UINT8) NsGetType ((ACPI_HANDLE) ThisEntry));
Status = AcpiNsAttachObject ((ACPI_HANDLE) ThisEntry, ObjDesc,
(UINT8) AcpiNsGetType ((ACPI_HANDLE) ThisEntry));
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS (Status);
}
/*****************************************************************************
*
* FUNCTION: AmlPrepIndexFieldValue
* FUNCTION: AcpiAmlPrepIndexFieldValue
*
* PARAMETERS: IndexReg - Index register
* PARAMETERS: ThisEntry - Owning NTE
* IndexReg - Index register
* DataReg - Data register
* FldFlg - Access, LockRule, or UpdateRule
* FldPos - Field position
* FldLen - Field length
* FieldFlags - Access, LockRule, or UpdateRule
* FieldPosition - Field position
* FieldLength - Field length
*
* RETURN: Status
*
* DESCRIPTION: Construct an ACPI_OBJECT_INTERNAL of type IndexField and connect
* it to the nte whose handle is at the object stack top
* DESCRIPTION: Construct an ACPI_OBJECT_INTERNAL of type IndexField and
* connect it to the parent NTE.
*
****************************************************************************/
ACPI_STATUS
AmlPrepIndexFieldValue (
AcpiAmlPrepIndexFieldValue (
NAME_TABLE_ENTRY *ThisEntry,
ACPI_HANDLE IndexReg,
ACPI_HANDLE DataReg,
UINT8 FldFlg,
INT32 FldPos,
INT32 FldLen)
UINT8 FieldFlags,
UINT8 FieldAttribute,
UINT32 FieldPosition,
UINT32 FieldLength)
{
ACPI_OBJECT_INTERNAL *ObjDesc = NULL;
UINT32 Granularity;
ACPI_OBJECT_INTERNAL *ObjDesc;
ACPI_STATUS Status;
FUNCTION_TRACE ("AmlPrepIndexFieldValue");
/* Parameter validation */
if (!IndexReg || !DataReg)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlPrepIndexFieldValue: null handle\n"));
@ -790,37 +510,30 @@ AmlPrepIndexFieldValue (
/* Allocate a new object descriptor */
ObjDesc = CmCreateInternalObject (INTERNAL_TYPE_IndexField);
ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_INDEX_FIELD);
if (!ObjDesc)
{
/* Unable to allocate new object descriptor */
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* ObjDesc, IndexRegion, and DataReg, and ObjDesc->IndexField.ValTyp valid */
/* Initialize areas of the object that are common to all fields */
ObjDesc->IndexField.Access = (UINT8) ((FldFlg & ACCESS_TYPE_MASK) >> ACCESS_TYPE_SHIFT);
ObjDesc->IndexField.LockRule = (UINT8) ((FldFlg & LOCK_RULE_MASK) >> LOCK_RULE_SHIFT);
ObjDesc->IndexField.UpdateRule = (UINT8) ((FldFlg & UPDATE_RULE_MASK) >> UPDATE_RULE_SHIFT);
ObjDesc->IndexField.Length = (UINT16) FldLen;
/* Decode the access type so we can compute offsets */
Granularity = AmlDecodeFieldAccessType (ObjDesc->Field.Access);
if (!Granularity)
Status = AcpiAmlPrepCommonFieldObject (ObjDesc, FieldFlags, FieldAttribute, FieldPosition, FieldLength);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
return_ACPI_STATUS (Status);
}
ObjDesc->Field.Granularity = (UINT8) Granularity;
ObjDesc->IndexField.BitOffset = (UINT8) (FldPos % Granularity);
ObjDesc->IndexField.Value = (UINT32) (FldPos / Granularity);
/* Initialize areas of the object that are specific to this field type */
ObjDesc->IndexField.Value = (UINT32) (FieldPosition / ObjDesc->Field.Granularity);
ObjDesc->IndexField.Index = IndexReg;
ObjDesc->IndexField.Data = DataReg;
/* Debug info */
DEBUG_PRINT (ACPI_INFO, ("AmlPrepIndexFieldValue: bitoff=%X off=%X gran=%X\n",
ObjDesc->IndexField.BitOffset, ObjDesc->IndexField.Offset, Granularity));
ObjDesc->IndexField.BitOffset, ObjDesc->IndexField.Offset, ObjDesc->Field.Granularity));
DEBUG_PRINT (ACPI_INFO, ("AmlPrepIndexFieldValue: set nte %p (%4.4s) val = %p\n",
ThisEntry, &(ThisEntry->Name), ObjDesc));
@ -828,17 +541,15 @@ AmlPrepIndexFieldValue (
DUMP_STACK_ENTRY (ObjDesc);
DUMP_ENTRY (IndexReg, ACPI_INFO);
DUMP_ENTRY (DataReg, ACPI_INFO);
DEBUG_PRINT (ACPI_INFO,
("============================================================\n"));
DEBUG_PRINT (ACPI_INFO, ("============================================================\n"));
/*
* Store the constructed descriptor (ObjDesc) into the nte whose
* handle is on TOS, preserving the current type of that nte.
*/
NsAttachObject ((ACPI_HANDLE) ThisEntry, ObjDesc,
(UINT8) NsGetType ((ACPI_HANDLE) ThisEntry));
Status = AcpiNsAttachObject ((ACPI_HANDLE) ThisEntry, ObjDesc,
(UINT8) AcpiNsGetType ((ACPI_HANDLE) ThisEntry));
return_ACPI_STATUS (AE_OK);
return_ACPI_STATUS (Status);
}

View File

@ -116,12 +116,12 @@
#define __IEREGION_C__
#include <acpi.h>
#include <interp.h>
#include <amlcode.h>
#include <namesp.h>
#include <hardware.h>
#include <events.h>
#include "acpi.h"
#include "interp.h"
#include "amlcode.h"
#include "namesp.h"
#include "hardware.h"
#include "events.h"
#define _COMPONENT INTERPRETER
@ -130,7 +130,7 @@
/*****************************************************************************
*
* FUNCTION: AmlSystemMemorySpaceHandler
* FUNCTION: AcpiAmlSystemMemorySpaceHandler
*
* PARAMETERS: Function - Read or Write operation
* Address - Where in the space to read or write
@ -145,95 +145,130 @@
****************************************************************************/
ACPI_STATUS
AmlSystemMemorySpaceHandler (
AcpiAmlSystemMemorySpaceHandler (
UINT32 Function,
UINT32 Address,
UINT32 Address, /* TBD: [Future] Should this be A POINTER for 64-bit support? */
UINT32 BitWidth,
UINT32 *Value,
void *Context)
{
ACPI_STATUS Status = AE_OK;
void *PhysicalAddrPtr = NULL;
void *LogicalAddrPtr = NULL;
MEM_HANDLER_CONTEXT *MemInfo = Context;
UINT32 Length;
FUNCTION_TRACE ("AmlSystemMemorySpaceHandler");
/* Decode the function parameter */
/* Validate and translate the bit width */
switch (BitWidth)
{
case 8:
Length = 1;
break;
case 16:
Length = 2;
break;
case 32:
Length = 4;
break;
default:
DEBUG_PRINT (ACPI_ERROR, ("AmlSystemMemorySpaceHandler: Invalid SystemMemory width %d\n", BitWidth));
return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
break;
}
/* Does the request fit into the cached memory mapping? */
if (((char *) Address < MemInfo->MappedPhysicalAddress) || /* Address is below the current mapping */
(((char *) Address + Length) > (MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) /* Goes beyond the current mapping */
{
/*
* The request cannot be resolved by the current memory mapping;
* Delete the existing mapping and create a new one.
*/
if (MemInfo->MappedLength)
{
/* Valid mapping, delete it */
AcpiOsdUnMapMemory (MemInfo->MappedLogicalAddress, MemInfo->MappedLength);
}
MemInfo->MappedLength = 0; /* In case of failure below */
/* Create a new mapping starting at the address given */
Status = AcpiOsdMapMemory ((void *) Address, SYSMEM_REGION_WINDOW_SIZE, (void **) &MemInfo->MappedLogicalAddress);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
MemInfo->MappedPhysicalAddress = (char *) Address;
MemInfo->MappedLength = SYSMEM_REGION_WINDOW_SIZE;
}
/* Generate a logical pointer corresponding to the address we want to access */
LogicalAddrPtr = MemInfo->MappedLogicalAddress + ((char *) Address - MemInfo->MappedPhysicalAddress);
/* Perform the memory read or write */
switch (Function)
{
case ADDRESS_SPACE_READ:
/*
* TBD: This may be too high an overhead to do every time.
* Probably should have a mapping cached.
*/
DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
("Read(%d width) Address:0x%08x\n", BitWidth, Address));
PhysicalAddrPtr = OsdMapMemory ((void *) Address, 4);
("Read (%d width) Address:0x%X\n", BitWidth, Address));
switch (BitWidth)
{
/* System memory width */
case 8:
*Value = (UINT32)* (UINT8 *) PhysicalAddrPtr;
*Value = (UINT32)* (UINT8 *) LogicalAddrPtr;
break;
case 16:
*Value = (UINT32)* (UINT16 *) PhysicalAddrPtr;
STORE16TO32 (Value, LogicalAddrPtr);
break;
case 32:
*Value = * (UINT32 *) PhysicalAddrPtr;
STORE32TO32 (Value, LogicalAddrPtr);
break;
default:
DEBUG_PRINT (ACPI_ERROR,
("AmlSystemMemorySpaceHandler: Invalid SystemMemory width %d\n", BitWidth));
Status = AE_AML_OPERAND_VALUE;
}
OsdUnMapMemory (PhysicalAddrPtr, 4);
break;
case ADDRESS_SPACE_WRITE:
/* TBD: This may be too high an overhead to do every time.
* Probably should have a mapping cached.
*/
DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
("Write(%d width) Address:0x%08x Value 0x%08x\n", BitWidth, Address, *Value));
("Write (%d width) Address:0x%p Value 0x%X\n", BitWidth, Address, *Value));
PhysicalAddrPtr = OsdMapMemory ((void *) Address, 4);
switch (BitWidth)
{
case 8:
*(UINT8 *) PhysicalAddrPtr = (UINT8) *Value;
*(UINT8 *) LogicalAddrPtr = (UINT8) *Value;
break;
case 16:
*(UINT16 *) PhysicalAddrPtr = (UINT16) *Value;
STORE16TO16 (LogicalAddrPtr, Value);
break;
case 32:
*(UINT32 *) PhysicalAddrPtr = *Value;
STORE32TO32 (LogicalAddrPtr, Value);
break;
default:
DEBUG_PRINT (ACPI_ERROR, (
"AmlSystemMemorySpaceHandler: Invalid SystemMemory width %d\n", BitWidth));
Status = AE_AML_OPERAND_VALUE;
}
OsdUnMapMemory (PhysicalAddrPtr, 4);
break;
@ -248,7 +283,7 @@ AmlSystemMemorySpaceHandler (
/*****************************************************************************
*
* FUNCTION: AmlSystemIoSpaceHandler
* FUNCTION: AcpiAmlSystemIoSpaceHandler
*
* PARAMETERS: Function - Read or Write operation
* Address - Where in the space to read or write
@ -263,7 +298,7 @@ AmlSystemMemorySpaceHandler (
****************************************************************************/
ACPI_STATUS
AmlSystemIoSpaceHandler (
AcpiAmlSystemIoSpaceHandler (
UINT32 Function,
UINT32 Address,
UINT32 BitWidth,
@ -291,15 +326,15 @@ AmlSystemIoSpaceHandler (
/* I/O Port width */
case 8:
*Value = (UINT32) OsdIn8 (Address);
*Value = (UINT32) AcpiOsdIn8 ((ACPI_IO_ADDRESS) Address);
break;
case 16:
*Value = (UINT32) OsdIn16 (Address);
*Value = (UINT32) AcpiOsdIn16 ((ACPI_IO_ADDRESS) Address);
break;
case 32:
*Value = OsdIn32 (Address);
*Value = AcpiOsdIn32 ((ACPI_IO_ADDRESS) Address);
break;
default:
@ -320,15 +355,15 @@ AmlSystemIoSpaceHandler (
{
/* I/O Port width */
case 8:
OsdOut8 (Address, (UINT8) *Value);
AcpiOsdOut8 ((ACPI_IO_ADDRESS) Address, (UINT8) *Value);
break;
case 16:
OsdOut16 (Address, (UINT16) *Value);
AcpiOsdOut16 ((ACPI_IO_ADDRESS) Address, (UINT16) *Value);
break;
case 32:
OsdOut32 (Address, *Value);
AcpiOsdOut32 ((ACPI_IO_ADDRESS) Address, *Value);
break;
default:
@ -348,10 +383,9 @@ AmlSystemIoSpaceHandler (
return_ACPI_STATUS (Status);
}
/*****************************************************************************
*
* FUNCTION: AmlPciConfigSpaceHandler
* FUNCTION: AcpiAmlPciConfigSpaceHandler
*
* PARAMETERS: Function - Read or Write operation
* Address - Where in the space to read or write
@ -366,7 +400,7 @@ AmlSystemIoSpaceHandler (
****************************************************************************/
ACPI_STATUS
AmlPciConfigSpaceHandler (
AcpiAmlPciConfigSpaceHandler (
UINT32 Function,
UINT32 Address,
UINT32 BitWidth,
@ -382,10 +416,8 @@ AmlPciConfigSpaceHandler (
FUNCTION_TRACE ("AmlPciConfigSpaceHandler");
/*
* The arguments to Osd(Read|Write)PciCfg(Byte|Word|Dword) are:
* The arguments to AcpiOsd(Read|Write)PciCfg(Byte|Word|Dword) are:
*
* SegBus - 0xSSSSBBBB - SSSS is the PCI bus segment
* BBBB is the PCI bus number
@ -401,11 +433,10 @@ AmlPciConfigSpaceHandler (
PCIContext = (PCI_HANDLER_CONTEXT *) Context;
PciBus = (PCIContext->SegNum) << 16;
PciBus |= PCIContext->BusNum;
PciBus = LOWORD(PCIContext->Seg) << 16;
PciBus |= LOWORD(PCIContext->Bus);
DevFunc = (PCIContext->DevNum) << 16;
DevFunc |= PCIContext->FuncNum;
DevFunc = PCIContext->DevFunc;
PciReg = (UINT8) Address;
@ -415,9 +446,8 @@ AmlPciConfigSpaceHandler (
case ADDRESS_SPACE_READ:
DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
("R%d S(%04x) B(%04x) D(%04x) F(%04x) R(%04x)\n",
BitWidth,PCIContext->SegNum,PCIContext->BusNum,PCIContext->DevNum,
PCIContext->FuncNum, PciReg));
("R%d S(%04x) B(%04x) DF(%08x) R(%04x)\n", BitWidth,
PCIContext->Seg,PCIContext->Bus,PCIContext->DevFunc, PciReg));
*Value = 0;
@ -426,15 +456,15 @@ AmlPciConfigSpaceHandler (
/* PCI Register width */
case 8:
Status = OsdReadPciCfgByte (PciBus, DevFunc, PciReg, (UINT8 *) Value);
Status = AcpiOsdReadPciCfgByte (PciBus, DevFunc, PciReg, (UINT8 *) Value);
break;
case 16:
Status = OsdReadPciCfgWord (PciBus, DevFunc, PciReg, (UINT16 *) Value);
Status = AcpiOsdReadPciCfgWord (PciBus, DevFunc, PciReg, (UINT16 *) Value);
break;
case 32:
Status = OsdReadPciCfgDword (PciBus, DevFunc, PciReg, Value);
Status = AcpiOsdReadPciCfgDword (PciBus, DevFunc, PciReg, Value);
break;
default:
@ -450,24 +480,29 @@ AmlPciConfigSpaceHandler (
case ADDRESS_SPACE_WRITE:
DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
("W%d S(%04x) B(%04x) D(%04x) F(%04x) R(%04x) D(%08x)\n",
BitWidth,PCIContext->SegNum,PCIContext->BusNum,PCIContext->DevNum,
PCIContext->FuncNum, PciReg,*Value));
("R%d S(%04x) B(%04x) DF(%08x) R(%04x)\n", BitWidth,
PCIContext->Seg,PCIContext->Bus,PCIContext->DevFunc, PciReg));
DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
("W%d S(%04x) B(%04x) DF(%08x) R(%04x) D(%08x)\n", BitWidth,
PCIContext->Seg,PCIContext->Bus,PCIContext->DevFunc,
PciReg,*Value));
switch (BitWidth)
{
/* PCI Register width */
case 8:
Status = OsdWritePciCfgByte (PciBus, DevFunc, PciReg, *(UINT8 *) Value);
Status = AcpiOsdWritePciCfgByte (PciBus, DevFunc, PciReg, *(UINT8 *) Value);
break;
case 16:
Status = OsdWritePciCfgWord (PciBus, DevFunc, PciReg, *(UINT16 *) Value);
Status = AcpiOsdWritePciCfgWord (PciBus, DevFunc, PciReg, *(UINT16 *) Value);
break;
case 32:
Status = OsdWritePciCfgDword (PciBus, DevFunc, PciReg, *Value);
Status = AcpiOsdWritePciCfgDword (PciBus, DevFunc, PciReg, *Value);
break;
default:
@ -490,4 +525,3 @@ AmlPciConfigSpaceHandler (
return_ACPI_STATUS (Status);
}

View File

@ -1,8 +1,7 @@
/******************************************************************************
*
* Module Name: amresnte - AML Interpreter object resolution
* $Revision: 1.27 $
*
* Module Name: iresnte - AML Interpreter object resolution
*
*****************************************************************************/
@ -10,8 +9,8 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
* reserved.
*
* 2. License
*
@ -39,9 +38,9 @@
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
@ -49,11 +48,11 @@
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
@ -87,7 +86,7 @@
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
@ -115,86 +114,83 @@
*
*****************************************************************************/
#define __AMRESNTE_C__
#define __IRESNTE_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"
#include "parser.h"
#include "dispatch.h"
#include "interp.h"
#include "namesp.h"
#include "tables.h"
#include "events.h"
#define _COMPONENT INTERPRETER
MODULE_NAME ("amresnte")
MODULE_NAME ("iresnte");
/*******************************************************************************
*
* FUNCTION: AcpiAmlResolveNodeToValue
/*****************************************************************************
*
* FUNCTION: AcpiAmlResolveEntryToValue
*
* PARAMETERS: StackPtr - Pointer to a location on a stack that contains
* a pointer to an Node
*
* a ptr to an NTE
*
* RETURN: Status
*
* DESCRIPTION: Resolve a ACPI_NAMESPACE_NODE (Node,
* A.K.A. a "direct name pointer")
* DESCRIPTION: Resolve a NAME_TABLE_ENTRY (nte, A.K.A. a "direct name pointer")
*
* 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:
* 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:
*
* ACPI_TYPE_INTEGER
* ACPI_TYPE_NUMBER
* ACPI_TYPE_STRING
* ACPI_TYPE_BUFFER
* ACPI_TYPE_MUTEX
* ACPI_TYPE_PACKAGE
*
******************************************************************************/
****************************************************************************/
ACPI_STATUS
AcpiAmlResolveNodeToValue (
ACPI_NAMESPACE_NODE **StackPtr,
ACPI_WALK_STATE *WalkState)
AcpiAmlResolveEntryToValue (
NAME_TABLE_ENTRY **StackPtr)
{
ACPI_STATUS Status = AE_OK;
ACPI_OPERAND_OBJECT *ValDesc = NULL;
ACPI_OPERAND_OBJECT *ObjDesc = NULL;
ACPI_NAMESPACE_NODE *Node;
ACPI_OBJECT_INTERNAL *ValDesc = NULL;
ACPI_OBJECT_INTERNAL *ObjDesc = NULL;
NAME_TABLE_ENTRY *StackEntry;
UINT8 *AmlPointer = NULL;
OBJECT_TYPE_INTERNAL EntryType;
BOOLEAN Locked;
BOOLEAN AttachedAmlPointer = FALSE;
UINT8 AmlOpcode = 0;
ACPI_INTEGER TempVal;
UINT32 TempVal;
OBJECT_TYPE_INTERNAL ObjectType;
FUNCTION_TRACE ("AmlResolveEntryToValue");
Node = *StackPtr;
StackEntry = *StackPtr;
/*
/*
* The stack pointer is a "Direct name ptr", and points to a
* a ACPI_NAMESPACE_NODE (Node). Get the pointer that is attached to
* the Node.
* a NAME_TABLE_ENTRY (nte). Get the pointer that is attached to
* the nte.
*/
ValDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node);
EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
ValDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) StackEntry);
EntryType = AcpiNsGetType ((ACPI_HANDLE) StackEntry);
DEBUG_PRINT (TRACE_EXEC, ("AmlResolveEntryToValue: Entry=%p ValDesc=%p Type=%X\n",
StackEntry, ValDesc, EntryType));
DEBUG_PRINT (TRACE_EXEC,
("AmlResolveEntryToValue: Entry=%p ValDesc=%p Type=%X\n",
Node, ValDesc, EntryType));
/*
* The ValDesc attached to the Node can be either:
* 1) An internal ACPI object
* The ValDesc attached to the NTE can be either:
* 1) An internal ACPI object
* 2) A pointer into the AML stream (into one of the ACPI system tables)
*/
@ -204,35 +200,13 @@ AcpiAmlResolveNodeToValue (
AmlOpcode = *((UINT8 *) ValDesc);
AmlPointer = ((UINT8 *) ValDesc) + 1;
DEBUG_PRINT (TRACE_EXEC,
("AmlResolveEntryToValue: Unparsed AML: %p Len=%X\n",
AmlOpcode, AmlPointer));
DEBUG_PRINT (TRACE_EXEC, ("AmlResolveEntryToValue: Unparsed AML: %p Len=%X\n",
AmlOpcode, AmlPointer));
}
/*
* Several EntryTypes do not require further processing, so
* we will return immediately
*/
/* Devices rarely have an attached object, return the Node
* and Method locals and arguments have a pseudo-Node
*/
if (EntryType == ACPI_TYPE_DEVICE ||
(Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL)))
{
return_ACPI_STATUS (AE_OK);
}
if (!ValDesc)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: No object attached to node %p\n",
Node));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
/*
* Action is based on the type of the Node, which indicates the type
* Action is based on the type of the NTE, which indicates the type
* of the attached object or pointer
*/
switch (EntryType)
@ -240,24 +214,31 @@ AcpiAmlResolveNodeToValue (
case ACPI_TYPE_PACKAGE:
/*
* ValDesc should point to either an ACPI_OBJECT_INTERNAL of
* type Package, or an initialization in the AML stream.
*/
if (!ValDesc)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal error - null ValDesc\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
if (AttachedAmlPointer)
{
/*
* This means that the package initialization is not parsed
* -- should not happen
* This means that the package initialization is not parsed -- should not happen
*/
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Unparsed Packages not supported!\n"));
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Unparsed Packages not supported!\n"));
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
}
/* ValDesc is an internal object in all cases by the time we get here */
if (ACPI_TYPE_PACKAGE != ValDesc->Common.Type)
if (!ValDesc || (ACPI_TYPE_PACKAGE != ValDesc->Common.Type))
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Object not a package, type %X\n",
ValDesc->Common.Type));
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal error - Bad package value\n"));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@ -270,59 +251,62 @@ AcpiAmlResolveNodeToValue (
case ACPI_TYPE_BUFFER:
if (!ValDesc)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal error - null Buffer ValuePtr\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
if (AttachedAmlPointer)
{
/*
* This means that the buffer initialization is not parsed
* -- should not happen
* This means that the buffer initialization is not parsed -- should not happen
*/
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Unparsed Buffers not supported!\n"));
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Unparsed Buffers not supported!\n"));
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
}
/* ValDesc is an internal object in all cases by the time we get here */
if (ACPI_TYPE_BUFFER != ValDesc->Common.Type)
if (!ValDesc || (ACPI_TYPE_BUFFER != ValDesc->Common.Type))
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Object not a buffer, type %X\n",
ValDesc->Common.Type));
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Bad buffer value\n"));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/* Return an additional reference to the object */
ObjDesc = ValDesc;
AcpiCmAddReference (ObjDesc);
DEBUG_PRINT (TRACE_BFIELD, ("AmlResolveEntryToValue: New Buffer descriptor seq# %ld @ %p \n",
ObjDesc->Buffer.Sequence, ObjDesc));
break;
case ACPI_TYPE_STRING:
if (AttachedAmlPointer)
{
/* Allocate a new string object */
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING);
if (!ObjDesc)
{
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Init the internal object */
ObjDesc->String.Pointer = (NATIVE_CHAR *) AmlPointer;
ObjDesc->String.Length = STRLEN (ObjDesc->String.Pointer);
ObjDesc->String.Pointer = (char *) AmlPointer;
ObjDesc->String.Length = STRLEN (AmlPointer);
}
else
{
if (ACPI_TYPE_STRING != ValDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Object not a string, type %X\n",
ValDesc->Common.Type));
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal error - Bad string value\n"));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@ -335,27 +319,106 @@ AcpiAmlResolveNodeToValue (
break;
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_NUMBER:
DEBUG_PRINT (TRACE_EXEC, ("AmlResolveEntryToValue: case Number \n"));
/*
* The Node has an attached internal object, make sure that it's a
* number
*/
if (ACPI_TYPE_INTEGER != ValDesc->Common.Type)
if (!ValDesc)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveToValue: Object not a Number, type %X\n",
ValDesc->Common.Type));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal error - null Number ValuePtr\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
/* Return an additional reference to the object */
/*
* A ACPI_TYPE_NUMBER can be either an object or an AML pointer
*/
if (AttachedAmlPointer)
{
/*
* 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:
STORE16TO32 (&TempVal, &((UINT8 *) ValDesc)[1]);
break;
case AML_DWORD_OP:
STORE32TO32 (&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;
}
else
{
/* The NTE has an attached internal object, make sure 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);
}
ObjDesc = ValDesc;
AcpiCmAddReference (ObjDesc);
break;
@ -364,7 +427,7 @@ AcpiAmlResolveNodeToValue (
/*
* TBD: [Investigate] Is this the correct solution?
*
* This section was extended to convert to generic buffer if
* This section was extended to convert to generic buffer if
* the return length is greater than 32 bits, but still allows
* for returning a type Number for smaller values because the
* caller can then apply arithmetic operators on those fields.
@ -379,15 +442,15 @@ AcpiAmlResolveNodeToValue (
}
else
{
ObjectType = ACPI_TYPE_INTEGER;
ObjectType = ACPI_TYPE_NUMBER;
}
/*
* Create the destination buffer object and the buffer space.
*/
ObjDesc = AcpiCmCreateInternalObject (ObjectType);
if (!ObjDesc)
{
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
@ -396,118 +459,122 @@ AcpiAmlResolveNodeToValue (
*/
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);
return_ACPI_STATUS (AE_NO_MEMORY);
}
ObjDesc->Buffer.Length = ValDesc->Field.Length;
Status = AcpiAmlGetNamedFieldValue ((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))
if (AE_OK != Status)
{
return_ACPI_STATUS (Status);
}
}
else
{
Status = AcpiAmlAccessNamedField (ACPI_READ, (ACPI_HANDLE) Node,
&TempVal, sizeof (TempVal));
Status = AcpiAmlGetNamedFieldValue ((ACPI_HANDLE) StackEntry, &TempVal, sizeof (TempVal));
if (ACPI_FAILURE (Status))
if (AE_OK != Status)
{
return_ACPI_STATUS (Status);
}
ObjDesc->Integer.Value = TempVal;
ObjDesc->Number.Value = TempVal;
}
DEBUG_PRINT (TRACE_EXEC,
("AmlResolveEntryToValue: DefField Entry=%p ValDesc=%p Type=%X\n",
Node, ValDesc, EntryType));
DEBUG_PRINT (TRACE_EXEC, ("AmlResolveEntryToValue: at DefField Entry=%p ValDesc=%p Type=%X\n",
StackEntry, ValDesc, EntryType));
break;
case INTERNAL_TYPE_BANK_FIELD:
if (!ValDesc)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal error - null BankField ValuePtr\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
if (AttachedAmlPointer)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: BankField cannot be an Aml ptr\n"));
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal error - BankField cannot be an AcpiAml ptr\n"));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
if (INTERNAL_TYPE_BANK_FIELD != ValDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR, (
"AmlResolveToValue: Object not a BankField, type %X\n",
ValDesc->Common.Type));
"AmlResolveToValue/BankField:Internal error - Name %4.4s type %d does not match value-type %d at %p\n",
&(((NAME_TABLE_ENTRY *) (*StackPtr))->Name), INTERNAL_TYPE_BANK_FIELD, ValDesc->Common.Type, ValDesc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/* Get the global lock if needed */
ObjDesc = (ACPI_OPERAND_OBJECT *) *StackPtr;
ObjDesc = (ACPI_OBJECT_INTERNAL *) *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));
/* Set Index value to select proper Data register */
/* perform the update */
Status = AcpiAmlSetNamedFieldValue (ValDesc->BankField.BankSelect,
&ValDesc->BankField.Value, sizeof (ValDesc->BankField.Value));
}
AcpiAmlReleaseGlobalLock (Locked);
if (ACPI_FAILURE (Status))
if (AE_OK != Status)
{
return_ACPI_STATUS (Status);
}
/* Read Data value */
Status = AcpiAmlAccessNamedField (ACPI_READ,
(ACPI_HANDLE) ValDesc->BankField.Container,
&TempVal, sizeof (TempVal));
if (ACPI_FAILURE (Status))
Status = AcpiAmlGetNamedFieldValue ((ACPI_HANDLE) ValDesc->BankField.Container, &TempVal, sizeof (TempVal));
if (AE_OK != Status)
{
return_ACPI_STATUS (Status);
}
/* Create an object for the result */
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER);
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
if (!ObjDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
ObjDesc->Integer.Value = TempVal;
ObjDesc->Number.Value = TempVal;
break;
case INTERNAL_TYPE_INDEX_FIELD:
if (!ValDesc)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal error - null IndexField ValuePtr\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
if (AttachedAmlPointer)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal - IndexField cannot be an Aml ptr\n"));
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal error - IndexField cannot be an AcpiAml ptr\n"));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
if (INTERNAL_TYPE_INDEX_FIELD != ValDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR, (
"AmlResolveToValue: Object not an IndexField, type %X\n",
ValDesc->Common.Type));
"AmlResolveToValue/IndexField: Internal error - Name %4.4s type %d does not match value-type %d at %p\n",
&(((NAME_TABLE_ENTRY *) (*StackPtr))->Name), INTERNAL_TYPE_INDEX_FIELD, ValDesc->Common.Type, ValDesc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@ -515,72 +582,71 @@ AcpiAmlResolveNodeToValue (
/* Set Index value to select proper Data register */
/* Get the global lock if needed */
ObjDesc = (ACPI_OPERAND_OBJECT *) *StackPtr;
ObjDesc = (ACPI_OBJECT_INTERNAL *) *StackPtr;
Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule);
/* Perform the update */
Status = AcpiAmlAccessNamedField (ACPI_WRITE,
ValDesc->IndexField.Index, &ValDesc->IndexField.Value,
sizeof (ValDesc->IndexField.Value));
{
/* Perform the update */
Status = AcpiAmlSetNamedFieldValue (ValDesc->IndexField.Index,
&ValDesc->IndexField.Value, sizeof (ValDesc->IndexField.Value));
}
AcpiAmlReleaseGlobalLock (Locked);
if (ACPI_FAILURE (Status))
if (AE_OK != Status)
{
return_ACPI_STATUS (Status);
}
/* Read Data value */
Status = AcpiAmlAccessNamedField (ACPI_READ, ValDesc->IndexField.Data,
&TempVal, sizeof (TempVal));
if (ACPI_FAILURE (Status))
Status = AcpiAmlGetNamedFieldValue (ValDesc->IndexField.Data, &TempVal, sizeof (TempVal));
if (AE_OK != Status)
{
return_ACPI_STATUS (Status);
}
/* Create an object for the result */
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER);
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER);
if (!ObjDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
ObjDesc->Integer.Value = TempVal;
ObjDesc->Number.Value = TempVal;
break;
case ACPI_TYPE_FIELD_UNIT:
if (!ValDesc)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal error - null FieldUnit ValuePtr\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
if (AttachedAmlPointer)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: FieldUnit cannot be an Aml ptr\n"));
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal error - FieldUnit cannot be an AcpiAml ptr\n"));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
if (ValDesc->Common.Type != (UINT8) EntryType)
{
DEBUG_PRINT (ACPI_ERROR, (
"AmlResolveToValue: Object type %X not same as EntryType %X\n",
ValDesc->Common.Type, EntryType));
"AmlResolveToValue/FieldUnit: Internal error - Name %4.4s type %d does not match value-type %d at %p\n",
&(((NAME_TABLE_ENTRY *) (*StackPtr))->Name), EntryType,
ValDesc->Common.Type, ValDesc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
break;
}
/* Create object for result */
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY);
if (!ObjDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
Status = AcpiAmlGetFieldUnitValue (ValDesc, ObjDesc);
if (ACPI_FAILURE (Status))
if ((Status = AcpiAmlGetFieldUnitValue (ValDesc, ObjDesc)) != AE_OK)
{
AcpiCmRemoveReference (ObjDesc);
return_ACPI_STATUS (Status);
@ -589,19 +655,30 @@ AcpiAmlResolveNodeToValue (
break;
/*
* For these objects, just return the object attached to the Node
*/
/*
* For these objects, just return the object attached to the NTE
*/
case ACPI_TYPE_MUTEX:
case ACPI_TYPE_METHOD:
case ACPI_TYPE_POWER:
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_THERMAL:
case ACPI_TYPE_EVENT:
case ACPI_TYPE_REGION:
case ACPI_TYPE_REGION:
/* There must be an object attached to this NTE */
if (!ValDesc)
{
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: NTE %p has no attached object\n",
StackEntry));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
/* Return an additional reference to the object */
ObjDesc = ValDesc;
@ -609,84 +686,44 @@ AcpiAmlResolveNodeToValue (
break;
/* Devices rarely have an attached object, return the NTE */
case ACPI_TYPE_DEVICE:
/* Method locals and arguments have a pseudo-NTE, just return it */
case INTERNAL_TYPE_METHOD_ARGUMENT:
case INTERNAL_TYPE_METHOD_LOCAL_VAR:
return_ACPI_STATUS (AE_OK);
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, no attached object!\n",
Node));
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Untyped entry %p - has no Rvalue\n",
StackEntry));
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 */
default:
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveEntryToValue: Node %p - Unknown object type %X\n",
Node, EntryType));
DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Entry %p - Unknown object type %d\n",
StackEntry, EntryType));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
} /* switch (EntryType) */
/* Put the object descriptor on the stack */
*StackPtr = (void *) ObjDesc;
@ -695,3 +732,4 @@ AcpiAmlResolveNodeToValue (
}