xref: /freebsd/sys/dev/xen/bus/intr-internal.h (revision 6699c22c)
1 /*-
2  * SPDX-License-Identifier: MIT OR GPL-2.0-only
3  *
4  * Copyright © 2002-2005 K A Fraser
5  * Copyright © 2005 Intel Corporation <xiaofeng.ling@intel.com>
6  * Copyright © 2005-2006 Kip Macy
7  * Copyright © 2013 Spectra Logic Corporation
8  * Copyright © 2015 Julien Grall
9  * Copyright © 2021,2022 Elliott Mitchell
10  *
11  * This file may be distributed separately from the Linux kernel, or
12  * incorporated into other software packages, subject to the following license:
13  *
14  * Permission is hereby granted, free of charge, to any person obtaining a copy
15  * of this source file (the "Software"), to deal in the Software without
16  * restriction, including without limitation the rights to use, copy, modify,
17  * merge, publish, distribute, sublicense, and/or sell copies of the Software,
18  * and to permit persons to whom the Software is furnished to do so, subject to
19  * the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be included in
22  * all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30  * IN THE SOFTWARE.
31  */
32 
33 #ifndef	_XEN_INTR_INTERNAL_H_
34 #define	_XEN_INTR_INTERNAL_H_
35 
36 #ifndef	_MACHINE__XEN_ARCH_INTR_H_
37 #error	"do not #include intr-internal.h, #include machine/arch-intr.h instead"
38 #endif
39 
40 /* Current implementation only supports 2L event channels. */
41 #define NR_EVENT_CHANNELS EVTCHN_2L_NR_CHANNELS
42 
43 enum evtchn_type {
44 	EVTCHN_TYPE_UNBOUND,
45 	EVTCHN_TYPE_VIRQ,
46 	EVTCHN_TYPE_IPI,
47 	EVTCHN_TYPE_PORT,
48 	EVTCHN_TYPE_COUNT
49 };
50 
51 struct xenisrc {
52 	xen_arch_isrc_t		xi_arch;	/* @TOP -> *xi_arch=*xenisrc */
53 	enum evtchn_type	xi_type;
54 	u_int			xi_cpu;		/* VCPU for delivery */
55 	evtchn_port_t		xi_port;
56 	u_int			xi_virq;
57 	void			*xi_cookie;
58 	bool			xi_close:1;	/* close on unbind? */
59 	bool			xi_masked:1;
60 	volatile u_int		xi_refcount;
61 };
62 
63 /***************** Functions called by the architecture code *****************/
64 
65 extern void	xen_intr_resume(void);
66 extern void	xen_intr_enable_source(struct xenisrc *isrc);
67 extern void	xen_intr_disable_source(struct xenisrc *isrc);
68 extern void	xen_intr_enable_intr(struct xenisrc *isrc);
69 extern void	xen_intr_disable_intr(struct xenisrc *isrc);
70 extern int	xen_intr_assign_cpu(struct xenisrc *isrc, u_int to_cpu);
71 
72 /******************* Functions implemented by each architecture **************/
73 
74 #if 0
75 /*
76  * These are sample prototypes, the architecture should include its own in
77  * <machine/xen/arch-intr.h>.  The architecture may implement these as inline.
78  */
79 void	xen_arch_intr_init(void);
80 struct xenisrc *xen_arch_intr_alloc(void);
81 void	xen_arch_intr_release(struct xenisrc *isrc);
82 u_int	xen_arch_intr_next_cpu(struct xenisrc *isrc);
83 u_long	xen_arch_intr_execute_handlers(struct xenisrc *isrc,
84 	    struct trapframe *frame);
85 int	xen_arch_intr_add_handler(const char *name,
86 	    driver_filter_t filter, driver_intr_t handler, void *arg,
87 	    enum intr_type flags, struct xenisrc *isrc,
88 	    void **cookiep);
89 int	xen_arch_intr_describe(struct xenisrc *isrc, void *cookie,
90 	    const char *descr);
91 int	xen_arch_intr_remove_handler(struct xenisrc *isrc,
92 	    void *cookie);
93 int	xen_arch_intr_event_bind(struct xenisrc *isrc, u_int cpu);
94 #endif
95 
96 #endif	/* _XEN_INTR_INTERNAL_H_ */
97