Generic soft interrupt implementation for NetBSD/i386. This could
probably be tuned somewhat, but this is a stop-gap measure to hold us until Bill Sommerfeld's new interrupt code comes in from the MP branch.
This commit is contained in:
parent
c025377acc
commit
8b3fc18a1f
|
@ -1,4 +1,4 @@
|
||||||
# $NetBSD: files.i386,v 1.184 2001/03/25 09:54:11 jdolecek Exp $
|
# $NetBSD: files.i386,v 1.185 2001/04/14 06:49:31 thorpej Exp $
|
||||||
#
|
#
|
||||||
# new style config file for i386 architecture
|
# new style config file for i386 architecture
|
||||||
#
|
#
|
||||||
|
@ -75,6 +75,7 @@ file netns/ns_cksum.c ns
|
||||||
file arch/i386/i386/pmap.c
|
file arch/i386/i386/pmap.c
|
||||||
file arch/i386/i386/process_machdep.c
|
file arch/i386/i386/process_machdep.c
|
||||||
file arch/i386/i386/procfs_machdep.c procfs
|
file arch/i386/i386/procfs_machdep.c procfs
|
||||||
|
file arch/i386/i386/softintr.c
|
||||||
file arch/i386/i386/sys_machdep.c
|
file arch/i386/i386/sys_machdep.c
|
||||||
file arch/i386/i386/syscall.c
|
file arch/i386/i386/syscall.c
|
||||||
file arch/i386/i386/trap.c
|
file arch/i386/i386/trap.c
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: machdep.c,v 1.430 2001/03/15 06:10:40 chs Exp $ */
|
/* $NetBSD: machdep.c,v 1.431 2001/04/14 06:49:31 thorpej Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
|
* Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
|
||||||
|
@ -2264,6 +2264,9 @@ init386(first_avail)
|
||||||
isa_defaultirq();
|
isa_defaultirq();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Initialize software interrupts. */
|
||||||
|
softintr_init();
|
||||||
|
|
||||||
splraise(-1);
|
splraise(-1);
|
||||||
enable_intr();
|
enable_intr();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,170 @@
|
||||||
|
/* $NetBSD: softintr.c,v 1.1 2001/04/14 06:49:30 thorpej Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Jason R. Thorpe.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generic soft interrupt implementation for NetBSD/i386.
|
||||||
|
*
|
||||||
|
* Note: This code is expected to go away when the i386-MP
|
||||||
|
* branch is merged.
|
||||||
|
*
|
||||||
|
* Also note: the netisr processing is left in i386/isa/icu.s
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
|
||||||
|
#include <machine/intr.h>
|
||||||
|
|
||||||
|
#include <uvm/uvm_extern.h>
|
||||||
|
|
||||||
|
struct i386_soft_intr i386_soft_intrs[I386_NSOFTINTR];
|
||||||
|
|
||||||
|
const int i386_soft_intr_to_ssir[I386_NSOFTINTR] = {
|
||||||
|
SIR_CLOCK,
|
||||||
|
SIR_NET,
|
||||||
|
SIR_SERIAL,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* softintr_init:
|
||||||
|
*
|
||||||
|
* Initialize the software interrupt system.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
softintr_init(void)
|
||||||
|
{
|
||||||
|
struct i386_soft_intr *si;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < I386_NSOFTINTR; i++) {
|
||||||
|
si = &i386_soft_intrs[i];
|
||||||
|
TAILQ_INIT(&si->softintr_q);
|
||||||
|
si->softintr_ssir = i386_soft_intr_to_ssir[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* softintr_dispatch:
|
||||||
|
*
|
||||||
|
* Process pending software interrupts.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
softintr_dispatch(int which)
|
||||||
|
{
|
||||||
|
struct i386_soft_intr *si = &i386_soft_intrs[which];
|
||||||
|
struct i386_soft_intrhand *sih;
|
||||||
|
int s;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
i386_softintr_lock(si, s);
|
||||||
|
sih = TAILQ_FIRST(&si->softintr_q);
|
||||||
|
if (sih == NULL) {
|
||||||
|
i386_softintr_unlock(si, s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
TAILQ_REMOVE(&si->softintr_q, sih, sih_q);
|
||||||
|
sih->sih_pending = 0;
|
||||||
|
i386_softintr_unlock(si, s);
|
||||||
|
|
||||||
|
uvmexp.softs++;
|
||||||
|
(*sih->sih_fn)(sih->sih_arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* softintr_establish: [interface]
|
||||||
|
*
|
||||||
|
* Register a software interrupt handler.
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
softintr_establish(int ipl, void (*func)(void *), void *arg)
|
||||||
|
{
|
||||||
|
struct i386_soft_intr *si;
|
||||||
|
struct i386_soft_intrhand *sih;
|
||||||
|
int which;
|
||||||
|
|
||||||
|
switch (ipl) {
|
||||||
|
case IPL_SOFTCLOCK:
|
||||||
|
which = I386_SOFTINTR_SOFTCLOCK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IPL_SOFTNET:
|
||||||
|
which = I386_SOFTINTR_SOFTNET;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IPL_SOFTSERIAL:
|
||||||
|
which = I386_SOFTINTR_SOFTSERIAL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
panic("softintr_establish");
|
||||||
|
}
|
||||||
|
|
||||||
|
si = &i386_soft_intrs[which];
|
||||||
|
|
||||||
|
sih = malloc(sizeof(*sih), M_DEVBUF, M_NOWAIT);
|
||||||
|
if (__predict_true(sih != NULL)) {
|
||||||
|
sih->sih_intrhead = si;
|
||||||
|
sih->sih_fn = func;
|
||||||
|
sih->sih_arg = arg;
|
||||||
|
sih->sih_pending = 0;
|
||||||
|
}
|
||||||
|
return (sih);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* softintr_disestablish: [interface]
|
||||||
|
*
|
||||||
|
* Unregister a software interrupt handler.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
softintr_disestablish(void *arg)
|
||||||
|
{
|
||||||
|
struct i386_soft_intrhand *sih = arg;
|
||||||
|
struct i386_soft_intr *si = sih->sih_intrhead;
|
||||||
|
int s;
|
||||||
|
|
||||||
|
i386_softintr_lock(si, s);
|
||||||
|
if (sih->sih_pending) {
|
||||||
|
TAILQ_REMOVE(&si->softintr_q, sih, sih_q);
|
||||||
|
sih->sih_pending = 0;
|
||||||
|
}
|
||||||
|
i386_softintr_unlock(si, s);
|
||||||
|
|
||||||
|
free(sih, M_DEVBUF);
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
/* $NetBSD: intr.h,v 1.18 2001/04/13 23:30:00 thorpej Exp $ */
|
/* $NetBSD: intr.h,v 1.19 2001/04/14 06:49:32 thorpej Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This code is derived from software contributed to The NetBSD Foundation
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
* by Charles M. Hannum.
|
* by Charles M. Hannum, and by Jason R. Thorpe.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
@ -153,10 +153,66 @@ softintr(mask)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define setsoftast() (astpending = 1)
|
#define setsoftast() (astpending = 1)
|
||||||
#define setsoftclock() softintr(SIR_CLOCK)
|
|
||||||
#define setsoftnet() softintr(SIR_NET)
|
#define setsoftnet() softintr(SIR_NET)
|
||||||
#define setsoftserial() softintr(SIR_SERIAL)
|
|
||||||
|
|
||||||
#endif /* !_LOCORE */
|
#endif /* !_LOCORE */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generic software interrupt support.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define I386_SOFTINTR_SOFTCLOCK 0
|
||||||
|
#define I386_SOFTINTR_SOFTNET 1
|
||||||
|
#define I386_SOFTINTR_SOFTSERIAL 2
|
||||||
|
#define I386_NSOFTINTR 3
|
||||||
|
|
||||||
|
#ifndef _LOCORE
|
||||||
|
#include <sys/queue.h>
|
||||||
|
|
||||||
|
struct i386_soft_intrhand {
|
||||||
|
TAILQ_ENTRY(i386_soft_intrhand)
|
||||||
|
sih_q;
|
||||||
|
struct i386_soft_intr *sih_intrhead;
|
||||||
|
void (*sih_fn)(void *);
|
||||||
|
void *sih_arg;
|
||||||
|
int sih_pending;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct i386_soft_intr {
|
||||||
|
TAILQ_HEAD(, i386_soft_intrhand)
|
||||||
|
softintr_q;
|
||||||
|
int softintr_ssir;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define i386_softintr_lock(si, s) \
|
||||||
|
do { \
|
||||||
|
(s) = splhigh(); \
|
||||||
|
} while (/*CONSTCOND*/0)
|
||||||
|
|
||||||
|
#define i386_softintr_unlock(si, s) \
|
||||||
|
do { \
|
||||||
|
splx((s)); \
|
||||||
|
} while (/*CONSTCOND*/0)
|
||||||
|
|
||||||
|
void *softintr_establish(int, void (*)(void *), void *);
|
||||||
|
void softintr_disestablish(void *);
|
||||||
|
void softintr_init(void);
|
||||||
|
void softintr_dispatch(int);
|
||||||
|
|
||||||
|
#define softintr_schedule(arg) \
|
||||||
|
do { \
|
||||||
|
struct i386_soft_intrhand *__sih = (arg); \
|
||||||
|
struct i386_soft_intr *__si = __sih->sih_intrhead; \
|
||||||
|
int __s; \
|
||||||
|
\
|
||||||
|
i386_softintr_lock(__si, __s); \
|
||||||
|
if (__sih->sih_pending == 0) { \
|
||||||
|
TAILQ_INSERT_TAIL(&__si->softintr_q, __sih, sih_q); \
|
||||||
|
__sih->sih_pending = 1; \
|
||||||
|
softintr(__si->softintr_ssir); \
|
||||||
|
} \
|
||||||
|
i386_softintr_unlock(__si, __s); \
|
||||||
|
} while (/*CONSTCOND*/0)
|
||||||
|
#endif /* _LOCORE */
|
||||||
|
|
||||||
#endif /* !_I386_INTR_H_ */
|
#endif /* !_I386_INTR_H_ */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: types.h,v 1.27 2001/01/07 17:55:40 fvdl Exp $ */
|
/* $NetBSD: types.h,v 1.28 2001/04/14 06:49:32 thorpej Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1990 The Regents of the University of California.
|
* Copyright (c) 1990 The Regents of the University of California.
|
||||||
|
@ -80,5 +80,6 @@ typedef int32_t register_t;
|
||||||
#define __HAVE_SYSCALL_INTERN
|
#define __HAVE_SYSCALL_INTERN
|
||||||
#define __HAVE_MINIMAL_EMUL
|
#define __HAVE_MINIMAL_EMUL
|
||||||
#define __HAVE_OLD_DISKLABEL
|
#define __HAVE_OLD_DISKLABEL
|
||||||
|
#define __HAVE_GENERIC_SOFT_INTERRUPTS
|
||||||
|
|
||||||
#endif /* _MACHTYPES_H_ */
|
#endif /* _MACHTYPES_H_ */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: icu.s,v 1.63 2000/07/02 04:40:37 cgd Exp $ */
|
/* $NetBSD: icu.s,v 1.64 2001/04/14 06:49:32 thorpej Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||||
|
@ -138,10 +138,11 @@ IDTVEC(doreti)
|
||||||
IDTVEC(softserial)
|
IDTVEC(softserial)
|
||||||
movl _C_LABEL(imask) + IPL_SOFTSERIAL * 4,%eax
|
movl _C_LABEL(imask) + IPL_SOFTSERIAL * 4,%eax
|
||||||
movl %eax,_C_LABEL(cpl)
|
movl %eax,_C_LABEL(cpl)
|
||||||
#include "com.h"
|
|
||||||
#if NCOM > 0
|
pushl $I386_SOFTINTR_SOFTSERIAL
|
||||||
call _C_LABEL(comsoft)
|
call _C_LABEL(softintr_dispatch)
|
||||||
#endif
|
addl $4,%esp
|
||||||
|
|
||||||
movl %ebx,_C_LABEL(cpl)
|
movl %ebx,_C_LABEL(cpl)
|
||||||
jmp %esi
|
jmp %esi
|
||||||
|
|
||||||
|
@ -151,6 +152,7 @@ IDTVEC(softnet)
|
||||||
xorl %edi,%edi
|
xorl %edi,%edi
|
||||||
xchgl _C_LABEL(netisr),%edi
|
xchgl _C_LABEL(netisr),%edi
|
||||||
|
|
||||||
|
/* XXX Do the legacy netisrs here for now. */
|
||||||
#define DONETISR(s, c) \
|
#define DONETISR(s, c) \
|
||||||
.globl _C_LABEL(c) ;\
|
.globl _C_LABEL(c) ;\
|
||||||
testl $(1 << s),%edi ;\
|
testl $(1 << s),%edi ;\
|
||||||
|
@ -162,12 +164,20 @@ IDTVEC(softnet)
|
||||||
|
|
||||||
#undef DONETISR
|
#undef DONETISR
|
||||||
|
|
||||||
|
pushl $I386_SOFTINTR_SOFTNET
|
||||||
|
call _C_LABEL(softintr_dispatch)
|
||||||
|
addl $4,%esp
|
||||||
|
|
||||||
movl %ebx,_C_LABEL(cpl)
|
movl %ebx,_C_LABEL(cpl)
|
||||||
jmp %esi
|
jmp %esi
|
||||||
|
|
||||||
IDTVEC(softclock)
|
IDTVEC(softclock)
|
||||||
movl _C_LABEL(imask) + IPL_SOFTCLOCK * 4,%eax
|
movl _C_LABEL(imask) + IPL_SOFTCLOCK * 4,%eax
|
||||||
movl %eax,_C_LABEL(cpl)
|
movl %eax,_C_LABEL(cpl)
|
||||||
call _C_LABEL(softclock)
|
|
||||||
|
pushl $I386_SOFTINTR_SOFTCLOCK
|
||||||
|
call _C_LABEL(softintr_dispatch)
|
||||||
|
addl $4,%esp
|
||||||
|
|
||||||
movl %ebx,_C_LABEL(cpl)
|
movl %ebx,_C_LABEL(cpl)
|
||||||
jmp %esi
|
jmp %esi
|
||||||
|
|
Loading…
Reference in New Issue