1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Xen Event Channels (internal header)
5 * Copyright (C) 2013 Citrix Systems R&D Ltd.
7 #ifndef __EVENTS_INTERNAL_H__
8 #define __EVENTS_INTERNAL_H__
10 struct evtchn_loop_ctrl
;
13 unsigned (*max_channels
)(void);
14 unsigned (*nr_channels
)(void);
16 int (*setup
)(evtchn_port_t port
);
17 void (*bind_to_cpu
)(evtchn_port_t evtchn
, unsigned int cpu
,
18 unsigned int old_cpu
);
20 void (*clear_pending
)(evtchn_port_t port
);
21 void (*set_pending
)(evtchn_port_t port
);
22 bool (*is_pending
)(evtchn_port_t port
);
23 bool (*test_and_set_mask
)(evtchn_port_t port
);
24 void (*mask
)(evtchn_port_t port
);
25 void (*unmask
)(evtchn_port_t port
);
27 void (*handle_events
)(unsigned cpu
, struct evtchn_loop_ctrl
*ctrl
);
30 int (*percpu_init
)(unsigned int cpu
);
31 int (*percpu_deinit
)(unsigned int cpu
);
34 extern const struct evtchn_ops
*evtchn_ops
;
36 int get_evtchn_to_irq(evtchn_port_t evtchn
);
37 void handle_irq_for_port(evtchn_port_t port
, struct evtchn_loop_ctrl
*ctrl
);
39 unsigned int cpu_from_evtchn(evtchn_port_t evtchn
);
41 static inline unsigned xen_evtchn_max_channels(void)
43 return evtchn_ops
->max_channels();
47 * Do any ABI specific setup for a bound event channel before it can
48 * be unmasked and used.
50 static inline int xen_evtchn_port_setup(evtchn_port_t evtchn
)
52 if (evtchn_ops
->setup
)
53 return evtchn_ops
->setup(evtchn
);
57 static inline void xen_evtchn_port_bind_to_cpu(evtchn_port_t evtchn
,
61 evtchn_ops
->bind_to_cpu(evtchn
, cpu
, old_cpu
);
64 static inline void clear_evtchn(evtchn_port_t port
)
66 evtchn_ops
->clear_pending(port
);
69 static inline void set_evtchn(evtchn_port_t port
)
71 evtchn_ops
->set_pending(port
);
74 static inline bool test_evtchn(evtchn_port_t port
)
76 return evtchn_ops
->is_pending(port
);
79 static inline bool test_and_set_mask(evtchn_port_t port
)
81 return evtchn_ops
->test_and_set_mask(port
);
84 static inline void mask_evtchn(evtchn_port_t port
)
86 return evtchn_ops
->mask(port
);
89 static inline void unmask_evtchn(evtchn_port_t port
)
91 return evtchn_ops
->unmask(port
);
94 static inline void xen_evtchn_handle_events(unsigned cpu
,
95 struct evtchn_loop_ctrl
*ctrl
)
97 return evtchn_ops
->handle_events(cpu
, ctrl
);
100 static inline void xen_evtchn_resume(void)
102 if (evtchn_ops
->resume
)
103 evtchn_ops
->resume();
106 void xen_evtchn_2l_init(void);
107 int xen_evtchn_fifo_init(void);
109 #endif /* #ifndef __EVENTS_INTERNAL_H__ */