Unify splraiseipl(9) implementation among m68k ports as per

suggestion from isaki@ on port-m68k.

For cesfic (compile test only):
- use static splraise4() for splvm() and remove isrcomputeipl() for IPL_VM
  because this port supports only one model
- make makeiplcookie(9) return PSL bits via ipl2psl_table[] rather than
  ipl indexes
- make ipl2psl_table[] uint16_t rather than int
This commit is contained in:
tsutsui 2008-06-22 16:34:15 +00:00
parent 836c01beb6
commit 152476802f
4 changed files with 22 additions and 102 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.18 2007/12/03 15:33:24 ad Exp $ */
/* $NetBSD: autoconf.c,v 1.19 2008/06/22 16:34:15 tsutsui Exp $ */
/*
* Copyright (c) 1997, 1999
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.18 2007/12/03 15:33:24 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.19 2008/06/22 16:34:15 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -160,8 +160,6 @@ cpu_configure()
(void)spl0();
cold = 0;
isrprintlevels();
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: isr.c,v 1.9 2008/05/03 23:17:03 martin Exp $ */
/* $NetBSD: isr.c,v 1.10 2008/06/22 16:34:15 tsutsui Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.9 2008/05/03 23:17:03 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.10 2008/06/22 16:34:15 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -52,8 +52,6 @@ isr_list_t isr_list[NISR];
extern int intrcnt[]; /* from locore.s */
void isrcomputeipl __P((void));
void
isrinit()
{
@ -65,78 +63,6 @@ isrinit()
}
}
/*
* Scan all of the ISRs, recomputing the interrupt levels for the spl*()
* calls. This doesn't have to be fast.
*/
void
isrcomputeipl()
{
struct isr *isr;
int ipl;
int biospl, netspl, ttyspl, vmspl;
/* Start with low values. */
biospl = netspl = ttyspl = vmspl = (PSL_S|PSL_IPL3);
for (ipl = 0; ipl < NISR; ipl++) {
for (isr = isr_list[ipl].lh_first; isr != NULL;
isr = isr->isr_link.le_next) {
/*
* Bump up the level for a given priority,
* if necessary.
*/
switch (isr->isr_priority) {
case ISRPRI_BIO:
if (ipl > PSLTOIPL(biospl))
biospl = IPLTOPSL(ipl);
break;
case ISRPRI_NET:
if (ipl > PSLTOIPL(netspl))
netspl = IPLTOPSL(ipl);
break;
case ISRPRI_TTY:
case ISRPRI_TTYNOBUF:
if (ipl > PSLTOIPL(ttyspl))
ttyspl = IPLTOPSL(ipl);
break;
default:
printf("priority = %d\n", isr->isr_priority);
panic("isrcomputeipl: bad priority");
}
}
}
/*
* Enforce `bio <= net <= tty <= vm'
*/
if (netspl < biospl)
netspl = biospl;
if (ttyspl < netspl)
ttyspl = netspl;
if (vmspl < ttyspl)
vmspl = ttyspl;
ipl2spl_table[IPL_VM] = vmspl;
}
void
isrprintlevels()
{
#ifdef DEBUG
printf("psl: vm = 0x%x\n", ipl2spl_table[IPL_VM]);
#endif
printf("interrupt levels: vm = %d\n", PSLTOIPL(ipl2spl_table[IPL_VM]));
}
/*
* Establish an interrupt handler.
* Called by driver attach functions.
@ -190,7 +116,7 @@ isrlink(func, arg, ipl, priority)
list = &isr_list[ipl];
if (list->lh_first == NULL) {
LIST_INSERT_HEAD(list, newisr, isr_link);
goto compute;
goto done;
}
/*
@ -202,7 +128,7 @@ isrlink(func, arg, ipl, priority)
curisr = curisr->isr_link.le_next) {
if (newisr->isr_priority > curisr->isr_priority) {
LIST_INSERT_BEFORE(curisr, newisr, isr_link);
goto compute;
goto done;
}
}
@ -212,9 +138,7 @@ isrlink(func, arg, ipl, priority)
*/
LIST_INSERT_AFTER(curisr, newisr, isr_link);
compute:
/* Compute new interrupt levels. */
isrcomputeipl();
done:
return (newisr);
}
@ -230,7 +154,6 @@ isrunlink(arg)
LIST_REMOVE(isr, isr_link);
free(isr, M_DEVBUF);
isrcomputeipl();
}
#endif
@ -292,13 +215,13 @@ cpu_intr_p(void)
return idepth != 0;
}
int ipl2spl_table[NIPL] = {
const uint16_t ipl2psl_table[NIPL] = {
[IPL_NONE] = PSL_S|PSL_IPL0,
[IPL_SOFTCLOCK] = PSL_S|PSL_IPL1,
[IPL_SOFTBIO] = PSL_S|PSL_IPL1,
[IPL_SOFTNET] = PSL_S|PSL_IPL1,
[IPL_SOFTSERIAL] = PSL_S|PSL_IPL1,
[IPL_VM] = PSL_S|PSL_IPL3,
[IPL_VM] = PSL_S|PSL_IPL4,
[IPL_SCHED] = PSL_S|PSL_IPL6,
[IPL_HIGH] = PSL_S|PSL_IPL6,
[IPL_HIGH] = PSL_S|PSL_IPL7,
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: isr.h,v 1.2 2008/05/03 23:17:03 martin Exp $ */
/* $NetBSD: isr.h,v 1.3 2008/06/22 16:34:15 tsutsui Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -67,4 +67,3 @@ void isrinit __P((void));
void *isrlink __P((int (*)(void *), void *, int, int));
void isrunlink __P((void *));
void isrdispatch __P((int));
void isrprintlevels __P((void));

View File

@ -1,4 +1,4 @@
/* $NetBSD: intr.h,v 1.9 2007/12/03 15:33:26 ad Exp $ */
/* $NetBSD: intr.h,v 1.10 2008/06/22 16:34:15 tsutsui Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@ -99,7 +99,7 @@
#define splsoftbio() splraise1()
#define splsoftnet() splraise1()
#define splsoftserial() splraise1()
#define splvm() _splraise(ipl2spl_table[IPL_VM])
#define splvm() splraise4()
#define splsched() spl6()
#define splhigh() spl7()
@ -118,25 +118,25 @@ int spl0 __P((void));
#define IPL_HIGH 7
#define NIPL 8
extern int ipl2spl_table[NIPL];
extern const uint16_t ipl2psl_table[NIPL];
typedef int ipl_t;
typedef struct {
uint16_t _ipl;
uint16_t _psl;
} ipl_cookie_t;
static inline ipl_cookie_t
makeiplcookie(ipl_t ipl)
{
return (ipl_cookie_t){._ipl = ipl};
return (ipl_cookie_t){._psl = ipl2psl_table[ipl]};
}
static inline int
splraiseipl(ipl_cookie_t icookie)
{
return _splraise(ipl2spl_table[icookie._ipl]);
return _splraise(icookie._psl);
}
#include <m68k/softintr.h>