2019-05-22 07:51:27 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2013-03-13 15:29:25 +00:00
|
|
|
/*
|
|
|
|
* Xen Event Channels (internal header)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Citrix Systems R&D Ltd.
|
|
|
|
*/
|
|
|
|
#ifndef __EVENTS_INTERNAL_H__
|
|
|
|
#define __EVENTS_INTERNAL_H__
|
|
|
|
|
2020-09-07 13:47:30 +00:00
|
|
|
struct evtchn_loop_ctrl;
|
|
|
|
|
2013-03-14 12:49:19 +00:00
|
|
|
struct evtchn_ops {
|
2013-10-17 14:23:15 +00:00
|
|
|
unsigned (*max_channels)(void);
|
|
|
|
unsigned (*nr_channels)(void);
|
|
|
|
|
2020-10-22 09:49:04 +00:00
|
|
|
int (*setup)(evtchn_port_t port);
|
|
|
|
void (*bind_to_cpu)(evtchn_port_t evtchn, unsigned int cpu,
|
|
|
|
unsigned int old_cpu);
|
2013-03-14 12:49:19 +00:00
|
|
|
|
2020-03-23 16:15:11 +00:00
|
|
|
void (*clear_pending)(evtchn_port_t port);
|
|
|
|
void (*set_pending)(evtchn_port_t port);
|
|
|
|
bool (*is_pending)(evtchn_port_t port);
|
|
|
|
bool (*test_and_set_mask)(evtchn_port_t port);
|
|
|
|
void (*mask)(evtchn_port_t port);
|
|
|
|
void (*unmask)(evtchn_port_t port);
|
2013-03-14 12:49:19 +00:00
|
|
|
|
2020-09-07 13:47:30 +00:00
|
|
|
void (*handle_events)(unsigned cpu, struct evtchn_loop_ctrl *ctrl);
|
2013-03-15 13:02:35 +00:00
|
|
|
void (*resume)(void);
|
2020-09-13 12:23:02 +00:00
|
|
|
|
|
|
|
int (*percpu_init)(unsigned int cpu);
|
|
|
|
int (*percpu_deinit)(unsigned int cpu);
|
2013-03-14 12:49:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct evtchn_ops *evtchn_ops;
|
|
|
|
|
2020-03-23 16:15:11 +00:00
|
|
|
int get_evtchn_to_irq(evtchn_port_t evtchn);
|
2020-09-07 13:47:30 +00:00
|
|
|
void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl);
|
2013-03-13 15:29:25 +00:00
|
|
|
|
2020-03-23 16:15:11 +00:00
|
|
|
unsigned int cpu_from_evtchn(evtchn_port_t evtchn);
|
2013-03-13 15:29:25 +00:00
|
|
|
|
2013-10-17 14:23:15 +00:00
|
|
|
static inline unsigned xen_evtchn_max_channels(void)
|
|
|
|
{
|
|
|
|
return evtchn_ops->max_channels();
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:54:57 +00:00
|
|
|
/*
|
|
|
|
* Do any ABI specific setup for a bound event channel before it can
|
|
|
|
* be unmasked and used.
|
|
|
|
*/
|
2020-10-22 09:49:04 +00:00
|
|
|
static inline int xen_evtchn_port_setup(evtchn_port_t evtchn)
|
2013-03-18 16:54:57 +00:00
|
|
|
{
|
|
|
|
if (evtchn_ops->setup)
|
2020-10-22 09:49:04 +00:00
|
|
|
return evtchn_ops->setup(evtchn);
|
2013-03-18 16:54:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-10-22 09:49:04 +00:00
|
|
|
static inline void xen_evtchn_port_bind_to_cpu(evtchn_port_t evtchn,
|
|
|
|
unsigned int cpu,
|
|
|
|
unsigned int old_cpu)
|
2013-03-14 12:49:19 +00:00
|
|
|
{
|
2020-10-22 09:49:04 +00:00
|
|
|
evtchn_ops->bind_to_cpu(evtchn, cpu, old_cpu);
|
2013-03-14 12:49:19 +00:00
|
|
|
}
|
|
|
|
|
2020-03-23 16:15:11 +00:00
|
|
|
static inline void clear_evtchn(evtchn_port_t port)
|
2013-03-14 12:49:19 +00:00
|
|
|
{
|
|
|
|
evtchn_ops->clear_pending(port);
|
|
|
|
}
|
|
|
|
|
2020-03-23 16:15:11 +00:00
|
|
|
static inline void set_evtchn(evtchn_port_t port)
|
2013-03-14 12:49:19 +00:00
|
|
|
{
|
|
|
|
evtchn_ops->set_pending(port);
|
|
|
|
}
|
|
|
|
|
2020-03-23 16:15:11 +00:00
|
|
|
static inline bool test_evtchn(evtchn_port_t port)
|
2013-03-14 12:49:19 +00:00
|
|
|
{
|
|
|
|
return evtchn_ops->is_pending(port);
|
|
|
|
}
|
|
|
|
|
2020-03-23 16:15:11 +00:00
|
|
|
static inline bool test_and_set_mask(evtchn_port_t port)
|
2013-03-14 12:49:19 +00:00
|
|
|
{
|
|
|
|
return evtchn_ops->test_and_set_mask(port);
|
|
|
|
}
|
|
|
|
|
2020-03-23 16:15:11 +00:00
|
|
|
static inline void mask_evtchn(evtchn_port_t port)
|
2013-03-14 12:49:19 +00:00
|
|
|
{
|
|
|
|
return evtchn_ops->mask(port);
|
|
|
|
}
|
|
|
|
|
2020-03-23 16:15:11 +00:00
|
|
|
static inline void unmask_evtchn(evtchn_port_t port)
|
2013-03-14 12:49:19 +00:00
|
|
|
{
|
|
|
|
return evtchn_ops->unmask(port);
|
|
|
|
}
|
2013-03-13 15:29:25 +00:00
|
|
|
|
2020-09-07 13:47:30 +00:00
|
|
|
static inline void xen_evtchn_handle_events(unsigned cpu,
|
|
|
|
struct evtchn_loop_ctrl *ctrl)
|
2013-03-14 12:49:19 +00:00
|
|
|
{
|
2020-09-07 13:47:30 +00:00
|
|
|
return evtchn_ops->handle_events(cpu, ctrl);
|
2013-03-14 12:49:19 +00:00
|
|
|
}
|
2013-03-13 15:29:25 +00:00
|
|
|
|
2013-03-15 13:02:35 +00:00
|
|
|
static inline void xen_evtchn_resume(void)
|
|
|
|
{
|
|
|
|
if (evtchn_ops->resume)
|
|
|
|
evtchn_ops->resume();
|
|
|
|
}
|
|
|
|
|
2013-03-14 12:49:19 +00:00
|
|
|
void xen_evtchn_2l_init(void);
|
2013-03-15 13:02:35 +00:00
|
|
|
int xen_evtchn_fifo_init(void);
|
2013-03-13 15:29:25 +00:00
|
|
|
|
|
|
|
#endif /* #ifndef __EVENTS_INTERNAL_H__ */
|