Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Xen Event Channels (internal header)
0004  *
0005  * Copyright (C) 2013 Citrix Systems R&D Ltd.
0006  */
0007 #ifndef __EVENTS_INTERNAL_H__
0008 #define __EVENTS_INTERNAL_H__
0009 
0010 struct evtchn_loop_ctrl;
0011 
0012 struct evtchn_ops {
0013     unsigned (*max_channels)(void);
0014     unsigned (*nr_channels)(void);
0015 
0016     int (*setup)(evtchn_port_t port);
0017     void (*remove)(evtchn_port_t port, unsigned int cpu);
0018     void (*bind_to_cpu)(evtchn_port_t evtchn, unsigned int cpu,
0019                 unsigned int old_cpu);
0020 
0021     void (*clear_pending)(evtchn_port_t port);
0022     void (*set_pending)(evtchn_port_t port);
0023     bool (*is_pending)(evtchn_port_t port);
0024     void (*mask)(evtchn_port_t port);
0025     void (*unmask)(evtchn_port_t port);
0026 
0027     void (*handle_events)(unsigned cpu, struct evtchn_loop_ctrl *ctrl);
0028     void (*resume)(void);
0029 
0030     int (*percpu_init)(unsigned int cpu);
0031     int (*percpu_deinit)(unsigned int cpu);
0032 };
0033 
0034 extern const struct evtchn_ops *evtchn_ops;
0035 
0036 int get_evtchn_to_irq(evtchn_port_t evtchn);
0037 void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl);
0038 
0039 unsigned int cpu_from_evtchn(evtchn_port_t evtchn);
0040 
0041 static inline unsigned xen_evtchn_max_channels(void)
0042 {
0043     return evtchn_ops->max_channels();
0044 }
0045 
0046 /*
0047  * Do any ABI specific setup for a bound event channel before it can
0048  * be unmasked and used.
0049  */
0050 static inline int xen_evtchn_port_setup(evtchn_port_t evtchn)
0051 {
0052     if (evtchn_ops->setup)
0053         return evtchn_ops->setup(evtchn);
0054     return 0;
0055 }
0056 
0057 static inline void xen_evtchn_port_remove(evtchn_port_t evtchn,
0058                       unsigned int cpu)
0059 {
0060     if (evtchn_ops->remove)
0061         evtchn_ops->remove(evtchn, cpu);
0062 }
0063 
0064 static inline void xen_evtchn_port_bind_to_cpu(evtchn_port_t evtchn,
0065                            unsigned int cpu,
0066                            unsigned int old_cpu)
0067 {
0068     evtchn_ops->bind_to_cpu(evtchn, cpu, old_cpu);
0069 }
0070 
0071 static inline void clear_evtchn(evtchn_port_t port)
0072 {
0073     evtchn_ops->clear_pending(port);
0074 }
0075 
0076 static inline void set_evtchn(evtchn_port_t port)
0077 {
0078     evtchn_ops->set_pending(port);
0079 }
0080 
0081 static inline bool test_evtchn(evtchn_port_t port)
0082 {
0083     return evtchn_ops->is_pending(port);
0084 }
0085 
0086 static inline void mask_evtchn(evtchn_port_t port)
0087 {
0088     return evtchn_ops->mask(port);
0089 }
0090 
0091 static inline void unmask_evtchn(evtchn_port_t port)
0092 {
0093     return evtchn_ops->unmask(port);
0094 }
0095 
0096 static inline void xen_evtchn_handle_events(unsigned cpu,
0097                         struct evtchn_loop_ctrl *ctrl)
0098 {
0099     return evtchn_ops->handle_events(cpu, ctrl);
0100 }
0101 
0102 static inline void xen_evtchn_resume(void)
0103 {
0104     if (evtchn_ops->resume)
0105         evtchn_ops->resume();
0106 }
0107 
0108 void xen_evtchn_2l_init(void);
0109 int xen_evtchn_fifo_init(void);
0110 
0111 #endif /* #ifndef __EVENTS_INTERNAL_H__ */