From ac66b8a24f113fc31215869648574af9f7fee26d Mon Sep 17 00:00:00 2001 From: lzw_29107 <2910729822@qq.com> Date: Thu, 15 Aug 2024 10:19:03 +0800 Subject: [PATCH] Add ACPI Table (EGIT) --- hw/arm/virt-acpi-build.c | 48 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 344a93f693bfa..71bb66f9a4b38 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -578,6 +578,49 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) acpi_table_end(linker, &table); } +/* EGIT */ +static void +build_egit(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) +{ + VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); + + uint32_t irqflags = vmc->claim_edge_triggered_timers ? + 1 : /* Interrupt is Edge triggered */ + 0; /* Interrupt is Level triggered */ + AcpiTable table = { .sig = "EGIT", .rev = 3, .oem_id = vms->oem_id, + .oem_table_id = vms->oem_table_id }; + + acpi_table_begin(&table, table_data); + + /* CntControlBase Physical Address */ + build_append_int_noprefix(table_data, 0xFFFFFFFFFFFFFFFF, 8); + /* + * FIXME: clarify comment: + * The interrupt values are the same with the device tree when adding 16 + */ + /* Secure EL1 timer GSIV */ + build_append_int_noprefix(table_data, ARCH_TIMER_S_EL1_IRQ, 4); + /* Non-Secure EL1 timer GSIV */ + build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL1_IRQ, 4); + /* Virtual timer GSIV */ + build_append_int_noprefix(table_data, ARCH_TIMER_VIRT_IRQ, 4); + /* Non-Secure EL2 timer GSIV */ + build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_IRQ, 4); + /* Secure EL1 timer Flags */ + build_append_int_noprefix(table_data, irqflags, 4); + /* Non-Secure EL1 timer Flags */ + build_append_int_noprefix(table_data, irqflags | + 1UL << 2, /* Always-on Capability */ + 4); + /* Virtual Timer Flags */ + build_append_int_noprefix(table_data, irqflags, 4); + /* Non-Secure EL2 timer Flags */ + build_append_int_noprefix(table_data, irqflags, 4); + + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + acpi_table_end(linker, &table); +} + /* * ACPI spec, Revision 6.5 * 5.2.25 Generic Timer Description Table (GTDT) @@ -965,7 +1008,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) dsdt = tables_blob->len; build_dsdt(tables_blob, tables->linker, vms); - /* FADT MADT PPTT GTDT MCFG SPCR DBG2 pointed to by RSDT */ + /* FADT MADT PPTT EGIT GTDT MCFG SPCR DBG2 pointed to by RSDT */ acpi_add_table(table_offsets, tables_blob); build_fadt_rev6(tables_blob, tables->linker, vms, dsdt); @@ -978,6 +1021,9 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) vms->oem_id, vms->oem_table_id); } + acpi_add_table(table_offsets, tables_blob); + build_egit(tables_blob, tables->linker, vms); + acpi_add_table(table_offsets, tables_blob); build_gtdt(tables_blob, tables->linker, vms);