All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: EDK2 devel <edk2-devel@lists.sourceforge.net>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
	Xen Devel <xen-devel@lists.xen.org>
Subject: [PATCH v3 10/19] OvmfPkg/XenBusDxe: Add Event Channel Notify.
Date: Fri, 17 Oct 2014 18:03:53 +0100	[thread overview]
Message-ID: <1413565442-29149-11-git-send-email-anthony.perard__45723.4844718643$1413566341$gmane$org@citrix.com> (raw)
In-Reply-To: <1413565442-29149-1-git-send-email-anthony.perard@citrix.com>

This first function is used to notify the other side that there is
something to do. The other side is another Xen domain.

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>

---
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
---
 .../Include/IndustryStandard/Xen/event_channel.h   | 118 +++++++++++++++++++++
 OvmfPkg/XenBusDxe/EventChannel.c                   |  49 +++++++++
 OvmfPkg/XenBusDxe/EventChannel.h                   |  52 +++++++++
 OvmfPkg/XenBusDxe/XenBusDxe.inf                    |   2 +
 4 files changed, 221 insertions(+)
 create mode 100644 OvmfPkg/Include/IndustryStandard/Xen/event_channel.h
 create mode 100644 OvmfPkg/XenBusDxe/EventChannel.c
 create mode 100644 OvmfPkg/XenBusDxe/EventChannel.h

diff --git a/OvmfPkg/Include/IndustryStandard/Xen/event_channel.h b/OvmfPkg/Include/IndustryStandard/Xen/event_channel.h
new file mode 100644
index 0000000..a09ed8d
--- /dev/null
+++ b/OvmfPkg/Include/IndustryStandard/Xen/event_channel.h
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * event_channel.h
+ *
+ * Event channels between domains.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright (c) 2003-2004, K A Fraser.
+ */
+
+#ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__
+#define __XEN_PUBLIC_EVENT_CHANNEL_H__
+
+#include "xen.h"
+
+/*
+ * `incontents 150 evtchn Event Channels
+ *
+ * Event channels are the basic primitive provided by Xen for event
+ * notifications. An event is the Xen equivalent of a hardware
+ * interrupt. They essentially store one bit of information, the event
+ * of interest is signalled by transitioning this bit from 0 to 1.
+ *
+ * Notifications are received by a guest via an upcall from Xen,
+ * indicating when an event arrives (setting the bit). Further
+ * notifications are masked until the bit is cleared again (therefore,
+ * guests must check the value of the bit after re-enabling event
+ * delivery to ensure no missed notifications).
+ *
+ * Event notifications can be masked by setting a flag; this is
+ * equivalent to disabling interrupts and can be used to ensure
+ * atomicity of certain operations in the guest kernel.
+ *
+ * Event channels are represented by the evtchn_* fields in
+ * struct shared_info and struct vcpu_info.
+ */
+
+/*
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_event_channel_op(enum event_channel_op cmd, VOID *args)
+ * `
+ * @cmd  == EVTCHNOP_* (event-channel operation).
+ * @args == struct evtchn_* Operation-specific extra arguments (NULL if none).
+ */
+
+/* ` enum event_channel_op { // EVTCHNOP_* => struct evtchn_* */
+#define EVTCHNOP_close            3
+#define EVTCHNOP_send             4
+#define EVTCHNOP_alloc_unbound    6
+/* ` } */
+
+typedef UINT32 evtchn_port_t;
+DEFINE_XEN_GUEST_HANDLE(evtchn_port_t);
+
+/*
+ * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as
+ * accepting interdomain bindings from domain <remote_dom>. A fresh port
+ * is allocated in <dom> and returned as <port>.
+ * NOTES:
+ *  1. If the caller is unprivileged then <dom> must be DOMID_SELF.
+ *  2. <rdom> may be DOMID_SELF, allowing loopback connections.
+ */
+struct evtchn_alloc_unbound {
+    /* IN parameters */
+    domid_t dom, remote_dom;
+    /* OUT parameters */
+    evtchn_port_t port;
+};
+typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t;
+
+/*
+ * EVTCHNOP_close: Close a local event channel <port>. If the channel is
+ * interdomain then the remote end is placed in the unbound state
+ * (EVTCHNSTAT_unbound), awaiting a new connection.
+ */
+struct evtchn_close {
+    /* IN parameters. */
+    evtchn_port_t port;
+};
+typedef struct evtchn_close evtchn_close_t;
+
+/*
+ * EVTCHNOP_send: Send an event to the remote end of the channel whose local
+ * endpoint is <port>.
+ */
+struct evtchn_send {
+    /* IN parameters. */
+    evtchn_port_t port;
+};
+typedef struct evtchn_send evtchn_send_t;
+
+#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/OvmfPkg/XenBusDxe/EventChannel.c b/OvmfPkg/XenBusDxe/EventChannel.c
new file mode 100644
index 0000000..53d43db
--- /dev/null
+++ b/OvmfPkg/XenBusDxe/EventChannel.c
@@ -0,0 +1,49 @@
+/** @file
+  Event Channel function implementation.
+
+  Event channel are use to notify of an event that happend in a shared
+  structure for example.
+
+  Copyright (C) 2014, Citrix Ltd.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  * Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+  * Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+  POSSIBILITY OF SUCH DAMAGE.
+
+**/
+#include "EventChannel.h"
+#include "XenHypercall.h"
+
+UINT32
+XenEventChannelNotify (
+  IN XENBUS_DEVICE *Dev,
+  IN evtchn_port_t Port
+  )
+{
+  INTN ReturnCode;
+  evtchn_send_t Send;
+
+  Send.port = Port;
+  ReturnCode = XenHypercallEventChannelOp (Dev, EVTCHNOP_send, &Send);
+  return ReturnCode;
+}
diff --git a/OvmfPkg/XenBusDxe/EventChannel.h b/OvmfPkg/XenBusDxe/EventChannel.h
new file mode 100644
index 0000000..5cbe43b
--- /dev/null
+++ b/OvmfPkg/XenBusDxe/EventChannel.h
@@ -0,0 +1,52 @@
+/** @file
+  Event Channel function declaration.
+
+  Copyright (C) 2014, Citrix Ltd.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  * Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+  * Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+  POSSIBILITY OF SUCH DAMAGE.
+
+**/
+#ifndef __XENBUS_EVENT_CHANNEL_H
+#define __XENBUS_EVENT_CHANNEL_H
+
+#include "XenBusDxe.h"
+
+#include <IndustryStandard/Xen/event_channel.h>
+
+/**
+  Send an event to the remote end of the channel whose local endpoint is Port.
+
+  @param Dev    A pointer to XENBUS_DEVICE.
+  @param Port   The port to notify.
+
+  @return       Return 0 on success, or return the errno code from the hypercall.
+**/
+UINT32
+XenEventChannelNotify (
+  IN XENBUS_DEVICE *Dev,
+  IN evtchn_port_t Port
+  );
+
+#endif
diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.inf b/OvmfPkg/XenBusDxe/XenBusDxe.inf
index b3421c2..bfa083e 100644
--- a/OvmfPkg/XenBusDxe/XenBusDxe.inf
+++ b/OvmfPkg/XenBusDxe/XenBusDxe.inf
@@ -37,6 +37,8 @@
   InterlockedCompareExchange16.h
   GrantTable.c
   GrantTable.h
+  EventChannel.c
+  EventChannel.h
 
 [Sources.IA32]
   Ia32/hypercall.S
-- 
Anthony PERARD

  parent reply	other threads:[~2014-10-17 17:03 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1413565442-29149-1-git-send-email-anthony.perard@citrix.com>
2014-10-17 17:03 ` [PATCH v3 01/19] OvmfPkg: Add the MIT license to License.txt Anthony PERARD
2014-10-17 17:03 ` [PATCH v3 02/19] OvmfPkg: Add public headers from Xen Project Anthony PERARD
2014-10-17 17:03 ` [PATCH v3 03/19] OvmfPkg: Add basic skeleton for the XenBus bus driver Anthony PERARD
2014-10-17 17:03 ` [PATCH v3 04/19] OvmfPkg/XenBusDxe: Add device state struct and create an ExitBoot services event Anthony PERARD
2014-10-17 17:03 ` [PATCH v3 05/19] OvmfPkg/XenBusDxe: Add support to make Xen Hypercalls Anthony PERARD
2014-10-17 17:03 ` [PATCH v3 06/19] OvmfPkg/XenBusDxe: Open PciIo protocol Anthony PERARD
2014-10-17 17:03 ` [PATCH v3 07/19] OvmfPkg: Introduce XenBus Protocol Anthony PERARD
2014-10-17 17:03 ` [PATCH v3 08/19] OvmfPkg/XenBusDxe: Add InterlockedCompareExchange16 Anthony PERARD
2014-10-17 17:03 ` [PATCH v3 09/19] OvmfPkg/XenBusDxe: Add Grant Table functions Anthony PERARD
2014-10-17 17:03 ` Anthony PERARD [this message]
2014-10-17 17:03 ` [PATCH v3 11/19] OvmfPkg/XenBusDxe: Add TestAndClearBit Anthony PERARD
2014-10-17 17:03 ` [PATCH v3 12/19] OvmfPkg/XenBusDxe: Add XenStore client implementation Anthony PERARD
2014-10-17 17:03 ` [PATCH v3 13/19] OvmfPkg/XenBusDxe: Add an helper AsciiStrDup Anthony PERARD
2014-10-17 17:03 ` [PATCH v3 14/19] OvmfPkg/XenBusDxe: Add XenStore function into the XenBus protocol Anthony PERARD
2014-10-17 17:03 ` [PATCH v3 15/19] OvmfPkg/XenBusDxe: Indroduce XenBus support itself Anthony PERARD
2014-10-17 17:03 ` [PATCH v3 16/19] OvmfPkg/XenBusDxe: Add Event Channel into XenBus protocol Anthony PERARD
2014-10-17 17:04 ` [PATCH v3 17/19] OvmfPkg/XenPvBlkDxe: Xen PV Block device, initial skeleton Anthony PERARD
2014-10-17 17:04 ` [PATCH v3 18/19] OvmfPkg/XenPvBlkDxe: Add BlockFront client Anthony PERARD
2014-10-17 17:04 ` [PATCH v3 19/19] OvmfPkg/XenPvBlkDxe: Add BlockIo Anthony PERARD
     [not found] ` <1413565442-29149-4-git-send-email-anthony.perard@citrix.com>
2014-10-19 23:27   ` [edk2] [PATCH v3 03/19] OvmfPkg: Add basic skeleton for the XenBus bus driver Jordan Justen
     [not found]   ` <20141019232711.22698.47223@jljusten-ivy>
2014-10-20 13:29     ` Anthony PERARD
     [not found] ` <1413565442-29149-3-git-send-email-anthony.perard@citrix.com>
2014-10-19 23:47   ` [edk2] [PATCH v3 02/19] OvmfPkg: Add public headers from Xen Project Jordan Justen
     [not found]   ` <20141019234732.22698.78740@jljusten-ivy>
2014-10-20  1:14     ` Andrew Fish
2014-10-20  1:14     ` Andrew Fish
2014-10-20 13:24     ` Anthony PERARD
     [not found] ` <1413565442-29149-9-git-send-email-anthony.perard@citrix.com>
2014-10-20  0:00   ` [edk2] [PATCH v3 08/19] OvmfPkg/XenBusDxe: Add InterlockedCompareExchange16 Jordan Justen
     [not found]   ` <20141020000013.22698.55324@jljusten-ivy>
2014-10-20 13:37     ` Anthony PERARD
     [not found] ` <1413565442-29149-16-git-send-email-anthony.perard@citrix.com>
2014-10-20  0:20   ` [edk2] [PATCH v3 15/19] OvmfPkg/XenBusDxe: Indroduce XenBus support itself Jordan Justen
     [not found]   ` <20141020002045.22698.90635@jljusten-ivy>
2014-10-20 13:41     ` Anthony PERARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='1413565442-29149-11-git-send-email-anthony.perard__45723.4844718643$1413566341$gmane$org@citrix.com' \
    --to=anthony.perard@citrix.com \
    --cc=edk2-devel@lists.sourceforge.net \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.