summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-11-09 17:46:04 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-11-09 17:46:04 +0000
commit89e6d77f7431193536f6e8be4383159bd21cb002 (patch)
tree54259a8a970d27a4f5506b4974c70ffa780295ae /sys
parent5b7265cc919c67ef59625027826fb5ed597a57d4 (diff)
IPL_xxx values on hp300 are logical values (although some of them happen to
match the real hardware level used for them). So instead of keeping a few loose variables to store the runtime computed psr bits to use for the logical IPL levels, just keep a complete array of all psr values. Thus we can have a correct splassert_check().
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/hp300/dev/dma.c4
-rw-r--r--sys/arch/hp300/hp300/intr.c70
-rw-r--r--sys/arch/hp300/include/intr.h32
3 files changed, 58 insertions, 48 deletions
diff --git a/sys/arch/hp300/dev/dma.c b/sys/arch/hp300/dev/dma.c
index ec2bca48bd5..4a3ff45eb9e 100644
--- a/sys/arch/hp300/dev/dma.c
+++ b/sys/arch/hp300/dev/dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dma.c,v 1.17 2005/11/17 23:56:02 miod Exp $ */
+/* $OpenBSD: dma.c,v 1.18 2007/11/09 17:46:00 miod Exp $ */
/* $NetBSD: dma.c,v 1.19 1997/05/05 21:02:39 thorpej Exp $ */
/*
@@ -209,7 +209,7 @@ dmacomputeipl()
* Our interrupt level must be as high as the highest
* device using DMA (i.e. splbio).
*/
- sc->sc_isr.isr_ipl = PSLTOIPL(hp300_bioipl);
+ sc->sc_isr.isr_ipl = PSLTOIPL(hp300_varpsl[IPL_BIO]);
sc->sc_isr.isr_func = dmaintr;
intr_establish(&sc->sc_isr, "dma");
diff --git a/sys/arch/hp300/hp300/intr.c b/sys/arch/hp300/hp300/intr.c
index 05efee7f737..3b65b31e911 100644
--- a/sys/arch/hp300/hp300/intr.c
+++ b/sys/arch/hp300/hp300/intr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.c,v 1.19 2007/11/09 17:32:27 miod Exp $ */
+/* $OpenBSD: intr.c,v 1.20 2007/11/09 17:46:01 miod Exp $ */
/* $NetBSD: intr.c,v 1.5 1998/02/16 20:58:30 thorpej Exp $ */
/*-
@@ -63,12 +63,24 @@ void netintr(void);
* of the vector table.
*/
#define ISRLOC 0x18
-#define NISR 8
typedef LIST_HEAD(, isr) isr_list_t;
isr_list_t isr_list[NISR];
-u_short hp300_bioipl, hp300_netipl, hp300_ttyipl, hp300_vmipl;
+/*
+ * Default interrupt priorities.
+ * IPL_BIO, IPL_NET, IPL_TTY and IPL_VM will be adjusted when devices attach.
+ */
+u_short hp300_varpsl[NISR] = {
+ PSL_S | PSL_IPL0, /* IPL_NONE */
+ PSL_S | PSL_IPL1, /* IPL_SOFT */
+ PSL_S | PSL_IPL3, /* IPL_BIO */
+ PSL_S | PSL_IPL3, /* IPL_NET */
+ PSL_S | PSL_IPL3, /* IPL_TTY */
+ PSL_S | PSL_IPL3, /* IPL_VM */
+ PSL_S | PSL_IPL6, /* IPL_CLOCK */
+ PSL_S | PSL_IPL7 /* IPL_HIGH */
+};
void intr_computeipl(void);
@@ -80,10 +92,6 @@ intr_init()
/* Initialize the ISR lists. */
for (i = 0; i < NISR; ++i)
LIST_INIT(&isr_list[i]);
-
- /* Default interrupt priorities. */
- hp300_bioipl = hp300_netipl = hp300_ttyipl = hp300_vmipl =
- (PSL_S|PSL_IPL3);
}
/*
@@ -97,8 +105,8 @@ intr_computeipl()
int ipl;
/* Start with low values. */
- hp300_bioipl = hp300_netipl = hp300_ttyipl = hp300_vmipl =
- (PSL_S|PSL_IPL3);
+ hp300_varpsl[IPL_BIO] = hp300_varpsl[IPL_NET] =
+ hp300_varpsl[IPL_TTY] = hp300_varpsl[IPL_VM] = PSL_S | PSL_IPL3;
for (ipl = 0; ipl < NISR; ipl++) {
LIST_FOREACH(isr, &isr_list[ipl], isr_link) {
@@ -108,23 +116,23 @@ intr_computeipl()
*/
switch (isr->isr_priority) {
case IPL_BIO:
- if (ipl > PSLTOIPL(hp300_bioipl))
- hp300_bioipl = IPLTOPSL(ipl);
+ if (ipl > PSLTOIPL(hp300_varpsl[IPL_BIO]))
+ hp300_varpsl[IPL_BIO] = IPLTOPSL(ipl);
break;
case IPL_NET:
- if (ipl > PSLTOIPL(hp300_netipl))
- hp300_netipl = IPLTOPSL(ipl);
+ if (ipl > PSLTOIPL(hp300_varpsl[IPL_NET]))
+ hp300_varpsl[IPL_NET] = IPLTOPSL(ipl);
break;
case IPL_TTY:
- if (ipl > PSLTOIPL(hp300_ttyipl))
- hp300_ttyipl = IPLTOPSL(ipl);
+ if (ipl > PSLTOIPL(hp300_varpsl[IPL_TTY]))
+ hp300_varpsl[IPL_TTY] = IPLTOPSL(ipl);
break;
default:
- printf("priority = %d\n", isr->isr_priority);
- panic("intr_computeipl: bad priority");
+ panic("intr_computeipl: bad priority %d",
+ isr->isr_priority);
}
}
}
@@ -133,14 +141,14 @@ intr_computeipl()
* Enforce `bio <= net <= tty <= vm'
*/
- if (hp300_netipl < hp300_bioipl)
- hp300_netipl = hp300_bioipl;
+ if (hp300_varpsl[IPL_NET] < hp300_varpsl[IPL_BIO])
+ hp300_varpsl[IPL_NET] = hp300_varpsl[IPL_BIO];
- if (hp300_ttyipl < hp300_netipl)
- hp300_ttyipl = hp300_netipl;
+ if (hp300_varpsl[IPL_TTY] < hp300_varpsl[IPL_NET])
+ hp300_varpsl[IPL_TTY] = hp300_varpsl[IPL_NET];
- if (hp300_vmipl < hp300_ttyipl)
- hp300_vmipl = hp300_ttyipl;
+ if (hp300_varpsl[IPL_VM] < hp300_varpsl[IPL_TTY])
+ hp300_varpsl[IPL_VM] = hp300_varpsl[IPL_TTY];
}
void
@@ -149,12 +157,13 @@ intr_printlevels()
#ifdef DEBUG
printf("psl: bio = 0x%x, net = 0x%x, tty = 0x%x, vm = 0x%x\n",
- hp300_bioipl, hp300_netipl, hp300_ttyipl, hp300_vmipl);
+ hp300_varpsl[IPL_BIO], hp300_varpsl[IPL_NET],
+ hp300_varpsl[IPL_TTY], hp300_varpsl[IPL_VM]);
#endif
printf("interrupt levels: bio = %d, net = %d, tty = %d\n",
- PSLTOIPL(hp300_bioipl), PSLTOIPL(hp300_netipl),
- PSLTOIPL(hp300_ttyipl));
+ PSLTOIPL(hp300_varpsl[IPL_BIO]), PSLTOIPL(hp300_varpsl[IPL_NET]),
+ PSLTOIPL(hp300_varpsl[IPL_TTY]));
}
/*
@@ -304,19 +313,20 @@ netintr()
void
splassert_check(int wantipl, const char *func)
{
- int oldipl;
+ int oldipl, realwantipl;
__asm __volatile ("movew sr,%0" : "=&d" (oldipl));
+ realwantipl = PSLTOIPL(hp300_varpsl[wantipl]);
oldipl = PSLTOIPL(oldipl);
- if (oldipl < wantipl) {
- splassert_fail(wantipl, oldipl, func);
+ if (oldipl < realwantipl) {
+ splassert_fail(realwantipl, oldipl, func);
/*
* If the splassert_ctl is set to not panic, raise the ipl
* in a feeble attempt to reduce damage.
*/
- _spl(PSL_S | IPLTOPSL(wantipl));
+ _spl(hp300_varpsl[wantipl]);
}
}
#endif
diff --git a/sys/arch/hp300/include/intr.h b/sys/arch/hp300/include/intr.h
index 9676a0f3c01..a151adebb6b 100644
--- a/sys/arch/hp300/include/intr.h
+++ b/sys/arch/hp300/include/intr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.h,v 1.21 2007/11/09 17:32:27 miod Exp $ */
+/* $OpenBSD: intr.h,v 1.22 2007/11/09 17:46:03 miod Exp $ */
/* $NetBSD: intr.h,v 1.2 1997/07/24 05:43:08 scottr Exp $ */
/*-
@@ -54,14 +54,7 @@ struct isr {
struct evcount isr_count;
};
-/*
- * These four globals contain the appropriate PSL_S|PSL_IPL? values
- * to raise interrupt priority to the requested level.
- */
-extern unsigned short hp300_bioipl;
-extern unsigned short hp300_netipl;
-extern unsigned short hp300_ttyipl;
-extern unsigned short hp300_vmipl;
+#define NISR 8
/*
* Interrupt "levels". These are a more abstract representation
@@ -74,23 +67,30 @@ extern unsigned short hp300_vmipl;
#define IPL_NONE 0
#define IPL_SOFTNET 1
#define IPL_SOFTCLOCK 1
-#define IPL_BIO 1
-#define IPL_NET 2
-#define IPL_TTY 3
+#define IPL_BIO 2
+#define IPL_NET 3
+#define IPL_TTY 4
+#define IPL_VM 5
#define IPL_CLOCK 6
#define IPL_STATCLOCK 6
#define IPL_HIGH 7
+/*
+ * This array contains the appropriate PSL_S|PSL_IPL? values
+ * to raise interrupt priority to the requested level.
+ */
+extern unsigned short hp300_varpsl[NISR];
+
/* These spl calls are used by machine-independent code. */
#define splsoft() _splraise(PSL_S | PSL_IPL1)
#define splsoftclock() splsoft()
#define splsoftnet() splsoft()
-#define splbio() _splraise(hp300_bioipl)
-#define splnet() _splraise(hp300_netipl)
-#define spltty() _splraise(hp300_ttyipl)
+#define splbio() _splraise(hp300_varpsl[IPL_BIO])
+#define splnet() _splraise(hp300_varpsl[IPL_NET])
+#define spltty() _splraise(hp300_varpsl[IPL_TTY])
#define splclock() _splraise(PSL_S | PSL_IPL6)
#define splstatclock() _splraise(PSL_S | PSL_IPL6)
-#define splvm() _splraise(hp300_vmipl)
+#define splvm() _splraise(hp300_varpsl[IPL_VM])
#define splhigh() _spl(PSL_S | PSL_IPL7)
#define splsched() splhigh()