i386: ACPI table generation code from seabios
This adds C code for generating ACPI tables at runtime,
imported from seabios git tree
commit 51684b7ced75fb76776e8ee84833fcfb6ecf12dd
Although ACPI tables come from a system BIOS on real hw,
it makes sense that the ACPI tables are coupled with the
virtual machine, since they have to abstract the x86 machine to
the OS's.
This is widely desired as a way to avoid the churn
and proliferation of QEMU-specific interfaces
associated with ACPI tables in bios code.
Notes:
As BIOS can reprogram devices prior to loading
ACPI tables, we pre-format ACPI tables but defer loading
hardware configuration there until tables are loaded.
The code structure was intentionally kept as close
to the seabios original as possible, to simplify
comparison and making sure we didn't lose anything
in translation.
Minor code duplication results, to help ensure there are no functional
regressions, I think it's better to merge it like this and do more code
changes in follow-up patches.
Cross-version compatibility concerns have been addressed:
ACPI tables are exposed to guest as FW_CFG entries.
When running with -M 1.5 and older, this patch disables ACPI
table generation, and doesn't expose ACPI
tables to guest.
As table content is likely to change over time,
the following measures are taken to simplify
cross-version migration:
- All tables besides the RSDP are packed in a single FW CFG entry.
This entry size is currently 23K. We round it up to 64K
to avoid too much churn there.
- Tables are placed in special ROM blob (not mapped into guest memory)
which is automatically migrated together with the guest, same
as BIOS code.
- Offsets where hardware configuration is loaded in ACPI tables
are also migrated, this is in case future ACPI changes make us
rearrange the tables in memory.
This patch reuses some code from SeaBIOS, which was originally under
LGPLv2 and then relicensed to GPLv3 or LGPLv3, in QEMU under GPLv2+. This
relicensing has been acked by all contributors that had contributed to the
code since the v2->v3 relicense. ACKs approving the v2+ relicensing are
listed below. The list might include ACKs from people not holding
copyright on any parts of the reused code, but it's better to err on the
side of caution and include them.
Affected SeaBIOS files (GPLv2+ license headers added)
<http://thread.gmane.org/gmane.comp.bios.coreboot.seabios/5949>:
src/acpi-dsdt-cpu-hotplug.dsl
src/acpi-dsdt-dbug.dsl
src/acpi-dsdt-hpet.dsl
src/acpi-dsdt-isa.dsl
src/acpi-dsdt-pci-crs.dsl
src/acpi.c
src/acpi.h
src/ssdt-misc.dsl
src/ssdt-pcihp.dsl
src/ssdt-proc.dsl
tools/acpi_extract.py
tools/acpi_extract_preprocess.py
Each one of the listed people agreed to the following:
> If you allow the use of your contribution in QEMU under the
> terms of GPLv2 or later as proposed by this patch,
> please respond to this mail including the line:
>
> Acked-by: Name <email address>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
Acked-by: Jason Baron <jbaron@akamai.com>
Acked-by: David Woodhouse <David.Woodhouse@intel.com>
Acked-by: Gleb Natapov <gleb@redhat.com>
Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
Acked-by: Dave Frodin <dave.frodin@se-eng.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Kevin O'Connor <kevin@koconnor.net>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Acked-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Magnus Christensson <magnus.christensson@intel.com>
Acked-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-07-24 19:56:14 +04:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#ifndef QEMU_ACPI_DEFS_H
|
|
|
|
#define QEMU_ACPI_DEFS_H
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ACPI_FADT_F_WBINVD,
|
|
|
|
ACPI_FADT_F_WBINVD_FLUSH,
|
|
|
|
ACPI_FADT_F_PROC_C1,
|
|
|
|
ACPI_FADT_F_P_LVL2_UP,
|
|
|
|
ACPI_FADT_F_PWR_BUTTON,
|
|
|
|
ACPI_FADT_F_SLP_BUTTON,
|
|
|
|
ACPI_FADT_F_FIX_RTC,
|
|
|
|
ACPI_FADT_F_RTC_S4,
|
|
|
|
ACPI_FADT_F_TMR_VAL_EXT,
|
|
|
|
ACPI_FADT_F_DCK_CAP,
|
|
|
|
ACPI_FADT_F_RESET_REG_SUP,
|
|
|
|
ACPI_FADT_F_SEALED_CASE,
|
|
|
|
ACPI_FADT_F_HEADLESS,
|
|
|
|
ACPI_FADT_F_CPU_SW_SLP,
|
|
|
|
ACPI_FADT_F_PCI_EXP_WAK,
|
|
|
|
ACPI_FADT_F_USE_PLATFORM_CLOCK,
|
|
|
|
ACPI_FADT_F_S4_RTC_STS_VALID,
|
|
|
|
ACPI_FADT_F_REMOTE_POWER_ON_CAPABLE,
|
|
|
|
ACPI_FADT_F_FORCE_APIC_CLUSTER_MODEL,
|
|
|
|
ACPI_FADT_F_FORCE_APIC_PHYSICAL_DESTINATION_MODE,
|
|
|
|
ACPI_FADT_F_HW_REDUCED_ACPI,
|
|
|
|
ACPI_FADT_F_LOW_POWER_S0_IDLE_CAPABLE,
|
|
|
|
};
|
|
|
|
|
2018-12-17 13:48:34 +03:00
|
|
|
typedef struct AcpiRsdpData {
|
2021-01-19 03:32:13 +03:00
|
|
|
char *oem_id; /* OEM identification */
|
2019-01-03 11:56:36 +03:00
|
|
|
uint8_t revision; /* Must be 0 for 1.0, 2 for 2.0 */
|
2018-12-17 13:48:34 +03:00
|
|
|
|
|
|
|
unsigned *rsdt_tbl_offset;
|
|
|
|
unsigned *xsdt_tbl_offset;
|
|
|
|
} AcpiRsdpData;
|
|
|
|
|
2015-05-29 13:28:55 +03:00
|
|
|
struct AcpiGenericAddress {
|
|
|
|
uint8_t space_id; /* Address space where struct or register exists */
|
|
|
|
uint8_t bit_width; /* Size in bits of given register */
|
|
|
|
uint8_t bit_offset; /* Bit offset within the register */
|
2018-02-28 17:23:48 +03:00
|
|
|
uint8_t access_width; /* ACPI 3.0: Minimum Access size (ACPI 3.0),
|
|
|
|
ACPI 2.0: Reserved, Table 5-1 */
|
2015-05-29 13:28:55 +03:00
|
|
|
uint64_t address; /* 64-bit address of struct or register */
|
2021-09-24 15:28:02 +03:00
|
|
|
};
|
2015-05-29 13:28:55 +03:00
|
|
|
|
2018-02-28 17:23:51 +03:00
|
|
|
typedef struct AcpiFadtData {
|
|
|
|
struct AcpiGenericAddress pm1a_cnt; /* PM1a_CNT_BLK */
|
|
|
|
struct AcpiGenericAddress pm1a_evt; /* PM1a_EVT_BLK */
|
|
|
|
struct AcpiGenericAddress pm_tmr; /* PM_TMR_BLK */
|
|
|
|
struct AcpiGenericAddress gpe0_blk; /* GPE0_BLK */
|
|
|
|
struct AcpiGenericAddress reset_reg; /* RESET_REG */
|
2020-05-20 16:19:49 +03:00
|
|
|
struct AcpiGenericAddress sleep_ctl; /* SLEEP_CONTROL_REG */
|
|
|
|
struct AcpiGenericAddress sleep_sts; /* SLEEP_STATUS_REG */
|
2018-02-28 17:23:51 +03:00
|
|
|
uint8_t reset_val; /* RESET_VALUE */
|
|
|
|
uint8_t rev; /* Revision */
|
|
|
|
uint32_t flags; /* Flags */
|
|
|
|
uint32_t smi_cmd; /* SMI_CMD */
|
|
|
|
uint16_t sci_int; /* SCI_INT */
|
|
|
|
uint8_t int_model; /* INT_MODEL */
|
|
|
|
uint8_t acpi_enable_cmd; /* ACPI_ENABLE */
|
|
|
|
uint8_t acpi_disable_cmd; /* ACPI_DISABLE */
|
|
|
|
uint8_t rtc_century; /* CENTURY */
|
|
|
|
uint16_t plvl2_lat; /* P_LVL2_LAT */
|
|
|
|
uint16_t plvl3_lat; /* P_LVL3_LAT */
|
2018-02-28 17:23:54 +03:00
|
|
|
uint16_t arm_boot_arch; /* ARM_BOOT_ARCH */
|
2022-03-04 18:40:30 +03:00
|
|
|
uint16_t iapc_boot_arch; /* IAPC_BOOT_ARCH */
|
2018-02-28 17:23:54 +03:00
|
|
|
uint8_t minor_ver; /* FADT Minor Version */
|
2018-02-28 17:23:51 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* respective tables offsets within ACPI_BUILD_TABLE_FILE,
|
|
|
|
* NULL if table doesn't exist (in that case field's value
|
|
|
|
* won't be patched by linker and will be kept set to 0)
|
|
|
|
*/
|
|
|
|
unsigned *facs_tbl_offset; /* FACS offset in */
|
|
|
|
unsigned *dsdt_tbl_offset;
|
|
|
|
unsigned *xdsdt_tbl_offset;
|
|
|
|
} AcpiFadtData;
|
|
|
|
|
2017-01-09 14:40:21 +03:00
|
|
|
#define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0)
|
|
|
|
#define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1)
|
2015-05-29 13:28:55 +03:00
|
|
|
|
i386: ACPI table generation code from seabios
This adds C code for generating ACPI tables at runtime,
imported from seabios git tree
commit 51684b7ced75fb76776e8ee84833fcfb6ecf12dd
Although ACPI tables come from a system BIOS on real hw,
it makes sense that the ACPI tables are coupled with the
virtual machine, since they have to abstract the x86 machine to
the OS's.
This is widely desired as a way to avoid the churn
and proliferation of QEMU-specific interfaces
associated with ACPI tables in bios code.
Notes:
As BIOS can reprogram devices prior to loading
ACPI tables, we pre-format ACPI tables but defer loading
hardware configuration there until tables are loaded.
The code structure was intentionally kept as close
to the seabios original as possible, to simplify
comparison and making sure we didn't lose anything
in translation.
Minor code duplication results, to help ensure there are no functional
regressions, I think it's better to merge it like this and do more code
changes in follow-up patches.
Cross-version compatibility concerns have been addressed:
ACPI tables are exposed to guest as FW_CFG entries.
When running with -M 1.5 and older, this patch disables ACPI
table generation, and doesn't expose ACPI
tables to guest.
As table content is likely to change over time,
the following measures are taken to simplify
cross-version migration:
- All tables besides the RSDP are packed in a single FW CFG entry.
This entry size is currently 23K. We round it up to 64K
to avoid too much churn there.
- Tables are placed in special ROM blob (not mapped into guest memory)
which is automatically migrated together with the guest, same
as BIOS code.
- Offsets where hardware configuration is loaded in ACPI tables
are also migrated, this is in case future ACPI changes make us
rearrange the tables in memory.
This patch reuses some code from SeaBIOS, which was originally under
LGPLv2 and then relicensed to GPLv3 or LGPLv3, in QEMU under GPLv2+. This
relicensing has been acked by all contributors that had contributed to the
code since the v2->v3 relicense. ACKs approving the v2+ relicensing are
listed below. The list might include ACKs from people not holding
copyright on any parts of the reused code, but it's better to err on the
side of caution and include them.
Affected SeaBIOS files (GPLv2+ license headers added)
<http://thread.gmane.org/gmane.comp.bios.coreboot.seabios/5949>:
src/acpi-dsdt-cpu-hotplug.dsl
src/acpi-dsdt-dbug.dsl
src/acpi-dsdt-hpet.dsl
src/acpi-dsdt-isa.dsl
src/acpi-dsdt-pci-crs.dsl
src/acpi.c
src/acpi.h
src/ssdt-misc.dsl
src/ssdt-pcihp.dsl
src/ssdt-proc.dsl
tools/acpi_extract.py
tools/acpi_extract_preprocess.py
Each one of the listed people agreed to the following:
> If you allow the use of your contribution in QEMU under the
> terms of GPLv2 or later as proposed by this patch,
> please respond to this mail including the line:
>
> Acked-by: Name <email address>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
Acked-by: Jason Baron <jbaron@akamai.com>
Acked-by: David Woodhouse <David.Woodhouse@intel.com>
Acked-by: Gleb Natapov <gleb@redhat.com>
Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
Acked-by: Dave Frodin <dave.frodin@se-eng.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Kevin O'Connor <kevin@koconnor.net>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Acked-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Magnus Christensson <magnus.christensson@intel.com>
Acked-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-07-24 19:56:14 +04:00
|
|
|
#endif
|