// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /****************************************************************************** * * Module Name: tbfadt - FADT table utilities * * Copyright (C) 2000 - 2023, Intel Corp. * *****************************************************************************/ #include <acpi/acpi.h> #include "accommon.h" #include "actables.h" #define _COMPONENT … ACPI_MODULE_NAME("tbfadt") /* Local prototypes */ static void acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, u8 space_id, u8 byte_width, u64 address, const char *register_name, u8 flags); static void acpi_tb_convert_fadt(void); static void acpi_tb_setup_fadt_registers(void); static u64 acpi_tb_select_address(char *register_name, u32 address32, u64 address64); /* Table for conversion of FADT to common internal format and FADT validation */ acpi_fadt_info; #define ACPI_FADT_OPTIONAL … #define ACPI_FADT_REQUIRED … #define ACPI_FADT_SEPARATE_LENGTH … #define ACPI_FADT_GPE_REGISTER … static struct acpi_fadt_info fadt_info_table[] = …; #define ACPI_FADT_INFO_ENTRIES … /* Table used to split Event Blocks into separate status/enable registers */ acpi_fadt_pm_info; static struct acpi_fadt_pm_info fadt_pm_info_table[] = …; #define ACPI_FADT_PM_INFO_ENTRIES … /******************************************************************************* * * FUNCTION: acpi_tb_init_generic_address * * PARAMETERS: generic_address - GAS struct to be initialized * space_id - ACPI Space ID for this register * byte_width - Width of this register * address - Address of the register * register_name - ASCII name of the ACPI register * * RETURN: None * * DESCRIPTION: Initialize a Generic Address Structure (GAS) * See the ACPI specification for a full description and * definition of this structure. * ******************************************************************************/ static void acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, u8 space_id, u8 byte_width, u64 address, const char *register_name, u8 flags) { … } /******************************************************************************* * * FUNCTION: acpi_tb_select_address * * PARAMETERS: register_name - ASCII name of the ACPI register * address32 - 32-bit address of the register * address64 - 64-bit address of the register * * RETURN: The resolved 64-bit address * * DESCRIPTION: Select between 32-bit and 64-bit versions of addresses within * the FADT. Used for the FACS and DSDT addresses. * * NOTES: * * Check for FACS and DSDT address mismatches. An address mismatch between * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and * DSDT/X_DSDT) could be a corrupted address field or it might indicate * the presence of two FACS or two DSDT tables. * * November 2013: * By default, as per the ACPICA specification, a valid 64-bit address is * used regardless of the value of the 32-bit address. However, this * behavior can be overridden via the acpi_gbl_use32_bit_fadt_addresses flag. * ******************************************************************************/ static u64 acpi_tb_select_address(char *register_name, u32 address32, u64 address64) { … } /******************************************************************************* * * FUNCTION: acpi_tb_parse_fadt * * PARAMETERS: None * * RETURN: None * * DESCRIPTION: Initialize the FADT, DSDT and FACS tables * (FADT contains the addresses of the DSDT and FACS) * ******************************************************************************/ void acpi_tb_parse_fadt(void) { … } /******************************************************************************* * * FUNCTION: acpi_tb_create_local_fadt * * PARAMETERS: table - Pointer to BIOS FADT * length - Length of the table * * RETURN: None * * DESCRIPTION: Get a local copy of the FADT and convert it to a common format. * Performs validation on some important FADT fields. * * NOTE: We create a local copy of the FADT regardless of the version. * ******************************************************************************/ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length) { … } /******************************************************************************* * * FUNCTION: acpi_tb_convert_fadt * * PARAMETERS: none - acpi_gbl_FADT is used. * * RETURN: None * * DESCRIPTION: Converts all versions of the FADT to a common internal format. * Expand 32-bit addresses to 64-bit as necessary. Also validate * important fields within the FADT. * * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), and must * contain a copy of the actual BIOS-provided FADT. * * Notes on 64-bit register addresses: * * After this FADT conversion, later ACPICA code will only use the 64-bit "X" * fields of the FADT for all ACPI register addresses. * * The 64-bit X fields are optional extensions to the original 32-bit FADT * V1.0 fields. Even if they are present in the FADT, they are optional and * are unused if the BIOS sets them to zero. Therefore, we must copy/expand * 32-bit V1.0 fields to the 64-bit X fields if the 64-bit X field is originally * zero. * * For ACPI 1.0 FADTs (that contain no 64-bit addresses), all 32-bit address * fields are expanded to the corresponding 64-bit X fields in the internal * common FADT. * * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded * to the corresponding 64-bit X fields, if the 64-bit field is originally * zero. Adhering to the ACPI specification, we completely ignore the 32-bit * field if the 64-bit field is valid, regardless of whether the host OS is * 32-bit or 64-bit. * * Possible additional checks: * (acpi_gbl_FADT.pm1_event_length >= 4) * (acpi_gbl_FADT.pm1_control_length >= 2) * (acpi_gbl_FADT.pm_timer_length >= 4) * Gpe block lengths must be multiple of 2 * ******************************************************************************/ static void acpi_tb_convert_fadt(void) { … } /******************************************************************************* * * FUNCTION: acpi_tb_setup_fadt_registers * * PARAMETERS: None, uses acpi_gbl_FADT. * * RETURN: None * * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally, * force FADT register definitions to their default lengths. * ******************************************************************************/ static void acpi_tb_setup_fadt_registers(void) { … }