hw/arm/virt-acpi: GIC and Arch Timer definitions in MADT and GTDT
RFC PATCH 5/7 hw/arm/virt-acpi: GIC and Arch Timer definitions in MADT and GTDT
ACPI v5.1 defines GTDT for ARM devices as a place to describe timer related information in the system. MADT is also updated with a number of relevant subtables that can describe GIC enabled ARM platforms.
For GTDT the Arch Timer interrupts must be provided, in the case of MADT the GICC and GICD subtables are used to define the GIC regions.
Signed-off-by Alexander Spyridakis <[email protected]>
--- hw/arm/virt-acpi.c | 65 +++++++++++++++++++++++++++++++++++++--- include/hw/acpi/acpi-defs.h | 73 ++++++++++++++++++++++++++++++++++++++++++++- include/hw/arm/virt-acpi.h | 6 ++++ 3 files changed, 139 insertions(+), 5 deletions(-)
hw/arm/virt-acpi.c +61 -4
@@ -121,14 +121,71 @@ static void acpi_create_xsdt(void)static void acpi_create_madt (uint32_t smp_cpus,const struct acpi_madt_info *info) { - acpi_table[MADT ] =NULL ; - acpi_size[MADT ] =0 ; +AcpiMultipleApicTable *madt; +AcpiMadtGenericInterrupt *gicc; +AcpiMadtGenericDistributor *gicd; +int i, madt_size; + + madt_size =sizeof (*madt) + (smp_cpus *sizeof (*gicc) +sizeof (*gicd)); + madt =g_malloc0 (madt_size); + +acpi_fill_common_header_data (madt,"APIC" ,1 , madt_size); + + madt->local_apic_address = *info->gic_cpu_base_addr; + +/* Point at the end of the madt structure */ + gicc = (AcpiMadtGenericInterrupt *)(madt +1 ); + +/* GICC subtable, one for each cpu in the guest*/ +for (i =0 ; i < smp_cpus; i++) { + gicc->type =ACPI_APIC_GENERIC_INTERRUPT ; + gicc->length =sizeof (*gicc); + + gicc->base_address = *info->gic_cpu_base_addr; + gicc->cpu_interface_number = i; + gicc->arm_mpidr = i; + gicc->uid = i; + gicc->flags =0x01 ; + + gicc++; + } + +/* GIC Distributor subtable */ + gicd = (AcpiMadtGenericDistributor *)(gicc); + gicd->type =ACPI_APIC_GENERIC_DISTRIBUTOR ; + gicd->length =sizeof (*gicd); + gicd->base_address = *info->gic_dist_base_addr; + +acpi_do_checksum (madt, madt->length, &madt->checksum); + + acpi_table[MADT ] = (void *)madt; + acpi_size[MADT ] = madt->length; }static void acpi_create_gtdt (const struct acpi_gtdt_info *irqs) { - acpi_table[GTDT ] =NULL ; - acpi_size[GTDT ] =0 ; +AcpiGenericTimerTable *gtdt; + + gtdt =g_malloc0 (sizeof (*gtdt)); +acpi_fill_common_header_data (gtdt,"GTDT" ,1 ,sizeof (*gtdt)); + +/* The interrupt values are the same with the device tree when adding 16 */ + gtdt->secure_el1_interrupt = irqs->timer_s_el1; + gtdt->secure_el1_flags =ACPI_EDGE_SENSITIVE ; + + gtdt->non_secure_el1_interrupt = irqs->timer_ns_el1; + gtdt->non_secure_el1_flags =ACPI_EDGE_SENSITIVE ; + + gtdt->virtual_timer_interrupt = irqs->timer_virt; + gtdt->virtual_timer_flags =ACPI_EDGE_SENSITIVE ; + + gtdt->non_secure_el2_interrupt = irqs->timer_ns_el2; + gtdt->non_secure_el2_flags =ACPI_EDGE_SENSITIVE ; + +acpi_do_checksum (gtdt, gtdt->length, >dt->checksum); + + acpi_table[GTDT ] = (void *)gtdt; + acpi_size[GTDT ] = gtdt->length; }static void acpi_create_fadt (void )
include/hw/acpi/acpi-defs.h +72 -1
85 lines not on this page · raw message
include/hw/arm/virt-acpi.h +6 -0
@@ -41,9 +41,15 @@ enum { };struct acpi_gtdt_info { +uint32_t timer_virt; +uint32_t timer_s_el1; +uint32_t timer_ns_el1; +uint32_t timer_ns_el2; };struct acpi_madt_info { +const hwaddr *gic_cpu_base_addr; +const hwaddr *gic_dist_base_addr; };struct acpi_dsdt_info {
Signature · 1 line
1.9.1