Module Name:    src
Committed By:   matt
Date:           Wed Dec 29 08:14:43 UTC 2010

Modified Files:
        src/sys/arch/newsmips/apbus [matt-nb5-mips64]: apbus.c if_snvar.h
        src/sys/arch/newsmips/dev [matt-nb5-mips64]: hb.c scsi_1185.c
        src/sys/arch/newsmips/include [matt-nb5-mips64]: intr.h
        src/sys/arch/newsmips/newsmips [matt-nb5-mips64]: autoconf.c clock.c
            machdep.c news3400.c news5000.c

Log Message:
Adapt to the new interrupt framework.
Use mips_set_wbflush instead of playing preprocessor games.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.21.22.1 src/sys/arch/newsmips/apbus/apbus.c
cvs rdiff -u -r1.12 -r1.12.22.1 src/sys/arch/newsmips/apbus/if_snvar.h
cvs rdiff -u -r1.18 -r1.18.22.1 src/sys/arch/newsmips/dev/hb.c
cvs rdiff -u -r1.19 -r1.19.22.1 src/sys/arch/newsmips/dev/scsi_1185.c
cvs rdiff -u -r1.23 -r1.23.18.1 src/sys/arch/newsmips/include/intr.h
cvs rdiff -u -r1.32 -r1.32.28.1 src/sys/arch/newsmips/newsmips/autoconf.c
cvs rdiff -u -r1.15 -r1.15.78.1 src/sys/arch/newsmips/newsmips/clock.c
cvs rdiff -u -r1.98.10.5 -r1.98.10.6 src/sys/arch/newsmips/newsmips/machdep.c
cvs rdiff -u -r1.19.36.1 -r1.19.36.2 \
    src/sys/arch/newsmips/newsmips/news3400.c
cvs rdiff -u -r1.17 -r1.17.36.1 src/sys/arch/newsmips/newsmips/news5000.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/newsmips/apbus/apbus.c
diff -u src/sys/arch/newsmips/apbus/apbus.c:1.21 src/sys/arch/newsmips/apbus/apbus.c:1.21.22.1
--- src/sys/arch/newsmips/apbus/apbus.c:1.21	Wed Apr  9 15:40:30 2008
+++ src/sys/arch/newsmips/apbus/apbus.c	Wed Dec 29 08:14:42 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: apbus.c,v 1.21 2008/04/09 15:40:30 tsutsui Exp $	*/
+/*	$NetBSD: apbus.c,v 1.21.22.1 2010/12/29 08:14:42 matt Exp $	*/
 
 /*-
  * Copyright (C) 1999 SHIMIZU Ryo.  All rights reserved.
@@ -27,13 +27,16 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: apbus.c,v 1.21 2008/04/09 15:40:30 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apbus.c,v 1.21.22.1 2010/12/29 08:14:42 matt Exp $");
+
+#define __INTR_PRIVATE
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>
 #include <sys/device.h>
 #include <sys/proc.h>
+#include <sys/intr.h>
 
 #include <uvm/uvm_extern.h>
 
@@ -41,7 +44,6 @@
 #include <machine/autoconf.h>
 #define _NEWSMIPS_BUS_DMA_PRIVATE
 #include <machine/bus.h>
-#include <machine/intr.h>
 #include <newsmips/apbus/apbusvar.h>
 
 static int  apbusmatch(device_t, cfdata_t, void *);
@@ -97,6 +99,8 @@
 	struct newsmips_intr *ip;
 	int i;
 
+	mips_set_wbflush(apbus_wbflush);
+
 	*(volatile uint32_t *)(NEWS5000_APBUS_INTST) = 0xffffffff;
 	*(volatile uint32_t *)(NEWS5000_APBUS_INTMSK) = 0xffffffff;
 	*(volatile uint32_t *)(NEWS5000_APBUS_CTRL) = 0x00000004;
@@ -176,9 +180,10 @@
 void
 apbus_wbflush(void)
 {
-	volatile int32_t *wbflush = (uint32_t *)NEWS5000_WBFLUSH;
+	volatile int32_t * const our_wbflush = (int32_t *)NEWS5000_WBFLUSH;
 
-	(void)*wbflush;
+	(*mips_locore_jumpvec.ljv_wbflush)();
+	(void)*our_wbflush;
 }
 
 /*

Index: src/sys/arch/newsmips/apbus/if_snvar.h
diff -u src/sys/arch/newsmips/apbus/if_snvar.h:1.12 src/sys/arch/newsmips/apbus/if_snvar.h:1.12.22.1
--- src/sys/arch/newsmips/apbus/if_snvar.h:1.12	Wed Apr  9 15:40:30 2008
+++ src/sys/arch/newsmips/apbus/if_snvar.h	Wed Dec 29 08:14:42 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_snvar.h,v 1.12 2008/04/09 15:40:30 tsutsui Exp $	*/
+/*	$NetBSD: if_snvar.h,v 1.12.22.1 2010/12/29 08:14:42 matt Exp $	*/
 
 /*
  * Copyright (c) 1991   Algorithmics Ltd (http://www.algor.co.uk)
@@ -32,14 +32,6 @@
 #define	SN_REGSIZE	(SN_NREGS * 4)
 
 #include <mips/locore.h>
-#undef wbflush	/* XXX */
-
-static inline void
-wbflush(void)
-{
-	mips3_wbflush();
-	apbus_wbflush();
-};
 
 /*
  * buffer sizes in 32 bit mode

Index: src/sys/arch/newsmips/dev/hb.c
diff -u src/sys/arch/newsmips/dev/hb.c:1.18 src/sys/arch/newsmips/dev/hb.c:1.18.22.1
--- src/sys/arch/newsmips/dev/hb.c:1.18	Wed Apr  9 15:40:30 2008
+++ src/sys/arch/newsmips/dev/hb.c	Wed Dec 29 08:14:43 2010
@@ -1,15 +1,16 @@
-/*	$NetBSD: hb.c,v 1.18 2008/04/09 15:40:30 tsutsui Exp $	*/
+/*	$NetBSD: hb.c,v 1.18.22.1 2010/12/29 08:14:43 matt Exp $	*/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hb.c,v 1.18 2008/04/09 15:40:30 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hb.c,v 1.18.22.1 2010/12/29 08:14:43 matt Exp $");
 
+#define __INTR_PRIVATE
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/malloc.h>
+#include <sys/intr.h>
 
 #include <machine/autoconf.h>
-#include <machine/intr.h>
 
 #include <newsmips/dev/hbvar.h>
 

Index: src/sys/arch/newsmips/dev/scsi_1185.c
diff -u src/sys/arch/newsmips/dev/scsi_1185.c:1.19 src/sys/arch/newsmips/dev/scsi_1185.c:1.19.22.1
--- src/sys/arch/newsmips/dev/scsi_1185.c:1.19	Wed Apr  9 15:40:30 2008
+++ src/sys/arch/newsmips/dev/scsi_1185.c	Wed Dec 29 08:14:43 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsi_1185.c,v 1.19 2008/04/09 15:40:30 tsutsui Exp $	*/
+/*	$NetBSD: scsi_1185.c,v 1.19.22.1 2010/12/29 08:14:43 matt Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -53,11 +53,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsi_1185.c,v 1.19 2008/04/09 15:40:30 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsi_1185.c,v 1.19.22.1 2010/12/29 08:14:43 matt Exp $");
 
+#define	__INTR_PRIVATE
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
+#include <sys/intr.h>
 
 #include <uvm/uvm_extern.h>
 

Index: src/sys/arch/newsmips/include/intr.h
diff -u src/sys/arch/newsmips/include/intr.h:1.23 src/sys/arch/newsmips/include/intr.h:1.23.18.1
--- src/sys/arch/newsmips/include/intr.h:1.23	Mon Apr 28 20:23:30 2008
+++ src/sys/arch/newsmips/include/intr.h	Wed Dec 29 08:14:43 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.23 2008/04/28 20:23:30 martin Exp $	*/
+/*	$NetBSD: intr.h,v 1.23.18.1 2010/12/29 08:14:43 matt Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -32,56 +32,15 @@
 #ifndef _MACHINE_INTR_H_
 #define _MACHINE_INTR_H_
 
-#define IPL_NONE	0	/* disable only this interrupt */
-#define IPL_SOFTCLOCK	1	/* clock software interrupts (SI 0) */
-#define IPL_SOFTBIO	1	/* bio software interrupts (SI 0) */
-#define IPL_SOFTNET	2	/* network software interrupts (SI 1) */
-#define IPL_SOFTSERIAL	2	/* serial software interrupts (SI 1) */
-#define	IPL_VM		3
-#define IPL_SCHED	4	/* disable clock interrupts */
-#define IPL_HIGH	4	/* disable all interrupts */
-
-#define _IPL_N		5
-
-#define _IPL_SI0_FIRST	IPL_SOFTCLOCK
-#define _IPL_SI0_LAST	IPL_SOFTBIO
-
-#define _IPL_SI1_FIRST	IPL_SOFTNET
-#define _IPL_SI1_LAST	IPL_SOFTSERIAL
+#include <mips/intr.h>
 
 #ifdef _KERNEL
-#ifndef _LOCORE
+#ifdef __INTR_PRIVATE
 
-#include <sys/device.h>
+#include <sys/evcnt.h>
 #include <mips/locore.h>
 
-extern const uint32_t ipl_sr_bits[_IPL_N];
-
-#define spl0()		(void)_spllower(0)
-#define splx(s)		(void)_splset(s)
-
-#define splsoft()	_splraise(ipl_sr_bits[IPL_SOFT])
-
-typedef int ipl_t;
-typedef struct {
-	ipl_t _sr;
-} ipl_cookie_t;
-
-static inline ipl_cookie_t
-makeiplcookie(ipl_t ipl)
-{
-
-	return (ipl_cookie_t){._sr = ipl_sr_bits[ipl]};
-}
-
-static inline int
-splraiseipl(ipl_cookie_t icookie)
-{
-
-	return _splraise(icookie._sr);
-}
-
-#include <sys/spl.h>
+extern const struct ipl_sr_map newmips_ipl_sr_map;
 
 struct newsmips_intrhand {
 	LIST_ENTRY(newsmips_intrhand) ih_q;
@@ -117,18 +76,14 @@
 extern u_int intrcnt[];
 
 /* handle i/o device interrupts */
-#ifdef news3400
-void news3400_intr(uint32_t, uint32_t, uint32_t, uint32_t);
-#endif
-#ifdef news5000
-void news5000_intr(uint32_t, uint32_t, uint32_t, uint32_t);
-#endif
-extern void (*hardware_intr)(uint32_t, uint32_t, uint32_t, uint32_t);
+void news3400_intr(int, vaddr_t, uint32_t);
+void news5000_intr(int, vaddr_t, uint32_t);
+extern void (*hardware_intr)(int, vaddr_t, uint32_t);
 
 extern void (*enable_intr)(void);
 extern void (*disable_intr)(void);
 extern void (*enable_timer)(void);
 
-#endif /* !_LOCORE */
+#endif /* __INTR_PRIVATE */
 #endif /* _KERNEL */
 #endif /* _MACHINE_INTR_H_ */

Index: src/sys/arch/newsmips/newsmips/autoconf.c
diff -u src/sys/arch/newsmips/newsmips/autoconf.c:1.32 src/sys/arch/newsmips/newsmips/autoconf.c:1.32.28.1
--- src/sys/arch/newsmips/newsmips/autoconf.c:1.32	Sat Feb 16 22:02:15 2008
+++ src/sys/arch/newsmips/newsmips/autoconf.c	Wed Dec 29 08:14:43 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.32 2008/02/16 22:02:15 he Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.32.28.1 2010/12/29 08:14:43 matt Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -85,20 +85,22 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.32 2008/02/16 22:02:15 he Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.32.28.1 2010/12/29 08:14:43 matt Exp $");
 
+#define __INTR_PRIVATE
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/buf.h>
 #include <sys/conf.h>
 #include <sys/reboot.h>
 #include <sys/device.h>
+#include <sys/intr.h>
+#include <sys/cpu.h>
 
 #include <dev/scsipi/scsi_all.h>
 #include <dev/scsipi/scsipi_all.h>
 #include <dev/scsipi/scsiconf.h>
 
-#include <machine/cpu.h>
 #include <machine/adrsmap.h>
 #include <machine/romcall.h>
 
@@ -129,7 +131,7 @@
 	/*
 	 * Kick off autoconfiguration
 	 */
-	_splnone();	/* enable all interrupts */
+	spl0();		/* enable all interrupts */
 	splhigh();	/* ...then disable device interrupts */
 
 	if (systype == NEWS3400) {
@@ -144,7 +146,7 @@
 	enable_intr();
 
 	/* Configuration is finished, turn on interrupts. */
-	_splnone();	/* enable all source forcing SOFT_INTs cleared */
+	spl0();		/* enable all source forcing SOFT_INTs cleared */
 }
 
 void

Index: src/sys/arch/newsmips/newsmips/clock.c
diff -u src/sys/arch/newsmips/newsmips/clock.c:1.15 src/sys/arch/newsmips/newsmips/clock.c:1.15.78.1
--- src/sys/arch/newsmips/newsmips/clock.c:1.15	Mon Sep  4 20:33:24 2006
+++ src/sys/arch/newsmips/newsmips/clock.c	Wed Dec 29 08:14:43 2010
@@ -1,4 +1,4 @@
-/*      $NetBSD: clock.c,v 1.15 2006/09/04 20:33:24 tsutsui Exp $	*/
+/*      $NetBSD: clock.c,v 1.15.78.1 2010/12/29 08:14:43 matt Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,15 +41,15 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.15 2006/09/04 20:33:24 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.15.78.1 2010/12/29 08:14:43 matt Exp $");
 
+#define __INTR_PRIVATE
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-
-#include <machine/cpu.h>
-#include <machine/intr.h>
+#include <sys/cpu.h>
+#include <sys/intr.h>
 
 /*
  * Set up the real-time and statistics clocks.  Leave stathz 0 only

Index: src/sys/arch/newsmips/newsmips/machdep.c
diff -u src/sys/arch/newsmips/newsmips/machdep.c:1.98.10.5 src/sys/arch/newsmips/newsmips/machdep.c:1.98.10.6
--- src/sys/arch/newsmips/newsmips/machdep.c:1.98.10.5	Sun Mar 21 17:38:34 2010
+++ src/sys/arch/newsmips/newsmips/machdep.c	Wed Dec 29 08:14:43 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.98.10.5 2010/03/21 17:38:34 cliff Exp $	*/
+/*	$NetBSD: machdep.c,v 1.98.10.6 2010/12/29 08:14:43 matt Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -76,7 +76,7 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.98.10.5 2010/03/21 17:38:34 cliff Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.98.10.6 2010/12/29 08:14:43 matt Exp $");
 
 /* from: Utah Hdr: machdep.c 1.63 91/04/24 */
 
@@ -84,6 +84,8 @@
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
 
+#define __INTR_PRIVATE
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/signalvar.h>
@@ -104,13 +106,13 @@
 #include <sys/syscallargs.h>
 #include <sys/kcore.h>
 #include <sys/ksyms.h>
+#include <sys/cpu.h>
+#include <sys/intr.h>
 
 #include <uvm/uvm_extern.h>
 
 #include <ufs/mfs/mfs_extern.h>		/* mfs_initminiroot() */
 
-#include <machine/cpu.h>
-#include <machine/intr.h>
 #include <machine/reg.h>
 #include <machine/psl.h>
 #include <machine/pte.h>
@@ -156,7 +158,7 @@
 int mem_cluster_cnt;
 
 struct idrom idrom;
-void (*hardware_intr)(uint32_t, uint32_t, uint32_t, uint32_t);
+void (*hardware_intr)(int, vaddr_t, uint32_t);
 void (*enable_intr)(void);
 void (*disable_intr)(void);
 void (*enable_timer)(void);
@@ -597,23 +599,11 @@
 }
 
 void
-cpu_intr(uint32_t status, uint32_t cause, uint32_t pc, uint32_t ipending)
+cpu_intr(int ppl, vaddr_t pc, uint32_t status)
 {
-	struct cpu_info *ci;
-
-	ci = curcpu();
 	uvmexp.intrs++;
 
 	/* device interrupts */
-	ci->ci_idepth++;
-	(*hardware_intr)(status, cause, pc, ipending);
-	ci->ci_idepth--;
-
-#ifdef __HAVE_FAST_SOFTINTS
-	/* software interrupts */
-	ipending &= MIPS_SOFT_INT_MASK;
-	if (ipending == 0)
-		return;
-	softint_process(ipending);
-#endif
+	(*hardware_intr)(ppl, pc, status);
+
 }

Index: src/sys/arch/newsmips/newsmips/news3400.c
diff -u src/sys/arch/newsmips/newsmips/news3400.c:1.19.36.1 src/sys/arch/newsmips/newsmips/news3400.c:1.19.36.2
--- src/sys/arch/newsmips/newsmips/news3400.c:1.19.36.1	Mon Feb  1 04:18:31 2010
+++ src/sys/arch/newsmips/newsmips/news3400.c	Wed Dec 29 08:14:43 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: news3400.c,v 1.19.36.1 2010/02/01 04:18:31 matt Exp $	*/
+/*	$NetBSD: news3400.c,v 1.19.36.2 2010/12/29 08:14:43 matt Exp $	*/
 
 /*-
  * Copyright (C) 1999 Tsubai Masanari.  All rights reserved.
@@ -27,25 +27,24 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: news3400.c,v 1.19.36.1 2010/02/01 04:18:31 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: news3400.c,v 1.19.36.2 2010/12/29 08:14:43 matt Exp $");
 
+#define __INTR_PRIVATE
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/proc.h>
 #include <sys/systm.h>
+#include <sys/cpu.h>
+#include <sys/intr.h>
+
+#include <mips/locore.h>
 
 #include <machine/adrsmap.h>
-#include <machine/cpu.h>
-#include <machine/intr.h>
 #include <machine/psl.h>
 #include <newsmips/newsmips/machid.h>
 
 #include <newsmips/dev/hbvar.h>
 
-#if !defined(FPEMUL)
-void MachFPInterrupt(unsigned, unsigned, unsigned, struct trapframe *);
-#endif
-
 int news3400_badaddr(void *, u_int);
 
 static void news3400_level0_intr(void);
@@ -63,76 +62,67 @@
  * Handle news3400 interrupts.
  */
 void
-news3400_intr(uint32_t status, uint32_t cause, uint32_t pc, uint32_t ipending)
+news3400_intr(int ppl, uint32_t pc, uint32_t status)
 {
-	struct clockframe cf;
-	struct cpu_info *ci;
+	uint32_t ipending;
+	int ipl;
 
-	ci = curcpu();
-	ci->ci_idepth++;
+	while (ppl < (ipl = splintr(&ipending))) {
 
 	/* handle clock interrupts ASAP */
-	if (ipending & MIPS_INT_MASK_2) {
-		int stat;
+		if (ipending & MIPS_INT_MASK_2) {
+			int stat;
 
-		stat = *(volatile uint8_t *)INTST0;
-		stat &= INTST0_TIMINT|INTST0_KBDINT|INTST0_MSINT;
+			stat = *(volatile uint8_t *)INTST0;
+			stat &= INTST0_TIMINT|INTST0_KBDINT|INTST0_MSINT;
 
-		*(volatile uint8_t *)INTCLR0 = stat;
-		if (stat & INTST0_TIMINT) {
-			cf.pc = pc;
-			cf.sr = status;
-			hardclock(&cf);
-			intrcnt[HARDCLOCK_INTR]++;
-			stat &= ~INTST0_TIMINT;
-		}
+			*(volatile uint8_t *)INTCLR0 = stat;
+			if (stat & INTST0_TIMINT) {
+				struct clockframe cf = {
+					.pc = pc,
+					.sr = status,
+					.intr = (curcpu()->ci_idepth > 0),
+				};
+				hardclock(&cf);
+				intrcnt[HARDCLOCK_INTR]++;
+			}
 
-		if (stat)
-			hb_intr_dispatch(2, stat);
+			if (stat)
+				hb_intr_dispatch(2, stat);
 
-		cause &= ~MIPS_INT_MASK_2;
-	}
-	/* If clock interrupts were enabled, re-enable them ASAP. */
-	_splset(MIPS_SR_INT_IE | (status & MIPS_INT_MASK_2));
-
-	if (ipending & MIPS_INT_MASK_5) {
-		*(volatile uint8_t *)INTCLR0 = INTCLR0_PERR;
-		printf("Memory error interrupt(?) at 0x%x\n", pc);
-		cause &= ~MIPS_INT_MASK_5;
-	}
+		}
 
-	/* asynchronous bus error */
-	if (ipending & MIPS_INT_MASK_4) {
-		*(volatile uint8_t *)INTCLR0 = INTCLR0_BERR;
-		cause &= ~MIPS_INT_MASK_4;
-		badaddr_flag = 1;
-	}
+		if (ipending & MIPS_INT_MASK_5) {
+			*(volatile uint8_t *)INTCLR0 = INTCLR0_PERR;
+			printf("Memory error interrupt(?) at 0x%x\n", pc);
+		}
 
-	if (ipending & MIPS_INT_MASK_1) {
-		news3400_level1_intr();
-		cause &= ~MIPS_INT_MASK_1;
-	}
+		/* asynchronous bus error */
+		if (ipending & MIPS_INT_MASK_4) {
+			*(volatile uint8_t *)INTCLR0 = INTCLR0_BERR;
+			badaddr_flag = 1;
+		}
 
-	if (ipending & MIPS_INT_MASK_0) {
-		news3400_level0_intr();
-		cause &= ~MIPS_INT_MASK_0;
-	}
+		if (ipending & MIPS_INT_MASK_1) {
+			news3400_level1_intr();
+		}
 
-	_splset((status & ~cause & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
+		if (ipending & MIPS_INT_MASK_0) {
+			news3400_level0_intr();
+		}
 
-	/* FPU nofiticaition */
-	if (ipending & INT_MASK_FPU) {
-		if (!USERMODE(status))
-			panic("kernel used FPU: PC %x, CR %x, SR %x",
-			      pc, cause, status);
+		/* FPU nofiticaition */
+		if (ipending & INT_MASK_FPU) {
+			if (!USERMODE(status))
+				panic("kernel used FPU: PC %x, SR %x",
+				      pc, status);
 
-		intrcnt[FPU_INTR]++;
+			intrcnt[FPU_INTR]++;
 #if !defined(FPEMUL)
-		MachFPInterrupt(status, cause, pc, curlwp->l_md.md_utf);
+			mips_fpu_intr(pc, curlwp->l_md.md_utf);
 #endif
+		}
 	}
-
-	ci->ci_idepth--;
 }
 
 #define LEVEL0_MASK \

Index: src/sys/arch/newsmips/newsmips/news5000.c
diff -u src/sys/arch/newsmips/newsmips/news5000.c:1.17 src/sys/arch/newsmips/newsmips/news5000.c:1.17.36.1
--- src/sys/arch/newsmips/newsmips/news5000.c:1.17	Mon Dec  3 15:34:05 2007
+++ src/sys/arch/newsmips/newsmips/news5000.c	Wed Dec 29 08:14:43 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: news5000.c,v 1.17 2007/12/03 15:34:05 ad Exp $	*/
+/*	$NetBSD: news5000.c,v 1.17.36.1 2010/12/29 08:14:43 matt Exp $	*/
 
 /*-
  * Copyright (C) 1999 SHIMIZU Ryo.  All rights reserved.
@@ -27,16 +27,17 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: news5000.c,v 1.17 2007/12/03 15:34:05 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: news5000.c,v 1.17.36.1 2010/12/29 08:14:43 matt Exp $");
 
+#define __INTR_PRIVATE
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/timetc.h>
 #include <sys/cpu.h>
+#include <sys/intr.h>
 
 #include <machine/adrsmap.h>
-#include <machine/intr.h>
 
 #include <newsmips/apbus/apbusvar.h>
 #include <newsmips/newsmips/machid.h>
@@ -55,112 +56,102 @@
  * Handle news5000 interrupts.
  */
 void
-news5000_intr(uint32_t status, uint32_t cause, uint32_t pc, uint32_t ipending)
+news5000_intr(int ppl, vaddr_t pc, uint32_t status)
 {
-	struct cpu_info *ci;
+	uint32_t ipending;
+	int ipl;
 
-	ci = curcpu();
-	ci->ci_idepth++;
+	while (ppl < (ipl = splintr(&ipending))) {
 
-	if (ipending & MIPS_INT_MASK_2) {
+		if (ipending & MIPS_INT_MASK_2) {
 #ifdef DEBUG
-		static int l2cnt = 0;
+			static int l2cnt = 0;
 #endif
-		uint32_t int2stat;
-		struct clockframe cf;
+			uint32_t int2stat;
+			struct clockframe cf;
 
-		int2stat = *(volatile uint32_t *)NEWS5000_INTST2;
+			int2stat = *(volatile uint32_t *)NEWS5000_INTST2;
 
 #ifdef DEBUG
-		l2cnt++;
-		if (l2cnt == 50) {
-			*(volatile uint32_t *)NEWS5000_LED_SEC = 1;
-		}
-		if (l2cnt == 100) {
-			*(volatile uint32_t *)NEWS5000_LED_SEC = 0;
-			l2cnt = 0;
-		}
+			l2cnt++;
+			if (l2cnt == 50) {
+				*(volatile uint32_t *)NEWS5000_LED_SEC = 1;
+			}
+			if (l2cnt == 100) {
+				*(volatile uint32_t *)NEWS5000_LED_SEC = 0;
+				l2cnt = 0;
+			}
 #endif
 
-		if (int2stat & NEWS5000_INT2_TIMER0) {
-			*(volatile uint32_t *)NEWS5000_TIMER0 = 1;
+			if (int2stat & NEWS5000_INT2_TIMER0) {
+				*(volatile uint32_t *)NEWS5000_TIMER0 = 1;
 
-			cf.pc = pc;
-			cf.sr = status;
+				cf.pc = pc;
+				cf.sr = status;
 
-			hardclock(&cf);
-			intrcnt[HARDCLOCK_INTR]++;
-		}
+				hardclock(&cf);
+				intrcnt[HARDCLOCK_INTR]++;
+			}
 
-		apbus_wbflush();
-		cause &= ~MIPS_INT_MASK_2;
-	}
-	/* If clock interrupts were enabled, re-enable them ASAP. */
-	_splset(MIPS_SR_INT_IE | (status & MIPS_INT_MASK_2));
+			apbus_wbflush();
+		}
 
-	if (ipending & MIPS_INT_MASK_5) {
-		uint32_t int5stat;
+		if (ipending & MIPS_INT_MASK_5) {
+			uint32_t int5stat;
 
-		int5stat = *(volatile u_int *)NEWS5000_INTST5;
-		printf("level5 interrupt (%08x)\n", int5stat);
+			int5stat = *(volatile u_int *)NEWS5000_INTST5;
+			printf("level5 interrupt (%08x)\n", int5stat);
 
-		apbus_wbflush();
-		cause &= ~MIPS_INT_MASK_5;
-	}
+			apbus_wbflush();
+		}
 
-	if (ipending & MIPS_INT_MASK_4) {
-		uint32_t int4stat;
+		if (ipending & MIPS_INT_MASK_4) {
+			uint32_t int4stat;
 
-		int4stat = *(volatile uint32_t *)NEWS5000_INTST4;
-		printf("level4 interrupt (%08x)\n", int4stat);
-		if (int4stat & NEWS5000_INT4_APBUS) {
-			uint32_t stat;
-
-			stat = *(volatile uint32_t *)NEWS5000_APBUS_INTST;
-			printf("APbus error 0x%04x\n", stat & 0xffff);
-			if (stat & NEWS5000_APBUS_INT_DMAADDR) {
-				printf("DMA Address Error: "
-				    "slot=%x, addr=0x%08x\n",
-				    *(volatile uint32_t *)NEWS5000_APBUS_DER_S,
-				    *(volatile uint32_t *)NEWS5000_APBUS_DER_A);
+			int4stat = *(volatile uint32_t *)NEWS5000_INTST4;
+			printf("level4 interrupt (%08x)\n", int4stat);
+			if (int4stat & NEWS5000_INT4_APBUS) {
+				uint32_t stat;
+
+				stat = *(volatile uint32_t *)NEWS5000_APBUS_INTST;
+				printf("APbus error 0x%04x\n", stat & 0xffff);
+				if (stat & NEWS5000_APBUS_INT_DMAADDR) {
+					printf("DMA Address Error: "
+					    "slot=%x, addr=0x%08x\n",
+					    *(volatile uint32_t *)NEWS5000_APBUS_DER_S,
+					    *(volatile uint32_t *)NEWS5000_APBUS_DER_A);
+				}
+				if (stat & NEWS5000_APBUS_INT_RDTIMEO)
+					printf("IO Read Timeout: addr=0x%08x\n",
+					    *(volatile uint32_t *)NEWS5000_APBUS_BER_A);
+				if (stat & NEWS5000_APBUS_INT_WRTIMEO)
+					printf("IO Write Timeout: addr=0x%08x\n",
+					    *(volatile uint32_t *)NEWS5000_APBUS_BER_A);
+				*(volatile uint32_t *)0xb4c00014 = stat;
 			}
-			if (stat & NEWS5000_APBUS_INT_RDTIMEO)
-				printf("IO Read Timeout: addr=0x%08x\n",
-				    *(volatile uint32_t *)NEWS5000_APBUS_BER_A);
-			if (stat & NEWS5000_APBUS_INT_WRTIMEO)
-				printf("IO Write Timeout: addr=0x%08x\n",
-				    *(volatile uint32_t *)NEWS5000_APBUS_BER_A);
-			*(volatile uint32_t *)0xb4c00014 = stat;
-		}
 
-		apbus_wbflush();
-		cause &= ~MIPS_INT_MASK_4;
-	}
+			apbus_wbflush();
+		}
 
-	if (ipending & MIPS_INT_MASK_3) {
-		uint32_t int3stat;
+		if (ipending & MIPS_INT_MASK_3) {
+			uint32_t int3stat;
 
-		int3stat = *(volatile uint32_t *)NEWS5000_INTST3;
-		printf("level3 interrupt (%08x)\n", int3stat);
+			int3stat = *(volatile uint32_t *)NEWS5000_INTST3;
+			printf("level3 interrupt (%08x)\n", int3stat);
 
-		apbus_wbflush();
-		cause &= ~MIPS_INT_MASK_3;
-	}
+			apbus_wbflush();
+		}
 
-	if (ipending & MIPS_INT_MASK_1) {
-		news5000_level1_intr();
-		apbus_wbflush();
-		cause &= ~MIPS_INT_MASK_1;
-	}
+		if (ipending & MIPS_INT_MASK_1) {
+			news5000_level1_intr();
+			apbus_wbflush();
+		}
 
-	if (ipending & MIPS_INT_MASK_0) {
-		news5000_level0_intr();
-		apbus_wbflush();
-		cause &= ~MIPS_INT_MASK_0;
+		if (ipending & MIPS_INT_MASK_0) {
+			news5000_level0_intr();
+			apbus_wbflush();
+		}
 	}
-
-	ci->ci_idepth--;
-	_splset((status & ~cause & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
 }
 
 

Reply via email to