From 113149606cbfeaf6af603a85310c49f6164339c0 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 6 Apr 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-04-06 --- port/fault.c | 1 - port/portdat.h | 4 +-- port/proc.c | 4 +-- port/sysfile.c | 1 - port/systab.h | 3 -- power/dat.h | 25 ++------------- power/l.s | 24 +++++++-------- power/main.c | 7 +++++ power/mmu.c | 82 +++++++++++++++++++++++--------------------------- 9 files changed, 63 insertions(+), 88 deletions(-) diff --git a/port/fault.c b/port/fault.c index 4a58a4fc159360ec555b5141902975fe58c096d0..14c16a79391f9f207e44da56b7107cfa44fc4b05 100644 --- a/port/fault.c +++ b/port/fault.c @@ -156,7 +156,6 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu) (*pg)->modref = PG_MOD|PG_REF; break; } - qunlock(&s->lk); if(doputmmu) diff --git a/port/portdat.h b/port/portdat.h index c80919d9bf99dd2204347df4eb749471fbbe83e3..947c13cd6974d0ba7c38507c50b094b8874dce69 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -487,7 +487,7 @@ enum NERR = 15, NNOTE = 5, - NSYSCALL = 37, /* MUST be equal to the real thing!!!! */ + NSYSCALL = 39, /* MUST be equal to the real thing!!!! */ Pcounter = 6, /* per process counters */ CSCNTR = 0, /* sched counter */ FAULTCNTR = 1, /* fault counter */ @@ -580,7 +580,7 @@ struct Proc /* statistics */ ulong counter[Pcounter]; /* specialized per process counters */ ulong syscall[NSYSCALL]; -ulong qpc; + /* * machine specific MMU */ diff --git a/port/proc.c b/port/proc.c index 9a936d277596033824378edec54add3cb7ee4c21..1695759852b340a949639e87869f287698530bde 100644 --- a/port/proc.c +++ b/port/proc.c @@ -711,9 +711,9 @@ procdump(void) s = p->psstate; if(s == 0) s = "kproc"; - print("%3d:%10s pc %8lux %8s (%s) q %lux ut %ld st %ld bss %lux\n", + print("%3d:%10s pc %8lux %8s (%s) ut %ld st %ld bss %lux\n", p->pid, p->text, p->pc, s, statename[p->state], - p->qpc, p->time[0], p->time[1], bss); + p->time[0], p->time[1], bss); } } diff --git a/port/sysfile.c b/port/sysfile.c index f79b525b21663b4734f408e3ff40ab8d6d31dc4d..b0fc1fb44cbc929264c6f861a813454d5da78832 100644 --- a/port/sysfile.c +++ b/port/sysfile.c @@ -317,7 +317,6 @@ sysread9p(ulong *arg) else n = mntread9p(c, (void*)arg[1], n, c->offset); - lock(c); c->offset += n; unlock(c); diff --git a/port/systab.h b/port/systab.h index 2df1a8c90f0b944efa4f9af5df7ec37e5e66be61..cfd4f459e5ad7e453688d6d6b735eed02e1c5e3e 100644 --- a/port/systab.h +++ b/port/systab.h @@ -42,7 +42,6 @@ Syscall sysunmount; Syscall syswait; Syscall syswrite9p; Syscall sysread9p; -Syscall ; Syscall sysdeath; Syscall *systab[]={ @@ -85,7 +84,6 @@ Syscall *systab[]={ [WAIT] syswait, [WRITE9P] syswrite9p, [READ9P] sysread9p, - }; char *sysctab[]={ @@ -128,5 +126,4 @@ char *sysctab[]={ [WAIT] "Wait", [WRITE9P] "Write9p", [READ9P] "Read9p", - }; diff --git a/power/dat.h b/power/dat.h index 5493811a69bf6305b2096da442a5852b7cc0a7a0..defef91792df0905b8df3d5000914a845f2f5609 100644 --- a/power/dat.h +++ b/power/dat.h @@ -1,7 +1,6 @@ typedef struct Conf Conf; typedef struct Lancepkt Lancepkt; typedef struct FPsave FPsave; -typedef struct Cycmsg Cycmsg; typedef struct Lance Lance; typedef struct Lancemem Lancemem; typedef struct Label Label; @@ -77,14 +76,6 @@ struct FPsave struct PMMU { int pidonmach[MAXMACH]; - /* - * I/O point for hotrod interfaces. - * This is the easiest way to allocate - * them, but not the prettiest or most general. - */ - Cycmsg *kcyc; - Cycmsg *ucyc; - Cycmsg *fcyc; }; /* @@ -98,14 +89,6 @@ struct Notsave #include "../port/portdat.h" -struct Cycmsg -{ - ulong cmd; - ulong param[5]; - Rendez r; - uchar intr; /* flag: interrupt has occurred */ -}; - /* First FOUR members offsets known by l.s */ struct Mach { @@ -113,18 +96,16 @@ struct Mach Softtlb *stb; /* Software tlb simulation */ Proc *proc; /* current process on this processor */ ulong splpc; /* pc that called splhi() */ + int tlbfault; /* this offset known in l.s/utlbmiss() */ + /* Ok to change from here */ ulong ticks; /* of the clock since boot time */ Label sched; /* scheduler wakeup */ Lock alarmlock; /* access to alarm list */ void *alarm; /* alarms bound to this clock */ - char pidhere[NTLBPID]; /* is this pid possibly in this mmu? */ int lastpid; /* last pid allocated on this machine */ - Proc *pidproc[NTLBPID]; /* tlb allocation table */ - Page *ufreeme; /* address of upage of exited process */ - Ureg *ur; + Proc *pidproc[NTLBPID]; /* process that owns this tlbpid on this mach */ - int tlbfault; /* this offset known in l.s/utlbmiss() */ int tlbpurge; int pfault; int cs; diff --git a/power/l.s b/power/l.s index 749937c8cbb2228cf0d751a11b88375a65ccb164..12d736ef9d58251a8407dfc9b4c74042d1c68900 100644 --- a/power/l.s +++ b/power/l.s @@ -238,8 +238,6 @@ TEXT tlbp(SB), $0 RET TEXT tlbvirt(SB), $0 - TLBP - NOOP MOVW M(TLBVIRT), R1 RET @@ -277,7 +275,8 @@ TEXT vector80(SB), $-4 JMP (R26) TEXT vector0(SB), $-4 -/* get m->tlbfault BUG +/* + get m->tlbfault BUG MOVW $((MACHADDR+368) & 0xffff0000), R26 OR $((MACHADDR+368) & 0xffff), R26 MOVW (R26), R27 @@ -296,15 +295,12 @@ TEXT utlbmiss(SB), $-4 XOR R26, R27 AND $(STLBSIZE-1), R27 SLL $8, R27 - /* - * R27 = (((tlbvirt<<1)^(tlbvirt>>12)) & (STLBSIZE-1)) << 8 - * (8 to clear zero in TLBPHYS) - */ - MOVW R27, M(TLBPHYS) - - MOVW $((MACHADDR+4)&0xffff0000), R26 /* get &mach[0].stb BUG */ - OR $((MACHADDR+4)&0xffff), R26 - MOVW $MPID, R27 /* add BY2PG*machno */ + /* R27 = (((tlbvirt<<1)^(tlbvirt>>12)) & (STLBSIZE-1)) << 8 (8 to clear zero in TLBPHYS) */ + MOVW R27, M(TLBPHYS) /* scratch register, store */ + + MOVW $((MACHADDR+4) & 0xffff0000), R26 /* get &mach[0].stb BUG */ + OR $((MACHADDR+4) & 0xffff), R26 + MOVW $MPID, R27 /* add BY2PG*machno */ MOVB 3(R27), R27 AND $7, R27 SLL $PGSHIFT, R27 @@ -790,3 +786,7 @@ _dcflush3: TEXT dcflush4(SB), $-4 RET + +TEXT getstatus(SB), $0 + MOVW M(STATUS), R1 + RET diff --git a/power/main.c b/power/main.c index 2295c84120eb9c60bbafb1d4162c129436efa0cf..e47156c533889f0dd1c48476afb211643912c434 100644 --- a/power/main.c +++ b/power/main.c @@ -52,12 +52,18 @@ machinit(void) int n; icflush(0, 64*1024); + dcflush(0, 64*1024); n = m->machno; memset(m, 0, sizeof(Mach)); m->machno = n; m->stb = &stlb[n][0]; m->ledval = 0xff; + + /* Setup call back ring buffer */ + m->cbin = m->calls; + m->cbout = m->calls; + m->cbend = &m->calls[NCALLBACK]; } void @@ -517,6 +523,7 @@ confinit(void) i = conf.npage-conf.upages; if(i > (12*MB)/BY2PG) conf.upages += i - ((12*MB)/BY2PG); + conf.ialloc = ((conf.npage-conf.upages)/2)*BY2PG; /* * clear MP bus error caused by sizing memory */ diff --git a/power/mmu.c b/power/mmu.c index 84f24d6a4db355a79c1f4294da7dbed267d2e06f..f326b3fe6e81f9a5c560f50fadda6fe83071f3b6 100644 --- a/power/mmu.c +++ b/power/mmu.c @@ -7,14 +7,17 @@ void mmuswitch(Proc *p) { + int tp; + if(p->newtlb) { memset(p->pidonmach, 0, sizeof p->pidonmach); p->newtlb = 0; } - if(p->pidonmach[m->machno] == 0) - newtlbpid(p); + tp = p->pidonmach[m->machno]; + if(tp == 0) + tp = newtlbpid(p); - putcontext(p->pidonmach[m->machno]); + putcontext(tp); } void @@ -30,34 +33,27 @@ int newtlbpid(Proc *p) { int i, s; - Proc *sp; - char *h; - - s = m->lastpid; - if(s >= NTLBPID) - s = 1; - i = s; - h = m->pidhere; - do{ - i++; - if(i >= NTLBPID) - i = 1; - }while(h[i] && i != s); + Proc **h; - if(i == s){ + i = m->lastpid; + h = m->pidproc; + for(s = 0; s < NTLBPID; s++) { i++; if(i >= NTLBPID) i = 1; + if(h[i] == 0) + break; } + if(h[i]) purgetlb(i); + if(h[i] != 0) + panic("newtlb"); - sp = m->pidproc[i]; - if(sp && sp->pidonmach[m->machno] == i) - sp->pidonmach[m->machno] = 0; m->pidproc[i] = p; p->pidonmach[m->machno] = i; m->lastpid = i; + return i; } @@ -73,7 +69,7 @@ putmmu(ulong tlbvirt, ulong tlbphys, Page *pg) if(*ctl == PG_TXTFLUSH) { dcflush((void*)pg->pa, BY2PG); icflush((void*)pg->pa, BY2PG); - *ctl &= ~PG_TXTFLUSH; + *ctl = PG_NOFLUSH; } tp = up->pidonmach[m->machno]; @@ -83,54 +79,50 @@ putmmu(ulong tlbvirt, ulong tlbphys, Page *pg) tlbvirt |= PTEPID(tp); putstlb(tlbvirt, tlbphys); puttlb(tlbvirt, tlbphys); - m->pidhere[tp] = 1; spllo(); } void -purgetlb(int pid) +purgetlb(int tlbpid) { - Softtlb *entry, *etab; - char *pidhere; + int i, mno; Proc *sp, **pidproc; - int i, rpid, mno; - char dead[NTLBPID]; + Softtlb *entry, *etab; m->tlbpurge++; + /* * find all pid entries that are no longer used by processes */ mno = m->machno; pidproc = m->pidproc; - memset(dead, 0, sizeof dead); - for(i=1; ipidonmach[mno] != i){ + if(sp && sp->pidonmach[mno] != i) pidproc[i] = 0; - dead[i] = 1; - } } - dead[pid] = 1; + + /* + * shoot down the one we want + */ + sp = pidproc[tlbpid]; + if(sp != 0) + sp->pidonmach[mno] = 0; + pidproc[tlbpid] = 0; + /* - * clean out all dead pids from the stlb; - * garbage collect pids with no entries + * clean out all dead tlbpids from the stlb; */ - memset(m->pidhere, 0, sizeof m->pidhere); - pidhere = m->pidhere; entry = m->stb; - etab = &entry[STLBSIZE]; - for(; entry < etab; entry++){ - rpid = TLBPID(entry->virt); - if(dead[rpid]) + for(etab = &entry[STLBSIZE]; entry < etab; entry++) + if(pidproc[TLBPID(entry->virt)] == 0) entry->virt = 0; - else - pidhere[rpid] = 1; - } + /* * clean up the hardware */ for(i=TLBROFF; i