1 /** @file 2 Event Channel function implementation. 3 4 Event channel are use to notify of an event that happend in a shared 5 structure for example. 6 7 Copyright (C) 2014, Citrix Ltd. 8 9 This program and the accompanying materials 10 are licensed and made available under the terms and conditions of the BSD License 11 which accompanies this distribution. The full text of the license may be found at 12 http://opensource.org/licenses/bsd-license.php 13 14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 16 17 **/ 18 #include "EventChannel.h" 19 20 #include <Library/XenHypercallLib.h> 21 22 UINT32 23 XenEventChannelNotify ( 24 IN XENBUS_DEVICE *Dev, 25 IN evtchn_port_t Port 26 ) 27 { 28 INTN ReturnCode; 29 evtchn_send_t Send; 30 31 Send.port = Port; 32 ReturnCode = XenHypercallEventChannelOp (EVTCHNOP_send, &Send); 33 return (UINT32)ReturnCode; 34 } 35 36 UINT32 37 EFIAPI 38 XenBusEventChannelAllocate ( 39 IN XENBUS_PROTOCOL *This, 40 IN domid_t DomainId, 41 OUT evtchn_port_t *Port 42 ) 43 { 44 evtchn_alloc_unbound_t Parameter; 45 UINT32 ReturnCode; 46 47 Parameter.dom = DOMID_SELF; 48 Parameter.remote_dom = DomainId; 49 ReturnCode = (UINT32)XenHypercallEventChannelOp ( 50 EVTCHNOP_alloc_unbound, 51 &Parameter); 52 if (ReturnCode != 0) { 53 DEBUG ((EFI_D_ERROR, "ERROR: alloc_unbound failed with rc=%d", ReturnCode)); 54 return ReturnCode; 55 } 56 *Port = Parameter.port; 57 return ReturnCode; 58 } 59 60 UINT32 61 EFIAPI 62 XenBusEventChannelNotify ( 63 IN XENBUS_PROTOCOL *This, 64 IN evtchn_port_t Port 65 ) 66 { 67 XENBUS_PRIVATE_DATA *Private; 68 69 Private = XENBUS_PRIVATE_DATA_FROM_THIS(This); 70 return XenEventChannelNotify (Private->Dev, Port); 71 } 72 73 UINT32 74 EFIAPI 75 XenBusEventChannelClose ( 76 IN XENBUS_PROTOCOL *This, 77 IN evtchn_port_t Port 78 ) 79 { 80 evtchn_close_t Close; 81 82 Close.port = Port; 83 return (UINT32)XenHypercallEventChannelOp (EVTCHNOP_close, &Close); 84 } 85