[PATCH RFC 07/13] xen: implement IO APIC support in Xen mptable parser

From: Roger Pau Monne <roger.pau_at_citrix.com>
Date: Tue, 24 Dec 2013 12:20:56 +0100
Use madt_setup_io (from madt.c) on Xen apic_enumerator, in order to
parse the interrupt sources from the IO APIC.

I would like to get opinions, but I think we should rename and move
madt_setup_io to io_apic.c.
---
 sys/amd64/include/apicvar.h |    1 +
 sys/i386/include/apicvar.h  |    1 +
 sys/x86/acpica/madt.c       |    5 ++---
 sys/x86/xen/mptable.c       |   24 +++++++++++++++++++++++-
 4 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/sys/amd64/include/apicvar.h b/sys/amd64/include/apicvar.h
index a48a76b..3974067 100644
--- a/sys/amd64/include/apicvar.h
+++ b/sys/amd64/include/apicvar.h
_at__at_ -233,6 +233,7 _at__at_ int	lapic_set_lvt_triggermode(u_int apic_id, u_int lvt,
 void	lapic_set_tpr(u_int vector);
 void	lapic_setup(int boot);
 void	xen_intr_handle_upcall(struct trapframe *frame);
+int	madt_setup_io(void);
 
 #endif /* !LOCORE */
 #endif /* _MACHINE_APICVAR_H_ */
diff --git a/sys/i386/include/apicvar.h b/sys/i386/include/apicvar.h
index c8ee9bc..05ec013 100644
--- a/sys/i386/include/apicvar.h
+++ b/sys/i386/include/apicvar.h
_at__at_ -232,6 +232,7 _at__at_ int	lapic_set_lvt_triggermode(u_int apic_id, u_int lvt,
 void	lapic_set_tpr(u_int vector);
 void	lapic_setup(int boot);
 void	xen_intr_handle_upcall(struct trapframe *frame);
+int	madt_setup_io(void);
 
 #endif /* !LOCORE */
 #endif /* _MACHINE_APICVAR_H_ */
diff --git a/sys/x86/acpica/madt.c b/sys/x86/acpica/madt.c
index 5929fde..6f3b591 100644
--- a/sys/x86/acpica/madt.c
+++ b/sys/x86/acpica/madt.c
_at__at_ -61,7 +61,7 _at__at_ static struct lapic_info {
 } lapics[MAX_APIC_ID + 1];
 
 static int madt_found_sci_override;
-static ACPI_TABLE_MADT *madt;
+ACPI_TABLE_MADT *madt;
 static vm_paddr_t madt_physaddr;
 static vm_offset_t madt_length;
 
_at__at_ -84,7 +84,6 _at__at_ static void	madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry,
 		    void *arg __unused);
 static void	madt_register(void *dummy);
 static int	madt_setup_local(void);
-static int	madt_setup_io(void);
 static void	madt_walk_table(acpi_subtable_handler *handler, void *arg);
 
 static struct apic_enumerator madt_enumerator = {
_at__at_ -147,7 +146,7 _at__at_ madt_setup_local(void)
 /*
  * Enumerate I/O APICs and setup interrupt sources.
  */
-static int
+int
 madt_setup_io(void)
 {
 	void *ioapic;
diff --git a/sys/x86/xen/mptable.c b/sys/x86/xen/mptable.c
index 0384886..46b03f3 100644
--- a/sys/x86/xen/mptable.c
+++ b/sys/x86/xen/mptable.c
_at__at_ -43,6 +43,9 _at__at_ __FBSDID("$FreeBSD$");
 #include <machine/intr_machdep.h>
 #include <machine/apicvar.h>
 
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/actables.h>
+
 #include <machine/cpu.h>
 #include <machine/smp.h>
 
_at__at_ -51,6 +54,9 _at__at_ __FBSDID("$FreeBSD$");
 
 #include <xen/interface/vcpu.h>
 
+/* From madt.c */
+extern ACPI_TABLE_MADT *madt;
+
 static int xenpv_probe(void);
 static int xenpv_probe_cpus(void);
 static int xenpv_setup_local(void);
_at__at_ -107,7 +113,23 _at__at_ xenpv_setup_local(void)
 static int
 xenpv_setup_io(void)
 {
-	return (0);
+	vm_paddr_t madt_physaddr;
+	vm_offset_t madt_length;
+
+	if (!xen_initial_domain())
+		return (0);
+
+	madt_physaddr = acpi_find_table(ACPI_SIG_MADT);
+	if (madt_physaddr == 0)
+		panic("could not find MADT table");
+	madt = acpi_map_table(madt_physaddr, ACPI_SIG_MADT);
+	if (madt == NULL)
+		panic("unable to map MADT");
+	madt_length = madt->Header.Length;
+	acpi_unmap_table(madt);
+	madt = pmap_mapbios(madt_physaddr, madt_length);
+
+	return (madt_setup_io());
 }
 
 static void
-- 
1.7.7.5 (Apple Git-26)
Received on Tue Dec 24 2013 - 10:22:44 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:45 UTC