1495e0022SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
29a489f45SDavid Vrabel /*
39a489f45SDavid Vrabel * Xen Event Channels (internal header)
49a489f45SDavid Vrabel *
59a489f45SDavid Vrabel * Copyright (C) 2013 Citrix Systems R&D Ltd.
69a489f45SDavid Vrabel */
79a489f45SDavid Vrabel #ifndef __EVENTS_INTERNAL_H__
89a489f45SDavid Vrabel #define __EVENTS_INTERNAL_H__
99a489f45SDavid Vrabel
10e99502f7SJuergen Gross struct evtchn_loop_ctrl;
11e99502f7SJuergen Gross
12ab9a1ccaSDavid Vrabel struct evtchn_ops {
13d0b075ffSDavid Vrabel unsigned (*max_channels)(void);
14d0b075ffSDavid Vrabel unsigned (*nr_channels)(void);
15d0b075ffSDavid Vrabel
167e14cde1SJuergen Gross int (*setup)(evtchn_port_t port);
17*9e77d96bSJuergen Gross void (*remove)(evtchn_port_t port, unsigned int cpu);
187e14cde1SJuergen Gross void (*bind_to_cpu)(evtchn_port_t evtchn, unsigned int cpu,
197e14cde1SJuergen Gross unsigned int old_cpu);
20ab9a1ccaSDavid Vrabel
210102e4efSYan Yankovskyi void (*clear_pending)(evtchn_port_t port);
220102e4efSYan Yankovskyi void (*set_pending)(evtchn_port_t port);
230102e4efSYan Yankovskyi bool (*is_pending)(evtchn_port_t port);
240102e4efSYan Yankovskyi void (*mask)(evtchn_port_t port);
250102e4efSYan Yankovskyi void (*unmask)(evtchn_port_t port);
26ab9a1ccaSDavid Vrabel
27e99502f7SJuergen Gross void (*handle_events)(unsigned cpu, struct evtchn_loop_ctrl *ctrl);
281fe56551SDavid Vrabel void (*resume)(void);
297beb290cSJuergen Gross
307beb290cSJuergen Gross int (*percpu_init)(unsigned int cpu);
317beb290cSJuergen Gross int (*percpu_deinit)(unsigned int cpu);
32ab9a1ccaSDavid Vrabel };
33ab9a1ccaSDavid Vrabel
34ab9a1ccaSDavid Vrabel extern const struct evtchn_ops *evtchn_ops;
35ab9a1ccaSDavid Vrabel
36e99502f7SJuergen Gross void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl);
379a489f45SDavid Vrabel
380102e4efSYan Yankovskyi unsigned int cpu_from_evtchn(evtchn_port_t evtchn);
399a489f45SDavid Vrabel
xen_evtchn_max_channels(void)40d0b075ffSDavid Vrabel static inline unsigned xen_evtchn_max_channels(void)
41d0b075ffSDavid Vrabel {
42d0b075ffSDavid Vrabel return evtchn_ops->max_channels();
43d0b075ffSDavid Vrabel }
44d0b075ffSDavid Vrabel
4508385875SDavid Vrabel /*
4608385875SDavid Vrabel * Do any ABI specific setup for a bound event channel before it can
4708385875SDavid Vrabel * be unmasked and used.
4808385875SDavid Vrabel */
xen_evtchn_port_setup(evtchn_port_t evtchn)497e14cde1SJuergen Gross static inline int xen_evtchn_port_setup(evtchn_port_t evtchn)
5008385875SDavid Vrabel {
5108385875SDavid Vrabel if (evtchn_ops->setup)
527e14cde1SJuergen Gross return evtchn_ops->setup(evtchn);
5308385875SDavid Vrabel return 0;
5408385875SDavid Vrabel }
5508385875SDavid Vrabel
xen_evtchn_port_remove(evtchn_port_t evtchn,unsigned int cpu)56*9e77d96bSJuergen Gross static inline void xen_evtchn_port_remove(evtchn_port_t evtchn,
57*9e77d96bSJuergen Gross unsigned int cpu)
58*9e77d96bSJuergen Gross {
59*9e77d96bSJuergen Gross if (evtchn_ops->remove)
60*9e77d96bSJuergen Gross evtchn_ops->remove(evtchn, cpu);
61*9e77d96bSJuergen Gross }
62*9e77d96bSJuergen Gross
xen_evtchn_port_bind_to_cpu(evtchn_port_t evtchn,unsigned int cpu,unsigned int old_cpu)637e14cde1SJuergen Gross static inline void xen_evtchn_port_bind_to_cpu(evtchn_port_t evtchn,
647e14cde1SJuergen Gross unsigned int cpu,
657e14cde1SJuergen Gross unsigned int old_cpu)
66ab9a1ccaSDavid Vrabel {
677e14cde1SJuergen Gross evtchn_ops->bind_to_cpu(evtchn, cpu, old_cpu);
68ab9a1ccaSDavid Vrabel }
699a489f45SDavid Vrabel
clear_evtchn(evtchn_port_t port)700102e4efSYan Yankovskyi static inline void clear_evtchn(evtchn_port_t port)
71ab9a1ccaSDavid Vrabel {
72ab9a1ccaSDavid Vrabel evtchn_ops->clear_pending(port);
73ab9a1ccaSDavid Vrabel }
749a489f45SDavid Vrabel
set_evtchn(evtchn_port_t port)750102e4efSYan Yankovskyi static inline void set_evtchn(evtchn_port_t port)
76ab9a1ccaSDavid Vrabel {
77ab9a1ccaSDavid Vrabel evtchn_ops->set_pending(port);
78ab9a1ccaSDavid Vrabel }
79ab9a1ccaSDavid Vrabel
test_evtchn(evtchn_port_t port)800102e4efSYan Yankovskyi static inline bool test_evtchn(evtchn_port_t port)
81ab9a1ccaSDavid Vrabel {
82ab9a1ccaSDavid Vrabel return evtchn_ops->is_pending(port);
83ab9a1ccaSDavid Vrabel }
84ab9a1ccaSDavid Vrabel
mask_evtchn(evtchn_port_t port)850102e4efSYan Yankovskyi static inline void mask_evtchn(evtchn_port_t port)
86ab9a1ccaSDavid Vrabel {
87ab9a1ccaSDavid Vrabel return evtchn_ops->mask(port);
88ab9a1ccaSDavid Vrabel }
89ab9a1ccaSDavid Vrabel
unmask_evtchn(evtchn_port_t port)900102e4efSYan Yankovskyi static inline void unmask_evtchn(evtchn_port_t port)
91ab9a1ccaSDavid Vrabel {
92ab9a1ccaSDavid Vrabel return evtchn_ops->unmask(port);
93ab9a1ccaSDavid Vrabel }
94ab9a1ccaSDavid Vrabel
xen_evtchn_handle_events(unsigned cpu,struct evtchn_loop_ctrl * ctrl)95e99502f7SJuergen Gross static inline void xen_evtchn_handle_events(unsigned cpu,
96e99502f7SJuergen Gross struct evtchn_loop_ctrl *ctrl)
97ab9a1ccaSDavid Vrabel {
98e99502f7SJuergen Gross return evtchn_ops->handle_events(cpu, ctrl);
99ab9a1ccaSDavid Vrabel }
100ab9a1ccaSDavid Vrabel
xen_evtchn_resume(void)1011fe56551SDavid Vrabel static inline void xen_evtchn_resume(void)
1021fe56551SDavid Vrabel {
1031fe56551SDavid Vrabel if (evtchn_ops->resume)
1041fe56551SDavid Vrabel evtchn_ops->resume();
1051fe56551SDavid Vrabel }
1061fe56551SDavid Vrabel
107ab9a1ccaSDavid Vrabel void xen_evtchn_2l_init(void);
1081fe56551SDavid Vrabel int xen_evtchn_fifo_init(void);
1099a489f45SDavid Vrabel
1109a489f45SDavid Vrabel #endif /* #ifndef __EVENTS_INTERNAL_H__ */
111