[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH RFC 15/18] OvmfPkg/XenbusDxe: Add Event Channel into XenBus protocol.



Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 OvmfPkg/Include/Protocol/Xenbus.h | 27 +++++++++++++++++++
 OvmfPkg/XenbusDxe/EventChannel.c  | 55 +++++++++++++++++++++++++++++++++++++++
 OvmfPkg/XenbusDxe/EventChannel.h  | 26 ++++++++++++++++++
 OvmfPkg/XenbusDxe/XenBus.c        |  3 +++
 4 files changed, 111 insertions(+)

diff --git a/OvmfPkg/Include/Protocol/Xenbus.h 
b/OvmfPkg/Include/Protocol/Xenbus.h
index 25408c1..aa37369 100644
--- a/OvmfPkg/Include/Protocol/Xenbus.h
+++ b/OvmfPkg/Include/Protocol/Xenbus.h
@@ -51,6 +51,7 @@ typedef enum {
 
 
 #include <IndustryStandard/Xen/grant_table.h>
+#include <IndustryStandard/Xen/event_channel.h>
 
 ///
 /// Function prototypes
@@ -138,6 +139,28 @@ EFI_STATUS
   );
 
 typedef
+int
+(EFIAPI *XENBUS_EVENT_CHANNEL_ALLOCATE) (
+  IN  XENBUS_PROTOCOL *This,
+  IN  domid_t         DomainId,
+  OUT evtchn_port_t   *Port
+  );
+
+typedef
+VOID
+(EFIAPI *XENBUS_EVENT_CHANNEL_NOTIFY) (
+  IN XENBUS_PROTOCOL  *This,
+  IN evtchn_port_t    Port
+  );
+
+typedef
+int
+(EFIAPI *XENBUS_EVENT_CHANNEL_CLOSE) (
+  IN XENBUS_PROTOCOL  *This,
+  IN evtchn_port_t    Port
+  );
+
+typedef
 XENSTORE_STATUS
 (EFIAPI *XENBUS_REGISTER_WATCH) (
   IN  XENBUS_PROTOCOL *This,
@@ -184,6 +207,10 @@ struct _XENBUS_PROTOCOL {
   XENBUS_GRANT_ACCESS           GrantAccess;
   XENBUS_GRANT_END_ACCESS       GrantEndAccess;
 
+  XENBUS_EVENT_CHANNEL_ALLOCATE EventChannelAllocate;
+  XENBUS_EVENT_CHANNEL_NOTIFY   EventChannelNotify;
+  XENBUS_EVENT_CHANNEL_CLOSE    EventChannelClose;
+
   XENBUS_REGISTER_WATCH         RegisterWatch;
   XENBUS_REGISTER_WATCH_BACKEND RegisterWatchBackend;
   XENBUS_UNREGISTER_WATCH       UnregisterWatch;
diff --git a/OvmfPkg/XenbusDxe/EventChannel.c b/OvmfPkg/XenbusDxe/EventChannel.c
index 4ab8a40..101a1e4 100644
--- a/OvmfPkg/XenbusDxe/EventChannel.c
+++ b/OvmfPkg/XenbusDxe/EventChannel.c
@@ -14,3 +14,58 @@ XenEventChannelNotify (
   ReturnCode = XenHypercallEventChannelOp (Dev, EVTCHNOP_send, &send);
   ASSERT (ReturnCode == 0);
 }
+
+int
+EFIAPI
+XenbusEventChannelAllocate (
+  IN XENBUS_PROTOCOL *This,
+  IN domid_t DomainId,
+  OUT evtchn_port_t *Port
+  )
+{
+  XENBUS_PRIVATE_DATA *Private;
+  evtchn_alloc_unbound_t op;
+  int rc;
+
+  Private = XENBUS_PRIVATE_DATA_FROM_THIS (This);
+
+  op.dom = DOMID_SELF;
+  op.remote_dom = DomainId;
+  rc = XenHypercallEventChannelOp (Private->Dev,
+                                   EVTCHNOP_alloc_unbound,
+                                   &op);
+  if (rc != 0) {
+    DEBUG ((EFI_D_ERROR, "ERROR: alloc_unbound failed with rc=%d", rc));
+    return rc;
+  }
+  *Port = op.port;
+  return rc;
+}
+
+VOID
+EFIAPI
+XenbusEventChannelNotify (
+  IN XENBUS_PROTOCOL *This,
+  IN evtchn_port_t Port
+  )
+{
+  XENBUS_PRIVATE_DATA *Private;
+
+  Private = XENBUS_PRIVATE_DATA_FROM_THIS(This);
+  XenEventChannelNotify (Private->Dev, Port);
+}
+
+int
+EFIAPI
+XenbusEventChannelClose (
+  IN XENBUS_PROTOCOL *This,
+  IN evtchn_port_t Port
+  )
+{
+  XENBUS_PRIVATE_DATA *Private;
+  evtchn_close_t close;
+
+  Private = XENBUS_PRIVATE_DATA_FROM_THIS(This);
+  close.port = Port;
+  return XenHypercallEventChannelOp (Private->Dev, EVTCHNOP_close, &close);
+}
diff --git a/OvmfPkg/XenbusDxe/EventChannel.h b/OvmfPkg/XenbusDxe/EventChannel.h
index 8a3f6d4..b1e16f0 100644
--- a/OvmfPkg/XenbusDxe/EventChannel.h
+++ b/OvmfPkg/XenbusDxe/EventChannel.h
@@ -11,4 +11,30 @@ XenEventChannelNotify (
   IN evtchn_port_t Port
   );
 
+/*
+ * Xenbus protocol
+ */
+
+int
+EFIAPI
+XenbusEventChannelAllocate (
+  IN XENBUS_PROTOCOL *This,
+  IN domid_t DomainId,
+  OUT evtchn_port_t *Port
+  );
+
+VOID
+EFIAPI
+XenbusEventChannelNotify (
+  IN XENBUS_PROTOCOL *This,
+  IN evtchn_port_t Port
+  );
+
+int
+EFIAPI
+XenbusEventChannelClose (
+  IN XENBUS_PROTOCOL *This,
+  IN evtchn_port_t Port
+  );
+
 #endif
diff --git a/OvmfPkg/XenbusDxe/XenBus.c b/OvmfPkg/XenbusDxe/XenBus.c
index b0cf1ba..f93423f 100644
--- a/OvmfPkg/XenbusDxe/XenBus.c
+++ b/OvmfPkg/XenbusDxe/XenBus.c
@@ -347,6 +347,9 @@ STATIC XENBUS_PRIVATE_DATA gXenbusPrivateData = {
   .XenbusIo.SetState = XenbusSetState,
   .XenbusIo.GrantAccess = XenbusGrantAccess,
   .XenbusIo.GrantEndAccess = XenbusGrantEndAccess,
+  .XenbusIo.EventChannelAllocate = XenbusEventChannelAllocate,
+  .XenbusIo.EventChannelNotify = XenbusEventChannelNotify,
+  .XenbusIo.EventChannelClose = XenbusEventChannelClose,
   .XenbusIo.RegisterWatch = XenbusRegisterWatch,
   .XenbusIo.RegisterWatchBackend = XenbusRegisterWatchBackend,
   .XenbusIo.UnregisterWatch = XenbusUnregisterWatch,
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.