]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
Infrastructure for connecting the xenbus ring
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 30 Mar 2016 17:50:03 +0000 (18:50 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 9 Aug 2017 15:37:25 +0000 (16:37 +0100)
Extra ABI and setup to obtain the xenstore ring location.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/setup.c
build/files.mk
common/xenbus.c [new file with mode: 0644]
include/xen/hvm/params.h
include/xen/io/xs_wire.h [new file with mode: 0644]
include/xtf.h
include/xtf/xenbus.h [new file with mode: 0644]

index ab1d060634514e47a467d72d2074ee295b68f113..526361d2a2187661b2e1e5798f4b228dc00664ba 100644 (file)
@@ -2,6 +2,7 @@
 #include <xtf/hypercall.h>
 #include <xtf/extable.h>
 #include <xtf/report.h>
+#include <xtf/xenbus.h>
 
 #include <arch/cpuid.h>
 #include <arch/desc.h>
@@ -172,6 +173,36 @@ static void setup_pv_console(void)
     init_pv_console(cons_ring, cons_evtchn);
 }
 
+static void setup_xenbus(void)
+{
+    xenbus_interface_t *xb_ring;
+    evtchn_port_t xb_port;
+
+    if ( IS_DEFINED(CONFIG_PV) )
+    {
+        xb_ring = mfn_to_virt(start_info->store_mfn);
+        xb_port = start_info->store_evtchn;
+    }
+    else /* HVM */
+    {
+        uint64_t raw_pfn, raw_evtchn;
+        int rc;
+
+        rc = hvm_get_param(HVM_PARAM_STORE_PFN, &raw_pfn);
+        if ( rc )
+            panic("Failed to get XenStore PFN: %d\n", rc);
+
+        rc = hvm_get_param(HVM_PARAM_STORE_EVTCHN, &raw_evtchn);
+        if ( rc )
+            panic("Failed to get XenStore evtchn: %d\n", rc);
+
+        xb_ring = pfn_to_virt(raw_pfn);
+        xb_port = raw_evtchn;
+    }
+
+    init_xenbus(xb_ring, xb_port);
+}
+
 static void map_shared_info(void)
 {
     int rc;
@@ -226,6 +257,7 @@ void arch_setup(void)
 
     setup_pv_console();
     map_shared_info();
+    setup_xenbus();
 }
 
 /*
index 8c50dd41e8462dfcbee32c02f56b3002a46926c6..6001a9254b1e5fe001428f43d8f678688bbb67f4 100644 (file)
@@ -14,6 +14,7 @@ obj-perarch += $(ROOT)/common/libc/string.o
 obj-perarch += $(ROOT)/common/libc/vsnprintf.o
 obj-perarch += $(ROOT)/common/report.o
 obj-perarch += $(ROOT)/common/setup.o
+obj-perarch += $(ROOT)/common/xenbus.o
 
 obj-perenv += $(ROOT)/arch/x86/decode.o
 obj-perenv += $(ROOT)/arch/x86/desc.o
diff --git a/common/xenbus.c b/common/xenbus.c
new file mode 100644 (file)
index 0000000..4a640ad
--- /dev/null
@@ -0,0 +1,25 @@
+#include <xtf/lib.h>
+#include <xtf/traps.h>
+#include <xtf/xenbus.h>
+
+static xenbus_interface_t *xb_ring;
+static evtchn_port_t xb_port;
+
+void init_xenbus(xenbus_interface_t *ring, evtchn_port_t port)
+{
+    if ( port >= (sizeof(shared_info.evtchn_pending) * CHAR_BIT) )
+        panic("evtchn %u out of evtchn_pending[] range\n", port);
+
+    xb_ring = ring;
+    xb_port = port;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index 101a5c57281a6fbc10d6627dc0de942d6d6757f1..886b986bcee39e2d7b96ca3b124e65da05737bd3 100644 (file)
@@ -5,6 +5,9 @@
 #ifndef XEN_PUBLIC_HVM_PARAMS_H
 #define XEN_PUBLIC_HVM_PARAMS_H
 
+#define HVM_PARAM_STORE_PFN       1
+#define HVM_PARAM_STORE_EVTCHN    2
+
 #define HVM_PARAM_CONSOLE_PFN    17
 #define HVM_PARAM_CONSOLE_EVTCHN 18
 
diff --git a/include/xen/io/xs_wire.h b/include/xen/io/xs_wire.h
new file mode 100644 (file)
index 0000000..a963c7d
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef XEN_PUBLIC_IO_XS_WIRE_H
+#define XEN_PUBLIC_IO_XS_WIRE_H
+
+/* API/ABI relevent to the XenBus shared memory interface. */
+
+#define XENBUS_RING_SIZE 1024
+static inline uint32_t mask_xenbus_idx(uint32_t idx)
+{
+    return idx & (XENBUS_RING_SIZE - 1);
+}
+
+struct xenbus_interface {
+    char req[XENBUS_RING_SIZE]; /* Requests to the xenstore daemon. */
+    char rsp[XENBUS_RING_SIZE]; /* Replies and async watch events. */
+    uint32_t req_cons, req_prod;
+    uint32_t rsp_cons, rsp_prod;
+    uint32_t server_features;
+    uint32_t connection;
+};
+typedef struct xenbus_interface xenbus_interface_t;
+
+#define XENBUS_SERVER_FEATURE_RECONNECTION 1
+
+#define XENBUS_CONNECTED 0
+#define XENBUS_RECONNECT 1
+
+#endif /* XEN_PUBLIC_IO_XS_WIRE_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index 134819aaf2226883adca1e7247218eed4de435ca..f1cebfafcfd812af2b215abd5bda1d6782530555 100644 (file)
@@ -23,6 +23,7 @@
 #include <xtf/exlog.h>
 #include <xtf/hypercall.h>
 #include <xtf/traps.h>
+#include <xtf/xenbus.h>
 
 /* Arch specific headers. */
 #include <arch/xtf.h>
diff --git a/include/xtf/xenbus.h b/include/xtf/xenbus.h
new file mode 100644 (file)
index 0000000..3ed77d5
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef XTF_XENBUS_H
+#define XTF_XENBUS_H
+
+#include <xtf/types.h>
+#include <xen/event_channel.h>
+#include <xen/io/xs_wire.h>
+
+void init_xenbus(xenbus_interface_t *ring, evtchn_port_t port);
+
+#endif /* XTF_XENBUS_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */