1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
2 | /* |
3 | * Xen Event Channels (internal header) |
4 | * |
5 | * Copyright (C) 2013 Citrix Systems R&D Ltd. |
6 | */ |
7 | #ifndef __EVENTS_INTERNAL_H__ |
8 | #define __EVENTS_INTERNAL_H__ |
9 | |
10 | struct evtchn_loop_ctrl; |
11 | |
12 | struct evtchn_ops { |
13 | unsigned (*max_channels)(void); |
14 | unsigned (*nr_channels)(void); |
15 | |
16 | int (*setup)(evtchn_port_t port); |
17 | void (*remove)(evtchn_port_t port, unsigned int cpu); |
18 | void (*bind_to_cpu)(evtchn_port_t evtchn, unsigned int cpu, |
19 | unsigned int old_cpu); |
20 | |
21 | void (*clear_pending)(evtchn_port_t port); |
22 | void (*set_pending)(evtchn_port_t port); |
23 | bool (*is_pending)(evtchn_port_t port); |
24 | void (*mask)(evtchn_port_t port); |
25 | void (*unmask)(evtchn_port_t port); |
26 | |
27 | void (*handle_events)(unsigned cpu, struct evtchn_loop_ctrl *ctrl); |
28 | void (*resume)(void); |
29 | |
30 | int (*percpu_init)(unsigned int cpu); |
31 | int (*percpu_deinit)(unsigned int cpu); |
32 | }; |
33 | |
34 | extern const struct evtchn_ops *evtchn_ops; |
35 | |
36 | void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl); |
37 | |
38 | unsigned int cpu_from_evtchn(evtchn_port_t evtchn); |
39 | |
40 | static inline unsigned xen_evtchn_max_channels(void) |
41 | { |
42 | return evtchn_ops->max_channels(); |
43 | } |
44 | |
45 | /* |
46 | * Do any ABI specific setup for a bound event channel before it can |
47 | * be unmasked and used. |
48 | */ |
49 | static inline int xen_evtchn_port_setup(evtchn_port_t evtchn) |
50 | { |
51 | if (evtchn_ops->setup) |
52 | return evtchn_ops->setup(evtchn); |
53 | return 0; |
54 | } |
55 | |
56 | static inline void xen_evtchn_port_remove(evtchn_port_t evtchn, |
57 | unsigned int cpu) |
58 | { |
59 | if (evtchn_ops->remove) |
60 | evtchn_ops->remove(evtchn, cpu); |
61 | } |
62 | |
63 | static inline void xen_evtchn_port_bind_to_cpu(evtchn_port_t evtchn, |
64 | unsigned int cpu, |
65 | unsigned int old_cpu) |
66 | { |
67 | evtchn_ops->bind_to_cpu(evtchn, cpu, old_cpu); |
68 | } |
69 | |
70 | static inline void clear_evtchn(evtchn_port_t port) |
71 | { |
72 | evtchn_ops->clear_pending(port); |
73 | } |
74 | |
75 | static inline void set_evtchn(evtchn_port_t port) |
76 | { |
77 | evtchn_ops->set_pending(port); |
78 | } |
79 | |
80 | static inline bool test_evtchn(evtchn_port_t port) |
81 | { |
82 | return evtchn_ops->is_pending(port); |
83 | } |
84 | |
85 | static inline void mask_evtchn(evtchn_port_t port) |
86 | { |
87 | return evtchn_ops->mask(port); |
88 | } |
89 | |
90 | static inline void unmask_evtchn(evtchn_port_t port) |
91 | { |
92 | return evtchn_ops->unmask(port); |
93 | } |
94 | |
95 | static inline void xen_evtchn_handle_events(unsigned cpu, |
96 | struct evtchn_loop_ctrl *ctrl) |
97 | { |
98 | return evtchn_ops->handle_events(cpu, ctrl); |
99 | } |
100 | |
101 | static inline void xen_evtchn_resume(void) |
102 | { |
103 | if (evtchn_ops->resume) |
104 | evtchn_ops->resume(); |
105 | } |
106 | |
107 | void xen_evtchn_2l_init(void); |
108 | int xen_evtchn_fifo_init(void); |
109 | |
110 | #endif /* #ifndef __EVENTS_INTERNAL_H__ */ |
111 | |