Author: tfaber Date: Thu Apr 14 19:38:40 2016 New Revision: 71158
URL: http://svn.reactos.org/svn/reactos?rev=71158&view=rev Log: [ACPICA] - Revert the changes adding arbitrary bit length read/write support since they cause problems on VirtualBox and will be reworked upstream. CORE-11115 #resolve
Modified: trunk/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c
Modified: trunk/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/acpica/har... ============================================================================== --- trunk/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c [iso-8859-1] Thu Apr 14 19:38:40 2016 @@ -91,9 +91,6 @@ UINT8 MaxBitWidth, UINT64 *Address) { - UINT8 BitWidth; - UINT8 AccessWidth; -
/* Must have a valid pointer to a GAS structure */
@@ -123,26 +120,24 @@ return (AE_SUPPORT); }
- /* Validate the AccessWidth */ - - if (Reg->AccessWidth > 4) + /* Validate the BitWidth */ + + if ((Reg->BitWidth != 8) && + (Reg->BitWidth != 16) && + (Reg->BitWidth != 32) && + (Reg->BitWidth != MaxBitWidth)) { ACPI_ERROR ((AE_INFO, - "Unsupported register access width: 0x%X", Reg->AccessWidth)); + "Unsupported register bit width: 0x%X", Reg->BitWidth)); return (AE_SUPPORT); }
- /* Validate the BitWidth, convert AccessWidth into number of bits */ - - AccessWidth = Reg->AccessWidth ? Reg->AccessWidth : 1; - AccessWidth = 1 << (AccessWidth + 2); - BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth); - if (MaxBitWidth < BitWidth) + /* Validate the BitOffset. Just a warning for now. */ + + if (Reg->BitOffset != 0) { ACPI_WARNING ((AE_INFO, - "Requested bit width 0x%X is smaller than register bit width 0x%X", - MaxBitWidth, BitWidth)); - return (AE_SUPPORT); + "Unsupported register bit offset: 0x%X", Reg->BitOffset)); }
return (AE_OK); @@ -163,7 +158,10 @@ * 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. * ******************************************************************************/
@@ -173,12 +171,7 @@ ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; - UINT8 AccessWidth; - UINT32 BitWidth; - UINT8 BitOffset; UINT64 Value64; - UINT32 Value32; - UINT8 Index; ACPI_STATUS Status;
@@ -193,65 +186,30 @@ 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 = Reg->AccessWidth ? Reg->AccessWidth : 1; - AccessWidth = 1 << (AccessWidth + 2); - BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth); - 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 (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); - } - } - - ACPI_SET_BITS (Value, Index * AccessWidth, - ((1 << AccessWidth) - 1), Value32); - - BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth; - Index++; + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address, &Value64, Reg->BitWidth); + + *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); @@ -279,12 +237,6 @@ ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; - UINT8 AccessWidth; - UINT32 BitWidth; - UINT8 BitOffset; - UINT64 Value64; - UINT32 NewValue32, OldValue32; - UINT8 Index; ACPI_STATUS Status;
@@ -298,111 +250,25 @@ { return (Status); } - - /* Convert AccessWidth into number of bits based */ - - AccessWidth = Reg->AccessWidth ? Reg->AccessWidth : 1; - AccessWidth = 1 << (AccessWidth + 2); - BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth); - 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) - { - NewValue32 = ACPI_GET_BITS (&Value, (Index * AccessWidth), - ((1 << AccessWidth) - 1)); - - 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++; + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + 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);