Field support update - restructure for > 32-bit support for all field

types.  Cleanup of field types


date	2001.04.06.23.12.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 17:19:04 +00:00
parent 53f49dd5da
commit e53c26ad7f
5 changed files with 1110 additions and 870 deletions

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: amconvrt - Object conversion routines
* $Revision: 1.9 $
* $Revision: 1.10 $
*
*****************************************************************************/
@ -559,7 +559,7 @@ AcpiAmlConvertToTargetType (
switch (DestinationType)
{
case INTERNAL_TYPE_FIELD:
case INTERNAL_TYPE_REGION_FIELD:
/*
* Named field can always handle conversions
*/
@ -585,7 +585,7 @@ AcpiAmlConvertToTargetType (
switch (DestinationType)
{
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_FIELD_UNIT:
case ACPI_TYPE_BUFFER_FIELD:
case INTERNAL_TYPE_BANK_FIELD:
case INTERNAL_TYPE_INDEX_FIELD:
/*

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: amcreate - Named object creation
* $Revision: 1.59 $
* $Revision: 1.60 $
*
*****************************************************************************/
@ -132,7 +132,7 @@
/*******************************************************************************
*
* FUNCTION: AcpiAmlExecCreateField
* FUNCTION: AcpiAmlCreateBufferField
*
* PARAMETERS: Opcode - The opcode to be executed
* Operands - List of operands for the opcode
@ -159,9 +159,8 @@
*
******************************************************************************/
ACPI_STATUS
AcpiAmlExecCreateField (
AcpiAmlCreateBufferField (
UINT8 *AmlPtr,
UINT32 AmlLength,
ACPI_NAMESPACE_NODE *Node,
@ -172,31 +171,26 @@ AcpiAmlExecCreateField (
ACPI_OPERAND_OBJECT *TmpDesc;
FUNCTION_TRACE ("AmlExecCreateField");
FUNCTION_TRACE ("AmlCreateBufferField");
/* Create the region descriptor */
/* Create the descriptor */
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_FIELD_UNIT);
ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_BUFFER_FIELD);
if (!ObjDesc)
{
Status = AE_NO_MEMORY;
goto Cleanup;
}
/* Construct the field object */
ObjDesc->FieldUnit.Access = (UINT8) ACCESS_ANY_ACC;
ObjDesc->FieldUnit.LockRule = (UINT8) GLOCK_NEVER_LOCK;
ObjDesc->FieldUnit.UpdateRule = (UINT8) UPDATE_PRESERVE;
/*
* Allocate a method object for this field unit
*/
ObjDesc->FieldUnit.Extra = AcpiCmCreateInternalObject (
ObjDesc->BufferField.Extra = AcpiCmCreateInternalObject (
INTERNAL_TYPE_EXTRA);
if (!ObjDesc->FieldUnit.Extra)
if (!ObjDesc->BufferField.Extra)
{
Status = AE_NO_MEMORY;
goto Cleanup;
@ -208,15 +202,15 @@ AcpiAmlExecCreateField (
* operands must be evaluated.
*/
ObjDesc->FieldUnit.Extra->Extra.Pcode = AmlPtr;
ObjDesc->FieldUnit.Extra->Extra.PcodeLength = AmlLength;
ObjDesc->FieldUnit.Node = Node;
ObjDesc->BufferField.Extra->Extra.Pcode = AmlPtr;
ObjDesc->BufferField.Extra->Extra.PcodeLength = AmlLength;
ObjDesc->BufferField.Node = Node;
/*
* This operation is supposed to cause the destination Name to refer
* to the defined FieldUnit -- it must not store the constructed
* FieldUnit object (or its current value) in some location that the
* to the defined BufferField -- it must not store the constructed
* BufferField object (or its current value) in some location that the
* Name may already be pointing to. So, if the Name currently contains
* a reference which would cause AcpiAmlExecStore() to perform an indirect
* store rather than setting the value of the Name itself, clobber that
@ -228,11 +222,10 @@ AcpiAmlExecCreateField (
switch (AcpiNsGetType (Node))
{
case ACPI_TYPE_FIELD_UNIT:
case ACPI_TYPE_BUFFER_FIELD:
case INTERNAL_TYPE_ALIAS:
case INTERNAL_TYPE_REGION_FIELD:
case INTERNAL_TYPE_BANK_FIELD:
case INTERNAL_TYPE_FIELD:
case INTERNAL_TYPE_INDEX_FIELD:
TmpDesc = AcpiNsGetAttachedObject (Node);
@ -244,7 +237,7 @@ AcpiAmlExecCreateField (
*/
DUMP_PATHNAME (Node,
"AmlExecCreateField: Removing Current Reference",
"AmlCreateBufferField: Removing Current Reference",
TRACE_BFIELD, _COMPONENT);
DUMP_ENTRY (Node, TRACE_BFIELD);

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: amdump - Interpreter debug output routines
* $Revision: 1.106 $
* $Revision: 1.107 $
*
*****************************************************************************/
@ -506,13 +506,13 @@ AcpiAmlDumpOperand (
break;
case INTERNAL_TYPE_FIELD:
case INTERNAL_TYPE_REGION_FIELD:
DEBUG_PRINT_RAW (ACPI_INFO,
("DefField: bits=%X acc=%X lock=%X update=%X at byte=%lX bit=%X of below:\n",
EntryDesc->Field.Length, EntryDesc->Field.Access,
EntryDesc->Field.LockRule, EntryDesc->Field.UpdateRule,
EntryDesc->Field.Offset, EntryDesc->Field.BitOffset));
("RegionField: bits=%X acc=%X lock=%X update=%X at byte=%lX bit=%X of below:\n",
EntryDesc->Field.BitLength, EntryDesc->Field.Access,
EntryDesc->Field.LockRule, EntryDesc->Field.UpdateRule,
EntryDesc->Field.Offset, EntryDesc->Field.BitOffset));
DUMP_STACK_ENTRY (EntryDesc->Field.RegionObj);
break;
@ -523,28 +523,27 @@ AcpiAmlDumpOperand (
break;
case ACPI_TYPE_FIELD_UNIT:
case ACPI_TYPE_BUFFER_FIELD:
DEBUG_PRINT_RAW (ACPI_INFO,
("FieldUnit: %X bits acc %X lock %X update %X at byte %lX bit %X of \n",
EntryDesc->FieldUnit.Length, EntryDesc->FieldUnit.Access,
EntryDesc->FieldUnit.LockRule, EntryDesc->FieldUnit.UpdateRule,
EntryDesc->FieldUnit.Offset, EntryDesc->FieldUnit.BitOffset));
("BufferField: %X bits at byte %lX bit %X of \n",
EntryDesc->BufferField.BitLength, EntryDesc->BufferField.Offset,
EntryDesc->BufferField.BitOffset));
if (!EntryDesc->FieldUnit.ContainerObj)
if (!EntryDesc->BufferField.BufferObj)
{
DEBUG_PRINT (ACPI_INFO, ("*NULL* \n"));
}
else if (ACPI_TYPE_BUFFER !=
EntryDesc->FieldUnit.ContainerObj->Common.Type)
EntryDesc->BufferField.BufferObj->Common.Type)
{
DEBUG_PRINT_RAW (ACPI_INFO, ("*not a Buffer* \n"));
}
else
{
DUMP_STACK_ENTRY (EntryDesc->FieldUnit.ContainerObj);
DUMP_STACK_ENTRY (EntryDesc->BufferField.BufferObj);
}
break;
@ -797,16 +796,13 @@ AcpiAmlDumpObjectDescriptor (
break;
case ACPI_TYPE_FIELD_UNIT:
case ACPI_TYPE_BUFFER_FIELD:
AcpiOsPrintf ("%20s : %s\n", "Type", "FieldUnit");
AcpiOsPrintf ("%20s : %X\n", "Access", ObjDesc->FieldUnit.Access);
AcpiOsPrintf ("%20s : %X\n", "LockRule", ObjDesc->FieldUnit.LockRule);
AcpiOsPrintf ("%20s : %X\n", "UpdateRule", ObjDesc->FieldUnit.UpdateRule);
AcpiOsPrintf ("%20s : %X\n", "Length", ObjDesc->FieldUnit.Length);
AcpiOsPrintf ("%20s : %X\n", "BitOffset", ObjDesc->FieldUnit.BitOffset);
AcpiOsPrintf ("%20s : %X\n", "Offset", ObjDesc->FieldUnit.Offset);
AcpiOsPrintf ("%20s : %p\n", "ContainerObj", ObjDesc->FieldUnit.ContainerObj);
AcpiOsPrintf ("%20s : %s\n", "Type", "BufferField");
AcpiOsPrintf ("%20s : %X\n", "BitLength", ObjDesc->BufferField.BitLength);
AcpiOsPrintf ("%20s : %X\n", "BitOffset", ObjDesc->BufferField.BitOffset);
AcpiOsPrintf ("%20s : %X\n", "Offset", ObjDesc->BufferField.Offset);
AcpiOsPrintf ("%20s : %p\n", "BufferObj", ObjDesc->BufferField.BufferObj);
break;
@ -888,13 +884,24 @@ AcpiAmlDumpObjectDescriptor (
AcpiOsPrintf ("%20s : %p\n", "AddrHandler", ObjDesc->ThermalZone.AddrHandler);
break;
case INTERNAL_TYPE_REGION_FIELD:
AcpiOsPrintf ("%20s : %p\n", "Granularity", ObjDesc->Field.Granularity);
AcpiOsPrintf ("%20s : %p\n", "BitLength", ObjDesc->Field.BitLength);
AcpiOsPrintf ("%20s : %p\n", "Offset", ObjDesc->Field.Offset);
AcpiOsPrintf ("%20s : %p\n", "BitOffset", ObjDesc->Field.BitOffset);
AcpiOsPrintf ("%20s : %p\n", "RegionObj", ObjDesc->Field.RegionObj);
break;
case INTERNAL_TYPE_BANK_FIELD:
AcpiOsPrintf ("%20s : %s\n", "Type", "BankField");
AcpiOsPrintf ("%20s : %X\n", "Access", ObjDesc->BankField.Access);
AcpiOsPrintf ("%20s : %X\n", "LockRule", ObjDesc->BankField.LockRule);
AcpiOsPrintf ("%20s : %X\n", "UpdateRule", ObjDesc->BankField.UpdateRule);
AcpiOsPrintf ("%20s : %X\n", "Length", ObjDesc->BankField.Length);
AcpiOsPrintf ("%20s : %X\n", "BitLength", ObjDesc->BankField.BitLength);
AcpiOsPrintf ("%20s : %X\n", "BitOffset", ObjDesc->BankField.BitOffset);
AcpiOsPrintf ("%20s : %X\n", "Offset", ObjDesc->BankField.Offset);
AcpiOsPrintf ("%20s : %X\n", "Value", ObjDesc->BankField.Value);
@ -909,7 +916,7 @@ AcpiAmlDumpObjectDescriptor (
AcpiOsPrintf ("%20s : %X\n", "Access", ObjDesc->IndexField.Access);
AcpiOsPrintf ("%20s : %X\n", "LockRule", ObjDesc->IndexField.LockRule);
AcpiOsPrintf ("%20s : %X\n", "UpdateRule", ObjDesc->IndexField.UpdateRule);
AcpiOsPrintf ("%20s : %X\n", "Length", ObjDesc->IndexField.Length);
AcpiOsPrintf ("%20s : %X\n", "BitLength", ObjDesc->IndexField.BitLength);
AcpiOsPrintf ("%20s : %X\n", "BitOffset", ObjDesc->IndexField.BitOffset);
AcpiOsPrintf ("%20s : %X\n", "Value", ObjDesc->IndexField.Value);
AcpiOsPrintf ("%20s : %X\n", "Index", ObjDesc->IndexField.Index);
@ -950,14 +957,6 @@ AcpiAmlDumpObjectDescriptor (
break;
case INTERNAL_TYPE_FIELD:
AcpiOsPrintf ("%20s : %p\n", "Granularity", ObjDesc->Field.Granularity);
AcpiOsPrintf ("%20s : %p\n", "Length", ObjDesc->Field.Length);
AcpiOsPrintf ("%20s : %p\n", "Offset", ObjDesc->Field.Offset);
AcpiOsPrintf ("%20s : %p\n", "BitOffset", ObjDesc->Field.BitOffset);
AcpiOsPrintf ("%20s : %p\n", "RegionObj", ObjDesc->Field.RegionObj);
break;
case INTERNAL_TYPE_ALIAS:

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: amfield - ACPI AML (p-code) execution - field manipulation
* $Revision: 1.81 $
* $Revision: 1.82 $
*
*****************************************************************************/
@ -130,137 +130,213 @@
MODULE_NAME ("amfield")
/*******************************************************************************
*
* FUNCTION: AcpiAmlSetupField
* FUNCTION: AcpiAmlReadDataFromField
*
* PARAMETERS: *ObjDesc - Field to be read or written
* *RgnDesc - Region containing field
* FieldBitWidth - Field Width in bits (8, 16, or 32)
* PARAMETERS: Mode - ACPI_READ or ACPI_WRITE
* *FieldNode - Parent node for field to be accessed
* *Buffer - Value(s) to be read or written
* BufferLength - Number of bytes to transfer
*
* RETURN: Status
* RETURN: Status3
*
* DESCRIPTION: Common processing for AcpiAmlReadField and AcpiAmlWriteField
*
* ACPI SPECIFICATION REFERENCES:
* Each of the Type1Opcodes is defined as specified in in-line
* comments below. For each one, use the following definitions.
*
* DefBitField := BitFieldOp SrcBuf BitIdx Destination
* DefByteField := ByteFieldOp SrcBuf ByteIdx Destination
* DefCreateField := CreateFieldOp SrcBuf BitIdx NumBits NameString
* DefDWordField := DWordFieldOp SrcBuf ByteIdx Destination
* DefWordField := WordFieldOp SrcBuf ByteIdx Destination
* BitIndex := TermArg=>Integer
* ByteIndex := TermArg=>Integer
* Destination := NameString
* NumBits := TermArg=>Integer
* SourceBuf := TermArg=>Buffer
* DESCRIPTION: Read or write a named field
*
******************************************************************************/
ACPI_STATUS
AcpiAmlSetupField (
AcpiAmlReadDataFromField (
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_OPERAND_OBJECT *RgnDesc,
UINT32 FieldBitWidth)
ACPI_OPERAND_OBJECT **RetBufferDesc)
{
ACPI_STATUS Status = AE_OK;
UINT32 FieldByteWidth;
ACPI_STATUS Status;
ACPI_OPERAND_OBJECT *BufferDesc;
UINT32 Length;
void *Buffer;
FUNCTION_TRACE ("AmlSetupField");
FUNCTION_TRACE_PTR ("AmlReadDataFromField", ObjDesc);
/* Parameter validation */
if (!ObjDesc || !RgnDesc)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlSetupField: Internal error - null handle\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
if (ACPI_TYPE_REGION != RgnDesc->Common.Type)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlSetupField: Needed Region, found type %x %s\n",
RgnDesc->Common.Type, AcpiCmGetTypeName (RgnDesc->Common.Type)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/*
* TBD: [Future] Acpi 2.0 supports Qword fields
* Allocate a buffer for the contents of the field.
*
* Init and validate Field width
* Possible values are 1, 2, 4
* If the field is larger than the size of an ACPI_INTEGER, create
* a BUFFER to hold it. Otherwise, use an INTEGER. This allows
* the use of arithmetic operators on the returned value if the
* field size is equal or smaller than an Integer.
*
* Note: Field.length is in bits.
*/
FieldByteWidth = DIV_8 (FieldBitWidth);
Length = ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength);
if ((FieldBitWidth != 8) &&
(FieldBitWidth != 16) &&
(FieldBitWidth != 32))
if (Length > sizeof (ACPI_INTEGER))
{
DEBUG_PRINT (ACPI_ERROR,
("AmlSetupField: Internal error - bad width %d\n", FieldBitWidth));
return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
}
/* Field is too large for an Integer, use a Buffer */
/*
* If the Region Address and Length have not been previously evaluated,
* evaluate them and save the results.
*/
if (!(RgnDesc->Region.Flags & AOPOBJ_DATA_VALID))
{
Status = AcpiDsGetRegionArguments (RgnDesc);
if (ACPI_FAILURE (Status))
BufferDesc = AcpiCmCreateInternalObject (ACPI_TYPE_BUFFER);
if (!BufferDesc)
{
return_ACPI_STATUS (Status);
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Create the actual read buffer */
BufferDesc->Buffer.Pointer = AcpiCmCallocate (Length);
if (!BufferDesc->Buffer.Pointer)
{
AcpiCmRemoveReference (BufferDesc);
return_ACPI_STATUS (AE_NO_MEMORY);
}
BufferDesc->Buffer.Length = Length;
Buffer = BufferDesc->Buffer.Pointer;
}
if ((ObjDesc->Common.Type == ACPI_TYPE_FIELD_UNIT) &&
(!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)))
else
{
/*
* Field Buffer and Index have not been previously evaluated,
*/
DEBUG_PRINT (ACPI_ERROR, ("Uninitialized field!\n"));
return_ACPI_STATUS (AE_AML_INTERNAL);
/* Field will fit within an Integer (normal case) */
BufferDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER);
if (!BufferDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
Length = sizeof (BufferDesc->Integer.Value);
Buffer = &BufferDesc->Integer.Value;
}
if (RgnDesc->Region.Length <
(ObjDesc->Field.Offset & ~((UINT32) FieldByteWidth - 1)) +
FieldByteWidth)
/* Read from the appropriate field */
switch (ObjDesc->Common.Type)
{
/*
* Offset rounded up to next multiple of field width
* exceeds region length, indicate an error
*/
case ACPI_TYPE_BUFFER_FIELD:
Status = AcpiAmlAccessBufferField (ACPI_READ, ObjDesc, Buffer, Length);
break;
DUMP_STACK_ENTRY (RgnDesc);
DUMP_STACK_ENTRY (ObjDesc);
case INTERNAL_TYPE_REGION_FIELD:
Status = AcpiAmlAccessRegionField (ACPI_READ, ObjDesc, Buffer, Length);
break;
DEBUG_PRINT (ACPI_ERROR,
("AmlSetupField: Operation at %08lX width %d bits exceeds len %08lX field=%p region=%p\n",
ObjDesc->Field.Offset, FieldBitWidth, RgnDesc->Region.Length,
ObjDesc, RgnDesc));
case INTERNAL_TYPE_BANK_FIELD:
Status = AcpiAmlAccessBankField (ACPI_READ, ObjDesc, Buffer, Length);
break;
return_ACPI_STATUS (AE_AML_REGION_LIMIT);
case INTERNAL_TYPE_INDEX_FIELD:
Status = AcpiAmlAccessIndexField (ACPI_READ, ObjDesc, Buffer, Length);
break;
default:
Status = AE_AML_INTERNAL;
}
return_ACPI_STATUS (AE_OK);
if (ACPI_FAILURE (Status))
{
AcpiCmRemoveReference (BufferDesc);
}
else
{
*RetBufferDesc = BufferDesc;
}
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlAccessNamedField
* FUNCTION: AcpiAmlWriteDataToField
*
* PARAMETERS: Mode - ACPI_READ or ACPI_WRITE
* *FieldNode - Parent node for field to be accessed
* *Buffer - Value(s) to be read or written
* BufferLength - Number of bytes to transfer
*
* RETURN: Status
*
* DESCRIPTION: Read or write a named field
*
******************************************************************************/
ACPI_STATUS
AcpiAmlWriteDataToField (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_STATUS Status;
UINT32 Length;
void *Buffer;
FUNCTION_TRACE_PTR ("AmlWriteDataToField", ObjDesc);
switch (SourceDesc->Common.Type)
{
case ACPI_TYPE_INTEGER:
Buffer = &SourceDesc->Integer.Value;
Length = sizeof (SourceDesc->Integer.Value);
break;
case ACPI_TYPE_BUFFER:
Buffer = SourceDesc->Buffer.Pointer;
Length = SourceDesc->Buffer.Length;
break;
case ACPI_TYPE_STRING:
Buffer = SourceDesc->String.Pointer;
Length = SourceDesc->String.Length;
break;
default:
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
switch (ObjDesc->Common.Type)
{
case ACPI_TYPE_BUFFER_FIELD:
Status = AcpiAmlAccessBufferField (ACPI_WRITE, ObjDesc, Buffer, Length);
break;
case INTERNAL_TYPE_REGION_FIELD:
Status = AcpiAmlAccessRegionField (ACPI_WRITE, ObjDesc, Buffer, Length);
break;
case INTERNAL_TYPE_BANK_FIELD:
Status = AcpiAmlAccessBankField (ACPI_WRITE, ObjDesc, Buffer, Length);
break;
case INTERNAL_TYPE_INDEX_FIELD:
Status = AcpiAmlAccessIndexField (ACPI_WRITE, ObjDesc, Buffer, Length);
break;
default:
return_ACPI_STATUS (AE_AML_INTERNAL);
}
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlAccessBufferField
*
* PARAMETERS: Mode - ACPI_READ or ACPI_WRITE
* *FieldNode - Parent node for field to be accessed
@ -274,83 +350,284 @@ AcpiAmlSetupField (
******************************************************************************/
ACPI_STATUS
AcpiAmlAccessNamedField (
AcpiAmlAccessBufferField (
UINT32 Mode,
ACPI_NAMESPACE_NODE *FieldNode,
ACPI_OPERAND_OBJECT *ObjDesc,
void *Buffer,
UINT32 BufferLength)
{
ACPI_OPERAND_OBJECT *ObjDesc = NULL;
ACPI_STATUS Status = AE_OK;
BOOLEAN Locked = FALSE;
UINT32 BitGranularity = 0;
ACPI_STATUS Status;
FUNCTION_TRACE_PTR ("AmlAccessRegionField", ObjDesc);
/*
* If the BufferField arguments have not been previously evaluated,
* evaluate them now and save the results.
*/
if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
{
Status = AcpiDsGetBufferFieldArguments (ObjDesc);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
Status = AcpiAmlCommonAccessField (Mode, ObjDesc,
Buffer, BufferLength);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlAccessRegionField
*
* PARAMETERS: Mode - ACPI_READ or ACPI_WRITE
* *FieldNode - Parent node for field to be accessed
* *Buffer - Value(s) to be read or written
* BufferLength - Number of bytes to transfer
*
* RETURN: Status
*
* DESCRIPTION: Read or write a named field
*
******************************************************************************/
ACPI_STATUS
AcpiAmlAccessRegionField (
UINT32 Mode,
ACPI_OPERAND_OBJECT *ObjDesc,
void *Buffer,
UINT32 BufferLength)
{
ACPI_STATUS Status;
BOOLEAN Locked;
FUNCTION_TRACE_PTR ("AmlAccessRegionField", ObjDesc);
/*
* Get the global lock if needed
*/
Locked = AcpiAmlAcquireGlobalLock (ObjDesc->Field.LockRule);
Status = AcpiAmlCommonAccessField (Mode, ObjDesc,
Buffer, BufferLength);
/*
* Release global lock if we acquired it earlier
*/
AcpiAmlReleaseGlobalLock (Locked);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlAccessBankField
*
* PARAMETERS: Mode - ACPI_READ or ACPI_WRITE
* *FieldNode - Parent node for field to be accessed
* *Buffer - Value(s) to be read or written
* BufferLength - Number of bytes to transfer
*
* RETURN: Status
*
* DESCRIPTION: Read or write a Bank Field
*
******************************************************************************/
ACPI_STATUS
AcpiAmlAccessBankField (
UINT32 Mode,
ACPI_OPERAND_OBJECT *ObjDesc,
void *Buffer,
UINT32 BufferLength)
{
ACPI_STATUS Status;
BOOLEAN Locked;
FUNCTION_TRACE_PTR ("AmlAccessBankField", ObjDesc);
/*
* Get the global lock if needed
*/
Locked = AcpiAmlAcquireGlobalLock (ObjDesc->BankField.LockRule);
/*
* Write the BankValue to the BankRegister to select the bank.
* The BankValue for this BankField is specified in the
* BankField ASL declaration. The BankRegister is always a Field in
* an operation region.
*/
Status = AcpiAmlCommonAccessField (ACPI_WRITE,
ObjDesc->BankField.BankRegisterObj,
&ObjDesc->BankField.Value,
sizeof (ObjDesc->BankField.Value));
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/*
* The bank was successfully selected, now read or write the actual
* data.
*/
Status = AcpiAmlCommonAccessField (Mode, ObjDesc, Buffer, BufferLength);
Cleanup:
/*
* Release global lock if we acquired it earlier
*/
AcpiAmlReleaseGlobalLock (Locked);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlAccessIndexField
*
* PARAMETERS: Mode - ACPI_READ or ACPI_WRITE
* *FieldNode - Parent node for field to be accessed
* *Buffer - Value(s) to be read or written
* BufferLength - Number of bytes to transfer
*
* RETURN: Status
*
* DESCRIPTION: Read or write a Index Field
*
******************************************************************************/
ACPI_STATUS
AcpiAmlAccessIndexField (
UINT32 Mode,
ACPI_OPERAND_OBJECT *ObjDesc,
void *Buffer,
UINT32 BufferLength)
{
ACPI_STATUS Status;
BOOLEAN Locked;
FUNCTION_TRACE_PTR ("AmlAccessIndexField", ObjDesc);
/*
* Get the global lock if needed
*/
Locked = AcpiAmlAcquireGlobalLock (ObjDesc->IndexField.LockRule);
/*
* Set Index value to select proper Data register
*/
Status = AcpiAmlCommonAccessField (ACPI_WRITE,
(ObjDesc->IndexField.Index)->Object,
&ObjDesc->IndexField.Value,
sizeof (ObjDesc->IndexField.Value));
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/* Now read/write the data register */
Status = AcpiAmlCommonAccessField (Mode, (ObjDesc->IndexField.Data)->Object,
Buffer, BufferLength);
Cleanup:
/*
* Release global lock if we acquired it earlier
*/
AcpiAmlReleaseGlobalLock (Locked);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlCommonAccessField
*
* PARAMETERS: Mode - ACPI_READ or ACPI_WRITE
* *FieldNode - Parent node for field to be accessed
* *Buffer - Value(s) to be read or written
* BufferLength - Size of buffer, in bytes. Must be large
* enough for all bits of the field.
*
* RETURN: Status
*
* DESCRIPTION: Read or write a named field
*
******************************************************************************/
ACPI_STATUS
AcpiAmlCommonAccessField (
UINT32 Mode,
ACPI_OPERAND_OBJECT *ObjDesc,
void *Buffer,
UINT32 BufferLength)
{
ACPI_STATUS Status;
UINT32 BitGranularity;
UINT32 ByteGranularity;
UINT32 DatumLength;
UINT32 ActualByteLength;
UINT32 ByteFieldLength;
FUNCTION_TRACE_PTR ("AmlAccessNamedField", FieldNode);
FUNCTION_TRACE_PTR ("AmlCommonAccessField", ObjDesc);
/* Parameter validation */
if ((!FieldNode) || (ACPI_READ == Mode && !Buffer))
if ((!ObjDesc) || (ACPI_READ == Mode && !Buffer))
{
DEBUG_PRINT (ACPI_ERROR,
("AcpiAmlAccessNamedField: Internal error - null parameter\n"));
("AcpiAmlCommonAccessField: Internal error - null parameter\n"));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
/* Get the attached field object */
ObjDesc = AcpiNsGetAttachedObject (FieldNode);
if (!ObjDesc)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlAccessNamedField: Internal error - null value pointer\n"));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
/* Check the type */
if (INTERNAL_TYPE_FIELD != AcpiNsGetType (FieldNode))
{
DEBUG_PRINT (ACPI_ERROR,
("AmlAccessNamedField: Name %4.4s type %x is not a defined field\n",
&(FieldNode->Name), AcpiNsGetType (FieldNode)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/* ObjDesc valid and FieldNode is a defined field */
DEBUG_PRINT (ACPI_INFO,
("AccessNamedField: Obj=%p Type=%x Buf=%p Len=%x\n",
("AccessField: Obj=%p Type=%x Buf=%p Len=%x\n",
ObjDesc, ObjDesc->Common.Type, Buffer, BufferLength));
DEBUG_PRINT (ACPI_INFO,
("AccessNamedField: Mode=%d FieldLen=%d, BitOffset=%d\n",
Mode, ObjDesc->FieldUnit.Length, ObjDesc->FieldUnit.BitOffset));
DUMP_ENTRY (FieldNode, ACPI_INFO);
("AccessField: Mode=%d FieldLen=%d, BitOffset=%d\n",
Mode, ObjDesc->CommonField.BitLength, ObjDesc->CommonField.BitOffset));
/* Double-check that the attached object is also a field */
if (INTERNAL_TYPE_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",
&(FieldNode->Name), AcpiNsGetType (FieldNode),
ObjDesc->Common.Type, ObjDesc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/*
/*
* Granularity was decoded from the field access type
* (AnyAcc will be the same as ByteAcc)
*/
BitGranularity = ObjDesc->FieldUnit.Granularity;
BitGranularity = ObjDesc->CommonField.Granularity;
ByteGranularity = DIV_8 (BitGranularity);
/*
@ -360,50 +637,18 @@ AcpiAmlAccessNamedField (
/* TBD: [Errors] should an error be returned in this case? */
ByteFieldLength = (UINT32) DIV_8 (ObjDesc->FieldUnit.Length + 7);
ByteFieldLength = ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength);
ActualByteLength = BufferLength;
if (BufferLength > ByteFieldLength)
{
DEBUG_PRINT (ACPI_INFO,
("AmlAccessNamedField: Byte length %X truncated to %X\n",
("AmlCommonAccessField: Byte length %X truncated to %X\n",
ActualByteLength, ByteFieldLength));
ActualByteLength = ByteFieldLength;
}
/*
* This code has been commented because it incorrectly changes the
* access granularity of a field. In the case of a DwordAccess
* field, reading/writing a byte-sized field unit, the read/write
* would occur on the nth BYTE instead of the nth DWORD.
*
* This code was originally introduced to deal with the case
* where a small Region had an associated Field with an AccessType
* that was larger than the entire region space - a violation of
* the ACPI specification.
*/
/* TBD: should these round down to a power of 2? */
/*
if (DIV_8 (BitGranularity) > ByteFieldLength)
{
DEBUG_PRINT (ACPI_INFO,
("AmlAccessNamedField: Bit granularity %X truncated to %X\n",
BitGranularity, MUL_8(ByteFieldLength)));
BitGranularity = MUL_8(ByteFieldLength);
}
if (ByteGranularity > ByteFieldLength)
{
DEBUG_PRINT (ACPI_INFO,
("AmlAccessNamedField: Byte granularity %X truncated to %X\n",
ByteGranularity, ByteFieldLength));
ByteGranularity = ByteFieldLength;
}
*/
/* Convert byte count to datum count, round up if necessary */
@ -414,10 +659,6 @@ AcpiAmlAccessNamedField (
ActualByteLength, DatumLength, BitGranularity, ByteGranularity));
/* Get the global lock if needed */
Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule);
/* Perform the actual read or write of the buffer */
@ -425,7 +666,7 @@ AcpiAmlAccessNamedField (
{
case ACPI_READ:
Status = AcpiAmlReadField (ObjDesc, Buffer, BufferLength,
Status = AcpiAmlExtractFromField (ObjDesc, Buffer, BufferLength,
ActualByteLength, DatumLength,
BitGranularity, ByteGranularity);
break;
@ -433,7 +674,7 @@ AcpiAmlAccessNamedField (
case ACPI_WRITE:
Status = AcpiAmlWriteField (ObjDesc, Buffer, BufferLength,
Status = AcpiAmlInsertIntoField (ObjDesc, Buffer, BufferLength,
ActualByteLength, DatumLength,
BitGranularity, ByteGranularity);
break;
@ -448,10 +689,6 @@ AcpiAmlAccessNamedField (
}
/* Release global lock if we acquired it earlier */
AcpiAmlReleaseGlobalLock (Locked);
return_ACPI_STATUS (Status);
}

File diff suppressed because it is too large Load Diff