From 3dc4b63048cdc4a84aa83bfb9b09fd751fb9d077 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 27 Jul 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-07-27 --- ss/dat.h | 1 + ss/l.s | 17 +++++------------ ss/main.c | 14 +++++++++++--- ss/trap.c | 30 ++++++++++++++++++++++++++++-- 4 files changed, 45 insertions(+), 17 deletions(-) diff --git a/ss/dat.h b/ss/dat.h index 50fca1904f541186212b2e3bf57c5340dbe48434..8d5d9f94897747dee07bb12fc1c979c46c08f3de 100644 --- a/ss/dat.h +++ b/ss/dat.h @@ -193,6 +193,7 @@ extern register Mach *m; /* R6 */ extern register User *u; /* R5 */ extern uchar *intrreg; +extern FPsave *initfpp; struct { diff --git a/ss/l.s b/ss/l.s index e83ecbe0d67e1c41d62e9dc77f209baccf36371a..7b4e534b89c57e48dff47615326bbef27391cf3e 100644 --- a/ss/l.s +++ b/ss/l.s @@ -468,15 +468,10 @@ TEXT putsegm(SB), $0 MOVW R8, (R7, 3) RETURN -/* - * in savefpregs and restfpregs, incoming R7 points to doubleword - * below where F0 will go; doubleword align in and backfill FSR - */ TEXT savefpregs(SB), $0 - ADD $8, R7 - ANDN $7, R7 /* now MOVD-aligned */ - MOVW FSR, -4(R7) + MOVW FSR, 0(R7) + ADD $4, R7 MOVD F0, (0*4)(R7) MOVD F2, (2*4)(R7) @@ -520,11 +515,9 @@ TEXT restfpregs(SB), $0 OR $PSREF, R8 MOVW R8, PSR - ADD $8, R7 - ANDN $7, R7 /* now MOVD-aligned */ - OR R0, R0 - - MOVW -4(R7), FSR + NOOP /* wait for PSR to quiesce */ + MOVW 0(R7), FSR + ADD $4, R7 MOVD (0*4)(R7), F0 MOVD (2*4)(R7), F2 diff --git a/ss/main.c b/ss/main.c index 6bac384bb62023e8989e844f999c0652dc58c33b..c1881f40d5a13b973cd910f090e10c093c22325e 100644 --- a/ss/main.c +++ b/ss/main.c @@ -35,6 +35,7 @@ main(void) initseg(); chandevreset(); streaminit(); + swapinit(); userinit(); clockinit(); schedinit(); @@ -112,7 +113,8 @@ init0(void) touser(USTKTOP-(1+MAXSYSARG)*BY2WD); } -FPsave initfp; +FPsave *initfpp; +uchar initfpa[sizeof(FPsave)+7]; void userinit(void) @@ -121,6 +123,7 @@ userinit(void) Segment *s; User *up; KMap *k; + ulong l; p = newproc(); p->pgrp = newpgrp(); @@ -132,8 +135,13 @@ userinit(void) strcpy(p->text, "*init*"); strcpy(p->user, eve); - savefpregs(&initfp); -/* initfp.fsr |= 0x1E << 23; /* trap on all but INEXACT */ + /* must align initfpp to an ODD word boundary */ + l = (ulong)initfpa; + l += 3; + l &= ~7; + l += 4; + initfpp = (FPsave*)l; + savefpregs(initfpp); p->fpstate = FPinit; /* diff --git a/ss/trap.c b/ss/trap.c index 44752d328f22718411cb350218ed2d1fe6f9708b..7dcac7818a1f537921d7fb4b0134e07e65f019a0 100644 --- a/ss/trap.c +++ b/ss/trap.c @@ -95,6 +95,29 @@ excname(ulong tbr) return excbuf; } +/* + * This routine is frightening. See comment in fptrap.c + */ +void +fpquiet(void) +{ + int i; + ulong fsr; + + i = 0; + fsr = getfsr(); + while(fsr & (1<<13)){ + if(fsr & 0x1F){ + print("trap in fpquiet\n"); + break; + } + if(++i > 1000){ + print("fp not quiescent\n"); + break; + } + } +} + void trap(Ureg *ur) { @@ -111,7 +134,8 @@ trap(Ureg *ur) tbr = (ur->tbr&0xFFF)>>4; if(tbr > 16){ /* interrupt */ if(u && u->p->state==Running){ - if(u->p->fpstate == FPactive) { + if(u->p->fpstate == FPactive){ + fpquiet(); savefpregs(&u->fpsave); u->p->fpstate = FPinactive; ur->psr &= ~PSREF; @@ -138,6 +162,7 @@ trap(Ureg *ur) case 1: /* instr. access */ case 9: /* data access */ if(u && u->p->fpstate==FPactive) { + fpquiet(); savefpregs(&u->fpsave); u->p->fpstate = FPinactive; ur->psr &= ~PSREF; @@ -161,7 +186,7 @@ trap(Ureg *ur) case 4: /* floating point disabled */ if(u && u->p){ if(u->p->fpstate == FPinit) - restfpregs(&initfp); + restfpregs(initfpp); else if(u->p->fpstate == FPinactive) restfpregs(&u->fpsave); else @@ -514,6 +539,7 @@ syscall(Ureg *aur) * guarantee anything about registers, */ if(u->p->fpstate == FPactive) { + fpquiet(); u->p->fpstate = FPinit; ur->psr &= ~PSREF; }