Adapt sun68k ports to recent interrupt handling changes.

XXX: sun2 (m68010) doesn't have CAS instructions.
This commit is contained in:
tsutsui 2007-12-04 15:12:07 +00:00
parent 72127ffc00
commit 2f66d76b2f
9 changed files with 67 additions and 200 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: zs.c,v 1.15 2007/11/09 00:05:06 ad Exp $ */
/* $NetBSD: zs.c,v 1.16 2007/12/04 15:12:07 tsutsui Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.15 2007/11/09 00:05:06 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.16 2007/12/04 15:12:07 tsutsui Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -61,6 +61,7 @@ __KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.15 2007/11/09 00:05:06 ad Exp $");
#include <sys/tty.h>
#include <sys/time.h>
#include <sys/syslog.h>
#include <sys/intr.h>
#include <machine/autoconf.h>
#include <machine/promlib.h>
@ -157,15 +158,19 @@ zs_attach(struct zsc_softc *zsc, struct zsdevice *zsd, int pri)
{
struct zsc_attach_args zsc_args;
struct zs_chanstate *cs;
int s, channel, softpri = IPL_SOFTSERIAL;
int s, channel;
if (zsd == NULL) {
printf("configuration incomplete\n");
return;
}
#if 0
/* we should use ipl2si(softpri) but it isn't exported */
printf(" softpri %d\n", _IPL_SOFT_LEVEL3);
#else
printf("\n");
#endif
/*
* Initialize software state for each channel.
@ -292,7 +297,8 @@ zs_attach(struct zsc_softc *zsc, struct zsdevice *zsd, int pri)
* Now safe to install interrupt handlers.
*/
bus_intr_establish(zsc->zsc_bustag, pri, IPL_SERIAL, 0, zshard, zsc);
if (!(zsc->zsc_softintr = softintr_establish(softpri, zssoft, zsc)))
if (!(zsc->zsc_softintr = softint_establish(SOFTINT_SERIAL,
zssoft, zsc)))
panic("zsattach: could not establish soft interrupt");
evcnt_attach_dynamic(&zsc->zsc_intrcnt, EVCNT_TYPE_INTR, NULL,
@ -342,7 +348,7 @@ zshard(void *arg)
if (((zsc->zsc_cs[0] && zsc->zsc_cs[0]->cs_softreq) ||
(zsc->zsc_cs[1] && zsc->zsc_cs[1]->cs_softreq)) &&
zsc->zsc_softintr) {
softintr_schedule(zsc->zsc_softintr);
softint_schedule(zsc->zsc_softintr);
}
return (rval);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.49 2007/03/16 12:12:14 tsutsui Exp $ */
/* $NetBSD: machdep.c,v 1.50 2007/12/04 15:12:07 tsutsui Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@ -160,7 +160,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.49 2007/03/16 12:12:14 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.50 2007/12/04 15:12:07 tsutsui Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -832,6 +832,7 @@ cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp)
return ENOEXEC;
}
#if 0
/*
* Soft interrupt support.
*/
@ -858,6 +859,7 @@ isr_soft_clear(int level)
bit = 1 << level;
enable_reg_and(~bit);
}
#endif
/*
* Like _bus_dmamap_load(), but for raw memory allocated with

View File

@ -1,4 +1,4 @@
/* $NetBSD: fd.c,v 1.59 2007/10/17 19:57:45 garbled Exp $ */
/* $NetBSD: fd.c,v 1.60 2007/12/04 15:12:07 tsutsui Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.59 2007/10/17 19:57:45 garbled Exp $");
__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.60 2007/12/04 15:12:07 tsutsui Exp $");
#include "opt_ddb.h"
@ -314,7 +314,7 @@ static void fdconf(struct fdc_softc *);
#define IPL_SOFTFD IPL_BIO
#define FDC_SOFTPRI 2
#define FD_SET_SWINTR() softintr_schedule(fdc->sc_si);
#define FD_SET_SWINTR() softint_schedule(fdc->sc_si);
/*
* The Floppy Control Register on the sun3x, not to be confused with the
@ -441,8 +441,12 @@ fdcattach(struct device *parent, struct device *self, void *aux)
}
*fdc->sc_reg_fvr = vec; /* Program controller w/ interrupt vector */
fdc->sc_si = softintr_establish(IPL_SOFTFD, fdcswintr, fdc);
fdc->sc_si = softint_establish(SOFTINT_BIO, fdcswintr, fdc);
#if 0
printf(": (softpri %d) chip 8207%c\n", FDC_SOFTPRI, code);
#else
printf(": chip 8207%c\n", code);
#endif
#ifdef FD_DEBUG
if (out_fdc(fdc, NE7CMD_VERSION) == 0 &&

View File

@ -1,4 +1,4 @@
/* $NetBSD: zs.c,v 1.80 2007/11/09 00:05:06 ad Exp $ */
/* $NetBSD: zs.c,v 1.81 2007/12/04 15:12:07 tsutsui Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.80 2007/11/09 00:05:06 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.81 2007/12/04 15:12:07 tsutsui Exp $");
#include "opt_kgdb.h"
@ -60,11 +60,12 @@ __KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.80 2007/11/09 00:05:06 ad Exp $");
#include <sys/tty.h>
#include <sys/time.h>
#include <sys/syslog.h>
#include <sys/cpu.h>
#include <sys/intr.h>
#include <uvm/uvm_extern.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <machine/mon.h>
#include <machine/z8530var.h>
@ -345,7 +346,7 @@ zs_attach(struct device *parent, struct device *self, void *aux)
didintr = 1;
isr_add_autovect(zshard, NULL, ca->ca_intpri);
}
zsc->zs_si = softintr_establish(IPL_SOFTSERIAL,
zsc->zs_si = softint_establish(SOFTINT_SERIAL,
(void (*)(void *))zsc_intr_soft, zsc);
/* XXX; evcnt_attach() ? */
@ -405,7 +406,7 @@ zshard(void *arg)
softreq = zsc->zsc_cs[0]->cs_softreq;
softreq |= zsc->zsc_cs[1]->cs_softreq;
if (softreq)
softintr_schedule(zsc->zs_si);
softint_schedule(zsc->zs_si);
}
return (rval);

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.71 2007/12/01 11:23:44 tsutsui Exp $ */
/* $NetBSD: autoconf.c,v 1.72 2007/12/04 15:12:07 tsutsui Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.71 2007/12/01 11:23:44 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.72 2007/12/04 15:12:07 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -80,12 +80,6 @@ void
cpu_configure(void)
{
/*
* Install handlers for our "soft" interrupts.
* There might be a better place to do this?
*/
softintr_init();
/* General device autoconfiguration. */
if (config_rootfound("mainbus", NULL) == NULL)
panic("%s: mainbus not found", __func__);

View File

@ -1,4 +1,4 @@
/* $NetBSD: intreg.c,v 1.26 2006/10/10 17:45:43 tsutsui Exp $ */
/* $NetBSD: intreg.c,v 1.27 2007/12/04 15:12:07 tsutsui Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: intreg.c,v 1.26 2006/10/10 17:45:43 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: intreg.c,v 1.27 2007/12/04 15:12:07 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -121,6 +121,7 @@ intreg_attach(struct device *parent, struct device *self, void *args)
}
#if 0
void
isr_soft_request(int level)
{
@ -144,4 +145,4 @@ isr_soft_clear(int level)
bit = 1 << level;
single_inst_bclr_b(*interrupt_reg, bit);
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: intr.h,v 1.16 2007/12/03 15:34:23 ad Exp $ */
/* $NetBSD: intr.h,v 1.17 2007/12/04 15:12:07 tsutsui Exp $ */
/*
* Copyright (c) 2001 Matt Fredette.
@ -121,8 +121,7 @@ _getsr(void)
#define splvm() splraise4()
/* Zilog Serial hardware interrupts (hard-wired at 6) */
#define splzs() splraise6()
#define splserial() splraise6()
#define splzs() splserial()
#define IPL_ZS IPL_SERIAL
/* Block out all interrupts (except NMI of course). */

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.21 2007/12/01 11:41:20 tsutsui Exp $ */
/* $NetBSD: autoconf.c,v 1.22 2007/12/04 15:12:08 tsutsui Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.21 2007/12/01 11:41:20 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.22 2007/12/04 15:12:08 tsutsui Exp $");
#include "opt_kgdb.h"
@ -97,12 +97,6 @@ cpu_configure(void)
#endif /* KGDB */
}
/*
* Install handlers for our "soft" interrupts.
* There might be a better place to do this?
*/
softintr_init();
/* General device autoconfiguration. */
if (config_rootfound("mainbus", NULL) == NULL)
panic("%s: mainbus not found", __func__);

View File

@ -1,4 +1,4 @@
/* $NetBSD: isr.c,v 1.17 2007/10/17 19:57:47 garbled Exp $ */
/* $NetBSD: isr.c,v 1.18 2007/12/04 15:12:08 tsutsui Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -37,26 +37,25 @@
*/
/*
* This handles multiple attach of autovectored interrupts,
* and the handy software interrupt request register.
* This handles multiple attach of autovectored interrupts.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.17 2007/10/17 19:57:47 garbled Exp $");
__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.18 2007/12/04 15:12:08 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/vmmeter.h>
#include <sys/cpu.h>
#include <sys/intr.h>
#include <uvm/uvm_extern.h>
#include <net/netisr.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <machine/intr.h>
#include <machine/mon.h>
#include <sun68k/sun68k/vector.h>
@ -72,15 +71,11 @@ struct isr {
int isr_ipl;
};
/*
* Generic soft interrupt support.
*/
#if 0
#define _IPL_NSOFT (_IPL_SOFT_LEVEL_MAX - _IPL_SOFT_LEVEL_MIN + 1)
#endif
struct softintr_head soft_level_heads[_IPL_NSOFT];
void *softnet_cookie;
static int softintr_handler(void *);
static void netintr(void);
int idepth;
void set_vector_entry(int, void *);
void *get_vector_entry(int);
@ -101,33 +96,6 @@ isr_add_custom(int level, void *handler)
}
/*
* netisr junk...
* should use an array of chars instead of
* a bitmask to avoid atomicity locking issues.
*/
void
netintr(void)
{
int n, s;
s = splhigh();
n = netisr;
netisr = 0;
splx(s);
#define DONETISR(bit, fn) do { \
if (n & (1 << bit)) \
fn(); \
} while (/* CONSTCOND */0)
#include <net/netisr_dispatch.h>
#undef DONETISR
}
static struct isr *isr_autovec_list[NUM_LEVELS];
/*
@ -140,6 +108,10 @@ isr_autovec(struct clockframe cf)
struct isr *isr;
int n, ipl, vec;
#ifdef DIAGNOSTIC
idepth++;
#endif
vec = (cf.cf_vo & 0xFFF) >> 2;
#ifdef DIAGNOSTIC
if ((vec < AUTOVEC_BASE) || (vec >= (AUTOVEC_BASE + NUM_LEVELS)))
@ -168,6 +140,10 @@ isr_autovec(struct clockframe cf)
printf("isr_autovec: ipl %d not claimed\n", ipl);
out:
#ifdef DIAGNOSTIC
idepth--;
#endif
LOCK_CAS_CHECK(&cf);
}
@ -209,6 +185,10 @@ isr_vectored(struct clockframe cf)
struct vector_handler *vh;
int ipl, vec;
#ifdef DIAGNOSTIC
idepth++;
#endif
vec = (cf.cf_vo & 0xFFF) >> 2;
ipl = _getsr();
ipl = (ipl >> 8) & 7;
@ -234,6 +214,9 @@ isr_vectored(struct clockframe cf)
printf("isr_vectored: vector=0x%x (not claimed)\n", vec);
out:
#ifdef DIAGNOSTIC
idepth--;
#endif
LOCK_CAS_CHECK(&cf);
}
@ -262,117 +245,13 @@ isr_add_vectored(isr_func_t func, void *arg, int level, int vec)
set_vector_entry(vec, (void *)_isr_vectored);
}
/*
* Generic soft interrupt support.
*/
/*
* The soft interrupt handler.
*/
static int
softintr_handler(void *arg)
bool
cpu_intr_p(void)
{
struct softintr_head *shd = arg;
struct softintr_handler *sh;
/* Clear the interrupt. */
isr_soft_clear(shd->shd_ipl);
uvmexp.softs++;
/* Dispatch any pending handlers. */
for (sh = LIST_FIRST(&shd->shd_intrs);
sh != NULL;
sh = LIST_NEXT(sh, sh_link)) {
if (sh->sh_pending) {
sh->sh_pending = 0;
(*sh->sh_func)(sh->sh_arg);
}
}
return 1;
return idepth != 0;
}
/*
* This initializes soft interrupts.
*/
void
softintr_init(void)
{
int ipl;
struct softintr_head *shd;
for (ipl = _IPL_SOFT_LEVEL_MIN; ipl <= _IPL_SOFT_LEVEL_MAX; ipl++) {
shd = &soft_level_heads[ipl - _IPL_SOFT_LEVEL_MIN];
shd->shd_ipl = ipl;
LIST_INIT(&shd->shd_intrs);
isr_add_autovect(softintr_handler, shd, ipl);
}
softnet_cookie = softintr_establish(IPL_SOFTNET,
(void (*)(void *))netintr, NULL);
}
static int
ipl2si(ipl_t ipl)
{
int si;
switch (ipl) {
case IPL_SOFTNET:
case IPL_SOFTCLOCK:
si = _IPL_SOFT_LEVEL1;
break;
case IPL_BIO: /* used by fd(4), which uses ipl 6 for hwintr */
si = _IPL_SOFT_LEVEL2;
break;
case IPL_SOFTSERIAL:
si = _IPL_SOFT_LEVEL3;
break;
default:
panic("ipl2si: %d\n", ipl);
}
return si;
}
/*
* This establishes a soft interrupt handler.
*/
void *
softintr_establish(int ipl, void (*func)(void *), void *arg)
{
struct softintr_handler *sh;
struct softintr_head *shd;
int si;
si = ipl2si(ipl);
shd = &soft_level_heads[si - _IPL_SOFT_LEVEL_MIN];
sh = malloc(sizeof(*sh), M_SOFTINTR, M_NOWAIT);
if (sh == NULL)
return NULL;
LIST_INSERT_HEAD(&shd->shd_intrs, sh, sh_link);
sh->sh_head = shd;
sh->sh_pending = 0;
sh->sh_func = func;
sh->sh_arg = arg;
return sh;
}
/*
* This disestablishes a soft interrupt handler.
*/
void
softintr_disestablish(void *arg)
{
struct softintr_handler *sh = arg;
LIST_REMOVE(sh, sh_link);
free(sh, M_SOFTINTR);
}
/*
* XXX - could just kill these...
*/
@ -396,26 +275,13 @@ get_vector_entry(int entry)
static const int ipl2psl_table[] = {
[IPL_NONE] = PSL_IPL0,
[IPL_SOFTBIO] = PSL_IPL1,
[IPL_SOFTCLOCK] = PSL_IPL1,
[IPL_SOFTNET] = PSL_IPL1,
[IPL_BIO] = PSL_IPL2,
[IPL_NET] = PSL_IPL3,
[IPL_SOFTSERIAL] = PSL_IPL3,
[IPL_TTY] = PSL_IPL4,
[IPL_LPT] = PSL_IPL4,
[IPL_VM] = PSL_IPL4,
#if 0
[IPL_AUDIO] =
#endif
[IPL_CLOCK] = PSL_IPL5,
[IPL_STATCLOCK] = PSL_IPL5,
[IPL_SERIAL] = PSL_IPL6,
[IPL_SCHED] = PSL_IPL7,
[IPL_SCHED] = PSL_IPL6,
[IPL_HIGH] = PSL_IPL7,
[IPL_LOCK] = PSL_IPL7,
#if 0
[IPL_IPI] =
#endif
};
ipl_cookie_t