2 * Xen Event Channels (internal header)
4 * Copyright (C) 2013 Citrix Systems R&D Ltd.
6 * This source code is licensed under the GNU General Public License,
7 * Version 2 or later. See the file COPYING for more details.
9 #ifndef __EVENTS_INTERNAL_H__
10 #define __EVENTS_INTERNAL_H__
12 /* Interrupt types. */
22 * Packed IRQ information:
23 * type - enum xen_irq_type
24 * event channel - irq->event channel mapping
25 * cpu - cpu this event channel is bound to
26 * index - type-specific information:
27 * PIRQ - vector, with MSB being "needs EIO", or physical IRQ of the HVM
28 * guest, or GSI (real passthrough IRQ) of the device.
34 struct list_head list
;
36 enum xen_irq_type type
; /* type */
38 unsigned int evtchn
; /* event channel */
39 unsigned short cpu
; /* cpu bound */
54 #define PIRQ_NEEDS_EOI (1 << 0)
55 #define PIRQ_SHAREABLE (1 << 1)
56 #define PIRQ_MSI_GROUP (1 << 2)
59 unsigned (*max_channels
)(void);
60 unsigned (*nr_channels
)(void);
62 int (*setup
)(struct irq_info
*info
);
63 void (*bind_to_cpu
)(struct irq_info
*info
, unsigned cpu
);
65 void (*clear_pending
)(unsigned port
);
66 void (*set_pending
)(unsigned port
);
67 bool (*is_pending
)(unsigned port
);
68 bool (*test_and_set_mask
)(unsigned port
);
69 void (*mask
)(unsigned port
);
70 void (*unmask
)(unsigned port
);
71 void (*close
)(unsigned port
, unsigned cpu
);
73 void (*handle_events
)(unsigned cpu
);
77 extern const struct evtchn_ops
*evtchn_ops
;
79 extern int **evtchn_to_irq
;
80 int get_evtchn_to_irq(unsigned int evtchn
);
82 struct irq_info
*info_for_irq(unsigned irq
);
83 unsigned cpu_from_irq(unsigned irq
);
84 unsigned cpu_from_evtchn(unsigned int evtchn
);
86 static inline unsigned xen_evtchn_max_channels(void)
88 return evtchn_ops
->max_channels();
92 * Do any ABI specific setup for a bound event channel before it can
93 * be unmasked and used.
95 static inline int xen_evtchn_port_setup(struct irq_info
*info
)
97 if (evtchn_ops
->setup
)
98 return evtchn_ops
->setup(info
);
102 static inline void xen_evtchn_port_bind_to_cpu(struct irq_info
*info
,
105 evtchn_ops
->bind_to_cpu(info
, cpu
);
108 static inline void clear_evtchn(unsigned port
)
110 evtchn_ops
->clear_pending(port
);
113 static inline void set_evtchn(unsigned port
)
115 evtchn_ops
->set_pending(port
);
118 static inline bool test_evtchn(unsigned port
)
120 return evtchn_ops
->is_pending(port
);
123 static inline bool test_and_set_mask(unsigned port
)
125 return evtchn_ops
->test_and_set_mask(port
);
128 static inline void mask_evtchn(unsigned port
)
130 return evtchn_ops
->mask(port
);
133 static inline void unmask_evtchn(unsigned port
)
135 return evtchn_ops
->unmask(port
);
138 static inline void xen_evtchn_handle_events(unsigned cpu
)
140 return evtchn_ops
->handle_events(cpu
);
143 static inline void xen_evtchn_resume(void)
145 if (evtchn_ops
->resume
)
146 evtchn_ops
->resume();
149 static inline void xen_evtchn_op_close(unsigned port
, unsigned cpu
)
151 if (evtchn_ops
->close
)
152 return evtchn_ops
->close(port
, cpu
);
155 void xen_evtchn_2l_init(void);
156 int xen_evtchn_fifo_init(void);
158 #endif /* #ifndef __EVENTS_INTERNAL_H__ */