From 298a18f6e709e21187fc9d80e8635b1f9c72faff Mon Sep 17 00:00:00 2001 From: tsutsui Date: Wed, 21 Mar 2007 10:56:26 +0000 Subject: [PATCH] Apply MI softintr(9) patch before it becomes rotten. Untested. See also: http://mail-index.netbsd.org/port-atari/2007/03/07/0000.html --- sys/arch/atari/atari/autoconf.c | 7 +++- sys/arch/atari/atari/intr.c | 27 ++++++++++++- sys/arch/atari/atari/locore.s | 5 +-- sys/arch/atari/atari/machdep.c | 72 +++++++++++---------------------- sys/arch/atari/atari/trap.c | 10 ++--- sys/arch/atari/conf/files.atari | 3 +- sys/arch/atari/include/cpu.h | 7 +--- sys/arch/atari/include/intr.h | 44 +++++++++++--------- sys/arch/atari/include/types.h | 3 +- 9 files changed, 92 insertions(+), 86 deletions(-) diff --git a/sys/arch/atari/atari/autoconf.c b/sys/arch/atari/atari/autoconf.c index ad9c83234785..0a83a436abef 100644 --- a/sys/arch/atari/atari/autoconf.c +++ b/sys/arch/atari/atari/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.52 2005/12/11 12:16:54 christos Exp $ */ +/* $NetBSD: autoconf.c,v 1.53 2007/03/21 10:56:26 tsutsui Exp $ */ /* * Copyright (c) 1995 Leo Weppelman @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.52 2005/12/11 12:16:54 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.53 2007/03/21 10:56:26 tsutsui Exp $"); #include #include @@ -63,6 +63,9 @@ cpu_configure() atari_realconfig = 1; + softintr_init(); + init_sicallback(); + if (config_rootfound("mainbus", __UNCONST("mainbus")) == NULL) panic("no mainbus found"); } diff --git a/sys/arch/atari/atari/intr.c b/sys/arch/atari/atari/intr.c index f15955f6ae7b..78192827676a 100644 --- a/sys/arch/atari/atari/intr.c +++ b/sys/arch/atari/atari/intr.c @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.11 2005/12/11 12:16:54 christos Exp $ */ +/* $NetBSD: intr.c,v 1.12 2007/03/21 10:56:26 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.11 2005/12/11 12:16:54 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.12 2007/03/21 10:56:26 tsutsui Exp $"); #include #include @@ -321,3 +321,26 @@ struct clockframe frame; else printf("intr_dispatch: stray level %d interrupt\n", vector); } + +static const int ipl2psl_table[] = { + [IPL_NONE] = PSL_IPL0, + [IPL_SOFT] = PSL_IPL1, + [IPL_SOFTCLOCK] = PSL_IPL1, + [IPL_SOFTNET] = PSL_IPL1, + [IPL_SOFTSERIAL] = PSL_IPL1, + [IPL_BIO] = PSL_IPL3, + [IPL_NET] = PSL_IPL3, + [IPL_TTY] = PSL_IPL4, + /* IPL_LPT == IPL_TTY */ + [IPL_VM] = PSL_IPL4, + [IPL_SERIAL] = PSL_IPL5, + [IPL_CLOCK] = PSL_IPL6, + [IPL_HIGH] = PSL_IPL7, +}; + +ipl_cookie_t +makeiplcookie(ipl_t ipl) +{ + + return (ipl_cookie_t){._psl = ipl2psl_table[ipl] | PSL_S}; +} diff --git a/sys/arch/atari/atari/locore.s b/sys/arch/atari/atari/locore.s index 813f631fc805..0a01de910738 100644 --- a/sys/arch/atari/atari/locore.s +++ b/sys/arch/atari/atari/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.96 2006/09/01 19:11:56 matt Exp $ */ +/* $NetBSD: locore.s,v 1.97 2007/03/21 10:56:26 tsutsui Exp $ */ /* * Copyright (c) 1980, 1990 The Regents of the University of California. @@ -758,7 +758,7 @@ ENTRY_NOPROFILE(lev1intr) movl _C_LABEL(stio_addr),%a0 | get KVA of ST-IO area moveb #0, %a0@(SCU_SOFTINT) | Turn off software interrupt addql #1,_C_LABEL(intrcnt)+16 | add another software interrupt - jbsr _C_LABEL(softint) | handle software interrupts + jbsr _C_LABEL(softintr_dispatch) | XXX handle software interrupts moveml %sp@+,%d0-%d1/%a0-%a1 addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS jra _ASM_LABEL(rei) @@ -803,7 +803,6 @@ ENTRY_NOPROFILE(lev7intr) * point for coprocessor mid-instruction frames (type 9), but we also test * for bus error frames (type 10 and 11). */ - BSS(ssir,1) ASENTRY_NOPROFILE(rei) #ifdef DEBUG tstl _C_LABEL(panicstr) | have we paniced? diff --git a/sys/arch/atari/atari/machdep.c b/sys/arch/atari/atari/machdep.c index 0d306850dcfb..c27f5283ff4f 100644 --- a/sys/arch/atari/atari/machdep.c +++ b/sys/arch/atari/atari/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.143 2007/03/04 05:59:39 christos Exp $ */ +/* $NetBSD: machdep.c,v 1.144 2007/03/21 10:56:26 tsutsui Exp $ */ /* * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.143 2007/03/04 05:59:39 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.144 2007/03/21 10:56:26 tsutsui Exp $"); #include "opt_ddb.h" #include "opt_compat_netbsd.h" @@ -133,7 +133,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.143 2007/03/04 05:59:39 christos Exp $ static void bootsync __P((void)); static void call_sicallbacks __P((void)); static void identifycpu __P((void)); -static void netintr __P((void)); void straymfpint __P((int, u_short)); void straytrap __P((int, u_short)); @@ -695,30 +694,6 @@ u_short evec; evec & 0xFFF, pc); } -/* - * Simulated software interrupt handler - */ -void -softint() -{ - if(ssir & SIR_NET) { - siroff(SIR_NET); - uvmexp.softs++; - netintr(); - } - if(ssir & SIR_CLOCK) { - siroff(SIR_CLOCK); - uvmexp.softs++; - /* XXXX softclock(&frame.f_stackadj); */ - softclock(NULL); - } - if (ssir & SIR_CBACK) { - siroff(SIR_CBACK); - uvmexp.softs++; - call_sicallbacks(); - } -} - int *nofault; int @@ -754,25 +729,6 @@ badbaddr(addr, size) return(0); } -/* - * Network interrupt handling - */ -static void -netintr() -{ -#define DONETISR(bit, fn) do { \ - if (netisr & (1 << bit)) { \ - netisr &= ~(1 << bit); \ - fn(); \ - } \ -} while (0) - -#include - -#undef DONETISR -} - - /* * this is a handy package to have asynchronously executed * function calls executed at very low interrupt priority. @@ -782,18 +738,29 @@ netintr() * Note: the installed functions are currently called in a * LIFO fashion, might want to change this to FIFO * later. + * + * XXX: Some of functions which use this callback should be rewritten + * XXX: to use MI softintr(9) directly. */ struct si_callback { struct si_callback *next; void (*function) __P((void *rock1, void *rock2)); void *rock1, *rock2; }; +static void *si_callback_cookie; static struct si_callback *si_callbacks; static struct si_callback *si_free; #ifdef DIAGNOSTIC static int ncbd; /* number of callback blocks dynamically allocated */ #endif +void init_sicallback(void) +{ + + si_callback_cookie = softintr_establish(IPL_SOFT, + (void (*)(void *))call_sicallbacks, NULL); +} + void add_sicallback (function, rock1, rock2) void (*function) __P((void *rock1, void *rock2)); void *rock1, *rock2; @@ -832,8 +799,17 @@ void *rock1, *rock2; /* * and cause a software interrupt (spl1). This interrupt might * happen immediately, or after returning to a safe enough level. + * + * XXX: + * According to and lev1intr() hander in locore.s, + * at least _ATARIHW_ machines (ATARITT and HADES?) seem to have + * some hardware support which can initiate real hardware interrupt + * at ipl 1 for software interrupt. But as per , + * this feature was not used at all on setsoft*() calls and + * traditional hp300 derived ssir (simulated software interrupt + * request) on VAX REI emulation in locore.s is used. */ - setsoftcback(); + softintr_schedule(si_callback_cookie); } void rem_sicallback(function) @@ -880,7 +856,7 @@ static void call_sicallbacks() rock2 = si->rock2; s = splhigh (); if(si_callbacks) - setsoftcback(); + softintr_schedule(si_callback_cookie); si->next = si_free; si_free = si; splx(s); diff --git a/sys/arch/atari/atari/trap.c b/sys/arch/atari/atari/trap.c index a187cf8169df..1615dc5e42de 100644 --- a/sys/arch/atari/atari/trap.c +++ b/sys/arch/atari/atari/trap.c @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.87 2007/03/04 05:59:39 christos Exp $ */ +/* $NetBSD: trap.c,v 1.88 2007/03/21 10:56:26 tsutsui Exp $ */ /* * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.87 2007/03/04 05:59:39 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.88 2007/03/21 10:56:26 tsutsui Exp $"); #include "opt_ddb.h" #include "opt_execfmt.h" @@ -107,7 +107,6 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.87 2007/03/04 05:59:39 christos Exp $"); #include #include #include -#include #include #ifdef DDB #include @@ -599,8 +598,9 @@ trap(type, code, v, frame) */ case T_SSIR: case T_SSIR|T_USER: - if(ssir) - softint(); + + softintr_dispatch(); + /* * If this was not an AST trap, we are all done. */ diff --git a/sys/arch/atari/conf/files.atari b/sys/arch/atari/conf/files.atari index d029d5ad7809..546c09d1fa62 100644 --- a/sys/arch/atari/conf/files.atari +++ b/sys/arch/atari/conf/files.atari @@ -1,5 +1,5 @@ # -# $NetBSD: files.atari,v 1.108 2005/12/11 12:16:54 christos Exp $ +# $NetBSD: files.atari,v 1.109 2007/03/21 10:56:27 tsutsui Exp $ maxpartitions 16 @@ -211,6 +211,7 @@ file arch/atari/atari/intr.c file arch/m68k/m68k/cacheops.c file arch/m68k/m68k/db_memrw.c ddb file arch/m68k/m68k/procfs_machdep.c procfs +file arch/m68k/m68k/softintr.c file arch/m68k/m68k/sys_machdep.c file arch/m68k/m68k/vm_machdep.c diff --git a/sys/arch/atari/include/cpu.h b/sys/arch/atari/include/cpu.h index 5bb1fe9116f3..8866c5c2ecd2 100644 --- a/sys/arch/atari/include/cpu.h +++ b/sys/arch/atari/include/cpu.h @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.51 2007/03/04 05:59:41 christos Exp $ */ +/* $NetBSD: cpu.h,v 1.52 2007/03/21 10:56:27 tsutsui Exp $ */ /* * Copyright (c) 1982, 1990 The Regents of the University of California. @@ -164,9 +164,6 @@ struct clockframe { extern int astpending; /* need trap before returning to user mode */ extern int want_resched; /* resched() was called */ -/* include support for software interrupts */ -#include - /* * The rest of this should probably be moved to ../atari/ataricpu.h, * although some of it could probably be put into generic 68k headers. @@ -268,11 +265,11 @@ void switch_lwp_exit __P((struct lwp *)); * Prototypes from machdep.c: */ typedef void (*si_farg)(void *, void *); /* XXX */ +void init_sicallback __P((void)); /* XXX */ void add_sicallback __P((si_farg, void *, void *)); void rem_sicallback __P((si_farg)); void dumpsys __P((void)); vaddr_t reserve_dumppages __P((vaddr_t)); -void softint __P((void)); /* diff --git a/sys/arch/atari/include/intr.h b/sys/arch/atari/include/intr.h index 9e904b018ee6..ee2b91355e27 100644 --- a/sys/arch/atari/include/intr.h +++ b/sys/arch/atari/include/intr.h @@ -1,4 +1,4 @@ -/* $NetBSD: intr.h,v 1.14 2007/03/11 05:22:25 thorpej Exp $ */ +/* $NetBSD: intr.h,v 1.15 2007/03/21 10:56:27 tsutsui Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -37,16 +37,22 @@ #define _ATARI_INTR_H_ #define IPL_NONE 0 /* disable no interrupts */ -#define IPL_BIO (PSL_S|PSL_IPL3) /* disable block I/O interrupts */ -#define IPL_NET (PSL_S|PSL_IPL3) /* disable network interrupts */ -#define IPL_TTY (PSL_S|PSL_IPL4) /* disable terminal interrupts */ +#define IPL_SOFTCLOCK 1 +#define IPL_SOFTNET 2 +#define IPL_SOFTSERIAL 3 +#define IPL_SOFT 4 +#define IPL_BIO 5 /* disable block I/O interrupts */ +#define IPL_NET 6 /* disable network interrupts */ +#define IPL_TTY 7 /* disable terminal interrupts */ #define IPL_LPT IPL_TTY -#define IPL_VM (PSL_S|PSL_IPL4) -#define IPL_CLOCK (PSL_S|PSL_IPL6) /* disable clock interrupts */ +#define IPL_VM 8 +#define IPL_SERIAL 9 +#define IPL_CLOCK 10 /* disable clock interrupts */ #define IPL_STATCLOCK IPL_CLOCK -#define IPL_HIGH (PSL_S|PSL_IPL7) /* disable all interrupts */ +#define IPL_HIGH 11 /* disable all interrupts */ #define IPL_SCHED IPL_HIGH #define IPL_LOCK IPL_HIGH +#define NIPL 12 #define IST_UNUSABLE -1 /* interrupt cannot be used */ #define IST_NONE 0 /* none (dummy) */ @@ -63,13 +69,15 @@ #define splnone() spl0() -#define splsoftclock() splraise1() -#define splsoftnet() splraise1() +#define splsoft() splraise1() +#define splsoftclock() splsoft() +#define splsoftnet() splsoft() +#define splsoftserial() splsoft() -#define splbio() _splraise(PSL_S|PSL_IPL3) -#define splnet() _splraise(PSL_S|PSL_IPL3) -#define spltty() _splraise(PSL_S|PSL_IPL4) -#define splvm() _splraise(PSL_S|PSL_IPL4) +#define splbio() splraise3() +#define splnet() splraise3() +#define spltty() splraise4() +#define splvm() splraise4() #define spllpt() spltty() @@ -89,12 +97,7 @@ typedef struct { uint16_t _psl; } ipl_cookie_t; -static inline ipl_cookie_t -makeiplcookie(ipl_t ipl) -{ - - return (ipl_cookie_t){._psl = ipl}; -} +ipl_cookie_t makeiplcookie(ipl_t); static inline int splraiseipl(ipl_cookie_t icookie) @@ -102,6 +105,9 @@ splraiseipl(ipl_cookie_t icookie) return _splraise(icookie._psl); } + +#include + #endif /* _KERNEL */ #endif /* _ATARI_INTR_H_ */ diff --git a/sys/arch/atari/include/types.h b/sys/arch/atari/include/types.h index 9a33e44522ef..54f75090dea2 100644 --- a/sys/arch/atari/include/types.h +++ b/sys/arch/atari/include/types.h @@ -1,8 +1,9 @@ -/* $NetBSD: types.h,v 1.8 2002/02/28 03:17:32 simonb Exp $ */ +/* $NetBSD: types.h,v 1.9 2007/03/21 10:56:27 tsutsui Exp $ */ #ifndef _MACHINE_TYPES_H_ #define _MACHINE_TYPES_H_ #include +#define __HAVE_GENERIC_SOFT_INTERRUPTS #endif