## diffname power/mmu.c 1990/0227
## diff -e /dev/null /n/bootesdump/1990/0227/sys/src/9/mips/mmu.c
0a
#include "u.h"
#include "lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
/*
* Called splhi, not in Running state
*/
void
mapstack(Proc *p)
{
short tp;
ulong tlbvirt, tlbphys;
tp = p->pidonmach[m->machno];
if(tp == 0){
tp = newtlbpid(p);
p->pidonmach[m->machno] = tp;
}
/* if(p->upage->va != (USERADDR|(p->pid&0xFFFF)))
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;
puttlbx(0, tlbvirt, tlbphys);
u = (User*)USERADDR;
}
/*
* Process must be non-interruptible
*/
int
newtlbpid(Proc *p)
{
int i;
Proc *sp;
i = m->lastpid+1;
if(i >= NTLBPID)
i = 1;
sp = m->pidproc[i];
if(sp){
sp->pidonmach[m->machno] = 0;
purgetlb(i);
}
m->pidproc[i] = p;
m->lastpid = i;
return i;
}
void
putmmu(ulong tlbvirt, ulong tlbphys)
{
short tp;
Proc *p;
splhi();
p = u->p;
/* if(p->state != Running)
panic("putmmu state %lux %lux %s\n", u, p, statename[p->state]);
*/
p->state = MMUing;
tp = p->pidonmach[m->machno];
if(tp == 0){
tp = newtlbpid(p);
p->pidonmach[m->machno] = tp;
}
tlbvirt |= PTEPID(tp);
puttlb(tlbvirt, tlbphys);
m->pidhere[tp] = 1;
p->state = Running;
spllo();
}
void
purgetlb(int pid)
{
int i, rpid;
if(m->pidhere[pid] == 0)
return;
memset(m->pidhere, 0, sizeof m->pidhere);
for(i=TLBROFF; i<NTLB; i++){
rpid = (gettlbvirt(i)>>6) & 0x3F;
if(rpid == pid)
puttlbx(i, KZERO | PTEPID(i), 0);
else
m->pidhere[rpid] = 1;
}
}
void
flushmmu(void)
{
splhi();
/* easiest is to forget what pid we had.... */
memset(u->p->pidonmach, 0, sizeof u->p->pidonmach);
/* ....then get a new one by trying to map our stack */
mapstack(u->p);
spllo();
}
.
## diffname power/mmu.c 1990/1211
## diff -e /n/bootesdump/1990/0227/sys/src/9/mips/mmu.c /n/bootesdump/1990/1211/sys/src/9/mips/mmu.c
103a
void
clearmmucache(void)
{
}
void
invalidateu(void)
{
puttlbx(0, KZERO | PTEPID(0), 0);
}
.
## diffname power/mmu.c 1991/0425
## diff -e /n/bootesdump/1991/0201/sys/src/9/mips/mmu.c /n/bootesdump/1991/0425/sys/src/9/power/mmu.c
113a
putstlb(KZERO | PTEPID(0), 0);
}
void
putstlb(ulong tlbvirt, ulong tlbphys)
{
Softtlb *entry;
entry = &m->stb[((tlbvirt<<1) ^ (tlbvirt>>12)) & (STLBSIZE-1)];
entry->phys = tlbphys;
entry->virt = tlbvirt;
if(tlbphys == 0)
entry->virt = 0;
.
91a
for(i = 0; i < NTLBPID; i++)
if(p[i] == 0){
sp = m->pidproc[i];
if(sp && sp->pidonmach[m->machno] == i)
sp->pidonmach[m->machno] = 0;
m->pidproc[i] = 0;
m->pidhere[i] = 0;
}
.
89,90c
entry = m->stb;
etab = &entry[STLBSIZE];
for(; entry < etab; entry++){
rpid = TLBPID(entry->virt);
if(rpid == pid){
entry->phys = 0;
entry->virt = 0;
}else
p[rpid] = 1;
.
84,87c
m->tlbpurge++;
m->pidproc[pid] = 0;
memset(p, 0, sizeof p);
for(i=TLBROFF; i<NTLB; i++)
if(TLBPID(gettlbvirt(i)) == pid)
.
82c
if(m->pidproc[pid] == 0)
.
79a
Softtlb *entry, *etab;
char p[NTLBPID];
Proc *sp;
.
70a
putstlb(tlbvirt, tlbphys);
.
49a
m->pidproc[i] = p;
.
48c
.
44a
if(sp->pidonmach[m->machno] == i)
sp->pidonmach[m->machno] = 0;
.
39c
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);
if(i == s){
sp = m->pidproc[i];
if(sp){
if(sp->pidonmach[m->machno] == i)
sp->pidonmach[m->machno] = 0;
purgetlb(i);
}
}
*/
.
37c
int i, s;
.
27a
putstlb(tlbvirt, tlbphys);
.
## diffname power/mmu.c 1991/0426
## diff -e /n/bootesdump/1991/0425/sys/src/9/power/mmu.c /n/bootesdump/1991/0426/sys/src/9/power/mmu.c
131,138d
116,117c
p = m->pidhere;
memset(m->pidhere, 0, sizeof m->pidhere);
.
112c
if(m->pidhere[pid] == 0)
.
108c
char *p;
.
73d
69,70d
61,64d
54,59c
i++;
if(i >= NTLBPID)
i = 1;
.
41c
.
## diffname power/mmu.c 1991/0430
## diff -e /n/bootesdump/1991/0426/sys/src/9/power/mmu.c /n/bootesdump/1991/0430/sys/src/9/power/mmu.c
120a
for(i=TLBROFF; i<NTLB; i++)
if(!p[TLBPID(gettlbvirt(i))])
puttlbx(i, KZERO | PTEPID(i), 0);
.
115c
sp = pidproc[rpid];
if(rpid == pid || !sp || sp->pidonmach[mno] != rpid){
.
112a
mno = m->machno;
pidproc = m->pidproc;
.
108,110d
102,104d
99,100c
Proc *sp, **pidproc;
int i, rpid, mno;
.
94a
stlbpopcnt(void)
{
Softtlb *entry, *etab;
entry = m->stb;
etab = &entry[STLBSIZE];
for(; entry < etab; entry++)
if(entry->virt)
m->spinlock++;
m->spinlock /= 2;
}
#endif
void
.
93a
#ifdef POPCNT
.
84,85d
82c
if(tp == 0)
.
64,65d
62c
if(h[i])
purgetlb(i);
.
58a
m->lastpid = i;
m->pidproc[i] = p;
p->pidonmach[m->machno] = i;
.
57a
.
46,51c
for(h = m->pidhere; h[i] && i != s; i = (i == NTLBPID - 1 ? 1 : i + 1))
;
.
28d
24c
/* don't set m->pidhere[tp] because we're only writing entry 0 */
.
19,20d
17c
if(tp == 0)
.
## diffname power/mmu.c 1991/0501
## diff -e /n/bootesdump/1991/0430/sys/src/9/power/mmu.c /n/bootesdump/1991/0501/sys/src/9/power/mmu.c
129c
if(!pidhere[TLBPID(gettlbvirt(i))])
.
127a
/*
* clean up the hardware
*/
.
125,126c
else
pidhere[rpid] = 1;
.
121,123c
if(dead[rpid])
.
117,118d
114a
pidhere = m->pidhere;
.
113c
/*
* 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; i<NTLBPID; i++){
sp = pidproc[i];
if(!sp || sp->pidonmach[mno] != i){
pidproc[i] = 0;
dead[i] = 1;
}
}
dead[pid] = 1;
/*
* clean out all dead pids from the stlb;
* garbage collect any pids with no entries
*/
.
110a
char dead[NTLBPID];
.
108c
char *pidhere;
.
90,104d
88d
56,61c
m->lastpid = i;
.
53c
if(sp && sp->pidonmach[m->machno] == i)
sp->pidonmach[m->machno] = 0;
.
51c
if(h[i])
purgetlb(i);
.
43,45c
h = m->pidhere;
do{
i++;
if(i >= NTLBPID)
i = 1;
}while(h[i] && i != s);
.
## diffname power/mmu.c 1991/0507
## diff -e /n/bootesdump/1991/0501/sys/src/9/power/mmu.c /n/bootesdump/1991/0507/sys/src/9/power/mmu.c
28a
void
mmurelease(Proc *p)
{
memset(p->pidonmach, 0, sizeof p->pidonmach);
}
.
## diffname power/mmu.c 1991/0705
## diff -e /n/bootesdump/1991/0507/sys/src/9/power/mmu.c /n/bootesdump/1991/0705/sys/src/9/power/mmu.c
78a
ctl = &pg->cachectl[m->machno];
if(*ctl == PG_TXTFLUSH) {
dcflush((void*)pg->pa, BY2PG);
icflush((void*)pg->pa, BY2PG);
*ctl = PG_NOFLUSH;
}
.
76a
char *ctl;
.
73c
putmmu(ulong tlbvirt, ulong tlbphys, Page *pg)
.
15a
if(p->newtlb) {
/* see flushmmu. */
memset(p->pidonmach, 0, sizeof p->pidonmach);
p->newtlb = 0;
}
.
## diffname power/mmu.c 1991/0926
## diff -e /n/bootesdump/1991/0705/sys/src/9/power/mmu.c /n/bootesdump/1991/0926/sys/src/9/power/mmu.c
106d
98d
## diffname power/mmu.c 1991/0928
## diff -e /n/bootesdump/1991/0926/sys/src/9/power/mmu.c /n/bootesdump/1991/0928/sys/src/9/power/mmu.c
25c
/* if(p->upage->va != (USERADDR|(p->pid&0xFFFF)) && p->pid != 0)
.
## diffname power/mmu.c 1992/0106
## diff -e /n/bootesdump/1991/0928/sys/src/9/power/mmu.c /n/bootesdump/1992/0106/sys/src/9/power/mmu.c
159,161c
u->p->newtlb = 1;
.
## diffname power/mmu.c 1992/0321
## diff -e /n/bootesdump/1992/0106/sys/src/9/power/mmu.c /n/bootesdump/1992/0321/sys/src/9/power/mmu.c
2c
#include "../port/lib.h"
.
## diffname power/mmu.c 1992/1130
## diff -e /n/bootesdump/1992/0321/sys/src/9/power/mmu.c /n/bootesdump/1992/1130/sys/src/9/power/mmu.c
180a
/* This hash function is also coded into utlbmiss in l.s */
.
134c
* garbage collect pids with no entries
.
100a
.
95,97d
68a
.
30c
tlbphys = p->upage->pa | PTEWRITE|PTEVALID|PTEGLOBL;
.
25,28c
.
17d
## diffname power/mmu.c 1993/0209
## diff -e /n/bootesdump/1992/1130/sys/src/9/power/mmu.c /n/bootesdump/1993/0209/sys/src/9/power/mmu.c
182a
/* Mapping routines for td's frame buffer
Page*
a16seg(Segment *s, ulong va)
{
Page *pg;
pg = smalloc(sizeof(Page));
memset(pg, 0, sizeof(Page));
pg->va = va;
pg->pa = 0xd0000 + (va - s->base);
pg->ref = 1;
return pg;
}
Page*
a32seg(Segment *s, ulong va)
{
Page *pg;
pg = smalloc(sizeof(Page));
memset(pg, 0, sizeof(Page));
pg->va = va;
pg->pa = VMEA32SUP(ulong, va - s->base);
pg->ref = 1;
return pg;
}
void
vmefree(Page *pg)
{
int x;
lock(pg);
x = --pg->ref;
unlock(pg);
if(x <= 0)
free(pg);
}
*/
.
## diffname power/mmu.c 1993/0210
## diff -e /n/bootesdump/1993/0209/sys/src/9/power/mmu.c /n/bootesdump/1993/0210/sys/src/9/power/mmu.c
183,222d
## diffname power/mmu.c 1993/0501
## diff -e /n/bootesdump/1993/0210/sys/src/9/power/mmu.c /n/fornaxdump/1993/0501/sys/src/brazil/power/mmu.c
162,168d
154,155c
up->newtlb = 1;
mmuswitch(up);
.
94c
tp = newtlbpid(up);
.
91,92c
tp = up->pidonmach[m->machno];
.
79d
21,28c
putcontext(p->pidonmach[m->machno]);
.
19a
if(p->pidonmach[m->machno] == 0)
newtlbpid(p);
.
13,15d
11c
mmuswitch(Proc *p)
.
7,9d
## diffname power/mmu.c 1993/0806
## diff -e /n/fornaxdump/1993/0501/sys/src/brazil/power/mmu.c /n/fornaxdump/1993/0806/sys/src/brazil/power/mmu.c
76c
*ctl &= ~PG_TXTFLUSH;
.
73c
if(*ctl & PG_TXTFLUSH) {
.
## diffname power/mmu.c 1993/0812
## diff -e /n/fornaxdump/1993/0806/sys/src/brazil/power/mmu.c /n/fornaxdump/1993/0812/sys/src/brazil/power/mmu.c
73c
if(*ctl == PG_TXTFLUSH) {
.
## diffname power/mmu.c 1994/0406
## diff -e /n/fornaxdump/1993/0812/sys/src/brazil/power/mmu.c /n/fornaxdump/1994/0406/sys/src/brazil/power/mmu.c
133c
if(pidproc[TLBPID(gettlbvirt(i))] == 0)
.
126,128c
.
121,124c
for(etab = &entry[STLBSIZE]; entry < etab; entry++)
if(pidproc[TLBPID(entry->virt)] == 0)
.
118,119c
sp = pidproc[tlbpid];
if(sp != 0)
sp->pidonmach[mno] = 0;
pidproc[tlbpid] = 0;
/*
* clean out all dead tlbpids from the stlb;
*/
.
115,116c
* shoot down the one we want
.
113c
.
110,111d
108c
if(sp && sp->pidonmach[mno] != i)
.
105,106c
for(i=1; i<NTLBPID; i++) {
.
99a
.
96,97c
Softtlb *entry, *etab;
.
93,94c
int i, mno;
.
91c
purgetlb(int tlbpid)
.
86d
76c
*ctl = PG_NOFLUSH;
.
60a
.
55,57d
53a
if(h[i] != 0)
panic("newtlb");
.
51a
.
45,50c
if(h[i] == 0)
break;
.
36,41c
i = m->lastpid;
h = m->pidproc;
for(s = 0; s < NTLBPID; s++) {
.
33,34c
Proc **h;
.
17c
putcontext(tp);
.
14,15c
tp = p->pidonmach[m->machno];
if(tp == 0)
tp = newtlbpid(p);
.
9a
int tp;
.
## diffname power/mmu.c 1997/0327 # deleted
## diff -e /n/fornaxdump/1994/0406/sys/src/brazil/power/mmu.c /n/emeliedump/1997/0327/sys/src/brazil/power/mmu.c
1,154d
|