1 | /** @file
|
---|
2 | Event Channel function implementation.
|
---|
3 |
|
---|
4 | Event channel are use to notify of an event that happened in a shared
|
---|
5 | structure for example.
|
---|
6 |
|
---|
7 | Copyright (C) 2014, Citrix Ltd.
|
---|
8 |
|
---|
9 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
10 |
|
---|
11 | **/
|
---|
12 | #include "EventChannel.h"
|
---|
13 |
|
---|
14 | #include <Library/XenHypercallLib.h>
|
---|
15 |
|
---|
16 | UINT32
|
---|
17 | XenEventChannelNotify (
|
---|
18 | IN XENBUS_DEVICE *Dev,
|
---|
19 | IN evtchn_port_t Port
|
---|
20 | )
|
---|
21 | {
|
---|
22 | INTN ReturnCode;
|
---|
23 | evtchn_send_t Send;
|
---|
24 |
|
---|
25 | Send.port = Port;
|
---|
26 | ReturnCode = XenHypercallEventChannelOp (EVTCHNOP_send, &Send);
|
---|
27 | return (UINT32)ReturnCode;
|
---|
28 | }
|
---|
29 |
|
---|
30 | UINT32
|
---|
31 | EFIAPI
|
---|
32 | XenBusEventChannelAllocate (
|
---|
33 | IN XENBUS_PROTOCOL *This,
|
---|
34 | IN domid_t DomainId,
|
---|
35 | OUT evtchn_port_t *Port
|
---|
36 | )
|
---|
37 | {
|
---|
38 | evtchn_alloc_unbound_t Parameter;
|
---|
39 | UINT32 ReturnCode;
|
---|
40 |
|
---|
41 | Parameter.dom = DOMID_SELF;
|
---|
42 | Parameter.remote_dom = DomainId;
|
---|
43 | ReturnCode = (UINT32)XenHypercallEventChannelOp (
|
---|
44 | EVTCHNOP_alloc_unbound,
|
---|
45 | &Parameter
|
---|
46 | );
|
---|
47 | if (ReturnCode != 0) {
|
---|
48 | DEBUG ((DEBUG_ERROR, "ERROR: alloc_unbound failed with rc=%d", ReturnCode));
|
---|
49 | return ReturnCode;
|
---|
50 | }
|
---|
51 |
|
---|
52 | *Port = Parameter.port;
|
---|
53 | return ReturnCode;
|
---|
54 | }
|
---|
55 |
|
---|
56 | UINT32
|
---|
57 | EFIAPI
|
---|
58 | XenBusEventChannelNotify (
|
---|
59 | IN XENBUS_PROTOCOL *This,
|
---|
60 | IN evtchn_port_t Port
|
---|
61 | )
|
---|
62 | {
|
---|
63 | XENBUS_PRIVATE_DATA *Private;
|
---|
64 |
|
---|
65 | Private = XENBUS_PRIVATE_DATA_FROM_THIS (This);
|
---|
66 | return XenEventChannelNotify (Private->Dev, Port);
|
---|
67 | }
|
---|
68 |
|
---|
69 | UINT32
|
---|
70 | EFIAPI
|
---|
71 | XenBusEventChannelClose (
|
---|
72 | IN XENBUS_PROTOCOL *This,
|
---|
73 | IN evtchn_port_t Port
|
---|
74 | )
|
---|
75 | {
|
---|
76 | evtchn_close_t Close;
|
---|
77 |
|
---|
78 | Close.port = Port;
|
---|
79 | return (UINT32)XenHypercallEventChannelOp (EVTCHNOP_close, &Close);
|
---|
80 | }
|
---|