gicv3.c revision 1.5 1 1.5 jmcneill /* $NetBSD: gicv3.c,v 1.5 2018/11/09 23:36:24 jmcneill Exp $ */
2 1.1 jmcneill
3 1.1 jmcneill /*-
4 1.1 jmcneill * Copyright (c) 2018 Jared McNeill <jmcneill (at) invisible.ca>
5 1.1 jmcneill * All rights reserved.
6 1.1 jmcneill *
7 1.1 jmcneill * Redistribution and use in source and binary forms, with or without
8 1.1 jmcneill * modification, are permitted provided that the following conditions
9 1.1 jmcneill * are met:
10 1.1 jmcneill * 1. Redistributions of source code must retain the above copyright
11 1.1 jmcneill * notice, this list of conditions and the following disclaimer.
12 1.1 jmcneill * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 jmcneill * notice, this list of conditions and the following disclaimer in the
14 1.1 jmcneill * documentation and/or other materials provided with the distribution.
15 1.1 jmcneill *
16 1.1 jmcneill * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1 jmcneill * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 jmcneill * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 jmcneill * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1 jmcneill * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 1.1 jmcneill * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 1.1 jmcneill * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 1.1 jmcneill * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 1.1 jmcneill * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 jmcneill * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 jmcneill * SUCH DAMAGE.
27 1.1 jmcneill */
28 1.1 jmcneill
29 1.1 jmcneill #include "opt_multiprocessor.h"
30 1.1 jmcneill
31 1.1 jmcneill #define _INTR_PRIVATE
32 1.1 jmcneill
33 1.1 jmcneill #include <sys/cdefs.h>
34 1.5 jmcneill __KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.5 2018/11/09 23:36:24 jmcneill Exp $");
35 1.1 jmcneill
36 1.1 jmcneill #include <sys/param.h>
37 1.1 jmcneill #include <sys/kernel.h>
38 1.1 jmcneill #include <sys/bus.h>
39 1.1 jmcneill #include <sys/device.h>
40 1.1 jmcneill #include <sys/intr.h>
41 1.1 jmcneill #include <sys/systm.h>
42 1.1 jmcneill #include <sys/cpu.h>
43 1.1 jmcneill
44 1.1 jmcneill #include <arm/locore.h>
45 1.1 jmcneill #include <arm/armreg.h>
46 1.1 jmcneill
47 1.1 jmcneill #include <arm/cortex/gicv3.h>
48 1.1 jmcneill #include <arm/cortex/gic_reg.h>
49 1.1 jmcneill
50 1.1 jmcneill #define PICTOSOFTC(pic) \
51 1.1 jmcneill ((void *)((uintptr_t)(pic) - offsetof(struct gicv3_softc, sc_pic)))
52 1.5 jmcneill #define LPITOSOFTC(lpi) \
53 1.5 jmcneill ((void *)((uintptr_t)(lpi) - offsetof(struct gicv3_softc, sc_lpi)))
54 1.1 jmcneill
55 1.4 jmcneill #define IPL_TO_PRIORITY(ipl) ((IPL_HIGH - (ipl)) << 4)
56 1.1 jmcneill
57 1.1 jmcneill static struct gicv3_softc *gicv3_softc;
58 1.1 jmcneill
59 1.1 jmcneill static inline uint32_t
60 1.1 jmcneill gicd_read_4(struct gicv3_softc *sc, bus_size_t reg)
61 1.1 jmcneill {
62 1.1 jmcneill return bus_space_read_4(sc->sc_bst, sc->sc_bsh_d, reg);
63 1.1 jmcneill }
64 1.1 jmcneill
65 1.1 jmcneill static inline void
66 1.1 jmcneill gicd_write_4(struct gicv3_softc *sc, bus_size_t reg, uint32_t val)
67 1.1 jmcneill {
68 1.1 jmcneill bus_space_write_4(sc->sc_bst, sc->sc_bsh_d, reg, val);
69 1.1 jmcneill }
70 1.1 jmcneill
71 1.1 jmcneill static inline void
72 1.1 jmcneill gicd_write_8(struct gicv3_softc *sc, bus_size_t reg, uint64_t val)
73 1.1 jmcneill {
74 1.1 jmcneill bus_space_write_8(sc->sc_bst, sc->sc_bsh_d, reg, val);
75 1.1 jmcneill }
76 1.1 jmcneill
77 1.1 jmcneill static inline uint32_t
78 1.1 jmcneill gicr_read_4(struct gicv3_softc *sc, u_int index, bus_size_t reg)
79 1.1 jmcneill {
80 1.1 jmcneill KASSERT(index < sc->sc_bsh_r_count);
81 1.1 jmcneill return bus_space_read_4(sc->sc_bst, sc->sc_bsh_r[index], reg);
82 1.1 jmcneill }
83 1.1 jmcneill
84 1.1 jmcneill static inline void
85 1.1 jmcneill gicr_write_4(struct gicv3_softc *sc, u_int index, bus_size_t reg, uint32_t val)
86 1.1 jmcneill {
87 1.1 jmcneill KASSERT(index < sc->sc_bsh_r_count);
88 1.1 jmcneill bus_space_write_4(sc->sc_bst, sc->sc_bsh_r[index], reg, val);
89 1.1 jmcneill }
90 1.1 jmcneill
91 1.1 jmcneill static inline uint64_t
92 1.1 jmcneill gicr_read_8(struct gicv3_softc *sc, u_int index, bus_size_t reg)
93 1.1 jmcneill {
94 1.1 jmcneill KASSERT(index < sc->sc_bsh_r_count);
95 1.1 jmcneill return bus_space_read_8(sc->sc_bst, sc->sc_bsh_r[index], reg);
96 1.1 jmcneill }
97 1.1 jmcneill
98 1.1 jmcneill static inline void
99 1.1 jmcneill gicr_write_8(struct gicv3_softc *sc, u_int index, bus_size_t reg, uint64_t val)
100 1.1 jmcneill {
101 1.1 jmcneill KASSERT(index < sc->sc_bsh_r_count);
102 1.1 jmcneill bus_space_write_8(sc->sc_bst, sc->sc_bsh_r[index], reg, val);
103 1.1 jmcneill }
104 1.1 jmcneill
105 1.1 jmcneill static void
106 1.1 jmcneill gicv3_unblock_irqs(struct pic_softc *pic, size_t irqbase, uint32_t mask)
107 1.1 jmcneill {
108 1.1 jmcneill struct gicv3_softc * const sc = PICTOSOFTC(pic);
109 1.1 jmcneill struct cpu_info * const ci = curcpu();
110 1.1 jmcneill const u_int group = irqbase / 32;
111 1.1 jmcneill
112 1.1 jmcneill if (group == 0) {
113 1.1 jmcneill sc->sc_enabled_sgippi |= mask;
114 1.1 jmcneill gicr_write_4(sc, ci->ci_gic_redist, GICR_ISENABLER0, mask);
115 1.5 jmcneill while (gicr_read_4(sc, ci->ci_gic_redist, GICR_CTLR) & GICR_CTLR_RWP)
116 1.1 jmcneill ;
117 1.1 jmcneill } else {
118 1.1 jmcneill gicd_write_4(sc, GICD_ISENABLERn(group), mask);
119 1.1 jmcneill while (gicd_read_4(sc, GICD_CTRL) & GICD_CTRL_RWP)
120 1.1 jmcneill ;
121 1.1 jmcneill }
122 1.1 jmcneill }
123 1.1 jmcneill
124 1.1 jmcneill static void
125 1.1 jmcneill gicv3_block_irqs(struct pic_softc *pic, size_t irqbase, uint32_t mask)
126 1.1 jmcneill {
127 1.1 jmcneill struct gicv3_softc * const sc = PICTOSOFTC(pic);
128 1.1 jmcneill struct cpu_info * const ci = curcpu();
129 1.1 jmcneill const u_int group = irqbase / 32;
130 1.1 jmcneill
131 1.1 jmcneill if (group == 0) {
132 1.1 jmcneill sc->sc_enabled_sgippi &= ~mask;
133 1.1 jmcneill gicr_write_4(sc, ci->ci_gic_redist, GICR_ICENABLER0, mask);
134 1.5 jmcneill while (gicr_read_4(sc, ci->ci_gic_redist, GICR_CTLR) & GICR_CTLR_RWP)
135 1.1 jmcneill ;
136 1.1 jmcneill } else {
137 1.1 jmcneill gicd_write_4(sc, GICD_ICENABLERn(group), mask);
138 1.1 jmcneill while (gicd_read_4(sc, GICD_CTRL) & GICD_CTRL_RWP)
139 1.1 jmcneill ;
140 1.1 jmcneill }
141 1.1 jmcneill }
142 1.1 jmcneill
143 1.1 jmcneill static void
144 1.1 jmcneill gicv3_establish_irq(struct pic_softc *pic, struct intrsource *is)
145 1.1 jmcneill {
146 1.1 jmcneill struct gicv3_softc * const sc = PICTOSOFTC(pic);
147 1.1 jmcneill const u_int group = is->is_irq / 32;
148 1.1 jmcneill uint32_t ipriority, icfg;
149 1.1 jmcneill uint64_t irouter;
150 1.1 jmcneill u_int n;
151 1.1 jmcneill
152 1.4 jmcneill const u_int ipriority_val = 0x80 | IPL_TO_PRIORITY(is->is_ipl);
153 1.1 jmcneill const u_int ipriority_shift = (is->is_irq & 0x3) * 8;
154 1.1 jmcneill const u_int icfg_shift = (is->is_irq & 0xf) * 2;
155 1.1 jmcneill
156 1.1 jmcneill if (group == 0) {
157 1.1 jmcneill /* SGIs and PPIs are always MP-safe */
158 1.1 jmcneill is->is_mpsafe = true;
159 1.1 jmcneill
160 1.1 jmcneill /* Update interrupt configuration and priority on all redistributors */
161 1.1 jmcneill for (n = 0; n < sc->sc_bsh_r_count; n++) {
162 1.1 jmcneill icfg = gicr_read_4(sc, n, GICR_ICFGRn(is->is_irq / 16));
163 1.1 jmcneill if (is->is_type == IST_LEVEL)
164 1.1 jmcneill icfg &= ~(0x2 << icfg_shift);
165 1.1 jmcneill if (is->is_type == IST_EDGE)
166 1.1 jmcneill icfg |= (0x2 << icfg_shift);
167 1.1 jmcneill gicr_write_4(sc, n, GICR_ICFGRn(is->is_irq / 16), icfg);
168 1.1 jmcneill
169 1.1 jmcneill ipriority = gicr_read_4(sc, n, GICR_IPRIORITYRn(is->is_irq / 4));
170 1.1 jmcneill ipriority &= ~(0xff << ipriority_shift);
171 1.2 jmcneill ipriority |= (ipriority_val << ipriority_shift);
172 1.1 jmcneill gicr_write_4(sc, n, GICR_IPRIORITYRn(is->is_irq / 4), ipriority);
173 1.1 jmcneill }
174 1.1 jmcneill } else {
175 1.1 jmcneill if (is->is_mpsafe) {
176 1.1 jmcneill /* Route MP-safe interrupts to all participating PEs */
177 1.1 jmcneill irouter = GICD_IROUTER_Interrupt_Routing_mode;
178 1.1 jmcneill } else {
179 1.1 jmcneill /* Route non-MP-safe interrupts to the primary PE only */
180 1.1 jmcneill irouter = sc->sc_default_irouter;
181 1.1 jmcneill }
182 1.1 jmcneill gicd_write_8(sc, GICD_IROUTER(is->is_irq), irouter);
183 1.1 jmcneill
184 1.1 jmcneill /* Update interrupt configuration */
185 1.1 jmcneill icfg = gicd_read_4(sc, GICD_ICFGRn(is->is_irq / 16));
186 1.1 jmcneill if (is->is_type == IST_LEVEL)
187 1.1 jmcneill icfg &= ~(0x2 << icfg_shift);
188 1.1 jmcneill if (is->is_type == IST_EDGE)
189 1.1 jmcneill icfg |= (0x2 << icfg_shift);
190 1.1 jmcneill gicd_write_4(sc, GICD_ICFGRn(is->is_irq / 16), icfg);
191 1.1 jmcneill
192 1.1 jmcneill /* Update interrupt priority */
193 1.1 jmcneill ipriority = gicd_read_4(sc, GICD_IPRIORITYRn(is->is_irq / 4));
194 1.1 jmcneill ipriority &= ~(0xff << ipriority_shift);
195 1.2 jmcneill ipriority |= (ipriority_val << ipriority_shift);
196 1.1 jmcneill gicd_write_4(sc, GICD_IPRIORITYRn(is->is_irq / 4), ipriority);
197 1.1 jmcneill }
198 1.1 jmcneill }
199 1.1 jmcneill
200 1.1 jmcneill static void
201 1.1 jmcneill gicv3_set_priority(struct pic_softc *pic, int ipl)
202 1.1 jmcneill {
203 1.4 jmcneill icc_pmr_write(IPL_TO_PRIORITY(ipl) << 1);
204 1.1 jmcneill }
205 1.1 jmcneill
206 1.1 jmcneill static void
207 1.1 jmcneill gicv3_dist_enable(struct gicv3_softc *sc)
208 1.1 jmcneill {
209 1.1 jmcneill uint32_t gicd_ctrl;
210 1.1 jmcneill u_int n;
211 1.1 jmcneill
212 1.1 jmcneill /* Disable the distributor */
213 1.1 jmcneill gicd_write_4(sc, GICD_CTRL, 0);
214 1.1 jmcneill
215 1.1 jmcneill /* Wait for register write to complete */
216 1.1 jmcneill while (gicd_read_4(sc, GICD_CTRL) & GICD_CTRL_RWP)
217 1.1 jmcneill ;
218 1.1 jmcneill
219 1.1 jmcneill /* Clear all INTID enable bits */
220 1.1 jmcneill for (n = 32; n < sc->sc_pic.pic_maxsources; n += 32)
221 1.1 jmcneill gicd_write_4(sc, GICD_ICENABLERn(n / 32), ~0);
222 1.1 jmcneill
223 1.1 jmcneill /* Set default priorities to lowest */
224 1.1 jmcneill for (n = 32; n < sc->sc_pic.pic_maxsources; n += 4)
225 1.1 jmcneill gicd_write_4(sc, GICD_IPRIORITYRn(n / 4), ~0);
226 1.1 jmcneill
227 1.1 jmcneill /* Set all interrupts to G1NS */
228 1.1 jmcneill for (n = 32; n < sc->sc_pic.pic_maxsources; n += 32) {
229 1.1 jmcneill gicd_write_4(sc, GICD_IGROUPRn(n / 32), ~0);
230 1.1 jmcneill gicd_write_4(sc, GICD_IGRPMODRn(n / 32), 0);
231 1.1 jmcneill }
232 1.1 jmcneill
233 1.1 jmcneill /* Set all interrupts level-sensitive by default */
234 1.1 jmcneill for (n = 32; n < sc->sc_pic.pic_maxsources; n += 16)
235 1.1 jmcneill gicd_write_4(sc, GICD_ICFGRn(n / 16), 0);
236 1.1 jmcneill
237 1.1 jmcneill /* Wait for register writes to complete */
238 1.1 jmcneill while (gicd_read_4(sc, GICD_CTRL) & GICD_CTRL_RWP)
239 1.1 jmcneill ;
240 1.1 jmcneill
241 1.1 jmcneill /* Enable Affinity routing and G1NS interrupts */
242 1.1 jmcneill gicd_ctrl = GICD_CTRL_EnableGrp1NS | GICD_CTRL_Enable | GICD_CTRL_ARE_NS;
243 1.1 jmcneill gicd_write_4(sc, GICD_CTRL, gicd_ctrl);
244 1.1 jmcneill }
245 1.1 jmcneill
246 1.1 jmcneill static void
247 1.1 jmcneill gicv3_redist_enable(struct gicv3_softc *sc, struct cpu_info *ci)
248 1.1 jmcneill {
249 1.1 jmcneill uint32_t icfg;
250 1.1 jmcneill u_int n, o;
251 1.1 jmcneill
252 1.1 jmcneill /* Clear INTID enable bits */
253 1.1 jmcneill gicr_write_4(sc, ci->ci_gic_redist, GICR_ICENABLER0, ~0);
254 1.1 jmcneill
255 1.1 jmcneill /* Wait for register write to complete */
256 1.5 jmcneill while (gicr_read_4(sc, ci->ci_gic_redist, GICR_CTLR) & GICR_CTLR_RWP)
257 1.1 jmcneill ;
258 1.1 jmcneill
259 1.1 jmcneill /* Set default priorities */
260 1.1 jmcneill for (n = 0; n < 32; n += 4) {
261 1.1 jmcneill uint32_t priority = 0;
262 1.1 jmcneill size_t byte_shift = 0;
263 1.1 jmcneill for (o = 0; o < 4; o++, byte_shift += 8) {
264 1.1 jmcneill struct intrsource * const is = sc->sc_pic.pic_sources[n + o];
265 1.1 jmcneill if (is == NULL)
266 1.1 jmcneill priority |= 0xff << byte_shift;
267 1.2 jmcneill else {
268 1.2 jmcneill const u_int ipriority_val = 0x80 | IPL_TO_PRIORITY(is->is_ipl);
269 1.2 jmcneill priority |= ipriority_val << byte_shift;
270 1.2 jmcneill }
271 1.1 jmcneill }
272 1.1 jmcneill gicr_write_4(sc, ci->ci_gic_redist, GICR_IPRIORITYRn(n / 4), priority);
273 1.1 jmcneill }
274 1.1 jmcneill
275 1.1 jmcneill /* Set all interrupts to G1NS */
276 1.1 jmcneill gicr_write_4(sc, ci->ci_gic_redist, GICR_IGROUPR0, ~0);
277 1.1 jmcneill gicr_write_4(sc, ci->ci_gic_redist, GICR_IGRPMODR0, 0);
278 1.1 jmcneill
279 1.1 jmcneill /* Restore PPI configs */
280 1.1 jmcneill for (n = 0, icfg = 0; n < 16; n++) {
281 1.1 jmcneill struct intrsource * const is = sc->sc_pic.pic_sources[16 + n];
282 1.1 jmcneill if (is != NULL && is->is_type == IST_EDGE)
283 1.1 jmcneill icfg |= (0x2 << (n * 2));
284 1.1 jmcneill }
285 1.1 jmcneill gicr_write_4(sc, ci->ci_gic_redist, GICR_ICFGRn(1), icfg);
286 1.1 jmcneill
287 1.1 jmcneill /* Restore current enable bits */
288 1.1 jmcneill gicr_write_4(sc, ci->ci_gic_redist, GICR_ISENABLER0, sc->sc_enabled_sgippi);
289 1.1 jmcneill
290 1.1 jmcneill /* Wait for register write to complete */
291 1.5 jmcneill while (gicr_read_4(sc, ci->ci_gic_redist, GICR_CTLR) & GICR_CTLR_RWP)
292 1.1 jmcneill ;
293 1.1 jmcneill }
294 1.1 jmcneill
295 1.1 jmcneill static uint64_t
296 1.1 jmcneill gicv3_cpu_identity(void)
297 1.1 jmcneill {
298 1.1 jmcneill u_int aff3, aff2, aff1, aff0;
299 1.1 jmcneill
300 1.1 jmcneill #ifdef __aarch64__
301 1.1 jmcneill const register_t mpidr = reg_mpidr_el1_read();
302 1.1 jmcneill aff0 = __SHIFTOUT(mpidr, MPIDR_AFF0);
303 1.1 jmcneill aff1 = __SHIFTOUT(mpidr, MPIDR_AFF1);
304 1.1 jmcneill aff2 = __SHIFTOUT(mpidr, MPIDR_AFF2);
305 1.1 jmcneill aff3 = __SHIFTOUT(mpidr, MPIDR_AFF3);
306 1.1 jmcneill #else
307 1.1 jmcneill const register_t mpidr = armreg_mpidr_read();
308 1.1 jmcneill aff0 = __SHIFTOUT(mpidr, MPIDR_AFF0);
309 1.1 jmcneill aff1 = __SHIFTOUT(mpidr, MPIDR_AFF1);
310 1.1 jmcneill aff2 = __SHIFTOUT(mpidr, MPIDR_AFF2);
311 1.1 jmcneill aff3 = 0;
312 1.1 jmcneill #endif
313 1.1 jmcneill
314 1.1 jmcneill return __SHIFTIN(aff0, GICR_TYPER_Affinity_Value_Aff0) |
315 1.1 jmcneill __SHIFTIN(aff1, GICR_TYPER_Affinity_Value_Aff1) |
316 1.1 jmcneill __SHIFTIN(aff2, GICR_TYPER_Affinity_Value_Aff2) |
317 1.1 jmcneill __SHIFTIN(aff3, GICR_TYPER_Affinity_Value_Aff3);
318 1.1 jmcneill }
319 1.1 jmcneill
320 1.1 jmcneill static u_int
321 1.1 jmcneill gicv3_find_redist(struct gicv3_softc *sc)
322 1.1 jmcneill {
323 1.1 jmcneill uint64_t gicr_typer;
324 1.1 jmcneill u_int n;
325 1.1 jmcneill
326 1.1 jmcneill const uint64_t cpu_identity = gicv3_cpu_identity();
327 1.1 jmcneill
328 1.1 jmcneill for (n = 0; n < sc->sc_bsh_r_count; n++) {
329 1.1 jmcneill gicr_typer = gicr_read_8(sc, n, GICR_TYPER);
330 1.1 jmcneill if ((gicr_typer & GICR_TYPER_Affinity_Value) == cpu_identity)
331 1.1 jmcneill return n;
332 1.1 jmcneill }
333 1.1 jmcneill
334 1.1 jmcneill const u_int aff0 = __SHIFTOUT(cpu_identity, GICR_TYPER_Affinity_Value_Aff0);
335 1.1 jmcneill const u_int aff1 = __SHIFTOUT(cpu_identity, GICR_TYPER_Affinity_Value_Aff1);
336 1.1 jmcneill const u_int aff2 = __SHIFTOUT(cpu_identity, GICR_TYPER_Affinity_Value_Aff2);
337 1.1 jmcneill const u_int aff3 = __SHIFTOUT(cpu_identity, GICR_TYPER_Affinity_Value_Aff3);
338 1.1 jmcneill
339 1.1 jmcneill panic("%s: could not find GICv3 redistributor for cpu %d.%d.%d.%d",
340 1.1 jmcneill cpu_name(curcpu()), aff3, aff2, aff1, aff0);
341 1.1 jmcneill }
342 1.1 jmcneill
343 1.1 jmcneill static uint64_t
344 1.1 jmcneill gicv3_sgir(struct gicv3_softc *sc)
345 1.1 jmcneill {
346 1.1 jmcneill const uint64_t cpu_identity = gicv3_cpu_identity();
347 1.1 jmcneill
348 1.1 jmcneill const u_int aff0 = __SHIFTOUT(cpu_identity, GICR_TYPER_Affinity_Value_Aff0);
349 1.1 jmcneill const u_int aff1 = __SHIFTOUT(cpu_identity, GICR_TYPER_Affinity_Value_Aff1);
350 1.1 jmcneill const u_int aff2 = __SHIFTOUT(cpu_identity, GICR_TYPER_Affinity_Value_Aff2);
351 1.1 jmcneill const u_int aff3 = __SHIFTOUT(cpu_identity, GICR_TYPER_Affinity_Value_Aff3);
352 1.1 jmcneill
353 1.1 jmcneill return __SHIFTIN(__BIT(aff0), ICC_SGIR_EL1_TargetList) |
354 1.1 jmcneill __SHIFTIN(aff1, ICC_SGIR_EL1_Aff1) |
355 1.1 jmcneill __SHIFTIN(aff2, ICC_SGIR_EL1_Aff2) |
356 1.1 jmcneill __SHIFTIN(aff3, ICC_SGIR_EL1_Aff3);
357 1.1 jmcneill }
358 1.1 jmcneill
359 1.1 jmcneill static void
360 1.1 jmcneill gicv3_cpu_init(struct pic_softc *pic, struct cpu_info *ci)
361 1.1 jmcneill {
362 1.1 jmcneill struct gicv3_softc * const sc = PICTOSOFTC(pic);
363 1.1 jmcneill uint32_t icc_sre, icc_ctlr, gicr_waker;
364 1.1 jmcneill
365 1.1 jmcneill ci->ci_gic_redist = gicv3_find_redist(sc);
366 1.1 jmcneill ci->ci_gic_sgir = gicv3_sgir(sc);
367 1.1 jmcneill
368 1.1 jmcneill if (CPU_IS_PRIMARY(ci)) {
369 1.1 jmcneill /* Store route to primary CPU for non-MPSAFE SPIs */
370 1.1 jmcneill const uint64_t cpu_identity = gicv3_cpu_identity();
371 1.1 jmcneill const u_int aff0 = __SHIFTOUT(cpu_identity, GICR_TYPER_Affinity_Value_Aff0);
372 1.1 jmcneill const u_int aff1 = __SHIFTOUT(cpu_identity, GICR_TYPER_Affinity_Value_Aff1);
373 1.1 jmcneill const u_int aff2 = __SHIFTOUT(cpu_identity, GICR_TYPER_Affinity_Value_Aff2);
374 1.1 jmcneill const u_int aff3 = __SHIFTOUT(cpu_identity, GICR_TYPER_Affinity_Value_Aff3);
375 1.1 jmcneill sc->sc_default_irouter =
376 1.1 jmcneill __SHIFTIN(aff0, GICD_IROUTER_Aff0) |
377 1.1 jmcneill __SHIFTIN(aff1, GICD_IROUTER_Aff1) |
378 1.1 jmcneill __SHIFTIN(aff2, GICD_IROUTER_Aff2) |
379 1.1 jmcneill __SHIFTIN(aff3, GICD_IROUTER_Aff3);
380 1.1 jmcneill }
381 1.1 jmcneill
382 1.1 jmcneill /* Enable System register access and disable IRQ/FIQ bypass */
383 1.1 jmcneill icc_sre = ICC_SRE_EL1_SRE | ICC_SRE_EL1_DFB | ICC_SRE_EL1_DIB;
384 1.1 jmcneill icc_sre_write(icc_sre);
385 1.1 jmcneill
386 1.1 jmcneill /* Mark the connected PE as being awake */
387 1.1 jmcneill gicr_waker = gicr_read_4(sc, ci->ci_gic_redist, GICR_WAKER);
388 1.1 jmcneill gicr_waker &= ~GICR_WAKER_ProcessorSleep;
389 1.1 jmcneill gicr_write_4(sc, ci->ci_gic_redist, GICR_WAKER, gicr_waker);
390 1.1 jmcneill while (gicr_read_4(sc, ci->ci_gic_redist, GICR_WAKER) & GICR_WAKER_ChildrenAsleep)
391 1.1 jmcneill ;
392 1.1 jmcneill
393 1.1 jmcneill /* Set initial priority mask */
394 1.4 jmcneill gicv3_set_priority(pic, IPL_HIGH);
395 1.1 jmcneill
396 1.1 jmcneill /* Disable preemption */
397 1.1 jmcneill const uint32_t icc_bpr = __SHIFTIN(0x7, ICC_BPR_EL1_BinaryPoint);
398 1.1 jmcneill icc_bpr1_write(icc_bpr);
399 1.1 jmcneill
400 1.1 jmcneill /* Enable group 1 interrupt signaling */
401 1.1 jmcneill icc_igrpen1_write(ICC_IGRPEN_EL1_Enable);
402 1.1 jmcneill
403 1.1 jmcneill /* Set EOI mode */
404 1.1 jmcneill icc_ctlr = icc_ctlr_read();
405 1.1 jmcneill icc_ctlr &= ~ICC_CTLR_EL1_EOImode;
406 1.1 jmcneill icc_ctlr_write(icc_ctlr);
407 1.1 jmcneill
408 1.1 jmcneill /* Enable redistributor */
409 1.1 jmcneill gicv3_redist_enable(sc, ci);
410 1.1 jmcneill
411 1.1 jmcneill /* Allow IRQ exceptions */
412 1.1 jmcneill cpsie(I32_bit);
413 1.1 jmcneill }
414 1.1 jmcneill
415 1.1 jmcneill #ifdef MULTIPROCESSOR
416 1.1 jmcneill static void
417 1.1 jmcneill gicv3_ipi_send(struct pic_softc *pic, const kcpuset_t *kcp, u_long ipi)
418 1.1 jmcneill {
419 1.1 jmcneill CPU_INFO_ITERATOR cii;
420 1.1 jmcneill struct cpu_info *ci;
421 1.1 jmcneill uint64_t intid, aff, targets;
422 1.1 jmcneill
423 1.1 jmcneill intid = __SHIFTIN(ipi, ICC_SGIR_EL1_INTID);
424 1.1 jmcneill if (kcp == NULL) {
425 1.1 jmcneill /* Interrupts routed to all PEs, excluding "self" */
426 1.1 jmcneill if (ncpu == 1)
427 1.1 jmcneill return;
428 1.1 jmcneill icc_sgi1r_write(intid | ICC_SGIR_EL1_IRM);
429 1.1 jmcneill } else {
430 1.1 jmcneill /* Interrupts routed to specific PEs */
431 1.1 jmcneill aff = 0;
432 1.1 jmcneill targets = 0;
433 1.1 jmcneill for (CPU_INFO_FOREACH(cii, ci)) {
434 1.2 jmcneill if (!kcpuset_isset(kcp, cpu_index(ci)))
435 1.2 jmcneill continue;
436 1.1 jmcneill if ((ci->ci_gic_sgir & ICC_SGIR_EL1_Aff) != aff) {
437 1.1 jmcneill if (targets != 0) {
438 1.1 jmcneill icc_sgi1r_write(intid | aff | targets);
439 1.1 jmcneill targets = 0;
440 1.1 jmcneill }
441 1.1 jmcneill aff = (ci->ci_gic_sgir & ICC_SGIR_EL1_Aff);
442 1.1 jmcneill }
443 1.1 jmcneill targets |= (ci->ci_gic_sgir & ICC_SGIR_EL1_TargetList);
444 1.1 jmcneill }
445 1.1 jmcneill if (targets != 0)
446 1.1 jmcneill icc_sgi1r_write(intid | aff | targets);
447 1.1 jmcneill }
448 1.1 jmcneill }
449 1.1 jmcneill #endif
450 1.1 jmcneill
451 1.1 jmcneill static const struct pic_ops gicv3_picops = {
452 1.1 jmcneill .pic_unblock_irqs = gicv3_unblock_irqs,
453 1.1 jmcneill .pic_block_irqs = gicv3_block_irqs,
454 1.1 jmcneill .pic_establish_irq = gicv3_establish_irq,
455 1.1 jmcneill .pic_set_priority = gicv3_set_priority,
456 1.1 jmcneill #ifdef MULTIPROCESSOR
457 1.1 jmcneill .pic_cpu_init = gicv3_cpu_init,
458 1.1 jmcneill .pic_ipi_send = gicv3_ipi_send,
459 1.1 jmcneill #endif
460 1.1 jmcneill };
461 1.1 jmcneill
462 1.5 jmcneill static void
463 1.5 jmcneill gicv3_lpi_unblock_irqs(struct pic_softc *pic, size_t irqbase, uint32_t mask)
464 1.5 jmcneill {
465 1.5 jmcneill struct gicv3_softc * const sc = LPITOSOFTC(pic);
466 1.5 jmcneill int bit;
467 1.5 jmcneill
468 1.5 jmcneill while ((bit = ffs(mask)) != 0) {
469 1.5 jmcneill sc->sc_lpiconf.base[irqbase + bit - 1] |= GIC_LPICONF_Enable;
470 1.5 jmcneill mask &= ~__BIT(bit - 1);
471 1.5 jmcneill }
472 1.5 jmcneill
473 1.5 jmcneill bus_dmamap_sync(sc->sc_dmat, sc->sc_lpiconf.map, irqbase, 32, BUS_DMASYNC_PREWRITE);
474 1.5 jmcneill }
475 1.5 jmcneill
476 1.5 jmcneill static void
477 1.5 jmcneill gicv3_lpi_block_irqs(struct pic_softc *pic, size_t irqbase, uint32_t mask)
478 1.5 jmcneill {
479 1.5 jmcneill struct gicv3_softc * const sc = LPITOSOFTC(pic);
480 1.5 jmcneill const u_int off = irqbase - pic->pic_irqbase;
481 1.5 jmcneill int bit;
482 1.5 jmcneill
483 1.5 jmcneill while ((bit = ffs(mask)) != 0) {
484 1.5 jmcneill sc->sc_lpiconf.base[off + bit - 1] &= ~GIC_LPICONF_Enable;
485 1.5 jmcneill mask &= ~__BIT(bit - 1);
486 1.5 jmcneill }
487 1.5 jmcneill
488 1.5 jmcneill bus_dmamap_sync(sc->sc_dmat, sc->sc_lpiconf.map, off, 32, BUS_DMASYNC_PREWRITE);
489 1.5 jmcneill }
490 1.5 jmcneill
491 1.5 jmcneill static void
492 1.5 jmcneill gicv3_lpi_establish_irq(struct pic_softc *pic, struct intrsource *is)
493 1.5 jmcneill {
494 1.5 jmcneill struct gicv3_softc * const sc = LPITOSOFTC(pic);
495 1.5 jmcneill
496 1.5 jmcneill sc->sc_lpiconf.base[is->is_irq] = IPL_TO_PRIORITY(is->is_ipl) | GIC_LPICONF_Res1;
497 1.5 jmcneill
498 1.5 jmcneill bus_dmamap_sync(sc->sc_dmat, sc->sc_lpiconf.map, is->is_irq, 1, BUS_DMASYNC_PREWRITE);
499 1.5 jmcneill }
500 1.5 jmcneill
501 1.5 jmcneill static void
502 1.5 jmcneill gicv3_lpi_cpu_init(struct pic_softc *pic, struct cpu_info *ci)
503 1.5 jmcneill {
504 1.5 jmcneill struct gicv3_softc * const sc = LPITOSOFTC(pic);
505 1.5 jmcneill struct gicv3_cpu_init *cpu_init;
506 1.5 jmcneill uint32_t ctlr;
507 1.5 jmcneill
508 1.5 jmcneill /* If physical LPIs are not supported on this redistributor, just return. */
509 1.5 jmcneill const uint64_t typer = gicr_read_8(sc, ci->ci_gic_redist, GICR_TYPER);
510 1.5 jmcneill if ((typer & GICR_TYPER_PLPIS) == 0)
511 1.5 jmcneill return;
512 1.5 jmcneill
513 1.5 jmcneill /* Interrupt target address for this CPU, used by ITS when GITS_TYPER.PTA == 0 */
514 1.5 jmcneill sc->sc_processor_id[cpu_index(ci)] = __SHIFTOUT(typer, GICR_TYPER_Processor_Number);
515 1.5 jmcneill
516 1.5 jmcneill /* Disable LPIs before making changes */
517 1.5 jmcneill ctlr = gicr_read_4(sc, ci->ci_gic_redist, GICR_CTLR);
518 1.5 jmcneill ctlr &= ~GICR_CTLR_Enable_LPIs;
519 1.5 jmcneill gicr_write_4(sc, ci->ci_gic_redist, GICR_CTLR, ctlr);
520 1.5 jmcneill arm_dsb();
521 1.5 jmcneill
522 1.5 jmcneill /* Setup the LPI configuration table */
523 1.5 jmcneill const uint64_t propbase = sc->sc_lpiconf.segs[0].ds_addr |
524 1.5 jmcneill __SHIFTIN(ffs(pic->pic_maxsources) - 1, GICR_PROPBASER_IDbits) |
525 1.5 jmcneill __SHIFTIN(GICR_Shareability_NS, GICR_PROPBASER_Shareability) |
526 1.5 jmcneill __SHIFTIN(GICR_Cache_NORMAL_NC, GICR_PROPBASER_InnerCache);
527 1.5 jmcneill gicr_write_8(sc, ci->ci_gic_redist, GICR_PROPBASER, propbase);
528 1.5 jmcneill
529 1.5 jmcneill /* Setup the LPI pending table */
530 1.5 jmcneill const uint64_t pendbase = sc->sc_lpipend[cpu_index(ci)].segs[0].ds_addr |
531 1.5 jmcneill __SHIFTIN(GICR_Shareability_NS, GICR_PENDBASER_Shareability) |
532 1.5 jmcneill __SHIFTIN(GICR_Cache_NORMAL_NC, GICR_PENDBASER_InnerCache) |
533 1.5 jmcneill GICR_PENDBASER_PTZ;
534 1.5 jmcneill gicr_write_8(sc, ci->ci_gic_redist, GICR_PENDBASER, pendbase);
535 1.5 jmcneill
536 1.5 jmcneill /* Enable LPIs */
537 1.5 jmcneill ctlr = gicr_read_4(sc, ci->ci_gic_redist, GICR_CTLR);
538 1.5 jmcneill ctlr |= GICR_CTLR_Enable_LPIs;
539 1.5 jmcneill gicr_write_4(sc, ci->ci_gic_redist, GICR_CTLR, ctlr);
540 1.5 jmcneill arm_dsb();
541 1.5 jmcneill
542 1.5 jmcneill /* Setup ITS if present */
543 1.5 jmcneill LIST_FOREACH(cpu_init, &sc->sc_cpu_init, list)
544 1.5 jmcneill cpu_init->func(cpu_init->arg, ci);
545 1.5 jmcneill }
546 1.5 jmcneill
547 1.5 jmcneill static const struct pic_ops gicv3_lpiops = {
548 1.5 jmcneill .pic_unblock_irqs = gicv3_lpi_unblock_irqs,
549 1.5 jmcneill .pic_block_irqs = gicv3_lpi_block_irqs,
550 1.5 jmcneill .pic_establish_irq = gicv3_lpi_establish_irq,
551 1.5 jmcneill #ifdef MULTIPROCESSOR
552 1.5 jmcneill .pic_cpu_init = gicv3_lpi_cpu_init,
553 1.5 jmcneill #endif
554 1.5 jmcneill };
555 1.5 jmcneill
556 1.5 jmcneill void
557 1.5 jmcneill gicv3_dma_alloc(struct gicv3_softc *sc, struct gicv3_dma *dma, bus_size_t len, bus_size_t align)
558 1.5 jmcneill {
559 1.5 jmcneill int nsegs, error;
560 1.5 jmcneill
561 1.5 jmcneill dma->len = len;
562 1.5 jmcneill error = bus_dmamem_alloc(sc->sc_dmat, dma->len, align, 0, dma->segs, 1, &nsegs, BUS_DMA_WAITOK);
563 1.5 jmcneill if (error)
564 1.5 jmcneill panic("bus_dmamem_alloc failed: %d", error);
565 1.5 jmcneill error = bus_dmamem_map(sc->sc_dmat, dma->segs, nsegs, len, (void **)&dma->base, BUS_DMA_WAITOK);
566 1.5 jmcneill if (error)
567 1.5 jmcneill panic("bus_dmamem_map failed: %d", error);
568 1.5 jmcneill error = bus_dmamap_create(sc->sc_dmat, len, 1, len, 0, BUS_DMA_WAITOK, &dma->map);
569 1.5 jmcneill if (error)
570 1.5 jmcneill panic("bus_dmamap_create failed: %d", error);
571 1.5 jmcneill error = bus_dmamap_load(sc->sc_dmat, dma->map, dma->base, dma->len, NULL, BUS_DMA_WAITOK);
572 1.5 jmcneill if (error)
573 1.5 jmcneill panic("bus_dmamap_load failed: %d", error);
574 1.5 jmcneill
575 1.5 jmcneill memset(dma->base, 0, dma->len);
576 1.5 jmcneill bus_dmamap_sync(sc->sc_dmat, dma->map, 0, dma->len, BUS_DMASYNC_PREWRITE);
577 1.5 jmcneill }
578 1.5 jmcneill
579 1.5 jmcneill static void
580 1.5 jmcneill gicv3_lpi_init(struct gicv3_softc *sc)
581 1.5 jmcneill {
582 1.5 jmcneill /*
583 1.5 jmcneill * Allocate LPI configuration table
584 1.5 jmcneill */
585 1.5 jmcneill gicv3_dma_alloc(sc, &sc->sc_lpiconf, sc->sc_lpi.pic_maxsources, 0x1000);
586 1.5 jmcneill KASSERT((sc->sc_lpiconf.segs[0].ds_addr & ~GICR_PROPBASER_Physical_Address) == 0);
587 1.5 jmcneill
588 1.5 jmcneill /*
589 1.5 jmcneill * Allocate LPI pending tables
590 1.5 jmcneill */
591 1.5 jmcneill const bus_size_t lpipend_sz = (sc->sc_lpi.pic_maxsources + sc->sc_lpi.pic_irqbase) / NBBY;
592 1.5 jmcneill for (int cpuindex = 0; cpuindex < MAXCPUS; cpuindex++) {
593 1.5 jmcneill gicv3_dma_alloc(sc, &sc->sc_lpipend[cpuindex], lpipend_sz, 0x10000);
594 1.5 jmcneill KASSERT((sc->sc_lpipend[cpuindex].segs[0].ds_addr & ~GICR_PENDBASER_Physical_Address) == 0);
595 1.5 jmcneill }
596 1.5 jmcneill }
597 1.5 jmcneill
598 1.1 jmcneill void
599 1.1 jmcneill gicv3_irq_handler(void *frame)
600 1.1 jmcneill {
601 1.1 jmcneill struct cpu_info * const ci = curcpu();
602 1.1 jmcneill struct gicv3_softc * const sc = gicv3_softc;
603 1.5 jmcneill struct pic_softc *pic;
604 1.1 jmcneill const int oldipl = ci->ci_cpl;
605 1.1 jmcneill
606 1.1 jmcneill ci->ci_data.cpu_nintr++;
607 1.1 jmcneill
608 1.1 jmcneill for (;;) {
609 1.1 jmcneill const uint32_t iar = icc_iar1_read();
610 1.1 jmcneill const uint32_t irq = __SHIFTOUT(iar, ICC_IAR_INTID);
611 1.1 jmcneill if (irq == ICC_IAR_INTID_SPURIOUS)
612 1.1 jmcneill break;
613 1.1 jmcneill
614 1.5 jmcneill pic = irq >= GIC_LPI_BASE ? &sc->sc_lpi : &sc->sc_pic;
615 1.5 jmcneill if (irq - pic->pic_irqbase >= pic->pic_maxsources)
616 1.1 jmcneill continue;
617 1.1 jmcneill
618 1.5 jmcneill struct intrsource * const is = pic->pic_sources[irq - pic->pic_irqbase];
619 1.1 jmcneill KASSERT(is != NULL);
620 1.1 jmcneill
621 1.1 jmcneill const int ipl = is->is_ipl;
622 1.2 jmcneill if (ci->ci_cpl < ipl)
623 1.1 jmcneill pic_set_priority(ci, ipl);
624 1.1 jmcneill
625 1.1 jmcneill cpsie(I32_bit);
626 1.1 jmcneill pic_dispatch(is, frame);
627 1.1 jmcneill cpsid(I32_bit);
628 1.1 jmcneill
629 1.1 jmcneill icc_eoi1r_write(iar);
630 1.1 jmcneill }
631 1.1 jmcneill
632 1.1 jmcneill if (ci->ci_cpl != oldipl)
633 1.1 jmcneill pic_set_priority(ci, oldipl);
634 1.1 jmcneill }
635 1.1 jmcneill
636 1.1 jmcneill int
637 1.1 jmcneill gicv3_init(struct gicv3_softc *sc)
638 1.1 jmcneill {
639 1.1 jmcneill const uint32_t gicd_typer = gicd_read_4(sc, GICD_TYPER);
640 1.1 jmcneill
641 1.1 jmcneill KASSERT(CPU_IS_PRIMARY(curcpu()));
642 1.1 jmcneill
643 1.5 jmcneill LIST_INIT(&sc->sc_cpu_init);
644 1.5 jmcneill
645 1.1 jmcneill sc->sc_pic.pic_ops = &gicv3_picops;
646 1.1 jmcneill sc->sc_pic.pic_maxsources = GICD_TYPER_LINES(gicd_typer);
647 1.1 jmcneill snprintf(sc->sc_pic.pic_name, sizeof(sc->sc_pic.pic_name), "gicv3");
648 1.1 jmcneill #ifdef MULTIPROCESSOR
649 1.1 jmcneill sc->sc_pic.pic_cpus = kcpuset_running;
650 1.1 jmcneill #endif
651 1.1 jmcneill pic_add(&sc->sc_pic, 0);
652 1.1 jmcneill
653 1.5 jmcneill if ((gicd_typer & GICD_TYPER_LPIS) != 0) {
654 1.5 jmcneill sc->sc_lpi.pic_ops = &gicv3_lpiops;
655 1.5 jmcneill sc->sc_lpi.pic_maxsources = 8192; /* Min. required by GICv3 spec */
656 1.5 jmcneill snprintf(sc->sc_lpi.pic_name, sizeof(sc->sc_lpi.pic_name), "gicv3-lpi");
657 1.5 jmcneill pic_add(&sc->sc_lpi, GIC_LPI_BASE);
658 1.5 jmcneill
659 1.5 jmcneill gicv3_lpi_init(sc);
660 1.5 jmcneill }
661 1.5 jmcneill
662 1.1 jmcneill KASSERT(gicv3_softc == NULL);
663 1.1 jmcneill gicv3_softc = sc;
664 1.1 jmcneill
665 1.1 jmcneill for (int i = 0; i < sc->sc_bsh_r_count; i++) {
666 1.1 jmcneill const uint64_t gicr_typer = gicr_read_8(sc, i, GICR_TYPER);
667 1.1 jmcneill const u_int aff0 = __SHIFTOUT(gicr_typer, GICR_TYPER_Affinity_Value_Aff0);
668 1.1 jmcneill const u_int aff1 = __SHIFTOUT(gicr_typer, GICR_TYPER_Affinity_Value_Aff1);
669 1.1 jmcneill const u_int aff2 = __SHIFTOUT(gicr_typer, GICR_TYPER_Affinity_Value_Aff2);
670 1.1 jmcneill const u_int aff3 = __SHIFTOUT(gicr_typer, GICR_TYPER_Affinity_Value_Aff3);
671 1.1 jmcneill
672 1.1 jmcneill aprint_debug_dev(sc->sc_dev, "redist %d: cpu %d.%d.%d.%d\n",
673 1.1 jmcneill i, aff3, aff2, aff1, aff0);
674 1.1 jmcneill }
675 1.1 jmcneill
676 1.1 jmcneill gicv3_dist_enable(sc);
677 1.1 jmcneill
678 1.1 jmcneill gicv3_cpu_init(&sc->sc_pic, curcpu());
679 1.5 jmcneill if ((gicd_typer & GICD_TYPER_LPIS) != 0)
680 1.5 jmcneill gicv3_lpi_cpu_init(&sc->sc_lpi, curcpu());
681 1.1 jmcneill
682 1.1 jmcneill #ifdef __HAVE_PIC_FAST_SOFTINTS
683 1.1 jmcneill intr_establish(SOFTINT_BIO, IPL_SOFTBIO, IST_MPSAFE | IST_EDGE, pic_handle_softint, (void *)SOFTINT_BIO);
684 1.1 jmcneill intr_establish(SOFTINT_CLOCK, IPL_SOFTCLOCK, IST_MPSAFE | IST_EDGE, pic_handle_softint, (void *)SOFTINT_CLOCK);
685 1.1 jmcneill intr_establish(SOFTINT_NET, IPL_SOFTNET, IST_MPSAFE | IST_EDGE, pic_handle_softint, (void *)SOFTINT_NET);
686 1.1 jmcneill intr_establish(SOFTINT_SERIAL, IPL_SOFTSERIAL, IST_MPSAFE | IST_EDGE, pic_handle_softint, (void *)SOFTINT_SERIAL);
687 1.1 jmcneill #endif
688 1.1 jmcneill
689 1.1 jmcneill #ifdef MULTIPROCESSOR
690 1.1 jmcneill intr_establish(IPI_AST, IPL_VM, IST_MPSAFE | IST_EDGE, pic_ipi_ast, (void *)-1);
691 1.1 jmcneill intr_establish(IPI_XCALL, IPL_HIGH, IST_MPSAFE | IST_EDGE, pic_ipi_xcall, (void *)-1);
692 1.1 jmcneill intr_establish(IPI_GENERIC, IPL_HIGH, IST_MPSAFE | IST_EDGE, pic_ipi_generic, (void *)-1);
693 1.1 jmcneill intr_establish(IPI_NOP, IPL_VM, IST_MPSAFE | IST_EDGE, pic_ipi_nop, (void *)-1);
694 1.1 jmcneill intr_establish(IPI_SHOOTDOWN, IPL_SCHED, IST_MPSAFE | IST_EDGE, pic_ipi_shootdown, (void *)-1);
695 1.1 jmcneill #ifdef DDB
696 1.1 jmcneill intr_establish(IPI_DDB, IPL_HIGH, IST_MPSAFE | IST_EDGE, pic_ipi_ddb, NULL);
697 1.1 jmcneill #endif
698 1.1 jmcneill #ifdef __HAVE_PREEMPTION
699 1.1 jmcneill intr_establish(IPI_KPREEMPT, IPL_VM, IST_MPSAFE | IST_EDGE, pic_ipi_kpreempt, (void *)-1);
700 1.1 jmcneill #endif
701 1.1 jmcneill #endif
702 1.1 jmcneill
703 1.1 jmcneill return 0;
704 1.1 jmcneill }
705