Deleted Added
full compact
4c4
< * $Revision: 104 $
---
> * $Revision: 106 $
848a849,917
> * FUNCTION: AcpiExCommonBufferSetup
> *
> * PARAMETERS: ObjDesc - Field object
> * BufferLength - Length of caller's buffer
> * DatumCount - Where the DatumCount is returned
> *
> * RETURN: Status, DatumCount
> *
> * DESCRIPTION: Common code to validate the incoming buffer size and compute
> * the number of field "datums" that must be read or written.
> * A "datum" is the smallest unit that can be read or written
> * to the field, it is either 1,2,4, or 8 bytes.
> *
> ******************************************************************************/
>
> ACPI_STATUS
> AcpiExCommonBufferSetup (
> ACPI_OPERAND_OBJECT *ObjDesc,
> UINT32 BufferLength,
> UINT32 *DatumCount)
> {
> UINT32 ByteFieldLength;
> UINT32 ActualByteFieldLength;
>
>
> ACPI_FUNCTION_TRACE ("ExCommonBufferSetup");
>
>
> /*
> * Incoming buffer must be at least as long as the field, we do not
> * allow "partial" field reads/writes. We do not care if the buffer is
> * larger than the field, this typically happens when an integer is
> * read/written to a field that is actually smaller than an integer.
> */
> ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (
> ObjDesc->CommonField.BitLength);
> if (ByteFieldLength > BufferLength)
> {
> ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
> "Field size %X (bytes) is too large for buffer (%X)\n",
> ByteFieldLength, BufferLength));
>
> return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
> }
>
> /*
> * Create "actual" field byte count (minimum number of bytes that
> * must be read), then convert to datum count (minimum number
> * of datum-sized units that must be read)
> */
> ActualByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (
> ObjDesc->CommonField.StartFieldBitOffset +
> ObjDesc->CommonField.BitLength);
>
>
> *DatumCount = ACPI_ROUND_UP_TO (ActualByteFieldLength,
> ObjDesc->CommonField.AccessByteWidth);
>
> ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
> "BufferBytes %X, ActualBytes %X, Datums %X, ByteGran %X\n",
> ByteFieldLength, ActualByteFieldLength,
> *DatumCount, ObjDesc->CommonField.AccessByteWidth));
>
> return_ACPI_STATUS (AE_OK);
> }
>
>
> /*******************************************************************************
> *
851,852c920,922
< * PARAMETERS: *ObjDesc - Field to be read
< * *Value - Where to store value
---
> * PARAMETERS: ObjDesc - Field to be read
> * Buffer - Where to store the field data
> * BufferLength - Length of Buffer
856c926
< * DESCRIPTION: Retrieve the value of the given field
---
> * DESCRIPTION: Retrieve the current value of the given field
872d941
< UINT32 ByteFieldLength;
880,888c949
< /*
< * The field must fit within the caller's buffer
< */
< ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength);
< if (ByteFieldLength > BufferLength)
< {
< ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
< "Field size %X (bytes) too large for buffer (%X)\n",
< ByteFieldLength, BufferLength));
---
> /* Validate buffer, compute number of datums */
890,906c951,952
< return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
< }
<
< /* Convert field byte count to datum count, round up if necessary */
<
< DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength,
< ObjDesc->CommonField.AccessByteWidth);
<
< /*
< * If the field is not aligned on a datum boundary and does not
< * fit within a single datum, we must read an extra datum.
< *
< * We could just split the aligned and non-aligned cases since the
< * aligned case is so very simple, but this would require more code.
< */
< if ((ObjDesc->CommonField.EndFieldValidBits != 0) &&
< (!(ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM)))
---
> Status = AcpiExCommonBufferSetup (ObjDesc, BufferLength, &DatumCount);
> if (ACPI_FAILURE (Status))
908c954
< DatumCount++;
---
> return_ACPI_STATUS (Status);
911,914d956
< ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
< "ByteLen %X, DatumLen %X, ByteGran %X\n",
< ByteFieldLength, DatumCount,ObjDesc->CommonField.AccessByteWidth));
<
1036,1037c1078,1080
< * PARAMETERS: *ObjDesc - Field to be set
< * Buffer - Value to store
---
> * PARAMETERS: ObjDesc - Field to be written
> * Buffer - Data to be written
> * BufferLength - Length of Buffer
1041c1084
< * DESCRIPTION: Store the value into the given field
---
> * DESCRIPTION: Store the Buffer contents into the given field
1058d1100
< UINT32 ByteFieldLength;
1065,1077c1107
< /*
< * Incoming buffer must be at least as long as the field, we do not
< * allow "partial" field writes. We do not care if the buffer is
< * larger than the field, this typically happens when an integer is
< * written to a field that is actually smaller than an integer.
< */
< ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (
< ObjDesc->CommonField.BitLength);
< if (BufferLength < ByteFieldLength)
< {
< ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
< "Buffer length %X too small for field %X\n",
< BufferLength, ByteFieldLength));
---
> /* Validate buffer, compute number of datums */
1079c1109,1112
< return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
---
> Status = AcpiExCommonBufferSetup (ObjDesc, BufferLength, &DatumCount);
> if (ACPI_FAILURE (Status))
> {
> return_ACPI_STATUS (Status);
1082,1094d1114
< ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (
< ObjDesc->CommonField.StartFieldBitOffset +
< ObjDesc->CommonField.BitLength);
<
< /* Convert byte count to datum count, round up if necessary */
<
< DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength,
< ObjDesc->CommonField.AccessByteWidth);
<
< ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
< "Bytes %X, Datums %X, ByteGran %X\n",
< ByteFieldLength, DatumCount, ObjDesc->CommonField.AccessByteWidth));
<