diff options
Diffstat (limited to 'sys/contrib/dev/acpica/exfldio.c')
-rw-r--r-- | sys/contrib/dev/acpica/exfldio.c | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/sys/contrib/dev/acpica/exfldio.c b/sys/contrib/dev/acpica/exfldio.c index 9bfc5d9..1cc535d 100644 --- a/sys/contrib/dev/acpica/exfldio.c +++ b/sys/contrib/dev/acpica/exfldio.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exfldio - Aml Field I/O - * $Revision: 92 $ + * $Revision: 96 $ * *****************************************************************************/ @@ -676,9 +676,10 @@ AcpiExWriteWithUpdateRule ( * * PARAMETERS: Datum - Where the Datum is returned * Buffer - Raw field buffer + * BufferLength - Entire length (used for big-endian only) * ByteGranularity - 1/2/4/8 Granularity of the field * (aka Datum Size) - * Offset - Datum offset into the buffer + * BufferOffset - Datum offset into the buffer * * RETURN: none * @@ -688,36 +689,45 @@ AcpiExWriteWithUpdateRule ( ******************************************************************************/ void -AcpiExGetBufferDatum( +AcpiExGetBufferDatum ( ACPI_INTEGER *Datum, void *Buffer, + UINT32 BufferLength, UINT32 ByteGranularity, - UINT32 Offset) + UINT32 BufferOffset) { + UINT32 Index; + ACPI_FUNCTION_ENTRY (); + /* Get proper index into buffer (handles big/little endian) */ + + Index = ACPI_BUFFER_INDEX (BufferLength, BufferOffset, ByteGranularity); + + /* Move the requested number of bytes */ + switch (ByteGranularity) { case ACPI_FIELD_BYTE_GRANULARITY: - *Datum = ((UINT8 *) Buffer) [Offset]; + *Datum = ((UINT8 *) Buffer) [Index]; break; case ACPI_FIELD_WORD_GRANULARITY: - ACPI_MOVE_UNALIGNED16_TO_32 (Datum, &(((UINT16 *) Buffer) [Offset])); + ACPI_MOVE_16_TO_64 (Datum, &(((UINT16 *) Buffer) [Index])); break; case ACPI_FIELD_DWORD_GRANULARITY: - ACPI_MOVE_UNALIGNED32_TO_32 (Datum, &(((UINT32 *) Buffer) [Offset])); + ACPI_MOVE_32_TO_64 (Datum, &(((UINT32 *) Buffer) [Index])); break; case ACPI_FIELD_QWORD_GRANULARITY: - ACPI_MOVE_UNALIGNED64_TO_64 (Datum, &(((UINT64 *) Buffer) [Offset])); + ACPI_MOVE_64_TO_64 (Datum, &(((UINT64 *) Buffer) [Index])); break; default: @@ -733,9 +743,10 @@ AcpiExGetBufferDatum( * * PARAMETERS: MergedDatum - Value to store * Buffer - Receiving buffer + * BufferLength - Entire length (used for big-endian only) * ByteGranularity - 1/2/4/8 Granularity of the field * (aka Datum Size) - * Offset - Datum offset into the buffer + * BufferOffset - Datum offset into the buffer * * RETURN: none * @@ -748,33 +759,41 @@ void AcpiExSetBufferDatum ( ACPI_INTEGER MergedDatum, void *Buffer, + UINT32 BufferLength, UINT32 ByteGranularity, - UINT32 Offset) + UINT32 BufferOffset) { + UINT32 Index; ACPI_FUNCTION_ENTRY (); + /* Get proper index into buffer (handles big/little endian) */ + + Index = ACPI_BUFFER_INDEX (BufferLength, BufferOffset, ByteGranularity); + + /* Move the requested number of bytes */ + switch (ByteGranularity) { case ACPI_FIELD_BYTE_GRANULARITY: - ((UINT8 *) Buffer) [Offset] = (UINT8) MergedDatum; + ((UINT8 *) Buffer) [Index] = (UINT8) MergedDatum; break; case ACPI_FIELD_WORD_GRANULARITY: - ACPI_MOVE_UNALIGNED16_TO_16 (&(((UINT16 *) Buffer)[Offset]), &MergedDatum); + ACPI_MOVE_64_TO_16 (&(((UINT16 *) Buffer)[Index]), &MergedDatum); break; case ACPI_FIELD_DWORD_GRANULARITY: - ACPI_MOVE_UNALIGNED32_TO_32 (&(((UINT32 *) Buffer)[Offset]), &MergedDatum); + ACPI_MOVE_64_TO_32 (&(((UINT32 *) Buffer)[Index]), &MergedDatum); break; case ACPI_FIELD_QWORD_GRANULARITY: - ACPI_MOVE_UNALIGNED64_TO_64 (&(((UINT64 *) Buffer)[Offset]), &MergedDatum); + ACPI_MOVE_64_TO_64 (&(((UINT64 *) Buffer)[Index]), &MergedDatum); break; default: @@ -876,8 +895,8 @@ AcpiExExtractFromField ( /* Store the datum to the caller buffer */ - AcpiExSetBufferDatum (MergedDatum, Buffer, ObjDesc->CommonField.AccessByteWidth, - DatumOffset); + AcpiExSetBufferDatum (MergedDatum, Buffer, BufferLength, + ObjDesc->CommonField.AccessByteWidth, DatumOffset); return_ACPI_STATUS (AE_OK); } @@ -956,7 +975,7 @@ AcpiExExtractFromField ( * Store the merged field datum in the caller's buffer, according to * the granularity of the field (size of each datum). */ - AcpiExSetBufferDatum (MergedDatum, Buffer, + AcpiExSetBufferDatum (MergedDatum, Buffer, BufferLength, ObjDesc->CommonField.AccessByteWidth, DatumOffset); /* @@ -1038,7 +1057,7 @@ AcpiExInsertIntoField ( /* Get a single datum from the caller's buffer */ - AcpiExGetBufferDatum (&PreviousRawDatum, Buffer, + AcpiExGetBufferDatum (&PreviousRawDatum, Buffer, BufferLength, ObjDesc->CommonField.AccessByteWidth, DatumOffset); /* @@ -1105,7 +1124,7 @@ AcpiExInsertIntoField ( * Get the next raw buffer datum. It may contain bits of the previous * field datum */ - AcpiExGetBufferDatum (&ThisRawDatum, Buffer, + AcpiExGetBufferDatum (&ThisRawDatum, Buffer, BufferLength, ObjDesc->CommonField.AccessByteWidth, DatumOffset); /* Create the field datum based on the field alignment */ |