]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
libxendevicemodel: add ability to inject an emulated MSI
authorIan Campbell <ian.campbell@citrix.com>
Wed, 10 Feb 2016 14:47:16 +0000 (14:47 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 10 Feb 2016 17:09:53 +0000 (17:09 +0000)
XXX underlying hypercall is not stable. Note this with the version of
    @@UNSTABLE. Also in order to build need to define __XEN_TOOLS__,
    use a separate source file to avoid accidentally poluting the
    stable bits of the library.

TBD replace hypercall with a stable variant and move to emuirq.c +
    version as @@1.0

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
tools/libs/devicemodel/Makefile
tools/libs/devicemodel/emuirq_unstable.c [new file with mode: 0644]
tools/libs/devicemodel/include/xendevicemodel.h
tools/libs/devicemodel/libxendevicemodel.map

index 86d2b1b821569852d554a85896a11957435edc03..4293bc06c49d04d8d74051c1b73878aa3658dd22 100644 (file)
@@ -14,7 +14,7 @@ LDLIBS   += $(LDLIBS_libxentoollog)
 LDLIBS   += $(LDLIBS_libxencall)
 
 SRCS-y   += core.c
-SRCS-y   += emuirq.c
+SRCS-y   += emuirq.c emuirq_unstable.c
 
 LIB_OBJS := $(patsubst %.c,%.o,$(SRCS-y))
 PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS-y))
@@ -24,6 +24,9 @@ ifneq ($(nosharedlibs),y)
 LIB += libxendevicemodel.so
 endif
 
+# XXX These use unstable hypervisor interfaces
+emuirq_unstable.o emuirq_unstable.opic: CFLAGS += -D__XEN_TOOLS__
+
 .PHONY: all
 all: build
 
diff --git a/tools/libs/devicemodel/emuirq_unstable.c b/tools/libs/devicemodel/emuirq_unstable.c
new file mode 100644 (file)
index 0000000..ecd773d
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+
+#include "private.h"
+
+int xendevicemodel_inject_msi(xendevicemodel_handle *dm,
+                              uint64_t addr, uint32_t data)
+{
+    xen_hvm_inject_msi_t *arg;
+    int ret = -1;
+
+    arg = xencall_alloc_buffer(dm->call, sizeof(*arg));
+    if ( arg == NULL )
+    {
+        LOGE(ERROR, "unable to allocate memory for inject MSI hypercall");
+        goto err;
+    }
+
+    arg->domid = dm->domid;
+    arg->addr  = addr;
+    arg->data  = data;
+
+    ret = xencall2(dm->call, __HYPERVISOR_hvm_op,
+                   HVMOP_inject_msi,
+                   (uintptr_t)arg);
+
+    if ( ret )
+        LOGE(ERROR, "inject MSI hypercall failed");
+
+    xencall_free_buffer(dm->call, arg);
+
+ err:
+    return ret;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index fde7b8d94229b7a0ae3c227469f769c6f413bb00..c5626d3c2f49f36fee75042be7e8bcdad2a8bf8b 100644 (file)
@@ -128,6 +128,9 @@ int xendevicemodel_s3_awaken(xendevicemodel_handle *dm);
  * @isa_irq     ISA IRQ 0..15 (inclusive).
  * @assert      Whether the given interrupt of the given type should be
  *              asserted or deasserted.
+ *
+ * For MSI injection is as if a device had written @data to guest
+ * physical address @addr.
  */
 int xendevicemodel_set_pci_intx_level(xendevicemodel_handle *dm,
                                       uint8_t domain, uint8_t bus, uint8_t dev,
@@ -137,6 +140,9 @@ int xendevicemodel_route_pci_intx_to_isa_irq(xendevicemodel_handle *dm,
 int xendevicemodel_set_isa_irq_level(xendevicemodel_handle *dm,
                                      uint8_t isa_irq, bool assert);
 
+int xendevicemodel_inject_msi(xendevicemodel_handle *dm,
+                              uint64_t addr, uint32_t data);
+
 /*
  * Memory handling
  * ===============
index 2ac9bfb1a93972b990da49d5724a1bd4d9bbd684..366363cabbffde6cb85cbf592cbbc659ecd20d12 100644 (file)
@@ -1,3 +1,9 @@
+/* While this section exists this library is not stable */
+UNSTABLE {
+       global:
+               xendevicemodel_inject_msi;
+};
+
 VERS_1.0 {
        global:
                xendevicemodel_open;