FreeBSD/sys/contrib/dev/acpica/components/hardware/hwxface.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiReadBitRegister
 *
 * PARAMETERS:  RegisterId      - ID of ACPI Bit Register to access
 *              ReturnValue     - Value that was read from the register,
 *                                normalized to bit position zero.
 *
 * RETURN:      Status and the value read from the specified Register. Value
 *              returned is normalized to bit0 (is shifted all the way right)
 *
 * DESCRIPTION: ACPI BitRegister read function. Does not acquire the HW lock.
 *
 * SUPPORTS:    Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
 *              PM2 Control.
 *
 * Note: The hardware lock is not required when reading the ACPI bit registers
 *       since almost all of them are single bit and it does not matter that
 *       the parent hardware register can be split across two physical
 *       registers. The only multi-bit field is SLP_TYP in the PM1 control
 *       register, but this field does not cross an 8-bit boundary (nor does
 *       it make much sense to actually read this field.)
 *
 ******************************************************************************/
AcpiReadBitRegister
PARAMETERS:  RegisterId      - ID of ACPI Bit Register to access
ReturnValue     - Value that was read from the register,
normalized to bit position zero.

Status and the value read from the specified Register. Value
returned is normalized to bit0 (is shifted all the way right)

ACPI BitRegister read function. Does not acquire the HW lock.



The hardware lock is not required when reading the ACPI bit registers
since almost all of them are single bit and it does not matter that
the parent hardware register can be split across two physical
registers. The only multi-bit field is SLP_TYP in the PM1 control
register, but this field does not cross an 8-bit boundary (nor does
it make much sense to actually read this field.)
AcpiReadBitRegister PARAMETERS : RegisterId - ID of ACPI Bit Register to access ReturnValue - Value that was read from the register normalized to bit position zero . Status and the value read from the specified Register . Value returned is normalized to bit0 ( is shifted all the way right ) ACPI BitRegister read function . Does not acquire the HW lock . The hardware lock is not required when reading the ACPI bit registers since almost all of them are single bit and it does not matter that the parent hardware register can be split across two physical registers . The only multi - bit field is SLP_TYP in the PM1 control register but this field does not cross an 8 - bit boundary ( nor does it make much sense to actually read this field . )
ACPI_STATUS
AcpiReadBitRegister (
    UINT32                  RegisterId,
    UINT32                  *ReturnValue)
{
    ACPI_BIT_REGISTER_INFO  *BitRegInfo;
    UINT32                  RegisterValue;
    UINT32                  Value;
    ACPI_STATUS             Status;
    ACPI_FUNCTION_TRACE_U32 (AcpiReadBitRegister, RegisterId);
    BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
    if (!BitRegInfo)
    {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }
    Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister,
        &RegisterValue);
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }
    Value = ((RegisterValue & BitRegInfo->AccessBitMask)
        >> BitRegInfo->BitPosition);
    ACPI_DEBUG_PRINT ((ACPI_DB_IO,
        "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n",
        RegisterId, BitRegInfo->ParentRegister, RegisterValue, Value));
    *ReturnValue = Value;
    return_ACPI_STATUS (AE_OK);
}
ACPI_STATUS AcpiReadBitRegister ( UINT32 RegisterId , UINT32 * ReturnValue ) { ACPI_BIT_REGISTER_INFO * BitRegInfo ; UINT32 RegisterValue ; UINT32 Value ; ACPI_STATUS Status ; ACPI_FUNCTION_TRACE_U32 ( AcpiReadBitRegister , RegisterId ) ; BitRegInfo = AcpiHwGetBitRegisterInfo ( RegisterId ) ; if ( ! BitRegInfo ) { return_ACPI_STATUS ( AE_BAD_PARAMETER ) ; } Status = AcpiHwRegisterRead ( BitRegInfo -> ParentRegister , & RegisterValue ) ; if ( ACPI_FAILURE ( Status ) ) { return_ACPI_STATUS ( Status ) ; } Value = ( ( RegisterValue & BitRegInfo -> AccessBitMask ) >> BitRegInfo -> BitPosition ) ; ACPI_DEBUG_PRINT ( ( ACPI_DB_IO , " \n " , RegisterId , BitRegInfo -> ParentRegister , RegisterValue , Value ) ) ; * ReturnValue = Value ; return_ACPI_STATUS ( AE_OK ) ; }
FUNCTION:    AcpiReadBitRegister
 PARAMETERS:  RegisterId      - ID of ACPI Bit Register to access
              ReturnValue     - Value that was read from the register,
                                normalized to bit position zero.
FUNCTION : AcpiReadBitRegister PARAMETERS : RegisterId - ID of ACPI Bit Register to access ReturnValue - Value that was read from the register normalized to bit position zero .
/* Get the info structure corresponding to the requested ACPI Register */ /* Read the entire parent register */ /* Normalize the value that was read, mask off other bits */