mirror of
https://github.com/acpica/acpica/
synced 2025-03-01 20:01:33 +03:00
Update to opcode names and typenames for fields
date 2001.03.30.18.16.00; author rmoore1; state Exp;
This commit is contained in:
parent
09b212d1f1
commit
53f49dd5da
@ -1,7 +1,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: amconvrt - Object conversion routines
|
||||
* $Revision: 1.8 $
|
||||
* $Revision: 1.9 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -559,7 +559,7 @@ AcpiAmlConvertToTargetType (
|
||||
|
||||
switch (DestinationType)
|
||||
{
|
||||
case INTERNAL_TYPE_DEF_FIELD:
|
||||
case INTERNAL_TYPE_FIELD:
|
||||
/*
|
||||
* Named field can always handle conversions
|
||||
*/
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: amdump - Interpreter debug output routines
|
||||
* $Revision: 1.104 $
|
||||
* $Revision: 1.106 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -506,14 +506,14 @@ AcpiAmlDumpOperand (
|
||||
break;
|
||||
|
||||
|
||||
case INTERNAL_TYPE_DEF_FIELD:
|
||||
case INTERNAL_TYPE_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));
|
||||
DUMP_STACK_ENTRY (EntryDesc->Field.Container);
|
||||
DUMP_STACK_ENTRY (EntryDesc->Field.RegionObj);
|
||||
break;
|
||||
|
||||
|
||||
@ -531,20 +531,20 @@ AcpiAmlDumpOperand (
|
||||
EntryDesc->FieldUnit.LockRule, EntryDesc->FieldUnit.UpdateRule,
|
||||
EntryDesc->FieldUnit.Offset, EntryDesc->FieldUnit.BitOffset));
|
||||
|
||||
if (!EntryDesc->FieldUnit.Container)
|
||||
if (!EntryDesc->FieldUnit.ContainerObj)
|
||||
{
|
||||
DEBUG_PRINT (ACPI_INFO, ("*NULL* \n"));
|
||||
}
|
||||
|
||||
else if (ACPI_TYPE_BUFFER !=
|
||||
EntryDesc->FieldUnit.Container->Common.Type)
|
||||
EntryDesc->FieldUnit.ContainerObj->Common.Type)
|
||||
{
|
||||
DEBUG_PRINT_RAW (ACPI_INFO, ("*not a Buffer* \n"));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
DUMP_STACK_ENTRY (EntryDesc->FieldUnit.Container);
|
||||
DUMP_STACK_ENTRY (EntryDesc->FieldUnit.ContainerObj);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -806,7 +806,7 @@ AcpiAmlDumpObjectDescriptor (
|
||||
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", "Container", ObjDesc->FieldUnit.Container);
|
||||
AcpiOsPrintf ("%20s : %p\n", "ContainerObj", ObjDesc->FieldUnit.ContainerObj);
|
||||
break;
|
||||
|
||||
|
||||
@ -898,8 +898,8 @@ AcpiAmlDumpObjectDescriptor (
|
||||
AcpiOsPrintf ("%20s : %X\n", "BitOffset", ObjDesc->BankField.BitOffset);
|
||||
AcpiOsPrintf ("%20s : %X\n", "Offset", ObjDesc->BankField.Offset);
|
||||
AcpiOsPrintf ("%20s : %X\n", "Value", ObjDesc->BankField.Value);
|
||||
AcpiOsPrintf ("%20s : %p\n", "Container", ObjDesc->BankField.Container);
|
||||
AcpiOsPrintf ("%20s : %X\n", "BankSelect", ObjDesc->BankField.BankSelect);
|
||||
AcpiOsPrintf ("%20s : %p\n", "RegionObj", ObjDesc->BankField.RegionObj);
|
||||
AcpiOsPrintf ("%20s : %X\n", "BankRegisterNode", ObjDesc->BankField.BankRegisterNode);
|
||||
break;
|
||||
|
||||
|
||||
@ -950,18 +950,18 @@ AcpiAmlDumpObjectDescriptor (
|
||||
break;
|
||||
|
||||
|
||||
case INTERNAL_TYPE_DEF_FIELD:
|
||||
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", "Container", ObjDesc->Field.Container);
|
||||
AcpiOsPrintf ("%20s : %p\n", "RegionObj", ObjDesc->Field.RegionObj);
|
||||
break;
|
||||
|
||||
|
||||
case INTERNAL_TYPE_ALIAS:
|
||||
case INTERNAL_TYPE_DEF_FIELD_DEFN:
|
||||
case INTERNAL_TYPE_FIELD_DEFN:
|
||||
case INTERNAL_TYPE_BANK_FIELD_DEFN:
|
||||
case INTERNAL_TYPE_INDEX_FIELD_DEFN:
|
||||
case INTERNAL_TYPE_IF:
|
||||
|
@ -1,7 +1,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: exfield - ACPI AML (p-code) execution - field manipulation
|
||||
* $Revision: 1.123 $
|
||||
* Module Name: amfield - ACPI AML (p-code) execution - field manipulation
|
||||
* $Revision: 1.81 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
*
|
||||
* 1. Copyright Notice
|
||||
*
|
||||
* Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
|
||||
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 2. License
|
||||
@ -115,359 +115,343 @@
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#define __EXFIELD_C__
|
||||
#define __AMFIELD_C__
|
||||
|
||||
#include "acpi.h"
|
||||
#include "acdispat.h"
|
||||
#include "acinterp.h"
|
||||
#include "amlcode.h"
|
||||
#include "acnamesp.h"
|
||||
#include "achware.h"
|
||||
#include "acevents.h"
|
||||
|
||||
|
||||
#define _COMPONENT ACPI_EXECUTER
|
||||
ACPI_MODULE_NAME ("exfield")
|
||||
MODULE_NAME ("amfield")
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiExReadDataFromField
|
||||
* FUNCTION: AcpiAmlSetupField
|
||||
*
|
||||
* PARAMETERS: WalkState - Current execution state
|
||||
* ObjDesc - The named field
|
||||
* RetBufferDesc - Where the return data object is stored
|
||||
* PARAMETERS: *ObjDesc - Field to be read or written
|
||||
* *RgnDesc - Region containing field
|
||||
* FieldBitWidth - Field Width in bits (8, 16, or 32)
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Read from a named field. Returns either an Integer or a
|
||||
* Buffer, depending on the size of the field.
|
||||
* 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
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiExReadDataFromField (
|
||||
ACPI_WALK_STATE *WalkState,
|
||||
AcpiAmlSetupField (
|
||||
ACPI_OPERAND_OBJECT *ObjDesc,
|
||||
ACPI_OPERAND_OBJECT **RetBufferDesc)
|
||||
ACPI_OPERAND_OBJECT *RgnDesc,
|
||||
UINT32 FieldBitWidth)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
ACPI_OPERAND_OBJECT *BufferDesc;
|
||||
ACPI_SIZE Length;
|
||||
void *Buffer;
|
||||
BOOLEAN Locked;
|
||||
ACPI_STATUS Status = AE_OK;
|
||||
UINT32 FieldByteWidth;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE_PTR ("ExReadDataFromField", ObjDesc);
|
||||
FUNCTION_TRACE ("AmlSetupField");
|
||||
|
||||
|
||||
/* Parameter validation */
|
||||
|
||||
if (!ObjDesc)
|
||||
if (!ObjDesc || !RgnDesc)
|
||||
{
|
||||
DEBUG_PRINT (ACPI_ERROR,
|
||||
("AmlSetupField: Internal error - null handle\n"));
|
||||
return_ACPI_STATUS (AE_AML_NO_OPERAND);
|
||||
}
|
||||
|
||||
if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_BUFFER_FIELD)
|
||||
if (ACPI_TYPE_REGION != RgnDesc->Common.Type)
|
||||
{
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_REGION_FIELD) &&
|
||||
(ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS))
|
||||
{
|
||||
/*
|
||||
* This is an SMBus read. We must create a buffer to hold the data
|
||||
* and directly access the region handler.
|
||||
*/
|
||||
BufferDesc = AcpiUtCreateBufferObject (ACPI_SMBUS_BUFFER_SIZE);
|
||||
if (!BufferDesc)
|
||||
{
|
||||
return_ACPI_STATUS (AE_NO_MEMORY);
|
||||
}
|
||||
|
||||
/* Lock entire transaction if requested */
|
||||
|
||||
Locked = AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
|
||||
|
||||
/*
|
||||
* Perform the read.
|
||||
* Note: Smbus protocol value is passed in upper 16-bits of Function
|
||||
*/
|
||||
Status = AcpiExAccessRegion (ObjDesc, 0,
|
||||
ACPI_CAST_PTR (ACPI_INTEGER, BufferDesc->Buffer.Pointer),
|
||||
ACPI_READ | (ObjDesc->Field.Attribute << 16));
|
||||
AcpiExReleaseGlobalLock (Locked);
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a buffer for the contents of the field.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength);
|
||||
if (Length > AcpiGbl_IntegerByteWidth)
|
||||
{
|
||||
/* Field is too large for an Integer, create a Buffer instead */
|
||||
|
||||
BufferDesc = AcpiUtCreateBufferObject (Length);
|
||||
if (!BufferDesc)
|
||||
{
|
||||
return_ACPI_STATUS (AE_NO_MEMORY);
|
||||
}
|
||||
Buffer = BufferDesc->Buffer.Pointer;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Field will fit within an Integer (normal case) */
|
||||
|
||||
BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
|
||||
if (!BufferDesc)
|
||||
{
|
||||
return_ACPI_STATUS (AE_NO_MEMORY);
|
||||
}
|
||||
|
||||
Length = AcpiGbl_IntegerByteWidth;
|
||||
BufferDesc->Integer.Value = 0;
|
||||
Buffer = &BufferDesc->Integer.Value;
|
||||
}
|
||||
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
||||
"FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n",
|
||||
ObjDesc, ACPI_GET_OBJECT_TYPE (ObjDesc), Buffer, (UINT32) Length));
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
||||
"FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n",
|
||||
ObjDesc->CommonField.BitLength,
|
||||
ObjDesc->CommonField.StartFieldBitOffset,
|
||||
ObjDesc->CommonField.BaseByteOffset));
|
||||
|
||||
/* Lock entire transaction if requested */
|
||||
|
||||
Locked = AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
|
||||
|
||||
/* Read from the field */
|
||||
|
||||
Status = AcpiExExtractFromField (ObjDesc, Buffer, (UINT32) Length);
|
||||
AcpiExReleaseGlobalLock (Locked);
|
||||
|
||||
|
||||
Exit:
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
AcpiUtRemoveReference (BufferDesc);
|
||||
}
|
||||
else if (RetBufferDesc)
|
||||
{
|
||||
*RetBufferDesc = BufferDesc;
|
||||
}
|
||||
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiExWriteDataToField
|
||||
*
|
||||
* PARAMETERS: SourceDesc - Contains data to write
|
||||
* ObjDesc - The named field
|
||||
* ResultDesc - Where the return value is returned, if any
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Write to a named field
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiExWriteDataToField (
|
||||
ACPI_OPERAND_OBJECT *SourceDesc,
|
||||
ACPI_OPERAND_OBJECT *ObjDesc,
|
||||
ACPI_OPERAND_OBJECT **ResultDesc)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
UINT32 Length;
|
||||
UINT32 RequiredLength;
|
||||
void *Buffer;
|
||||
void *NewBuffer;
|
||||
BOOLEAN Locked;
|
||||
ACPI_OPERAND_OBJECT *BufferDesc;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE_PTR ("ExWriteDataToField", ObjDesc);
|
||||
|
||||
|
||||
/* Parameter validation */
|
||||
|
||||
if (!SourceDesc || !ObjDesc)
|
||||
{
|
||||
return_ACPI_STATUS (AE_AML_NO_OPERAND);
|
||||
}
|
||||
|
||||
if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_BUFFER_FIELD)
|
||||
{
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_REGION_FIELD) &&
|
||||
(ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS))
|
||||
{
|
||||
/*
|
||||
* This is an SMBus write. We will bypass the entire field mechanism
|
||||
* and handoff the buffer directly to the handler.
|
||||
*
|
||||
* Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE).
|
||||
*/
|
||||
if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_BUFFER)
|
||||
{
|
||||
ACPI_REPORT_ERROR (("SMBus write requires Buffer, found type %s\n",
|
||||
AcpiUtGetObjectTypeName (SourceDesc)));
|
||||
|
||||
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
|
||||
}
|
||||
|
||||
if (SourceDesc->Buffer.Length < ACPI_SMBUS_BUFFER_SIZE)
|
||||
{
|
||||
ACPI_REPORT_ERROR ((
|
||||
"SMBus write requires Buffer of length %X, found length %X\n",
|
||||
ACPI_SMBUS_BUFFER_SIZE, SourceDesc->Buffer.Length));
|
||||
|
||||
return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
|
||||
}
|
||||
|
||||
BufferDesc = AcpiUtCreateBufferObject (ACPI_SMBUS_BUFFER_SIZE);
|
||||
if (!BufferDesc)
|
||||
{
|
||||
return_ACPI_STATUS (AE_NO_MEMORY);
|
||||
}
|
||||
|
||||
Buffer = BufferDesc->Buffer.Pointer;
|
||||
ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer,
|
||||
ACPI_SMBUS_BUFFER_SIZE);
|
||||
|
||||
/* Lock entire transaction if requested */
|
||||
|
||||
Locked = AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
|
||||
|
||||
/*
|
||||
* Perform the write (returns status and perhaps data in the
|
||||
* same buffer)
|
||||
* Note: SMBus protocol type is passed in upper 16-bits of Function.
|
||||
*/
|
||||
Status = AcpiExAccessRegion (ObjDesc, 0,
|
||||
(ACPI_INTEGER *) Buffer,
|
||||
ACPI_WRITE | (ObjDesc->Field.Attribute << 16));
|
||||
AcpiExReleaseGlobalLock (Locked);
|
||||
|
||||
*ResultDesc = BufferDesc;
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
/* Get a pointer to the data to be written */
|
||||
|
||||
switch (ACPI_GET_OBJECT_TYPE (SourceDesc))
|
||||
{
|
||||
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:
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* We must have a buffer that is at least as long as the field
|
||||
* we are writing to. This is because individual fields are
|
||||
* indivisible and partial writes are not supported -- as per
|
||||
* the ACPI specification.
|
||||
* TBD: [Future] Acpi 2.0 supports Qword fields
|
||||
*
|
||||
* Init and validate Field width
|
||||
* Possible values are 1, 2, 4
|
||||
*/
|
||||
NewBuffer = NULL;
|
||||
RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES (
|
||||
ObjDesc->CommonField.BitLength);
|
||||
|
||||
if (Length < RequiredLength)
|
||||
FieldByteWidth = DIV_8 (FieldBitWidth);
|
||||
|
||||
if ((FieldBitWidth != 8) &&
|
||||
(FieldBitWidth != 16) &&
|
||||
(FieldBitWidth != 32))
|
||||
{
|
||||
/* We need to create a new buffer */
|
||||
DEBUG_PRINT (ACPI_ERROR,
|
||||
("AmlSetupField: Internal error - bad width %d\n", FieldBitWidth));
|
||||
return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
|
||||
}
|
||||
|
||||
NewBuffer = ACPI_MEM_CALLOCATE (RequiredLength);
|
||||
if (!NewBuffer)
|
||||
|
||||
/*
|
||||
* 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))
|
||||
{
|
||||
return_ACPI_STATUS (AE_NO_MEMORY);
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the original data to the new buffer, starting
|
||||
* at Byte zero. All unused (upper) bytes of the
|
||||
* buffer will be 0.
|
||||
*/
|
||||
ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, Length);
|
||||
Buffer = NewBuffer;
|
||||
Length = RequiredLength;
|
||||
}
|
||||
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
||||
"FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n",
|
||||
SourceDesc, AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (SourceDesc)),
|
||||
ACPI_GET_OBJECT_TYPE (SourceDesc), Buffer, Length));
|
||||
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
|
||||
"FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n",
|
||||
ObjDesc, AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc)),
|
||||
ACPI_GET_OBJECT_TYPE (ObjDesc),
|
||||
ObjDesc->CommonField.BitLength,
|
||||
ObjDesc->CommonField.StartFieldBitOffset,
|
||||
ObjDesc->CommonField.BaseByteOffset));
|
||||
|
||||
/* Lock entire transaction if requested */
|
||||
|
||||
Locked = AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
|
||||
|
||||
/* Write to the field */
|
||||
|
||||
Status = AcpiExInsertIntoField (ObjDesc, Buffer, Length);
|
||||
AcpiExReleaseGlobalLock (Locked);
|
||||
|
||||
/* Free temporary buffer if we used one */
|
||||
|
||||
if (NewBuffer)
|
||||
if ((ObjDesc->Common.Type == ACPI_TYPE_FIELD_UNIT) &&
|
||||
(!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)))
|
||||
{
|
||||
ACPI_MEM_FREE (NewBuffer);
|
||||
/*
|
||||
* Field Buffer and Index have not been previously evaluated,
|
||||
*/
|
||||
DEBUG_PRINT (ACPI_ERROR, ("Uninitialized field!\n"));
|
||||
return_ACPI_STATUS (AE_AML_INTERNAL);
|
||||
}
|
||||
|
||||
if (RgnDesc->Region.Length <
|
||||
(ObjDesc->Field.Offset & ~((UINT32) FieldByteWidth - 1)) +
|
||||
FieldByteWidth)
|
||||
{
|
||||
/*
|
||||
* Offset rounded up to next multiple of field width
|
||||
* exceeds region length, indicate an error
|
||||
*/
|
||||
|
||||
DUMP_STACK_ENTRY (RgnDesc);
|
||||
DUMP_STACK_ENTRY (ObjDesc);
|
||||
|
||||
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));
|
||||
|
||||
return_ACPI_STATUS (AE_AML_REGION_LIMIT);
|
||||
}
|
||||
|
||||
return_ACPI_STATUS (AE_OK);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiAmlAccessNamedField
|
||||
*
|
||||
* 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
|
||||
AcpiAmlAccessNamedField (
|
||||
UINT32 Mode,
|
||||
ACPI_NAMESPACE_NODE *FieldNode,
|
||||
void *Buffer,
|
||||
UINT32 BufferLength)
|
||||
{
|
||||
ACPI_OPERAND_OBJECT *ObjDesc = NULL;
|
||||
ACPI_STATUS Status = AE_OK;
|
||||
BOOLEAN Locked = FALSE;
|
||||
UINT32 BitGranularity = 0;
|
||||
UINT32 ByteGranularity;
|
||||
UINT32 DatumLength;
|
||||
UINT32 ActualByteLength;
|
||||
UINT32 ByteFieldLength;
|
||||
|
||||
|
||||
FUNCTION_TRACE_PTR ("AmlAccessNamedField", FieldNode);
|
||||
|
||||
|
||||
/* Parameter validation */
|
||||
|
||||
if ((!FieldNode) || (ACPI_READ == Mode && !Buffer))
|
||||
{
|
||||
DEBUG_PRINT (ACPI_ERROR,
|
||||
("AcpiAmlAccessNamedField: 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",
|
||||
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);
|
||||
|
||||
|
||||
/* 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;
|
||||
ByteGranularity = DIV_8 (BitGranularity);
|
||||
|
||||
/*
|
||||
* Check if request is too large for the field, and silently truncate
|
||||
* if necessary
|
||||
*/
|
||||
|
||||
/* TBD: [Errors] should an error be returned in this case? */
|
||||
|
||||
ByteFieldLength = (UINT32) DIV_8 (ObjDesc->FieldUnit.Length + 7);
|
||||
|
||||
|
||||
ActualByteLength = BufferLength;
|
||||
if (BufferLength > ByteFieldLength)
|
||||
{
|
||||
DEBUG_PRINT (ACPI_INFO,
|
||||
("AmlAccessNamedField: 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 */
|
||||
|
||||
DatumLength = (ActualByteLength + (ByteGranularity-1)) / ByteGranularity;
|
||||
|
||||
DEBUG_PRINT (ACPI_INFO,
|
||||
("ByteLen=%x, DatumLen=%x, BitGran=%x, ByteGran=%x\n",
|
||||
ActualByteLength, DatumLength, BitGranularity, ByteGranularity));
|
||||
|
||||
|
||||
/* Get the global lock if needed */
|
||||
|
||||
Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule);
|
||||
|
||||
|
||||
/* Perform the actual read or write of the buffer */
|
||||
|
||||
switch (Mode)
|
||||
{
|
||||
case ACPI_READ:
|
||||
|
||||
Status = AcpiAmlReadField (ObjDesc, Buffer, BufferLength,
|
||||
ActualByteLength, DatumLength,
|
||||
BitGranularity, ByteGranularity);
|
||||
break;
|
||||
|
||||
|
||||
case ACPI_WRITE:
|
||||
|
||||
Status = AcpiAmlWriteField (ObjDesc, Buffer, BufferLength,
|
||||
ActualByteLength, DatumLength,
|
||||
BitGranularity, ByteGranularity);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
|
||||
DEBUG_PRINT (ACPI_ERROR,
|
||||
("AccessNamedField: Unknown I/O Mode: %X\n", Mode));
|
||||
Status = AE_BAD_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Release global lock if we acquired it earlier */
|
||||
|
||||
AcpiAmlReleaseGlobalLock (Locked);
|
||||
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user