From 5bae185f421c34e2cca7d11e4e493c7940e74233 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 14 Sep 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-09-14 --- gnot/fns.h | 1 + gnot/l.s | 5 +++++ gnot/screen.c | 6 +++++- pc/vga.c | 2 -- port/devbit.c | 4 ++-- port/taslock.c | 16 ++++++---------- ss/clock.c | 3 ++- ss/main.c | 10 +++------- ss/mmu.c | 45 --------------------------------------------- ss/screen.c | 7 ++++++- ss/trap.c | 36 +++++++++++++++++++----------------- 11 files changed, 49 insertions(+), 86 deletions(-) diff --git a/gnot/fns.h b/gnot/fns.h index f3b4059a2439d2b61a25d03eeb94393c10ce5e0a..924b972bbe21c5e11ae5c973b321cd526320fcdf 100644 --- a/gnot/fns.h +++ b/gnot/fns.h @@ -19,6 +19,7 @@ void fpregrestore(char*); void fpregsave(char*); void fprestore(FPsave*); void fpsave(FPsave*); +ulong getsr(void); #define icflush(a, b) void incontoggle(void); KMap* kmap(Page*); diff --git a/gnot/l.s b/gnot/l.s index 03d2f52a67b55dd649124bcd9f5129681b8df055..23437af475e2b581b3ee1816f8ebe211d297dab6 100644 --- a/gnot/l.s +++ b/gnot/l.s @@ -330,6 +330,11 @@ TEXT duartreadtimer+0(SB), $0 MOVW R1, SR RTS +TEXT getsr+0(SB), $0 + MOVL $0, R0 + MOVW SR, R0 + RTS + GLOBL mousetab(SB), $128 DATA mousetab+ 0(SB)/4, -1 /* x down, */ DATA mousetab+ 4(SB)/4, 1 /* y up */ diff --git a/gnot/screen.c b/gnot/screen.c index c59e1758f75717fc064e33922b676f8cf6acf3a8..f07a65b928284cf7b9c599618938e92034d45531 100644 --- a/gnot/screen.c +++ b/gnot/screen.c @@ -67,7 +67,11 @@ screenputs(char *s, int n) int i; char buf[4]; - lock(&screenlock); + if(getsr() & 0x0700){ + if(!canlock(&screenlock)) + return; /* don't deadlock trying to print in interrupt */ + }else + lock(&screenlock); while(n > 0){ i = chartorune(&r, s); if(i == 0){ diff --git a/pc/vga.c b/pc/vga.c index 38a73d5f177efba95aac69fa3a45585854ab88a1..00a51b2e74d3d223db1052c610faf3db45798f33 100644 --- a/pc/vga.c +++ b/pc/vga.c @@ -277,7 +277,6 @@ screenputs(char *s, int n) int i; char buf[4]; - lock(&screenlock); while(n > 0){ i = chartorune(&r, s); if(i == 0){ @@ -306,7 +305,6 @@ screenputs(char *s, int n) out.pos = gsubfstring(&gscreen, out.pos, defont, buf, flipD[S]); } } - unlock(&screenlock); } int diff --git a/port/devbit.c b/port/devbit.c index 98549596c56c8e379aff0d287c65514702ea628f..db23e3bba4004233c2627ebf15bbee470bced8f9 100644 --- a/port/devbit.c +++ b/port/devbit.c @@ -251,10 +251,10 @@ bitreset(void) ulong r; Arena *a; - memmove(&bdefont0, defont, sizeof(*defont)); - bdefont = &bdefont0; if(!conf.monitor) return; + memmove(&bdefont0, defont, sizeof(*defont)); + bdefont = &bdefont0; bit.map = smalloc(DMAP*sizeof(GBitmap*)); bit.nmap = DMAP; getcolor(0, &r, &r, &r); diff --git a/port/taslock.c b/port/taslock.c index 31c25b562777ee6781db1b721866f9e95be6b0ea..fae34ae1e4f329b30f3873fb6b7ae66d2c175b28 100644 --- a/port/taslock.c +++ b/port/taslock.c @@ -8,24 +8,22 @@ void lock(Lock *l) { - Lock *ll = l; int i; ulong pc; pc = getcallerpc(((uchar*)&l) - sizeof(l)); - for(i = 0; i < 100000000; i++){ - if (tas(&ll->key) == 0){ + + for(i = 0; i < 10000000; i++){ + if (tas(&l->key) == 0){ if(u) u->p->hasspin = 1; - ll->pc = pc; + l->pc = pc; return; } } - i = l->key; l->key = 0; - - panic("lock loop 0x%lux key 0x%lux pc 0x%lux held by pc 0x%lux\n", l, i, - pc, l->pc); + panic("lock loop 0x%lux key 0x%lux pc 0x%lux held by pc 0x%lux\n", + l->key, i, pc, l->pc); } int @@ -42,8 +40,6 @@ canlock(Lock *l) void unlock(Lock *l) { - int s; - l->pc = 0; l->key = 0; if(u && u->p) diff --git a/ss/clock.c b/ss/clock.c index e93cd733b75204e83a6ce5a45d5bcefb82c69bc9..141eb8348e2018ee442d2af3d07c04912d4a930d 100644 --- a/ss/clock.c +++ b/ss/clock.c @@ -65,7 +65,8 @@ clock(Ureg *ur) kproftimer(ur->pc); if(m->fpunsafe) return; - if((ur->psr&SPL(0xF))==0 && p && p->state==Running){ + + if((ur->psr&SPL(0xF))==0 && p && p->state==Running) { if(anyready()){ if(p->hasspin) p->hasspin = 0; diff --git a/ss/main.c b/ss/main.c index f18a6d38f8ccfc610ca53ced85640f0f6c0e1c3b..84c78b7d93c439be98d1e8b317be408a885c54b3 100644 --- a/ss/main.c +++ b/ss/main.c @@ -146,7 +146,6 @@ init0(void) kproc("alarm", alarmkproc, 0); chandevinit(); - if(!waserror()){ ksetterm("sun %s"); ksetenv("cputype", "sparc"); @@ -291,12 +290,9 @@ confinit(void) putw4(va, INVALIDPTE); /* - * Look for a frame buffer. This isn't done the way the - * ROM does it. Instead we ask if we know the machine type - * and just use the builtin frame buffer if we can. Otherwise - * we just look in slot 3 which is where it usually is. - * The ROM scans the slots in a specified order and uses - * the first one it finds. Too much bother. + * Look for a frame buffer. Do it the way the + * ROM does it: scan the slots in a specified order and use + * the first one it finds. * * If we find a frame buffer, we always use it as a console * rather than the attached terminal, if any. This means diff --git a/ss/mmu.c b/ss/mmu.c index 055c37e25346160d170fbc391ab290f12e46e939..4dff6b14f820d82f0bd76f2515117c1c21764f1e 100644 --- a/ss/mmu.c +++ b/ss/mmu.c @@ -5,51 +5,6 @@ #include "fns.h" #include "io.h" -#define SERIALPORT 0xF0000000 /* MMU bypass */ - -static int -rawputc(int c) -{ - if(c == '\n') - rawputc('\r'); - while((getsysspaceb(SERIALPORT+4) & (1<<2)) == 0) - delay(10); - putsysspaceb(SERIALPORT+6, c); - if(c == '\n') - delay(20); - return c; -} - -void -rawputs(char *s) -{ - while(*s) - rawputc(*s++); -} - -void -rawprint(char *fmt, ...) -{ - char buf[PRINTSIZE]; - - doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)); - rawputs(buf); -} - -static void -rawpanic(char *fmt, ...) -{ - char buf[PRINTSIZE]; - int s; - - s = splhi(); - doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)); - rawputs("rawpanic: "); - rawputs(buf); - systemreset(); - splx(s); -} - /* * WARNING: Even though all MMU data is in the mach structure or * pointed to by it, this code will not work on a multi-processor diff --git a/ss/screen.c b/ss/screen.c index cfbb91207f685843bc84b3b07cf123d88d3d52d8..184f818e602071ab1e7cc829d7a93d261d2c7a84 100644 --- a/ss/screen.c +++ b/ss/screen.c @@ -168,7 +168,12 @@ screenputs(char *s, int n) if(!conf.monitor) return; - lock(&screenlock); + + if((getpsr()&SPL(15))){ + if(!canlock(&screenlock)) + return; /* don't deadlock trying to print in interrupt */ + }else + lock(&screenlock); while(n > 0){ i = chartorune(&r, s); if(i == 0){ diff --git a/ss/trap.c b/ss/trap.c index 48b21422cdb8651e1433585710f8c30717f59420..5d581619d05a0613ab201aaf2a1e07cfec9e7374 100644 --- a/ss/trap.c +++ b/ss/trap.c @@ -99,7 +99,7 @@ excname(ulong tbr) void trap(Ureg *ur) { - int user, x, fpunsafe; + int user, x; char buf[64]; ulong tbr, iw; @@ -113,7 +113,6 @@ trap(Ureg *ur) if(u) u->dbgreg = ur; - fpunsafe = 0; user = !(ur->psr&PSRPSUPER); /* SS2 bug: flush cache line holding trap entry in table */ if(conf.ss2cachebug) @@ -122,8 +121,8 @@ trap(Ureg *ur) if(u && u->p->state==Running){ /* if active, FPop at head of Q is probably an excep */ if(u->p->fpstate == FPactive){ - fpunsafe = 1; - m->fpunsafe = 1; + fpquiet(); + savefpregs(&u->fpsave); u->p->fpstate = FPinactive; } } @@ -151,8 +150,8 @@ trap(Ureg *ur) case 1: /* instr. access */ case 9: /* data access */ if(u && u->p->fpstate==FPactive) { - fpunsafe = 1; - m->fpunsafe = 1; + fpquiet(); + savefpregs(&u->fpsave); u->p->fpstate = FPinactive; } if(u){ @@ -205,11 +204,6 @@ trap(Ureg *ur) panic("kernel trap: %s pc=0x%lux\n", excname(tbr), ur->pc); } Return: - /* - * Handled the interrupt; now it's safe to look at the FPQ - */ - if(fpunsafe) - fpquiet(); if(user){ notify(ur); if(u->p->fpstate == FPinactive) { @@ -366,19 +360,27 @@ dumpstack(void) ulong l, v; int i; extern ulong etext; -print("no dumpstack\n"); -return; + static int dumping; + + if(dumping == 1){ + print("no dumpstack\n"); + return; + } + + dumping = 1; if(u){ i = 0; for(l=(ulong)&l; l