// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /****************************************************************************** * * Module Name: hwvalid - I/O request validation * * Copyright (C) 2000 - 2023, Intel Corp. * *****************************************************************************/ #include <acpi/acpi.h> #include "accommon.h" #define _COMPONENT … ACPI_MODULE_NAME("hwvalid") /* Local prototypes */ static acpi_status acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width); /* * Protected I/O ports. Some ports are always illegal, and some are * conditionally illegal. This table must remain ordered by port address. * * The table is used to implement the Microsoft port access rules that * first appeared in Windows XP. Some ports are always illegal, and some * ports are only illegal if the BIOS calls _OSI with nothing newer than * the specific _OSI strings. * * This provides ACPICA with the desired port protections and * Microsoft compatibility. * * Description of port entries: * DMA: DMA controller * PIC0: Programmable Interrupt Controller (8259A) * PIT1: System Timer 1 * PIT2: System Timer 2 failsafe * RTC: Real-time clock * CMOS: Extended CMOS * DMA1: DMA 1 page registers * DMA1L: DMA 1 Ch 0 low page * DMA2: DMA 2 page registers * DMA2L: DMA 2 low page refresh * ARBC: Arbitration control * SETUP: Reserved system board setup * POS: POS channel select * PIC1: Cascaded PIC * IDMA: ISA DMA * ELCR: PIC edge/level registers * PCI: PCI configuration space */ static const struct acpi_port_info acpi_protected_ports[] = …; #define ACPI_PORT_INFO_ENTRIES … /****************************************************************************** * * FUNCTION: acpi_hw_validate_io_request * * PARAMETERS: Address Address of I/O port/register * bit_width 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. * ******************************************************************************/ static acpi_status acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width) { … } /****************************************************************************** * * FUNCTION: acpi_hw_read_port * * PARAMETERS: Address Address of I/O port/register to read * Value Where value (data) is returned * 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 acpi_os_read_port that performs validation on both the port * address and the length. * *****************************************************************************/ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width) { … } /****************************************************************************** * * FUNCTION: acpi_hw_write_port * * 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 acpi_os_write_port that performs validation on both the port * address and the length. * *****************************************************************************/ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width) { … } /****************************************************************************** * * FUNCTION: acpi_hw_validate_io_block * * PARAMETERS: Address Address of I/O port/register blobk * bit_width Number of bits (8,16,32) in each register * count Number of registers in the block * * RETURN: Status * * DESCRIPTION: Validates a block of I/O ports/registers. * ******************************************************************************/ acpi_status acpi_hw_validate_io_block(u64 address, u32 bit_width, u32 count) { … }