FreeBSD/sys/contrib/dev/acpica/components/hardware/hwregs.c
/******************************************************************************
 *
 * FUNCTION:    AcpiHwRead
 *
 * PARAMETERS:  Value               - Where the value is returned
 *              Reg                 - GAS register structure
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Read from either memory or IO space. This is a 32-bit max
 *              version of AcpiRead, used internally since the overhead of
 *              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.
 *
 ******************************************************************************/
AcpiHwRead
PARAMETERS:  Value               - Where the value is returned
Reg                 - GAS register structure

Status

Read from either memory or IO space. This is a 32-bit max
version of AcpiRead, used internally since the overhead of
64-bit values is not needed.


BitWidth must be exactly 8, 16, or 32.
AcpiHwRead PARAMETERS : Value - Where the value is returned Reg - GAS register structure Status Read from either memory or IO space . This is a 32 - bit max version of AcpiRead used internally since the overhead of 64 - bit values is not needed . BitWidth must be exactly 8 16 or 32 .
ACPI_STATUS
AcpiHwRead (
    UINT32                  *Value,
    ACPI_GENERIC_ADDRESS    *Reg)
{
    UINT64                  Address;
    UINT64                  Value64;
    ACPI_STATUS             Status;
    ACPI_FUNCTION_NAME (HwRead);
    Status = AcpiHwValidateRegister (Reg, 32, &Address);
    if (ACPI_FAILURE (Status))
    {
        return (Status);
    }
    *Value = 0;
    if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
    {
        Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
            Address, &Value64, Reg->BitWidth);
        *Value = (UINT32) Value64;
    }
    else 
    {
        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, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address),
        AcpiUtGetRegionName (Reg->SpaceId)));
    return (Status);
}
ACPI_STATUS AcpiHwRead ( UINT32 * Value , ACPI_GENERIC_ADDRESS * Reg ) { UINT64 Address ; UINT64 Value64 ; ACPI_STATUS Status ; ACPI_FUNCTION_NAME ( HwRead ) ; Status = AcpiHwValidateRegister ( Reg , 32 , & Address ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } * Value = 0 ; if ( Reg -> SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY ) { Status = AcpiOsReadMemory ( ( ACPI_PHYSICAL_ADDRESS ) Address , & Value64 , Reg -> BitWidth ) ; * Value = ( UINT32 ) Value64 ; } else { Status = AcpiHwReadPort ( ( ACPI_IO_ADDRESS ) Address , Value , Reg -> BitWidth ) ; } ACPI_DEBUG_PRINT ( ( ACPI_DB_IO , " \n " , * Value , Reg -> BitWidth , ACPI_FORMAT_UINT64 ( Address ) , AcpiUtGetRegionName ( Reg -> SpaceId ) ) ) ; return ( Status ) ; }
FUNCTION:    AcpiHwRead
 PARAMETERS:  Value               - Where the value is returned
              Reg                 - GAS register structure
FUNCTION : AcpiHwRead PARAMETERS : Value - Where the value is returned Reg - GAS register structure
/* Validate contents of the GAS register */ /* Initialize entire 32-bit return value to zero */ /*
     * Two address spaces supported: Memory or IO. PCI_Config is
     * not supported here because the GAS structure is insufficient
     */ /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */