1 #ifndef _IPXE_XENEVENT_H
2 #define _IPXE_XENEVENT_H
3 
4 /** @file
5  *
6  * Xen events
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <ipxe/xen.h>
13 #include <xen/event_channel.h>
14 
15 /**
16  * Close event channel
17  *
18  * @v xen		Xen hypervisor
19  * @v close		Event descriptor
20  * @ret xenrc		Xen status code
21  */
22 static inline __attribute__ (( always_inline )) int
xenevent_close(struct xen_hypervisor * xen,struct evtchn_close * close)23 xenevent_close ( struct xen_hypervisor *xen, struct evtchn_close *close ) {
24 
25 	return xen_hypercall_2 ( xen, __HYPERVISOR_event_channel_op,
26 				 EVTCHNOP_close, virt_to_phys ( close ) );
27 }
28 
29 /**
30  * Send event
31  *
32  * @v xen		Xen hypervisor
33  * @v send		Event descriptor
34  * @ret xenrc		Xen status code
35  */
36 static inline __attribute__ (( always_inline )) int
xenevent_send(struct xen_hypervisor * xen,struct evtchn_send * send)37 xenevent_send ( struct xen_hypervisor *xen, struct evtchn_send *send ) {
38 
39 	return xen_hypercall_2 ( xen, __HYPERVISOR_event_channel_op,
40 				 EVTCHNOP_send, virt_to_phys ( send ) );
41 }
42 
43 /**
44  * Allocate an unbound event channel
45  *
46  * @v xen		Xen hypervisor
47  * @v alloc_unbound	Event descriptor
48  * @ret xenrc		Xen status code
49  */
50 static inline __attribute__ (( always_inline )) int
xenevent_alloc_unbound(struct xen_hypervisor * xen,struct evtchn_alloc_unbound * alloc_unbound)51 xenevent_alloc_unbound ( struct xen_hypervisor *xen,
52 			 struct evtchn_alloc_unbound *alloc_unbound ) {
53 
54 	return xen_hypercall_2 ( xen, __HYPERVISOR_event_channel_op,
55 				 EVTCHNOP_alloc_unbound,
56 				 virt_to_phys ( alloc_unbound ) );
57 }
58 
59 #endif /* _IPXE_XENEVENT_H */
60