Skip to content

Commit

Permalink
Hardware: Add optimized access bit width support
Browse files Browse the repository at this point in the history
For Access Size = 0, it actually can use user expected access bit width.
This patch implements this. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
Lv Zheng committed Apr 15, 2016
1 parent c23034a commit c49a751
Showing 1 changed file with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions source/components/hardware/hwregs.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@

/* Local Prototypes */

static UINT8
AcpiHwGetAccessBitWidth (
ACPI_GENERIC_ADDRESS *Reg,
UINT8 MaxBitWidth);

static ACPI_STATUS
AcpiHwReadMultiple (
UINT32 *Value,
Expand All @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit c49a751

Please sign in to comment.