diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-03-20 18:39:31 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-03-20 18:39:31 +0000 |
commit | de205eb784cd13060a4e090ea170659a2d3fcb40 (patch) | |
tree | b825d497a58e8c24a4dcad75b0c7852066a7cea8 /sys | |
parent | f5f7f35b190c0ef7d6734b2505ade8930107e47e (diff) |
Switch vax to __HAVE_GENERIC_SOFT_INTERRUPTS.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/vax/conf/files.vax | 67 | ||||
-rw-r--r-- | sys/arch/vax/include/_types.h | 5 | ||||
-rw-r--r-- | sys/arch/vax/include/cpu.h | 4 | ||||
-rw-r--r-- | sys/arch/vax/include/intr.h | 46 | ||||
-rw-r--r-- | sys/arch/vax/vax/autoconf.c | 4 | ||||
-rw-r--r-- | sys/arch/vax/vax/intvec.s | 42 | ||||
-rw-r--r-- | sys/arch/vax/vax/softintr.c | 192 |
7 files changed, 293 insertions, 67 deletions
diff --git a/sys/arch/vax/conf/files.vax b/sys/arch/vax/conf/files.vax index 34c89ba13f0..f0b0cb02e7d 100644 --- a/sys/arch/vax/conf/files.vax +++ b/sys/arch/vax/conf/files.vax @@ -1,4 +1,4 @@ -# $OpenBSD: files.vax,v 1.49 2008/10/10 20:21:39 deraadt Exp $ +# $OpenBSD: files.vax,v 1.50 2009/03/20 18:39:26 miod Exp $ # $NetBSD: files.vax,v 1.60 1999/08/27 20:04:32 ragge Exp $ # # new style config file for vax architecture @@ -161,6 +161,11 @@ major {sd = 20} major {st = 21} major {cd = 22} +# builtin NCR53C95 SCSI Controller on VAXstation 4000 VLC/60/9x +device asc: scsi, ncr53c9x +attach asc at vsbus with asc_vsbus +file arch/vax/vsa/asc_vsbus.c asc needs-flag + # builtin NCR5380 SCSI-controller on VAXstation device ncr: scsi, ncr5380sbc attach ncr at vsbus @@ -350,15 +355,21 @@ file arch/vax/vax/led.c led needs-flag # These are general files needed for compilation. file dev/cninit.c -file arch/vax/vax/locore.c -file arch/vax/vax/mem.c +file arch/vax/vax/autoconf.c +file arch/vax/vax/bus_dma.c +file arch/vax/vax/bus_mem.c file arch/vax/vax/clock.c -file arch/vax/vax/gencons.c vax8600|vax8200|vax780|vax750|vax630|vax650|vax660|vax670|vax680 -file arch/vax/vax/pmap.c -file arch/vax/vax/machdep.c -file arch/vax/vax/ka820.c vax8200 +file arch/vax/vax/conf.c file arch/vax/vax/crx.c vax8200 -file arch/vax/vax/ka630.c vax630 +file arch/vax/vax/cvax.c vax60 | vax650 +file arch/vax/vax/db_disasm.c ddb +file arch/vax/vax/db_machdep.c ddb +file arch/vax/vax/disksubr.c disk | tape +file arch/vax/vax/emulate.s insn_emulate +file arch/vax/vax/findcpu.c +file arch/vax/vax/gencons.c vax8600|vax8200|vax780|vax750|vax630|vax650|vax660|vax670|vax680 +file arch/vax/vax/in_cksum.c inet +file arch/vax/vax/in4_cksum.c inet file arch/vax/vax/ka410.c vax410 file arch/vax/vax/ka43.c vax43 file arch/vax/vax/ka46.c vax46 @@ -366,39 +377,29 @@ file arch/vax/vax/ka48.c vax48 file arch/vax/vax/ka49.c vax49 file arch/vax/vax/ka53.c vax53 file arch/vax/vax/ka60.c vax60 -file arch/vax/vax/emulate.s insn_emulate -file arch/vax/vax/unimpl_emul.s insn_emulate +file arch/vax/vax/ka630.c vax630 file arch/vax/vax/ka650.c vax650 file arch/vax/vax/ka660.c vax660 file arch/vax/vax/ka670.c vax670 file arch/vax/vax/ka680.c vax680 -file arch/vax/vax/vxt.c vxt -file arch/vax/vax/cvax.c vax60 | vax650 +file arch/vax/vax/ka820.c vax8200 +file arch/vax/vax/locore.c +file arch/vax/vax/machdep.c +file arch/vax/vax/mem.c +file arch/vax/vax/mutex.c +file arch/vax/vax/opcodes.c +file arch/vax/vax/pmap.c file arch/vax/vax/scb.c -file arch/vax/vax/conf.c -file arch/vax/vax/urem.s -file arch/vax/vax/udiv.s -file arch/vax/vax/trap.c -file arch/vax/vax/bus_dma.c -file arch/vax/vax/bus_mem.c file arch/vax/vax/sgmap.c +file arch/vax/vax/softintr.c +file arch/vax/vax/trap.c +file arch/vax/vax/udiv.s +file arch/vax/vax/unimpl_emul.s insn_emulate +file arch/vax/vax/urem.s file arch/vax/vax/vm_machdep.c -file arch/vax/vax/findcpu.c -file arch/vax/vax/autoconf.c -file arch/vax/vax/mutex.c -file arch/vax/vax/in_cksum.c inet -file arch/vax/vax/in4_cksum.c inet -file arch/vax/vax/disksubr.c disk | tape -file arch/vax/vax/db_machdep.c ddb -file arch/vax/vax/db_disasm.c ddb -file arch/vax/vax/opcodes.c -file arch/vax/uba/uba_dma.c uba +file arch/vax/vax/vxt.c vxt file arch/vax/vax/wscons_machdep.c wsdisplay | wskbd - -# builtin NCR53C95 SCSI Controller on VAXstation 4000 VLC/60/9x -device asc: scsi, ncr53c9x -attach asc at vsbus with asc_vsbus -file arch/vax/vsa/asc_vsbus.c asc needs-flag +file arch/vax/uba/uba_dma.c uba include "compat/ultrix/files.ultrix" include "compat/vax1k/files.vax1k" diff --git a/sys/arch/vax/include/_types.h b/sys/arch/vax/include/_types.h index 678bd907faf..3de226fcb3a 100644 --- a/sys/arch/vax/include/_types.h +++ b/sys/arch/vax/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.8 2008/07/21 20:50:55 martynas Exp $ */ +/* $OpenBSD: _types.h,v 1.9 2009/03/20 18:39:30 miod Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -116,4 +116,7 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; +/* Feature test macros */ +#define __HAVE_GENERIC_SOFT_INTERRUPTS + #endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/vax/include/cpu.h b/sys/arch/vax/include/cpu.h index 68e9478ee17..d260460a2a3 100644 --- a/sys/arch/vax/include/cpu.h +++ b/sys/arch/vax/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.33 2008/10/15 23:23:50 deraadt Exp $ */ +/* $OpenBSD: cpu.h,v 1.34 2009/03/20 18:39:30 miod Exp $ */ /* $NetBSD: cpu.h,v 1.41 1999/10/21 20:01:36 ragge Exp $ */ /* @@ -100,8 +100,6 @@ extern struct device *booted_from; extern int mastercpu; extern int bootdev; -#define setsoftnet() mtpr(IPL_SOFTNET,PR_SIRR) -#define setsoftclock() mtpr(IPL_SOFTCLOCK,PR_SIRR) /* * Preempt the current process if in interrupt from user mode, * or after the current trap/syscall if in system mode. diff --git a/sys/arch/vax/include/intr.h b/sys/arch/vax/include/intr.h index cc135ccf42f..a567d59f773 100644 --- a/sys/arch/vax/include/intr.h +++ b/sys/arch/vax/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.10 2009/03/15 19:40:40 miod Exp $ */ +/* $OpenBSD: intr.h,v 1.11 2009/03/20 18:39:30 miod Exp $ */ /* $NetBSD: intr.h,v 1.1 1998/08/18 23:55:00 matt Exp $ */ /* @@ -38,8 +38,10 @@ /* Interrupt Priority Levels are not mutually exclusive. */ #define IPL_NONE 0x00 -#define IPL_SOFTCLOCK 0x08 -#define IPL_SOFTNET 0x0c +#define IPL_SOFT 0x08 +#define IPL_SOFTCLOCK 0x09 +#define IPL_SOFTNET 0x0a +#define IPL_SOFTTTY 0x0b #define IPL_BIO 0x15 /* block I/O */ #define IPL_NET 0x15 /* network */ #define IPL_TTY 0x16 /* terminal */ @@ -121,4 +123,42 @@ void splassert_check(int, const char *); #define splsoftassert(wantipl) do { /* nothing */ } while (0) #endif +#define SI_SOFT 0 /* for IPL_SOFT */ +#define SI_SOFTCLOCK 1 /* for IPL_SOFTCLOCK */ +#define SI_SOFTNET 2 /* for IPL_SOFTNET */ +#define SI_SOFTTTY 3 /* for IPL_SOFTTTY */ + +#define SI_NQUEUES 4 + +#ifndef _LOCORE + +#include <machine/mutex.h> +#include <sys/queue.h> + +struct soft_intrhand { + TAILQ_ENTRY(soft_intrhand) sih_list; + void (*sih_func)(void *); + void *sih_arg; + struct soft_intrq *sih_siq; + int sih_pending; +}; + +struct soft_intrq { + TAILQ_HEAD(, soft_intrhand) siq_list; + int siq_si; + struct mutex siq_mtx; +}; + +void softintr_disestablish(void *); +void *softintr_establish(int, void (*)(void *), void *); +void softintr_init(void); +void softintr_schedule(void *); + +/* XXX For legacy software interrupts. */ +extern struct soft_intrhand *softnet_intrhand; + +#define setsoftnet() softintr_schedule(softnet_intrhand) + +#endif /* _LOCORE */ + #endif /* _VAX_INTR_H */ diff --git a/sys/arch/vax/vax/autoconf.c b/sys/arch/vax/vax/autoconf.c index 82d551c8439..6ff47efb8bd 100644 --- a/sys/arch/vax/vax/autoconf.c +++ b/sys/arch/vax/vax/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.31 2008/08/18 23:19:29 miod Exp $ */ +/* $OpenBSD: autoconf.c,v 1.32 2009/03/20 18:39:30 miod Exp $ */ /* $NetBSD: autoconf.c,v 1.45 1999/10/23 14:56:05 ragge Exp $ */ /* @@ -77,6 +77,8 @@ int booted_partition; /* defaults to 0 (aka 'a' partition) */ void cpu_configure() { + softintr_init(); + if (config_rootfound("mainbus", NULL) == NULL) panic("mainbus not configured"); diff --git a/sys/arch/vax/vax/intvec.s b/sys/arch/vax/vax/intvec.s index 3b0e6b35e16..875f922326e 100644 --- a/sys/arch/vax/vax/intvec.s +++ b/sys/arch/vax/vax/intvec.s @@ -1,4 +1,4 @@ -/* $OpenBSD: intvec.s,v 1.22 2008/08/18 23:05:38 miod Exp $ */ +/* $OpenBSD: intvec.s,v 1.23 2009/03/20 18:39:30 miod Exp $ */ /* $NetBSD: intvec.s,v 1.39 1999/06/28 08:20:48 itojun Exp $ */ /* @@ -121,11 +121,11 @@ _rpb: NOVEC; # Unused, 94 NOVEC; # Unused, 98 NOVEC; # Unused, 9C - INTVEC(softclock,ISTACK) # Software clock interrupt - NOVEC; # Unused, A4 - NOVEC; # Unused, A8 - NOVEC; # Unused, AC - INTVEC(netint, ISTACK) # Network interrupt + INTVEC(softintr,ISTACK) # Software interrupts (IPL_SOFT) + INTVEC(softintr,ISTACK) # Software interrupts (IPL_SOFTCLOCK) + INTVEC(softintr,ISTACK) # Software interrupts (IPL_SOFTNET) + INTVEC(softintr,ISTACK) # Software interrupts (IPL_SOFTTTY) + NOVEC; # Unused, B0 NOVEC; # Unused, B4 NOVEC; # Unused, B8 INTVEC(ddbtrap, ISTACK) # Kernel debugger trap, BC @@ -192,7 +192,7 @@ L4: addl2 (sp)+,sp # remove info pushed on stack 2: movl _memtest,(sp) # REI to new address rei - TRAPCALL(invkstk, T_KSPNOTVAL) +TRAPCALL(invkstk, T_KSPNOTVAL) ENTRY(privinflt) # Privileged/unimplemented instruction #ifdef INSN_EMULATE @@ -202,9 +202,9 @@ ENTRY(privinflt) # Privileged/unimplemented instruction pushl $T_PRIVINFLT jbr trap - TRAPCALL(xfcflt, T_XFCFLT); - TRAPCALL(resopflt, T_RESOPFLT) - TRAPCALL(resadflt, T_RESADFLT) +TRAPCALL(xfcflt, T_XFCFLT); +TRAPCALL(resopflt, T_RESOPFLT) +TRAPCALL(resadflt, T_RESADFLT) /* * Translation fault, used only when simulating page reference bit. @@ -244,10 +244,10 @@ access_v: ptelen: movl $T_PTELEN, (sp) # PTE must expand (or send segv) jbr trap; - TRAPCALL(tracep, T_TRCTRAP) - TRAPCALL(breakp, T_BPTFLT) +TRAPCALL(tracep, T_TRCTRAP) +TRAPCALL(breakp, T_BPTFLT) - TRAPARGC(arithflt, T_ARITHFLT) +TRAPARGC(arithflt, T_ARITHFLT) ENTRY(syscall) # Main system call pushl $T_SYSCALL @@ -277,26 +277,16 @@ ENTRY(sbiflt) pushab sbifltmsg calls $1, _panic - TRAPCALL(astintr, T_ASTFLT) +TRAPCALL(astintr, T_ASTFLT) - FASTINTR(softclock,softclock) +FASTINTR(softintr,softintr_dispatch) .data .global _netisr _netisr: .long 0 # scheduling bits for network -ENTRY(netint) - PUSHR -/* XXX this relies on -traditional-cpp, since we can't use _C_LABEL here */ -#define DONETISR(bit, fn) \ - bbcc $bit,_netisr,1f; calls $0,_/**/fn; 1: -#include <net/netisr_dispatch.h> -#undef DONETISR - POPR - rei - - TRAPCALL(ddbtrap, T_KDBTRAP) +TRAPCALL(ddbtrap, T_KDBTRAP) ENTRY(hardclock) mtpr $0xc1,$PR_ICCS # Reset interrupt flag diff --git a/sys/arch/vax/vax/softintr.c b/sys/arch/vax/vax/softintr.c new file mode 100644 index 00000000000..13cd95c6c53 --- /dev/null +++ b/sys/arch/vax/vax/softintr.c @@ -0,0 +1,192 @@ +/* $OpenBSD: softintr.c,v 1.1 2009/03/20 18:39:30 miod Exp $ */ +/* $NetBSD: softintr.c,v 1.2 2003/07/15 00:24:39 lukem Exp $ */ + +/* + * Copyright (c) 2001 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Jason R. Thorpe for Wasabi Systems, Inc. + * + * 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 for the NetBSD Project by + * Wasabi Systems, Inc. + * 4. The name of Wasabi Systems, Inc. may not be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC + * 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. + */ + +#include <sys/param.h> +#include <sys/malloc.h> + +/* XXX Network interrupts should be converted to new softintrs. */ +#include <net/netisr.h> + +#include <uvm/uvm_extern.h> + +#include <machine/atomic.h> +#include <machine/intr.h> +#include <machine/mtpr.h> + +void softintr_dispatch(void); + +struct soft_intrq soft_intrq[SI_NQUEUES]; + +struct soft_intrhand *softnet_intrhand; + +void netintr(void); + +/* + * Initialize the software interrupt system. + */ +void +softintr_init(void) +{ + struct soft_intrq *siq; + int i; + + for (i = 0; i < SI_NQUEUES; i++) { + siq = &soft_intrq[i]; + TAILQ_INIT(&siq->siq_list); + siq->siq_si = IPL_SOFT + i; + mtx_init(&siq->siq_mtx, IPL_HIGH); + } + + /* XXX Establish legacy software interrupt handlers. */ + softnet_intrhand = softintr_establish(IPL_SOFTNET, + (void (*)(void *))netintr, NULL); +} + +/* + * Process pending software interrupts. The corresponding queue is + * computed from the current interrupt level. + */ +void +softintr_dispatch() +{ + struct soft_intrq *siq; + struct soft_intrhand *sih; + int si; + + si = mfpr(PR_IPL) - IPL_SOFT; + siq = &soft_intrq[si]; + + for (;;) { + mtx_enter(&siq->siq_mtx); + sih = TAILQ_FIRST(&siq->siq_list); + if (sih == NULL) { + mtx_leave(&siq->siq_mtx); + break; + } + + TAILQ_REMOVE(&siq->siq_list, sih, sih_list); + sih->sih_pending = 0; + + uvmexp.softs++; + + mtx_leave(&siq->siq_mtx); + + (*sih->sih_func)(sih->sih_arg); + } +} + +/* + * Register a software interrupt handler. + */ +void * +softintr_establish(int ipl, void (*func)(void *), void *arg) +{ + struct soft_intrhand *sih; + int si; + + si = ipl - IPL_SOFT; + if (si < 0 || si > SI_NQUEUES) { + printf("softintr_establish: unknown soft IPL %d\n", ipl); + return NULL; + } + + sih = malloc(sizeof(*sih), M_DEVBUF, M_NOWAIT); + if (__predict_true(sih != NULL)) { + sih->sih_func = func; + sih->sih_arg = arg; + sih->sih_siq = &soft_intrq[si]; + sih->sih_pending = 0; + } + return (sih); +} + +/* + * Unregister a software interrupt handler. + */ +void +softintr_disestablish(void *arg) +{ + struct soft_intrhand *sih = arg; + struct soft_intrq *siq = sih->sih_siq; + + mtx_enter(&siq->siq_mtx); + if (sih->sih_pending) { + TAILQ_REMOVE(&siq->siq_list, sih, sih_list); + sih->sih_pending = 0; + } + mtx_leave(&siq->siq_mtx); + + free(sih, M_DEVBUF); +} + +/* + * Schedule a software interrupt. + */ +void +softintr_schedule(void *arg) +{ + struct soft_intrhand *sih = (struct soft_intrhand *)arg; + struct soft_intrq *siq = sih->sih_siq; + + mtx_enter(&siq->siq_mtx); + if (sih->sih_pending == 0) { + TAILQ_INSERT_TAIL(&siq->siq_list, sih, sih_list); + sih->sih_pending = 1; + mtpr(siq->siq_si, PR_SIRR); + } + mtx_leave(&siq->siq_mtx); +} + +int netisr; + +void +netintr(void) +{ + int n; + + while ((n = netisr) != 0) { + atomic_clearbits_int(&netisr, n); +#define DONETISR(bit, fn) \ + do { \ + if (n & (1 << (bit))) \ + fn(); \ + } while (0) +#include <net/netisr_dispatch.h> +#undef DONETISR + } +} |