]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/XenBusDxe: Add Event Channel Notify.
authorAnthony PERARD <anthony.perard@citrix.com>
Wed, 29 Oct 2014 06:50:24 +0000 (06:50 +0000)
committerjljusten <jljusten@Edk2>
Wed, 29 Oct 2014 06:50:24 +0000 (06:50 +0000)
This first function is used to notify the other side that there is
something to do. The other side is another Xen domain.

Change in V4:
- Replace the license by the commonly used file header text.

Change in V3:
- Return error code from hypercall instead of ASSERT for
  XenEventChannelNotify
- moving event_channel.h to this patch.

Change in V2:
- file header
- coding style
- adding comment to functions
- Licenses

License: This patch adds event_channel.h which is under MIT licence.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16265 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/Include/IndustryStandard/Xen/event_channel.h [new file with mode: 0644]
OvmfPkg/XenBusDxe/EventChannel.c [new file with mode: 0644]
OvmfPkg/XenBusDxe/EventChannel.h [new file with mode: 0644]
OvmfPkg/XenBusDxe/XenBusDxe.inf

diff --git a/OvmfPkg/Include/IndustryStandard/Xen/event_channel.h b/OvmfPkg/Include/IndustryStandard/Xen/event_channel.h
new file mode 100644 (file)
index 0000000..6377ce7
--- /dev/null
@@ -0,0 +1,118 @@
+/******************************************************************************\r
+ * event_channel.h\r
+ *\r
+ * Event channels between domains.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy\r
+ * of this software and associated documentation files (the "Software"), to\r
+ * deal in the Software without restriction, including without limitation the\r
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\r
+ * sell copies of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\r
+ * DEALINGS IN THE SOFTWARE.\r
+ *\r
+ * Copyright (c) 2003-2004, K A Fraser.\r
+ */\r
+\r
+#ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__\r
+#define __XEN_PUBLIC_EVENT_CHANNEL_H__\r
+\r
+#include "xen.h"\r
+\r
+/*\r
+ * `incontents 150 evtchn Event Channels\r
+ *\r
+ * Event channels are the basic primitive provided by Xen for event\r
+ * notifications. An event is the Xen equivalent of a hardware\r
+ * interrupt. They essentially store one bit of information, the event\r
+ * of interest is signalled by transitioning this bit from 0 to 1.\r
+ *\r
+ * Notifications are received by a guest via an upcall from Xen,\r
+ * indicating when an event arrives (setting the bit). Further\r
+ * notifications are masked until the bit is cleared again (therefore,\r
+ * guests must check the value of the bit after re-enabling event\r
+ * delivery to ensure no missed notifications).\r
+ *\r
+ * Event notifications can be masked by setting a flag; this is\r
+ * equivalent to disabling interrupts and can be used to ensure\r
+ * atomicity of certain operations in the guest kernel.\r
+ *\r
+ * Event channels are represented by the evtchn_* fields in\r
+ * struct shared_info and struct vcpu_info.\r
+ */\r
+\r
+/*\r
+ * ` enum neg_errnoval\r
+ * ` HYPERVISOR_event_channel_op(enum event_channel_op cmd, VOID *args)\r
+ * `\r
+ * @cmd  == EVTCHNOP_* (event-channel operation).\r
+ * @args == struct evtchn_* Operation-specific extra arguments (NULL if none).\r
+ */\r
+\r
+/* ` enum event_channel_op { // EVTCHNOP_* => struct evtchn_* */\r
+#define EVTCHNOP_close            3\r
+#define EVTCHNOP_send             4\r
+#define EVTCHNOP_alloc_unbound    6\r
+/* ` } */\r
+\r
+typedef UINT32 evtchn_port_t;\r
+DEFINE_XEN_GUEST_HANDLE(evtchn_port_t);\r
+\r
+/*\r
+ * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as\r
+ * accepting interdomain bindings from domain <remote_dom>. A fresh port\r
+ * is allocated in <dom> and returned as <port>.\r
+ * NOTES:\r
+ *  1. If the caller is unprivileged then <dom> must be DOMID_SELF.\r
+ *  2. <rdom> may be DOMID_SELF, allowing loopback connections.\r
+ */\r
+struct evtchn_alloc_unbound {\r
+    /* IN parameters */\r
+    domid_t dom, remote_dom;\r
+    /* OUT parameters */\r
+    evtchn_port_t port;\r
+};\r
+typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t;\r
+\r
+/*\r
+ * EVTCHNOP_close: Close a local event channel <port>. If the channel is\r
+ * interdomain then the remote end is placed in the unbound state\r
+ * (EVTCHNSTAT_unbound), awaiting a new connection.\r
+ */\r
+struct evtchn_close {\r
+    /* IN parameters. */\r
+    evtchn_port_t port;\r
+};\r
+typedef struct evtchn_close evtchn_close_t;\r
+\r
+/*\r
+ * EVTCHNOP_send: Send an event to the remote end of the channel whose local\r
+ * endpoint is <port>.\r
+ */\r
+struct evtchn_send {\r
+    /* IN parameters. */\r
+    evtchn_port_t port;\r
+};\r
+typedef struct evtchn_send evtchn_send_t;\r
+\r
+#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */\r
+\r
+/*\r
+ * Local variables:\r
+ * mode: C\r
+ * c-file-style: "BSD"\r
+ * c-basic-offset: 4\r
+ * tab-width: 4\r
+ * indent-tabs-mode: nil\r
+ * End:\r
+ */\r
diff --git a/OvmfPkg/XenBusDxe/EventChannel.c b/OvmfPkg/XenBusDxe/EventChannel.c
new file mode 100644 (file)
index 0000000..c4076c4
--- /dev/null
@@ -0,0 +1,33 @@
+/** @file\r
+  Event Channel function implementation.\r
+\r
+  Event channel are use to notify of an event that happend in a shared\r
+  structure for example.\r
+\r
+  Copyright (C) 2014, Citrix Ltd.\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#include "EventChannel.h"\r
+#include "XenHypercall.h"\r
+\r
+UINT32\r
+XenEventChannelNotify (\r
+  IN XENBUS_DEVICE *Dev,\r
+  IN evtchn_port_t Port\r
+  )\r
+{\r
+  INTN ReturnCode;\r
+  evtchn_send_t Send;\r
+\r
+  Send.port = Port;\r
+  ReturnCode = XenHypercallEventChannelOp (Dev, EVTCHNOP_send, &Send);\r
+  return ReturnCode;\r
+}\r
diff --git a/OvmfPkg/XenBusDxe/EventChannel.h b/OvmfPkg/XenBusDxe/EventChannel.h
new file mode 100644 (file)
index 0000000..5f3171d
--- /dev/null
@@ -0,0 +1,36 @@
+/** @file\r
+  Event Channel function declaration.\r
+\r
+  Copyright (C) 2014, Citrix Ltd.\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#ifndef __XENBUS_EVENT_CHANNEL_H\r
+#define __XENBUS_EVENT_CHANNEL_H\r
+\r
+#include "XenBusDxe.h"\r
+\r
+#include <IndustryStandard/Xen/event_channel.h>\r
+\r
+/**\r
+  Send an event to the remote end of the channel whose local endpoint is Port.\r
+\r
+  @param Dev    A pointer to XENBUS_DEVICE.\r
+  @param Port   The port to notify.\r
+\r
+  @return       Return 0 on success, or return the errno code from the hypercall.\r
+**/\r
+UINT32\r
+XenEventChannelNotify (\r
+  IN XENBUS_DEVICE *Dev,\r
+  IN evtchn_port_t Port\r
+  );\r
+\r
+#endif\r
index 080e55a9bbfa14d622d6fb857140ed9628e6999d..0af1946e2658108fd7c370c4da838eaa283df23b 100644 (file)
@@ -40,6 +40,8 @@
   InterlockedCompareExchange16.h\r
   GrantTable.c\r
   GrantTable.h\r
+  EventChannel.c\r
+  EventChannel.h\r
 \r
 [Sources.IA32]\r
   Ia32/hypercall.S\r