mirror of
https://github.com/acpica/acpica/
synced 2025-02-24 17:34:43 +03:00
commit
9ebfa93b4e
@ -1018,20 +1018,9 @@ AcpiExInsertIntoField (
|
||||
|
||||
AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
|
||||
|
||||
/*
|
||||
* Create the bitmasks used for bit insertion.
|
||||
* Note: This if/else is used to bypass compiler differences with the
|
||||
* shift operator
|
||||
*/
|
||||
if (AccessBitWidth == ACPI_INTEGER_BIT_SIZE)
|
||||
{
|
||||
WidthMask = ACPI_UINT64_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
WidthMask = ACPI_MASK_BITS_ABOVE (AccessBitWidth);
|
||||
}
|
||||
/* Create the bitmasks used for bit insertion */
|
||||
|
||||
WidthMask = ACPI_MASK_BITS_ABOVE_64 (AccessBitWidth);
|
||||
Mask = WidthMask &
|
||||
ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset);
|
||||
|
||||
|
@ -126,6 +126,11 @@
|
||||
|
||||
/* Local Prototypes */
|
||||
|
||||
static UINT8
|
||||
AcpiHwGetAccessBitWidth (
|
||||
ACPI_GENERIC_ADDRESS *Reg,
|
||||
UINT8 MaxBitWidth);
|
||||
|
||||
static ACPI_STATUS
|
||||
AcpiHwReadMultiple (
|
||||
UINT32 *Value,
|
||||
@ -141,6 +146,43 @@ AcpiHwWriteMultiple (
|
||||
#endif /* !ACPI_REDUCED_HARDWARE */
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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
|
||||
@ -206,8 +248,7 @@ AcpiHwValidateRegister (
|
||||
|
||||
/* Validate the BitWidth, convert AccessWidth into number of bits */
|
||||
|
||||
AccessWidth = Reg->AccessWidth ? Reg->AccessWidth : 1;
|
||||
AccessWidth = 1 << (AccessWidth + 2);
|
||||
AccessWidth = AcpiHwGetAccessBitWidth (Reg, MaxBitWidth);
|
||||
BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth);
|
||||
if (MaxBitWidth < BitWidth)
|
||||
{
|
||||
@ -270,8 +311,7 @@ AcpiHwRead (
|
||||
* into number of bits based
|
||||
*/
|
||||
*Value = 0;
|
||||
AccessWidth = Reg->AccessWidth ? Reg->AccessWidth : 1;
|
||||
AccessWidth = 1 << (AccessWidth + 2);
|
||||
AccessWidth = AcpiHwGetAccessBitWidth (Reg, 32);
|
||||
BitWidth = Reg->BitOffset + Reg->BitWidth;
|
||||
BitOffset = Reg->BitOffset;
|
||||
|
||||
@ -315,7 +355,7 @@ AcpiHwRead (
|
||||
}
|
||||
|
||||
ACPI_SET_BITS (Value, Index * AccessWidth,
|
||||
(1 << AccessWidth) - 1, Value32);
|
||||
ACPI_MASK_BITS_ABOVE_32 (AccessWidth), Value32);
|
||||
|
||||
BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth;
|
||||
Index++;
|
||||
@ -373,8 +413,7 @@ AcpiHwWrite (
|
||||
|
||||
/* Convert AccessWidth into number of bits based */
|
||||
|
||||
AccessWidth = Reg->AccessWidth ? Reg->AccessWidth : 1;
|
||||
AccessWidth = 1 << (AccessWidth + 2);
|
||||
AccessWidth = AcpiHwGetAccessBitWidth (Reg, 32);
|
||||
BitWidth = Reg->BitOffset + Reg->BitWidth;
|
||||
BitOffset = Reg->BitOffset;
|
||||
|
||||
@ -386,7 +425,7 @@ AcpiHwWrite (
|
||||
while (BitWidth)
|
||||
{
|
||||
NewValue32 = ACPI_GET_BITS (&Value, Index * AccessWidth,
|
||||
(1 << AccessWidth) - 1);
|
||||
ACPI_MASK_BITS_ABOVE_32 (AccessWidth));
|
||||
|
||||
if (BitOffset > AccessWidth)
|
||||
{
|
||||
|
@ -345,9 +345,21 @@
|
||||
* Bit positions start at zero.
|
||||
* MASK_BITS_ABOVE creates a mask starting AT the position and above
|
||||
* MASK_BITS_BELOW creates a mask starting one bit BELOW the position
|
||||
* MASK_BITS_ABOVE/BELOW accpets a bit offset to create a mask
|
||||
* MASK_BITS_ABOVE/BELOW_32/64 accpets a bit width to create a mask
|
||||
* Note: The ACPI_INTEGER_BIT_SIZE check is used to bypass compiler
|
||||
* differences with the shift operator
|
||||
*/
|
||||
#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_UINT64_MAX) << ((UINT32) (position))))
|
||||
#define ACPI_MASK_BITS_BELOW(position) ((ACPI_UINT64_MAX) << ((UINT32) (position)))
|
||||
#define ACPI_MASK_BITS_ABOVE_32(width) ((UINT32) ACPI_MASK_BITS_ABOVE(width))
|
||||
#define ACPI_MASK_BITS_BELOW_32(width) ((UINT32) ACPI_MASK_BITS_BELOW(width))
|
||||
#define ACPI_MASK_BITS_ABOVE_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \
|
||||
ACPI_UINT64_MAX : \
|
||||
ACPI_MASK_BITS_ABOVE(width))
|
||||
#define ACPI_MASK_BITS_BELOW_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \
|
||||
(UINT64) 0 : \
|
||||
ACPI_MASK_BITS_BELOW(width))
|
||||
|
||||
/* Bitfields within ACPI registers */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user