From owner-svn-src-head@FreeBSD.ORG Tue Sep 30 16:46:50 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2F0B4957; Tue, 30 Sep 2014 16:46:50 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 18A36819; Tue, 30 Sep 2014 16:46:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8UGkoVF092624; Tue, 30 Sep 2014 16:46:50 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8UGkkNZ092605; Tue, 30 Sep 2014 16:46:46 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201409301646.s8UGkkNZ092605@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: Roger Pau Monné Date: Tue, 30 Sep 2014 16:46:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272310 - in head/sys: amd64/amd64 conf dev/acpica i386/i386 x86/include x86/x86 x86/xen xen xen/interface X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Sep 2014 16:46:50 -0000 Author: royger Date: Tue Sep 30 16:46:45 2014 New Revision: 272310 URL: http://svnweb.freebsd.org/changeset/base/272310 Log: msi: add Xen MSI implementation This patch adds support for MSI interrupts when running on Xen. Apart from adding the Xen related code needed in order to register MSI interrupts this patch also makes the msi_init function a hook in init_ops, so different MSI implementations can have different initialization functions. Sponsored by: Citrix Systems R&D xen/interface/physdev.h: - Add the MAP_PIRQ_TYPE_MULTI_MSI to map multi-vector MSI to the Xen public interface. x86/include/init.h: - Add a hook for setting custom msi_init methods. amd64/amd64/machdep.c: i386/i386/machdep.c: - Set the default msi_init hook to point to the native MSI initialization method. x86/xen/pv.c: - Set the Xen MSI init hook when running as a Xen guest. x86/x86/local_apic.c: - Call the msi_init hook instead of directly calling msi_init. xen/xen_intr.h: x86/xen/xen_intr.c: - Introduce support for registering/releasing MSI interrupts with Xen. - The MSI interrupts will use the same PIC as the IO APIC interrupts. xen/xen_msi.h: x86/xen/xen_msi.c: - Introduce a Xen MSI implementation. x86/xen/xen_nexus.c: - Overwrite the default MSI hooks in the Xen Nexus to use the Xen MSI implementation. x86/xen/xen_pci.c: - Introduce a Xen specific PCI bus that inherits from the ACPI PCI bus and overwrites the native MSI methods. - This is needed because when running under Xen the MSI messages used to configure MSI interrupts on PCI devices are written by Xen itself. dev/acpica/acpi_pci.c: - Lower the quality of the ACPI PCI bus so the newly introduced Xen PCI bus can take over when needed. conf/files.i386: conf/files.amd64: - Add the newly created files to the build process. Added: head/sys/x86/xen/xen_msi.c (contents, props changed) head/sys/x86/xen/xen_pci.c (contents, props changed) head/sys/xen/xen_msi.h (contents, props changed) Modified: head/sys/amd64/amd64/machdep.c head/sys/conf/files.amd64 head/sys/conf/files.i386 head/sys/dev/acpica/acpi_pci.c head/sys/i386/i386/machdep.c head/sys/x86/include/init.h head/sys/x86/x86/local_apic.c head/sys/x86/xen/pv.c head/sys/x86/xen/xen_intr.c head/sys/x86/xen/xen_nexus.c head/sys/xen/interface/physdev.h head/sys/xen/xen_intr.h Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Tue Sep 30 16:36:50 2014 (r272309) +++ head/sys/amd64/amd64/machdep.c Tue Sep 30 16:46:45 2014 (r272310) @@ -177,6 +177,7 @@ struct init_ops init_ops = { .mp_bootaddress = mp_bootaddress, .start_all_aps = native_start_all_aps, #endif + .msi_init = msi_init, }; /* Modified: head/sys/conf/files.amd64 ============================================================================== --- head/sys/conf/files.amd64 Tue Sep 30 16:36:50 2014 (r272309) +++ head/sys/conf/files.amd64 Tue Sep 30 16:46:45 2014 (r272310) @@ -582,3 +582,5 @@ x86/xen/pvcpu_enum.c optional xenhvm x86/xen/xen_apic.c optional xenhvm x86/xen/xenpv.c optional xenhvm x86/xen/xen_nexus.c optional xenhvm +x86/xen/xen_msi.c optional xenhvm +x86/xen/xen_pci.c optional xenhvm Modified: head/sys/conf/files.i386 ============================================================================== --- head/sys/conf/files.i386 Tue Sep 30 16:36:50 2014 (r272309) +++ head/sys/conf/files.i386 Tue Sep 30 16:46:45 2014 (r272310) @@ -599,3 +599,4 @@ x86/xen/xen_intr.c optional xen | xenhv x86/xen/xen_apic.c optional xenhvm x86/xen/xenpv.c optional xen | xenhvm x86/xen/xen_nexus.c optional xen | xenhvm +x86/xen/xen_msi.c optional xen | xenhvm Modified: head/sys/dev/acpica/acpi_pci.c ============================================================================== --- head/sys/dev/acpica/acpi_pci.c Tue Sep 30 16:36:50 2014 (r272309) +++ head/sys/dev/acpica/acpi_pci.c Tue Sep 30 16:46:45 2014 (r272310) @@ -282,7 +282,7 @@ acpi_pci_probe(device_t dev) if (acpi_get_handle(dev) == NULL) return (ENXIO); device_set_desc(dev, "ACPI PCI bus"); - return (0); + return (BUS_PROBE_DEFAULT); } static int Modified: head/sys/i386/i386/machdep.c ============================================================================== --- head/sys/i386/i386/machdep.c Tue Sep 30 16:36:50 2014 (r272309) +++ head/sys/i386/i386/machdep.c Tue Sep 30 16:46:45 2014 (r272310) @@ -248,6 +248,9 @@ struct mem_range_softc mem_range_softc; struct init_ops init_ops = { .early_clock_source_init = i8254_init, .early_delay = i8254_delay, +#ifdef DEV_APIC + .msi_init = msi_init, +#endif }; static void Modified: head/sys/x86/include/init.h ============================================================================== --- head/sys/x86/include/init.h Tue Sep 30 16:36:50 2014 (r272309) +++ head/sys/x86/include/init.h Tue Sep 30 16:46:45 2014 (r272310) @@ -41,6 +41,7 @@ struct init_ops { void (*parse_memmap)(caddr_t, vm_paddr_t *, int *); u_int (*mp_bootaddress)(u_int); int (*start_all_aps)(void); + void (*msi_init)(void); }; extern struct init_ops init_ops; Modified: head/sys/x86/x86/local_apic.c ============================================================================== --- head/sys/x86/x86/local_apic.c Tue Sep 30 16:36:50 2014 (r272309) +++ head/sys/x86/x86/local_apic.c Tue Sep 30 16:46:45 2014 (r272310) @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef DDB #include @@ -1438,7 +1439,7 @@ apic_setup_io(void *dummy __unused) lapic_dump("BSP"); /* Enable the MSI "pic". */ - msi_init(); + init_ops.msi_init(); } SYSINIT(apic_setup_io, SI_SUB_INTR, SI_ORDER_THIRD, apic_setup_io, NULL); Modified: head/sys/x86/xen/pv.c ============================================================================== --- head/sys/x86/xen/pv.c Tue Sep 30 16:36:50 2014 (r272309) +++ head/sys/x86/xen/pv.c Tue Sep 30 16:46:45 2014 (r272310) @@ -60,11 +60,13 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include +#include #include @@ -117,6 +119,7 @@ struct init_ops xen_init_ops = { #ifdef SMP .start_all_aps = xen_pv_start_all_aps, #endif + .msi_init = xen_msi_init, }; static struct bios_smap xen_smap[MAX_E820_ENTRIES]; Modified: head/sys/x86/xen/xen_intr.c ============================================================================== --- head/sys/x86/xen/xen_intr.c Tue Sep 30 16:36:50 2014 (r272309) +++ head/sys/x86/xen/xen_intr.c Tue Sep 30 16:46:45 2014 (r272310) @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -63,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #ifdef DDB #include @@ -1373,6 +1375,64 @@ xen_register_pirq(int vector, enum intr_ } int +xen_register_msi(device_t dev, int vector, int count) +{ + struct physdev_map_pirq msi_irq; + struct xenisrc *isrc; + int ret; + + memset(&msi_irq, 0, sizeof(msi_irq)); + msi_irq.domid = DOMID_SELF; + msi_irq.type = count == 1 ? + MAP_PIRQ_TYPE_MSI_SEG : MAP_PIRQ_TYPE_MULTI_MSI; + msi_irq.index = -1; + msi_irq.pirq = -1; + msi_irq.bus = pci_get_bus(dev) | (pci_get_domain(dev) << 16); + msi_irq.devfn = (pci_get_slot(dev) << 3) | pci_get_function(dev); + msi_irq.entry_nr = count; + + ret = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &msi_irq); + if (ret != 0) + return (ret); + if (count != msi_irq.entry_nr) { + panic("unable to setup all requested MSI vectors " + "(expected %d got %d)", count, msi_irq.entry_nr); + } + + mtx_lock(&xen_intr_isrc_lock); + for (int i = 0; i < count; i++) { + isrc = xen_intr_alloc_isrc(EVTCHN_TYPE_PIRQ, vector + i); + KASSERT(isrc != NULL, + ("xen: unable to allocate isrc for interrupt")); + isrc->xi_pirq = msi_irq.pirq + i; + } + mtx_unlock(&xen_intr_isrc_lock); + + return (0); +} + +int +xen_release_msi(int vector) +{ + struct physdev_unmap_pirq unmap; + struct xenisrc *isrc; + int ret; + + isrc = (struct xenisrc *)intr_lookup_source(vector); + if (isrc == NULL) + return (ENXIO); + + unmap.pirq = isrc->xi_pirq; + ret = HYPERVISOR_physdev_op(PHYSDEVOP_unmap_pirq, &unmap); + if (ret != 0) + return (ret); + + xen_intr_release_isrc(isrc); + + return (0); +} + +int xen_intr_describe(xen_intr_handle_t port_handle, const char *fmt, ...) { char descr[MAXCOMLEN + 1]; Added: head/sys/x86/xen/xen_msi.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/x86/xen/xen_msi.c Tue Sep 30 16:46:45 2014 (r272310) @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2014 Roger Pau Monné + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static struct mtx msi_lock; +static int msi_last_irq; + +void +xen_msi_init(void) +{ + + mtx_init(&msi_lock, "msi", NULL, MTX_DEF); +} + +/* + * Try to allocate 'count' interrupt sources with contiguous IDT values. + */ +int +xen_msi_alloc(device_t dev, int count, int maxcount, int *irqs) +{ + int i, ret = 0; + + mtx_lock(&msi_lock); + + /* If we would exceed the max, give up. */ + if ((msi_last_irq + count) > NUM_MSI_INTS) { + mtx_unlock(&msi_lock); + return (ENXIO); + } + + /* Allocate MSI vectors */ + for (i = 0; i < count; i++) + irqs[i] = FIRST_MSI_INT + msi_last_irq++; + + mtx_unlock(&msi_lock); + + ret = xen_register_msi(dev, irqs[0], count); + if (ret != 0) + return (ret); + + for (i = 0; i < count; i++) + nexus_add_irq(irqs[i]); + + return (0); +} + +int +xen_msi_release(int *irqs, int count) +{ + int i, ret; + + for (i = 0; i < count; i++) { + ret = xen_release_msi(irqs[i]); + if (ret != 0) + return (ret); + } + + return (0); +} + +int +xen_msi_map(int irq, uint64_t *addr, uint32_t *data) +{ + + return (0); +} + +int +xen_msix_alloc(device_t dev, int *irq) +{ + + return (ENXIO); +} + +int +xen_msix_release(int irq) +{ + + return (ENOENT); +} Modified: head/sys/x86/xen/xen_nexus.c ============================================================================== --- head/sys/x86/xen/xen_nexus.c Tue Sep 30 16:36:50 2014 (r272309) +++ head/sys/x86/xen/xen_nexus.c Tue Sep 30 16:46:45 2014 (r272310) @@ -45,6 +45,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include + +#include "pcib_if.h" /* * Xen nexus(4) driver. @@ -111,6 +114,41 @@ nexus_xen_config_intr(device_t dev, int return (intr_config_intr(irq, trig, pol)); } +static int +nexus_xen_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + + return (xen_msix_alloc(dev, irq)); +} + +static int +nexus_xen_release_msix(device_t pcib, device_t dev, int irq) +{ + + return (xen_msix_release(irq)); +} + +static int +nexus_xen_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, int *irqs) +{ + + return (xen_msi_alloc(dev, count, maxcount, irqs)); +} + +static int +nexus_xen_release_msi(device_t pcib, device_t dev, int count, int *irqs) +{ + + return (xen_msi_release(irqs, count)); +} + +static int +nexus_xen_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, uint32_t *data) +{ + + return (xen_msi_map(irq, addr, data)); +} + static device_method_t nexus_xen_methods[] = { /* Device interface */ DEVMETHOD(device_probe, nexus_xen_probe), @@ -119,6 +157,13 @@ static device_method_t nexus_xen_methods /* INTR */ DEVMETHOD(bus_config_intr, nexus_xen_config_intr), + /* MSI */ + DEVMETHOD(pcib_alloc_msi, nexus_xen_alloc_msi), + DEVMETHOD(pcib_release_msi, nexus_xen_release_msi), + DEVMETHOD(pcib_alloc_msix, nexus_xen_alloc_msix), + DEVMETHOD(pcib_release_msix, nexus_xen_release_msix), + DEVMETHOD(pcib_map_msi, nexus_xen_map_msi), + { 0, 0 } }; Added: head/sys/x86/xen/xen_pci.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/x86/xen/xen_pci.c Tue Sep 30 16:46:45 2014 (r272310) @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2014 Roger Pau Monné + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include "pcib_if.h" +#include "pci_if.h" + +static int xen_pci_probe(device_t dev); + +static void xen_pci_enable_msi_method(device_t dev, device_t child, + uint64_t address, uint16_t data); +static void xen_pci_disable_msi_method(device_t dev, device_t child); + +static device_method_t xen_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, xen_pci_probe), + + /* PCI interface overwrites */ + DEVMETHOD(pci_enable_msi, xen_pci_enable_msi_method), + DEVMETHOD(pci_disable_msi, xen_pci_disable_msi_method), + + DEVMETHOD_END +}; + +static devclass_t pci_devclass; + +DECLARE_CLASS(acpi_pci_driver); +DEFINE_CLASS_1(pci, xen_pci_driver, xen_pci_methods, sizeof(struct pci_softc), + acpi_pci_driver); +DRIVER_MODULE(xen_pci, pcib, xen_pci_driver, pci_devclass, 0, 0); +MODULE_DEPEND(xen_pci, pci, 1, 1, 1); +MODULE_DEPEND(xen_pci, acpi, 1, 1, 1); +MODULE_VERSION(xen_pci, 1); + +static int +xen_pci_probe(device_t dev) +{ + + device_set_desc(dev, "Xen PCI bus"); + + if (!xen_pv_domain()) + return (ENXIO); + + return (BUS_PROBE_SPECIFIC); +} + +static void +xen_pci_enable_msi_method(device_t dev, device_t child, uint64_t address, + uint16_t data) +{ + struct pci_devinfo *dinfo = device_get_ivars(child); + struct pcicfg_msi *msi = &dinfo->cfg.msi; + + /* Enable MSI in the control register. */ + msi->msi_ctrl |= PCIM_MSICTRL_MSI_ENABLE; + pci_write_config(child, msi->msi_location + PCIR_MSI_CTRL, + msi->msi_ctrl, 2); +} + +static void +xen_pci_disable_msi_method(device_t dev, device_t child) +{ + struct pci_devinfo *dinfo = device_get_ivars(child); + struct pcicfg_msi *msi = &dinfo->cfg.msi; + + msi->msi_ctrl &= ~PCIM_MSICTRL_MSI_ENABLE; + pci_write_config(child, msi->msi_location + PCIR_MSI_CTRL, + msi->msi_ctrl, 2); +} Modified: head/sys/xen/interface/physdev.h ============================================================================== --- head/sys/xen/interface/physdev.h Tue Sep 30 16:36:50 2014 (r272309) +++ head/sys/xen/interface/physdev.h Tue Sep 30 16:46:45 2014 (r272310) @@ -151,6 +151,7 @@ DEFINE_XEN_GUEST_HANDLE(physdev_irq_t); #define MAP_PIRQ_TYPE_GSI 0x1 #define MAP_PIRQ_TYPE_UNKNOWN 0x2 #define MAP_PIRQ_TYPE_MSI_SEG 0x3 +#define MAP_PIRQ_TYPE_MULTI_MSI 0x4 #define PHYSDEVOP_map_pirq 13 struct physdev_map_pirq { Modified: head/sys/xen/xen_intr.h ============================================================================== --- head/sys/xen/xen_intr.h Tue Sep 30 16:36:50 2014 (r272309) +++ head/sys/xen/xen_intr.h Tue Sep 30 16:46:45 2014 (r272310) @@ -224,4 +224,26 @@ void xen_intr_signal(xen_intr_handle_t h */ evtchn_port_t xen_intr_port(xen_intr_handle_t handle); +/** + * Setup MSI vector interrupt(s). + * + * \param dev The device that requests the binding. + * + * \param vector Requested initial vector to bind the MSI interrupt(s) to. + * + * \param count Number of vectors to allocate. + * + * \returns 0 on success, otherwise an errno. + */ +int xen_register_msi(device_t dev, int vector, int count); + +/** + * Teardown a MSI vector interrupt. + * + * \param vector Requested vector to release. + * + * \returns 0 on success, otherwise an errno. + */ +int xen_release_msi(int vector); + #endif /* _XEN_INTR_H_ */ Added: head/sys/xen/xen_msi.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/xen/xen_msi.h Tue Sep 30 16:46:45 2014 (r272310) @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2014 Roger Pau Monné + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef __XEN_MSI_H__ +#define __XEN_MSI_H__ + +void xen_msi_init(void); +int xen_msi_map(int irq, uint64_t *addr, uint32_t *data); +int xen_msi_alloc(device_t dev, int count, int maxcount, int *irqs); +int xen_msi_release(int *irqs, int count); +int xen_msix_alloc(device_t dev, int *irq); +int xen_msix_release(int irq); + +#endif /* !__XEN_MSI_H__ */ \ No newline at end of file