Deleted Added
full compact
obio.c (182901) obio.c (183173)
1/*-
2 * Copyright (c) 2007, Oleksandr Tymoshenko <gonzo@freebsd.org>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 17 unchanged lines hidden (view full) ---

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.
31 */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2007, Oleksandr Tymoshenko <gonzo@freebsd.org>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 17 unchanged lines hidden (view full) ---

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.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/mips/idt/obio.c 182901 2008-09-10 03:49:08Z gonzo $");
34__FBSDID("$FreeBSD: head/sys/mips/idt/obio.c 183173 2008-09-19 04:10:09Z imp $");
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/bus.h>
39#include <sys/interrupt.h>
40#include <sys/kernel.h>
41#include <sys/module.h>
42#include <sys/rman.h>

--- 225 unchanged lines hidden (view full) ---

268
269 irq = rman_get_start(ires);
270
271 if (irq >= NIRQS)
272 panic("%s: bad irq %d", __func__, irq);
273
274 event = sc->sc_eventstab[irq];
275 if (event == NULL) {
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/bus.h>
39#include <sys/interrupt.h>
40#include <sys/kernel.h>
41#include <sys/module.h>
42#include <sys/rman.h>

--- 225 unchanged lines hidden (view full) ---

268
269 irq = rman_get_start(ires);
270
271 if (irq >= NIRQS)
272 panic("%s: bad irq %d", __func__, irq);
273
274 event = sc->sc_eventstab[irq];
275 if (event == NULL) {
276 error = intr_event_create(&event, (void *)irq, 0,
276 error = intr_event_create(&event, (void *)irq, 0, irq,
277 (mask_fn)obio_mask_irq, (mask_fn)obio_unmask_irq,
278 NULL, NULL,
279 "obio intr%d:", irq);
280
281 sc->sc_eventstab[irq] = event;
282 }
283
284 intr_event_add_handler(event, device_get_nameunit(child), filt,

--- 38 unchanged lines hidden (view full) ---

323 return (result);
324}
325
326static int
327obio_intr(void *arg)
328{
329 struct obio_softc *sc = arg;
330 struct intr_event *event;
277 (mask_fn)obio_mask_irq, (mask_fn)obio_unmask_irq,
278 NULL, NULL,
279 "obio intr%d:", irq);
280
281 sc->sc_eventstab[irq] = event;
282 }
283
284 intr_event_add_handler(event, device_get_nameunit(child), filt,

--- 38 unchanged lines hidden (view full) ---

323 return (result);
324}
325
326static int
327obio_intr(void *arg)
328{
329 struct obio_softc *sc = arg;
330 struct intr_event *event;
331 struct intr_handler *ih;
332 uint32_t irqstat, ipend, imask, xpend;
331 uint32_t irqstat, ipend, imask, xpend;
333 int irq, thread, group, i, ret;
332 int irq, thread, group, i;
334
335 irqstat = 0;
336 irq = 0;
337 for (group = 2; group <= 6; group++) {
338 ipend = ICU_REG_READ(ICU_GROUP_IPEND_REG(group));
339 imask = ICU_REG_READ(ICU_GROUP_MASK_REG(group));
340 xpend = ipend;
341 ipend &= ~imask;
342
343 while ((i = fls(xpend)) != 0) {
344 xpend &= ~(1 << (i - 1));
345 irq = IP_IRQ(group, i - 1);
346 }
347
348 while ((i = fls(ipend)) != 0) {
349 ipend &= ~(1 << (i - 1));
350 irq = IP_IRQ(group, i - 1);
351 event = sc->sc_eventstab[irq];
352 thread = 0;
333
334 irqstat = 0;
335 irq = 0;
336 for (group = 2; group <= 6; group++) {
337 ipend = ICU_REG_READ(ICU_GROUP_IPEND_REG(group));
338 imask = ICU_REG_READ(ICU_GROUP_MASK_REG(group));
339 xpend = ipend;
340 ipend &= ~imask;
341
342 while ((i = fls(xpend)) != 0) {
343 xpend &= ~(1 << (i - 1));
344 irq = IP_IRQ(group, i - 1);
345 }
346
347 while ((i = fls(ipend)) != 0) {
348 ipend &= ~(1 << (i - 1));
349 irq = IP_IRQ(group, i - 1);
350 event = sc->sc_eventstab[irq];
351 thread = 0;
353#ifndef INTR_FILTER
354 obio_mask_irq(irq);
355#endif
356 if (!event || TAILQ_EMPTY(&event->ie_handlers)) {
352 if (!event || TAILQ_EMPTY(&event->ie_handlers)) {
357#ifdef INTR_FILTER
358 obio_unmask_irq(irq);
359#endif
353 /* TODO: Log stray IRQs */
360 continue;
361 }
362
354 continue;
355 }
356
363#ifdef INTR_FILTER
364 /* TODO: frame instead of NULL? */
365 intr_event_handle(event, NULL);
366 /* XXX: Log stray IRQs */
357 /* TODO: frame instead of NULL? */
358 intr_event_handle(event, NULL);
359 /* XXX: Log stray IRQs */
367#else
368 /* Execute fast handlers. */
369 TAILQ_FOREACH(ih, &event->ie_handlers,
370 ih_next) {
371 if (ih->ih_filter == NULL)
372 thread = 1;
373 else
374 ret = ih->ih_filter(ih->ih_argument);
375 /*
376 * Wrapper handler special case: see
377 * intr_execute_handlers() in
378 * i386/intr_machdep.c
379 */
380 if (!thread) {
381 if (ret == FILTER_SCHEDULE_THREAD)
382 thread = 1;
383 }
384 }
385
386 /* Schedule thread if needed. */
387 if (thread)
388 intr_event_schedule_thread(event);
389 else
390 obio_unmask_irq(irq);
391 }
392 }
360 }
361 }
393#endif
394#if 0
395 ipend = ICU_REG_READ(ICU_IPEND2);
396 printf("ipend2 = %08x!\n", ipend);
397
398 ipend = ICU_REG_READ(ICU_IPEND3);
399 printf("ipend3 = %08x!\n", ipend);
400
401 ipend = ICU_REG_READ(ICU_IPEND4);

--- 113 unchanged lines hidden ---
362#if 0
363 ipend = ICU_REG_READ(ICU_IPEND2);
364 printf("ipend2 = %08x!\n", ipend);
365
366 ipend = ICU_REG_READ(ICU_IPEND3);
367 printf("ipend3 = %08x!\n", ipend);
368
369 ipend = ICU_REG_READ(ICU_IPEND4);

--- 113 unchanged lines hidden ---