Extra ABI and setup to obtain the xenstore ring location.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
#include <xtf/hypercall.h>
#include <xtf/extable.h>
#include <xtf/report.h>
+#include <xtf/xenbus.h>
#include <arch/cpuid.h>
#include <arch/desc.h>
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;
setup_pv_console();
map_shared_info();
+ setup_xenbus();
}
/*
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
--- /dev/null
+#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:
+ */
#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
--- /dev/null
+#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:
+ */
#include <xtf/exlog.h>
#include <xtf/hypercall.h>
#include <xtf/traps.h>
+#include <xtf/xenbus.h>
/* Arch specific headers. */
#include <arch/xtf.h>
--- /dev/null
+#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:
+ */