From owner-freebsd-current@FreeBSD.ORG Tue Dec 24 11:22:44 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4FE13410; Tue, 24 Dec 2013 11:22:44 +0000 (UTC) Received: from SMTP.CITRIX.COM (smtp.citrix.com [66.165.176.89]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id CD62A167C; Tue, 24 Dec 2013 11:22:42 +0000 (UTC) X-IronPort-AV: E=Sophos;i="4.95,542,1384300800"; d="scan'208";a="87481881" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 24 Dec 2013 11:22:30 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.2.342.4; Tue, 24 Dec 2013 06:22:29 -0500 Received: from gateway-cbg.eng.citrite.net ([10.80.16.17] helo=localhost.localdomain) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1VvQ4E-0007qS-3a; Tue, 24 Dec 2013 11:22:30 +0000 From: Roger Pau Monne To: , , , , , , Subject: [PATCH RFC 07/13] xen: implement IO APIC support in Xen mptable parser Date: Tue, 24 Dec 2013 12:20:56 +0100 Message-ID: <1387884062-41154-8-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 1.7.7.5 (Apple Git-26) In-Reply-To: <1387884062-41154-1-git-send-email-roger.pau@citrix.com> References: <1387884062-41154-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain X-DLP: MIA2 Cc: Roger Pau Monne X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Dec 2013 11:22:44 -0000 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 @@ -233,6 +233,7 @@ 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 @@ -232,6 +232,7 @@ 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 @@ -61,7 +61,7 @@ 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; @@ -84,7 +84,6 @@ 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 = { @@ -147,7 +146,7 @@ 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 @@ -43,6 +43,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + #include #include @@ -51,6 +54,9 @@ __FBSDID("$FreeBSD$"); #include +/* 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); @@ -107,7 +113,23 @@ 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)