From 82a008e85162e5080b3b87ee59fa829c7d1bd375 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 30 Nov 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-11-30 --- power/dat.h | 4 ---- power/mmu.c | 16 ++++++---------- power/trap.c | 20 ++++++++------------ 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/power/dat.h b/power/dat.h index 21518b8ecc63509c1ed551629cd40fa466c23049..36eec58d9a7fec588ccb388cef63be0b2cbf9592 100644 --- a/power/dat.h +++ b/power/dat.h @@ -109,10 +109,6 @@ struct Mach int load; int intr; int ledval; /* value last written to LED */ -ulong cause; -ulong status; -ulong ur; -ulong sp; int stack[1]; }; diff --git a/power/mmu.c b/power/mmu.c index aef0f7bfaf46d2f528751bde5716e835ce743077..39635632545fdd4d852f7cb51ec6885982764d43 100644 --- a/power/mmu.c +++ b/power/mmu.c @@ -14,7 +14,6 @@ mapstack(Proc *p) ulong tlbvirt, tlbphys; if(p->newtlb) { - /* see flushmmu. */ memset(p->pidonmach, 0, sizeof p->pidonmach); p->newtlb = 0; } @@ -22,12 +21,9 @@ mapstack(Proc *p) tp = p->pidonmach[m->machno]; if(tp == 0) tp = newtlbpid(p); -/* if(p->upage->va != (USERADDR|(p->pid&0xFFFF)) && p->pid != 0) - panic("mapstack %d 0x%lux 0x%lux", p->pid, p->upage->pa, p->upage->va); -*/ - /* don't set m->pidhere[tp] because we're only writing entry 0 */ + tlbvirt = USERADDR | PTEPID(tp); - tlbphys = p->upage->pa | PTEWRITE | PTEVALID | PTEGLOBL; + tlbphys = p->upage->pa | PTEWRITE|PTEVALID|PTEGLOBL; puttlbx(0, tlbvirt, tlbphys); u = (User*)USERADDR; } @@ -66,6 +62,7 @@ newtlbpid(Proc *p) } if(h[i]) purgetlb(i); + sp = m->pidproc[i]; if(sp && sp->pidonmach[m->machno] == i) sp->pidonmach[m->machno] = 0; @@ -92,12 +89,10 @@ putmmu(ulong tlbvirt, ulong tlbphys, Page *pg) } p = u->p; -/* if(p->state != Running) - panic("putmmu state %lux %lux %s\n", u, p, statename[p->state]); -*/ tp = p->pidonmach[m->machno]; if(tp == 0) tp = newtlbpid(p); + tlbvirt |= PTEPID(tp); putstlb(tlbvirt, tlbphys); puttlb(tlbvirt, tlbphys); @@ -131,7 +126,7 @@ purgetlb(int pid) dead[pid] = 1; /* * clean out all dead pids from the stlb; - * garbage collect any pids with no entries + * garbage collect pids with no entries */ memset(m->pidhere, 0, sizeof m->pidhere); pidhere = m->pidhere; @@ -178,6 +173,7 @@ putstlb(ulong tlbvirt, ulong tlbphys) { Softtlb *entry; + /* This hash function is also coded into utlbmiss in l.s */ entry = &m->stb[((tlbvirt<<1) ^ (tlbvirt>>12)) & (STLBSIZE-1)]; entry->phys = tlbphys; entry->virt = tlbvirt; diff --git a/power/trap.c b/power/trap.c index d9c39fdadd87b512a6403bcb998d9b6a09b513d6..0024aa621bc8c4b00dc8be0d16104313016d8acf 100644 --- a/power/trap.c +++ b/power/trap.c @@ -103,9 +103,10 @@ trap(Ureg *ur) if(u == 0) panic("fault u==0 pc %lux addr %lux", ur->pc, ur->badvaddr); - spllo(); x = u->p->insyscall; u->p->insyscall = 1; + + spllo(); faultmips(ur, user, ecode); u->p->insyscall = x; break; @@ -165,12 +166,11 @@ trap(Ureg *ur) void intr(Ureg *ur) { - int i, any; - uchar xxx; - uchar pend, npend; long v; + int i, any; ulong cause; static int bogies; + uchar pend, npend, xxx; m->intr++; cause = ur->cause&(INTR5|INTR4|INTR3|INTR2|INTR1); @@ -450,7 +450,7 @@ noted(Ureg **urp, ulong arg0) Ureg *nur; nur = u->ureg; - if(nur->status!=u->svstatus) { + if(nur->status != u->svstatus) { pprint("bad noted ureg status %lux\n", nur->status); pexit("Suicide", 0); } @@ -505,12 +505,8 @@ syscall(Ureg *aur) ur = aur; p->pc = ur->pc; u->dbgreg = aur; - ur->cause = 15<<2; /* for debugging: system call is undef 15; - /* - * since the system call interface does not - * guarantee anything about registers, we can - * smash them. but we must save fpstatus. - */ + ur->cause = 15<<2; /* for debugging: system call is undef 15; */ + if(p->fpstate == FPactive) { if((ur->status&CU1) == 0) panic("syscall: FPactive but no CU1"); @@ -525,8 +521,8 @@ syscall(Ureg *aur) procctl(p); u->scallnr = ur->r1; - sp = ur->sp; u->nerrlab = 0; + sp = ur->sp; ret = -1; if(!waserror()){ if(u->scallnr >= sizeof systab/sizeof systab[0]) {