M gnot/fns.h => gnot/fns.h +1 -0
@@ 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*);
M gnot/l.s => gnot/l.s +5 -0
@@ 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 */
M gnot/screen.c => gnot/screen.c +5 -1
@@ 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){
M pc/vga.c => pc/vga.c +0 -2
@@ 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
M port/devbit.c => port/devbit.c +2 -2
@@ 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);
M port/taslock.c => port/taslock.c +6 -10
@@ 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)
M ss/clock.c => ss/clock.c +2 -1
@@ 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;
M ss/main.c => ss/main.c +3 -7
@@ 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
M ss/mmu.c => ss/mmu.c +0 -45
@@ 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
M ss/screen.c => ss/screen.c +6 -1
@@ 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){
M ss/trap.c => ss/trap.c +19 -17
@@ 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<USERADDR+BY2PG; l+=4){
v = *(ulong*)l;
- if(KTZERO < v && v < (ulong)&etext)
+ if(KTZERO < v && v < (ulong)&etext){
print("%lux=%lux ", l, v);
- ++i;
- if((i&7) == 0)
- print("\n");
+ ++i;
+ if((i&3) == 0)
+ print("\n");
+ }
}
}
+ print("\n");
}
void