From owner-freebsd-current@FreeBSD.ORG Tue Dec 24 11:22:40 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 293593F7; Tue, 24 Dec 2013 11:22:40 +0000 (UTC) Received: from SMTP02.CITRIX.COM (smtp02.citrix.com [66.165.176.63]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A68D41674; Tue, 24 Dec 2013 11:22:38 +0000 (UTC) X-IronPort-AV: E=Sophos;i="4.95,542,1384300800"; d="scan'208";a="85272671" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO02.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:28 -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 1VvQ4D-0007qS-2Q; Tue, 24 Dec 2013 11:22:29 +0000 From: Roger Pau Monne To: , , , , , , Subject: [PATCH RFC 05/13] xen: implement Xen IO APIC ops Date: Tue, 24 Dec 2013 12:20:54 +0100 Message-ID: <1387884062-41154-6-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: MIA1 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:40 -0000 Implement a different set of hooks for IO APIC to use when running under Xen Dom0. --- sys/x86/xen/pv.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index ab4afba..e5ad200 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -58,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -73,6 +75,11 @@ static caddr_t xen_pv_parse_preload_data(u_int64_t); static void xen_pv_parse_memmap(caddr_t, vm_paddr_t *, int *); static void xen_pv_set_init_ops(void); + +static u_int xen_pv_ioapic_read(volatile ioapic_t *, int); +static void xen_pv_ioapic_write(volatile ioapic_t *, int, u_int); +static void xen_pv_ioapic_register_intr(struct ioapic_intsrc *); + /*---------------------------- Extern Declarations ---------------------------*/ /* Variables used by amd64 mp_machdep to start APs */ extern struct mtx ap_boot_mtx; @@ -92,6 +99,13 @@ struct init_ops xen_init_ops = { .parse_memmap = xen_pv_parse_memmap, }; +/* Xen ioapic_ops implementation */ +struct ioapic_ops xen_ioapic_ops = { + .read = xen_pv_ioapic_read, + .write = xen_pv_ioapic_write, + .register_intr = xen_pv_ioapic_register_intr, +}; + static struct { const char *ev; @@ -342,6 +356,34 @@ xen_pv_parse_memmap(caddr_t kmdp, vm_paddr_t *physmap, int *physmap_idx) bios_add_smap_entries(xen_smap, size, physmap, physmap_idx); } +static u_int +xen_pv_ioapic_read(volatile ioapic_t *apic, int reg) +{ + struct physdev_apic apic_op; + int rc; + + mtx_assert(&icu_lock, MA_OWNED); + + apic_op.apic_physbase = pmap_kextract((vm_offset_t) apic); + apic_op.reg = reg; + rc = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op); + if (rc) + panic("apic_read operation failed"); + + return (apic_op.value); +} + +static void +xen_pv_ioapic_write(volatile ioapic_t *apic, int reg, u_int val) +{ +} + +static void +xen_pv_ioapic_register_intr(struct ioapic_intsrc *pin) +{ + xen_register_pirq(pin->io_irq, pin->io_activehi, pin->io_edgetrigger); +} + static void xen_pv_set_init_ops(void) { @@ -349,4 +391,6 @@ xen_pv_set_init_ops(void) init_ops = xen_init_ops; /* Disable lapic */ lapic_disabled = true; + /* IOAPIC ops for Xen PV */ + ioapic_ops = xen_ioapic_ops; } -- 1.7.7.5 (Apple Git-26)