diff options
author | jkim <jkim@FreeBSD.org> | 2016-04-30 06:48:48 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2016-04-30 06:48:48 +0000 |
commit | 470b1c2a5e88c5167cc16afc572255dfac167af1 (patch) | |
tree | 937479d0b3c095324ea3067354c5d063e9081b42 /sys/contrib/dev/acpica/components/hardware | |
parent | c5ca227cf4ecfea80e454e2cf3ac7fd5e6434f8e (diff) | |
download | FreeBSD-src-470b1c2a5e88c5167cc16afc572255dfac167af1.zip FreeBSD-src-470b1c2a5e88c5167cc16afc572255dfac167af1.tar.gz |
Revert AccessWidth/BitOffset support for AcpiHwWrite() and AcpiHwRead() for
now. The following upstream commits are reverted from hwregs.c:
https://github.com/acpica/acpica/commit/96ece05
https://github.com/acpica/acpica/commit/3d8583a
https://github.com/acpica/acpica/commit/48eea5e
https://github.com/acpica/acpica/commit/0a212c3
https://github.com/acpica/acpica/commit/41f6aef
https://github.com/acpica/acpica/commit/26434b9
https://github.com/acpica/acpica/commit/c23034a
https://github.com/acpica/acpica/commit/c49a751
Note this commit will be reverted when the upstream fixes the code properly.
Diffstat (limited to 'sys/contrib/dev/acpica/components/hardware')
-rw-r--r-- | sys/contrib/dev/acpica/components/hardware/hwregs.c | 225 |
1 files changed, 30 insertions, 195 deletions
diff --git a/sys/contrib/dev/acpica/components/hardware/hwregs.c b/sys/contrib/dev/acpica/components/hardware/hwregs.c index ad879d7..ebb4ce7 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwregs.c +++ b/sys/contrib/dev/acpica/components/hardware/hwregs.c @@ -54,11 +54,6 @@ /* Local Prototypes */ -static UINT8 -AcpiHwGetAccessBitWidth ( - ACPI_GENERIC_ADDRESS *Reg, - UINT8 MaxBitWidth); - static ACPI_STATUS AcpiHwReadMultiple ( UINT32 *Value, @@ -76,43 +71,6 @@ AcpiHwWriteMultiple ( /****************************************************************************** * - * FUNCTION: AcpiHwGetAccessBitWidth - * - * PARAMETERS: Reg - GAS register structure - * MaxBitWidth - Max BitWidth supported (32 or 64) - * - * RETURN: Status - * - * DESCRIPTION: Obtain optimal access bit width - * - ******************************************************************************/ - -static UINT8 -AcpiHwGetAccessBitWidth ( - ACPI_GENERIC_ADDRESS *Reg, - UINT8 MaxBitWidth) -{ - - if (!Reg->AccessWidth) - { - if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO) - { - return (32); - } - else - { - return (MaxBitWidth); - } - } - else - { - return (1 << (Reg->AccessWidth + 2)); - } -} - - -/****************************************************************************** - * * FUNCTION: AcpiHwValidateRegister * * PARAMETERS: Reg - GAS register structure @@ -134,6 +92,7 @@ AcpiHwValidateRegister ( UINT64 *Address) { UINT8 BitWidth; + UINT8 BitEnd; UINT8 AccessWidth; @@ -176,8 +135,11 @@ AcpiHwValidateRegister ( /* Validate the BitWidth, convert AccessWidth into number of bits */ - AccessWidth = AcpiHwGetAccessBitWidth (Reg, MaxBitWidth); - BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth); + BitEnd = Reg->BitOffset + Reg->BitWidth; + AccessWidth = Reg->AccessWidth ? Reg->AccessWidth : 1; + AccessWidth = 1 << (AccessWidth + 2); + BitWidth = ACPI_ROUND_UP (BitEnd, AccessWidth) - + ACPI_ROUND_DOWN (Reg->BitOffset, AccessWidth); if (MaxBitWidth < BitWidth) { ACPI_WARNING ((AE_INFO, @@ -204,7 +166,10 @@ AcpiHwValidateRegister ( * 64-bit values is not needed. * * LIMITATIONS: <These limitations also apply to AcpiHwWrite> + * BitWidth must be exactly 8, 16, or 32. * SpaceID must be SystemMemory or SystemIO. + * BitOffset and AccessWidth are currently ignored, as there has + * not been a need to implement these. * ******************************************************************************/ @@ -214,12 +179,7 @@ AcpiHwRead ( ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; - UINT8 AccessWidth; - UINT32 BitWidth; - UINT8 BitOffset; UINT64 Value64; - UINT32 Value32; - UINT8 Index; ACPI_STATUS Status; @@ -234,64 +194,30 @@ AcpiHwRead ( return (Status); } - /* - * Initialize entire 32-bit return value to zero, convert AccessWidth - * into number of bits based - */ + /* Initialize entire 32-bit return value to zero */ + *Value = 0; - AccessWidth = AcpiHwGetAccessBitWidth (Reg, 32); - BitWidth = Reg->BitOffset + Reg->BitWidth; - BitOffset = Reg->BitOffset; /* * Two address spaces supported: Memory or IO. PCI_Config is * not supported here because the GAS structure is insufficient */ - Index = 0; - while (BitWidth) + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) { - if (BitOffset > AccessWidth) - { - Value32 = 0; - BitOffset -= AccessWidth; - } - else - { - if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) - { - Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) - Address + Index * ACPI_DIV_8 (AccessWidth), - &Value64, AccessWidth); - Value32 = (UINT32) Value64; - } - else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ - { - Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) - Address + Index * ACPI_DIV_8 (AccessWidth), - &Value32, AccessWidth); - } - - if (BitOffset) - { - Value32 &= ACPI_MASK_BITS_BELOW (BitOffset); - BitOffset = 0; - } - if (BitWidth < AccessWidth) - { - Value32 &= ACPI_MASK_BITS_ABOVE (BitWidth); - } - } + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address, &Value64, Reg->BitWidth); - ACPI_SET_BITS (Value, Index * AccessWidth, - ACPI_MASK_BITS_ABOVE_32 (AccessWidth), Value32); - - BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth; - Index++; + *Value = (UINT32) Value64; + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address, Value, Reg->BitWidth); } ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", - *Value, AccessWidth, ACPI_FORMAT_UINT64 (Address), + *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); @@ -319,12 +245,6 @@ AcpiHwWrite ( ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; - UINT8 AccessWidth; - UINT32 BitWidth; - UINT8 BitOffset; - UINT64 Value64; - UINT32 NewValue32, OldValue32; - UINT8 Index; ACPI_STATUS Status; @@ -339,109 +259,24 @@ AcpiHwWrite ( return (Status); } - /* Convert AccessWidth into number of bits based */ - - AccessWidth = AcpiHwGetAccessBitWidth (Reg, 32); - BitWidth = Reg->BitOffset + Reg->BitWidth; - BitOffset = Reg->BitOffset; - /* * Two address spaces supported: Memory or IO. PCI_Config is * not supported here because the GAS structure is insufficient */ - Index = 0; - while (BitWidth) + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) { - NewValue32 = ACPI_GET_BITS (&Value, Index * AccessWidth, - ACPI_MASK_BITS_ABOVE_32 (AccessWidth)); - - if (BitOffset > AccessWidth) - { - BitOffset -= AccessWidth; - } - else - { - if (BitOffset) - { - NewValue32 &= ACPI_MASK_BITS_BELOW (BitOffset); - } - - if (BitWidth < AccessWidth) - { - NewValue32 &= ACPI_MASK_BITS_ABOVE (BitWidth); - } - - if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) - { - if (BitOffset || BitWidth < AccessWidth) - { - /* - * Read old values in order not to modify the bits that - * are beyond the register BitWidth/BitOffset setting. - */ - Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) - Address + Index * ACPI_DIV_8 (AccessWidth), - &Value64, AccessWidth); - OldValue32 = (UINT32) Value64; - - if (BitOffset) - { - OldValue32 &= ACPI_MASK_BITS_ABOVE (BitOffset + 1); - BitOffset = 0; - } - - if (BitWidth < AccessWidth) - { - OldValue32 &= ACPI_MASK_BITS_BELOW (BitWidth - 1); - } - - NewValue32 |= OldValue32; - } - - Value64 = (UINT64) NewValue32; - Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) - Address + Index * ACPI_DIV_8 (AccessWidth), - Value64, AccessWidth); - } - else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ - { - if (BitOffset || BitWidth < AccessWidth) - { - /* - * Read old values in order not to modify the bits that - * are beyond the register BitWidth/BitOffset setting. - */ - Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) - Address + Index * ACPI_DIV_8 (AccessWidth), - &OldValue32, AccessWidth); - - if (BitOffset) - { - OldValue32 &= ACPI_MASK_BITS_ABOVE (BitOffset + 1); - BitOffset = 0; - } - - if (BitWidth < AccessWidth) - { - OldValue32 &= ACPI_MASK_BITS_BELOW (BitWidth - 1); - } - - NewValue32 |= OldValue32; - } - - Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) - Address + Index * ACPI_DIV_8 (AccessWidth), - NewValue32, AccessWidth); - } - } - - BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth; - Index++; + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address, (UINT64) Value, Reg->BitWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address, Value, Reg->BitWidth); } ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", - Value, AccessWidth, ACPI_FORMAT_UINT64 (Address), + Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); |