1 /* Event channel handling private header. */
2
3 #ifndef EVENT_CHANNEL_H
4 #define EVENT_CHANNEL_H
5
6 #include <xen/event.h>
7
max_evtchns(const struct domain * d)8 static inline unsigned int max_evtchns(const struct domain *d)
9 {
10 return d->evtchn_fifo ? EVTCHN_FIFO_NR_CHANNELS
11 : BITS_PER_EVTCHN_WORD(d) * BITS_PER_EVTCHN_WORD(d);
12 }
13
evtchn_is_busy(const struct domain * d,const struct evtchn * evtchn)14 static inline bool evtchn_is_busy(const struct domain *d,
15 const struct evtchn *evtchn)
16 {
17 return d->evtchn_port_ops->is_busy &&
18 d->evtchn_port_ops->is_busy(d, evtchn);
19 }
20
evtchn_port_unmask(struct domain * d,struct evtchn * evtchn)21 static inline void evtchn_port_unmask(struct domain *d,
22 struct evtchn *evtchn)
23 {
24 if ( evtchn_usable(evtchn) )
25 d->evtchn_port_ops->unmask(d, evtchn);
26 }
27
evtchn_port_set_priority(struct domain * d,struct evtchn * evtchn,unsigned int priority)28 static inline int evtchn_port_set_priority(struct domain *d,
29 struct evtchn *evtchn,
30 unsigned int priority)
31 {
32 if ( !d->evtchn_port_ops->set_priority )
33 return -ENOSYS;
34 if ( !evtchn_usable(evtchn) )
35 return -EACCES;
36 return d->evtchn_port_ops->set_priority(d, evtchn, priority);
37 }
38
evtchn_port_print_state(struct domain * d,const struct evtchn * evtchn)39 static inline void evtchn_port_print_state(struct domain *d,
40 const struct evtchn *evtchn)
41 {
42 d->evtchn_port_ops->print_state(d, evtchn);
43 }
44
45 /* 2-level */
46
47 void evtchn_2l_init(struct domain *d);
48
49 /* FIFO */
50
51 #ifdef CONFIG_EVTCHN_FIFO
52 struct evtchn_init_control;
53 struct evtchn_expand_array;
54
55 int evtchn_fifo_init_control(struct evtchn_init_control *init_control);
56 int evtchn_fifo_expand_array(const struct evtchn_expand_array *expand_array);
57 void evtchn_fifo_destroy(struct domain *d);
58 #else
evtchn_fifo_init_control(struct evtchn_init_control * init_control)59 static inline int evtchn_fifo_init_control(struct evtchn_init_control *init_control)
60 {
61 return -EOPNOTSUPP;
62 }
evtchn_fifo_expand_array(const struct evtchn_expand_array * expand_array)63 static inline int evtchn_fifo_expand_array(const struct evtchn_expand_array *expand_array)
64 {
65 return -EOPNOTSUPP;
66 }
evtchn_fifo_destroy(struct domain * d)67 static inline void evtchn_fifo_destroy(struct domain *d)
68 {
69 return;
70 }
71 #endif /* CONFIG_EVTCHN_FIFO */
72
73 #endif /* EVENT_CHANNEL_H */
74
75 /*
76 * Local variables:
77 * mode: C
78 * c-file-style: "BSD"
79 * c-basic-offset: 4
80 * tab-width: 4
81 * indent-tabs-mode: nil
82 * End:
83 */
84