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 /* Interrupt types. */
20 * Packed IRQ information:
21 * type - enum xen_irq_type
22 * event channel - irq->event channel mapping
23 * cpu - cpu this event channel is bound to
24 * index - type-specific information:
25 * PIRQ - vector, with MSB being "needs EIO", or physical IRQ of the HVM
26 * guest, or GSI (real passthrough IRQ) of the device.
32 struct list_head list
;
34 enum xen_irq_type type
; /* type */
36 unsigned int evtchn
; /* event channel */
37 unsigned short cpu
; /* cpu bound */
52 #define PIRQ_NEEDS_EOI (1 << 0)
53 #define PIRQ_SHAREABLE (1 << 1)
54 #define PIRQ_MSI_GROUP (1 << 2)
57 unsigned (*max_channels
)(void);
58 unsigned (*nr_channels
)(void);
60 int (*setup
)(struct irq_info
*info
);
61 void (*bind_to_cpu
)(struct irq_info
*info
, unsigned cpu
);
63 void (*clear_pending
)(unsigned port
);
64 void (*set_pending
)(unsigned port
);
65 bool (*is_pending
)(unsigned port
);
66 bool (*test_and_set_mask
)(unsigned port
);
67 void (*mask
)(unsigned port
);
68 void (*unmask
)(unsigned port
);
70 void (*handle_events
)(unsigned cpu
);
74 extern const struct evtchn_ops
*evtchn_ops
;
76 extern int **evtchn_to_irq
;
77 int get_evtchn_to_irq(unsigned int evtchn
);
79 struct irq_info
*info_for_irq(unsigned irq
);
80 unsigned cpu_from_irq(unsigned irq
);
81 unsigned cpu_from_evtchn(unsigned int evtchn
);
83 static inline unsigned xen_evtchn_max_channels(void)
85 return evtchn_ops
->max_channels();
89 * Do any ABI specific setup for a bound event channel before it can
90 * be unmasked and used.
92 static inline int xen_evtchn_port_setup(struct irq_info
*info
)
94 if (evtchn_ops
->setup
)
95 return evtchn_ops
->setup(info
);
99 static inline void xen_evtchn_port_bind_to_cpu(struct irq_info
*info
,
102 evtchn_ops
->bind_to_cpu(info
, cpu
);
105 static inline void clear_evtchn(unsigned port
)
107 evtchn_ops
->clear_pending(port
);
110 static inline void set_evtchn(unsigned port
)
112 evtchn_ops
->set_pending(port
);
115 static inline bool test_evtchn(unsigned port
)
117 return evtchn_ops
->is_pending(port
);
120 static inline bool test_and_set_mask(unsigned port
)
122 return evtchn_ops
->test_and_set_mask(port
);
125 static inline void mask_evtchn(unsigned port
)
127 return evtchn_ops
->mask(port
);
130 static inline void unmask_evtchn(unsigned port
)
132 return evtchn_ops
->unmask(port
);
135 static inline void xen_evtchn_handle_events(unsigned cpu
)
137 return evtchn_ops
->handle_events(cpu
);
140 static inline void xen_evtchn_resume(void)
142 if (evtchn_ops
->resume
)
143 evtchn_ops
->resume();
146 void xen_evtchn_2l_init(void);
147 int xen_evtchn_fifo_init(void);
149 #endif /* #ifndef __EVENTS_INTERNAL_H__ */