deps/acpica/source/components/hardware/hwvalid.c
/******************************************************************************
 *
 * FUNCTION:    AcpiHwWritePort
 *
 * PARAMETERS:  Address             Address of I/O port/register to write
 *              Value               Value to write
 *              Width               Number of bits
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Write data to an I/O port or register. This is a front-end
 *              to AcpiOsWritePort that performs validation on both the port
 *              address and the length.
 *
 *****************************************************************************/
AcpiHwWritePort
PARAMETERS:  Address             Address of I/O port/register to write
Value               Value to write
Width               Number of bits

Status

Write data to an I/O port or register. This is a front-end
to AcpiOsWritePort that performs validation on both the port
address and the length.
AcpiHwWritePort PARAMETERS : Address Address of I / O port / register to write Value Value to write Width Number of bits Status Write data to an I / O port or register . This is a front - end to AcpiOsWritePort that performs validation on both the port address and the length .
ACPI_STATUS
AcpiHwWritePort (
    ACPI_IO_ADDRESS         Address,
    UINT32                  Value,
    UINT32                  Width)
{
    ACPI_STATUS             Status;
    UINT32                  i;
    if (AcpiGbl_TruncateIoAddresses)
    {
        Address &= ACPI_UINT16_MAX;
    }
    Status = AcpiHwValidateIoRequest (Address, Width);
    if (ACPI_SUCCESS (Status))
    {
        Status = AcpiOsWritePort (Address, Value, Width);
        return (Status);
    }
    if (Status != AE_AML_ILLEGAL_ADDRESS)
    {
        return (Status);
    }
    for (i = 0; i < Width; i += 8)
    {
        if (AcpiHwValidateIoRequest (Address, 8) == AE_OK)
        {
            Status = AcpiOsWritePort (Address, (Value >> i) & 0xFF, 8);
            if (ACPI_FAILURE (Status))
            {
                return (Status);
            }
        }
        Address++;
    }
    return (AE_OK);
}
ACPI_STATUS AcpiHwWritePort ( ACPI_IO_ADDRESS Address , UINT32 Value , UINT32 Width ) { ACPI_STATUS Status ; UINT32 i ; if ( AcpiGbl_TruncateIoAddresses ) { Address &= ACPI_UINT16_MAX ; } Status = AcpiHwValidateIoRequest ( Address , Width ) ; if ( ACPI_SUCCESS ( Status ) ) { Status = AcpiOsWritePort ( Address , Value , Width ) ; return ( Status ) ; } if ( Status != AE_AML_ILLEGAL_ADDRESS ) { return ( Status ) ; } for ( i = 0 ; i < Width ; i += 8 ) { if ( AcpiHwValidateIoRequest ( Address , 8 ) == AE_OK ) { Status = AcpiOsWritePort ( Address , ( Value >> i ) & 0xFF , 8 ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } } Address ++ ; } return ( AE_OK ) ; }
FUNCTION:    AcpiHwWritePort
 PARAMETERS:  Address             Address of I/O port/register to write
              Value               Value to write
              Width               Number of bits
FUNCTION : AcpiHwWritePort PARAMETERS : Address Address of I / O port / register to write Value Value to write 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 write one byte */