1 /* $NetBSD: intr.h,v 1.30 2009/03/27 15:47:33 dyoung Exp $ */
2 /* NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp */
5 * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Charles M. Hannum, and by Jason R. Thorpe.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
36 #include <machine/intrdefs.h>
40 #include <xen/hypervisor.h>
41 #include <xen/evtchn.h>
42 #include <machine/cpu.h>
43 #include <machine/pic.h>
44 #include <sys/evcnt.h>
49 * Struct describing an event channel.
53 int ev_maxlevel
; /* max. IPL for this source */
54 uint32_t ev_imask
; /* interrupt mask */
55 struct intrhand
*ev_handlers
; /* handler chain */
56 struct evcnt ev_evcnt
; /* interrupt counter */
57 char ev_evname
[32]; /* event counter name */
61 * Structure describing an interrupt level. struct cpu_info has an array of
62 * IPL_MAX of theses. The index in the array is equal to the stub number of
63 * the stubcode as present in vector.s
74 /* for x86 compatibility */
75 extern struct intrstub i8259_stubs
[];
76 extern struct intrstub ioapic_edge_stubs
[];
77 extern struct intrstub ioapic_level_stubs
[];
80 struct intrhand
*ipl_handlers
; /* handler chain */
81 void *ipl_recurse
; /* entry for spllower */
82 void *ipl_resume
; /* entry for doreti */
84 u_long ipl_evt_mask1
; /* pending events for this IPL */
85 u_long ipl_evt_mask2
[NR_EVENT_CHANNELS
];
91 * Interrupt handler chains. These are linked in both the evtsource and
93 * The handler is called with its (single) argument.
97 int (*ih_fun
)(void *);
100 int (*ih_realfun
)(void *);
102 struct intrhand
*ih_ipl_next
;
103 struct intrhand
*ih_evt_next
;
104 struct cpu_info
*ih_cpu
;
107 struct xen_intr_handle
{
108 int pirq
; /* also contains the APIC_INT_* flags if NIOAPIC > 0 */
112 extern struct intrstub xenev_stubs
[];
114 #define IUNMASK(ci,level) (ci)->ci_iunmask[(level)]
116 extern void Xspllower(int);
121 #define SPL_ASSERT_BELOW(x) KDASSERT(curcpu()->ci_ilevel < (x))
126 #define spl0() spllower(IPL_NONE)
127 #define splx(x) spllower(x)
129 typedef uint8_t ipl_t
;
134 static inline ipl_cookie_t
135 makeiplcookie(ipl_t ipl
)
138 return (ipl_cookie_t
){._ipl
= ipl
};
142 splraiseipl(ipl_cookie_t icookie
)
145 return splraise(icookie
._ipl
);
156 struct pcibus_attach_args
;
158 #ifdef MULTIPROCESSOR
159 int intr_biglock_wrapper(void *);
162 void intr_default_setup(void);
164 void intr_calculatemasks(struct evtsource
*);
166 void *intr_establish(int, struct pic
*, int, int, int, int (*)(void *), void *, bool);
167 void intr_disestablish(struct intrhand
*);
168 const char *intr_string(int);
169 void cpu_intr_init(struct cpu_info
*);
170 int xen_intr_map(int *, int);
172 void intr_printconfig(void);
174 int intr_find_mpmapping(int, int, struct xen_intr_handle
*);
175 struct pic
*intr_findpic(int);
176 void intr_add_pcibus(struct pcibus_attach_args
*);
178 int x86_send_ipi(struct cpu_info
*, int);
179 void x86_broadcast_ipi(int);
180 void x86_multicast_ipi(int, int);
182 #endif /* !_LOCORE */
184 #endif /* _XEN_INTR_H_ */