deps/acpica/source/components/hardware/hwvalid.c
/******************************************************************************
 *
 * FUNCTION:    AcpiHwReadPort
 *
 * PARAMETERS:  Address             Address of I/O port/register to read
 *              Value               Where value is placed
 *              Width               Number of bits
 *
 * RETURN:      Status and value read from port
 *
 * DESCRIPTION: Read data from an I/O port or register. This is a front-end
 *              to AcpiOsReadPort that performs validation on both the port
 *              address and the length.
 *
 *****************************************************************************/
AcpiHwReadPort
PARAMETERS:  Address             Address of I/O port/register to read
Value               Where value is placed
Width               Number of bits

Status and value read from port

Read data from an I/O port or register. This is a front-end
to AcpiOsReadPort that performs validation on both the port
address and the length.
AcpiHwReadPort PARAMETERS : Address Address of I / O port / register to read Value Where value is placed Width Number of bits Status and value read from port Read data from an I / O port or register . This is a front - end to AcpiOsReadPort that performs validation on both the port address and the length .
ACPI_STATUS
AcpiHwReadPort (
    ACPI_IO_ADDRESS         Address,
    UINT32                  *Value,
    UINT32                  Width)
{
    ACPI_STATUS             Status;
    UINT32                  OneByte;
    UINT32                  i;
    if (AcpiGbl_TruncateIoAddresses)
    {
        Address &= ACPI_UINT16_MAX;
    }
    Status = AcpiHwValidateIoRequest (Address, Width);
    if (ACPI_SUCCESS (Status))
    {
        Status = AcpiOsReadPort (Address, Value, Width);
        return (Status);
    }
    if (Status != AE_AML_ILLEGAL_ADDRESS)
    {
        return (Status);
    }
    for (i = 0, *Value = 0; i < Width; i += 8)
    {
        if (AcpiHwValidateIoRequest (Address, 8) == AE_OK)
        {
            Status = AcpiOsReadPort (Address, &OneByte, 8);
            if (ACPI_FAILURE (Status))
            {
                return (Status);
            }
            *Value |= (OneByte << i);
        }
        Address++;
    }
    return (AE_OK);
}
ACPI_STATUS AcpiHwReadPort ( ACPI_IO_ADDRESS Address , UINT32 * Value , UINT32 Width ) { ACPI_STATUS Status ; UINT32 OneByte ; UINT32 i ; if ( AcpiGbl_TruncateIoAddresses ) { Address &= ACPI_UINT16_MAX ; } Status = AcpiHwValidateIoRequest ( Address , Width ) ; if ( ACPI_SUCCESS ( Status ) ) { Status = AcpiOsReadPort ( Address , Value , Width ) ; return ( Status ) ; } if ( Status != AE_AML_ILLEGAL_ADDRESS ) { return ( Status ) ; } for ( i = 0 , * Value = 0 ; i < Width ; i += 8 ) { if ( AcpiHwValidateIoRequest ( Address , 8 ) == AE_OK ) { Status = AcpiOsReadPort ( Address , & OneByte , 8 ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } * Value |= ( OneByte << i ) ; } Address ++ ; } return ( AE_OK ) ; }
FUNCTION:    AcpiHwReadPort
 PARAMETERS:  Address             Address of I/O port/register to read
              Value               Where value is placed
              Width               Number of bits
FUNCTION : AcpiHwReadPort PARAMETERS : Address Address of I / O port / register to read Value Where value is placed Width Number of bits
/* Truncate address to 16 bits if requested */ /* Validate the entire request and perform the I/O */ /*
     * There has been a protection violation within the request. Fall
     * back to byte granularity port I/O and ignore the failing bytes.
     * This provides Windows compatibility.
     */ /* Validate and read one byte */