FreeBSD/sys/contrib/dev/acpica/components/hardware/hwvalid.c
/******************************************************************************
 *
 * FUNCTION:    AcpiHwValidateIoRequest
 *
 * PARAMETERS:  Address             Address of I/O port/register
 *              BitWidth            Number of bits (8,16,32)
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Validates an I/O request (address/length). Certain ports are
 *              always illegal and some ports are only illegal depending on
 *              the requests the BIOS AML code makes to the predefined
 *              _OSI method.
 *
 ******************************************************************************/
AcpiHwValidateIoRequest
PARAMETERS:  Address             Address of I/O port/register
BitWidth            Number of bits (8,16,32)

Status

Validates an I/O request (address/length). Certain ports are
always illegal and some ports are only illegal depending on
the requests the BIOS AML code makes to the predefined
_OSI method.
AcpiHwValidateIoRequest PARAMETERS : Address Address of I / O port / register BitWidth Number of bits ( 8 16 32 ) Status Validates an I / O request ( address / length ) . Certain ports are always illegal and some ports are only illegal depending on the requests the BIOS AML code makes to the predefined _OSI method .
static ACPI_STATUS
AcpiHwValidateIoRequest (
    ACPI_IO_ADDRESS         Address,
    UINT32                  BitWidth)
{
    UINT32                  i;
    UINT32                  ByteWidth;
    ACPI_IO_ADDRESS         LastAddress;
    const ACPI_PORT_INFO    *PortInfo;
    ACPI_FUNCTION_TRACE (HwValidateIoRequest);
    if ((BitWidth != 8) &&
        (BitWidth != 16) &&
        (BitWidth != 32))
    {
        ACPI_ERROR ((AE_INFO,
            "Bad BitWidth parameter: %8.8X", BitWidth));
        return (AE_BAD_PARAMETER);
    }
    PortInfo = AcpiProtectedPorts;
    ByteWidth = ACPI_DIV_8 (BitWidth);
    LastAddress = Address + ByteWidth - 1;
    ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Address %8.8X%8.8X LastAddress %8.8X%8.8X Length %X",
        ACPI_FORMAT_UINT64 (Address), ACPI_FORMAT_UINT64 (LastAddress),
        ByteWidth));
    if (LastAddress > ACPI_UINT16_MAX)
    {
        ACPI_ERROR ((AE_INFO,
            "Illegal I/O port address/length above 64K: %8.8X%8.8X/0x%X",
            ACPI_FORMAT_UINT64 (Address), ByteWidth));
        return_ACPI_STATUS (AE_LIMIT);
    }
    if (Address > AcpiProtectedPorts[ACPI_PORT_INFO_ENTRIES - 1].End)
    {
        return_ACPI_STATUS (AE_OK);
    }
    for (i = 0; i < ACPI_PORT_INFO_ENTRIES; i++, PortInfo++)
    {
        if ((Address <= PortInfo->End) && (LastAddress >= PortInfo->Start))
        {
            if (AcpiGbl_OsiData >= PortInfo->OsiDependency)
            {
                ACPI_DEBUG_PRINT ((ACPI_DB_IO,
                    "Denied AML access to port 0x%8.8X%8.8X/%X (%s 0x%.4X-0x%.4X)",
                    ACPI_FORMAT_UINT64 (Address), ByteWidth, PortInfo->Name,
                    PortInfo->Start, PortInfo->End));
                return_ACPI_STATUS (AE_AML_ILLEGAL_ADDRESS);
            }
        }
        if (LastAddress <= PortInfo->End)
        {
            break;
        }
    }
    return_ACPI_STATUS (AE_OK);
}
static ACPI_STATUS AcpiHwValidateIoRequest ( ACPI_IO_ADDRESS Address , UINT32 BitWidth ) { UINT32 i ; UINT32 ByteWidth ; ACPI_IO_ADDRESS LastAddress ; const ACPI_PORT_INFO * PortInfo ; ACPI_FUNCTION_TRACE ( HwValidateIoRequest ) ; if ( ( BitWidth != 8 ) && ( BitWidth != 16 ) && ( BitWidth != 32 ) ) { ACPI_ERROR ( ( AE_INFO , " " , BitWidth ) ) ; return ( AE_BAD_PARAMETER ) ; } PortInfo = AcpiProtectedPorts ; ByteWidth = ACPI_DIV_8 ( BitWidth ) ; LastAddress = Address + ByteWidth - 1 ; ACPI_DEBUG_PRINT ( ( ACPI_DB_IO , " " , ACPI_FORMAT_UINT64 ( Address ) , ACPI_FORMAT_UINT64 ( LastAddress ) , ByteWidth ) ) ; if ( LastAddress > ACPI_UINT16_MAX ) { ACPI_ERROR ( ( AE_INFO , " " , ACPI_FORMAT_UINT64 ( Address ) , ByteWidth ) ) ; return_ACPI_STATUS ( AE_LIMIT ) ; } if ( Address > AcpiProtectedPorts [ ACPI_PORT_INFO_ENTRIES - 1 ] . End ) { return_ACPI_STATUS ( AE_OK ) ; } for ( i = 0 ; i < ACPI_PORT_INFO_ENTRIES ; i ++ , PortInfo ++ ) { if ( ( Address <= PortInfo -> End ) && ( LastAddress >= PortInfo -> Start ) ) { if ( AcpiGbl_OsiData >= PortInfo -> OsiDependency ) { ACPI_DEBUG_PRINT ( ( ACPI_DB_IO , " " , ACPI_FORMAT_UINT64 ( Address ) , ByteWidth , PortInfo -> Name , PortInfo -> Start , PortInfo -> End ) ) ; return_ACPI_STATUS ( AE_AML_ILLEGAL_ADDRESS ) ; } } if ( LastAddress <= PortInfo -> End ) { break ; } } return_ACPI_STATUS ( AE_OK ) ; }
FUNCTION:    AcpiHwValidateIoRequest
 PARAMETERS:  Address             Address of I/O port/register
              BitWidth            Number of bits (8,16,32)
FUNCTION : AcpiHwValidateIoRequest PARAMETERS : Address Address of I / O port / register BitWidth Number of bits ( 8 16 32 )
/* Supported widths are 8/16/32 */ /* Maximum 16-bit address in I/O space */ /* Exit if requested address is not within the protected port table */ /* Check request against the list of protected I/O ports */ /*
         * Check if the requested address range will write to a reserved
         * port. Four cases to consider:
         *
         * 1) Address range is contained completely in the port address range
         * 2) Address range overlaps port range at the port range start
         * 3) Address range overlaps port range at the port range end
         * 4) Address range completely encompasses the port range
         */ /* Port illegality may depend on the _OSI calls made by the BIOS */ /* Finished if address range ends before the end of this port */