M port/fault.c => port/fault.c +0 -1
@@ 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)
M port/portdat.h => port/portdat.h +2 -2
@@ 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
*/
M port/proc.c => port/proc.c +2 -2
@@ 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);
}
}
M port/sysfile.c => port/sysfile.c +0 -1
@@ 317,7 317,6 @@ sysread9p(ulong *arg)
else
n = mntread9p(c, (void*)arg[1], n, c->offset);
-
lock(c);
c->offset += n;
unlock(c);
M port/systab.h => port/systab.h +0 -3
@@ 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",
-
};
M power/dat.h => power/dat.h +3 -22
@@ 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;
M power/l.s => power/l.s +12 -12
@@ 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
M power/main.c => power/main.c +7 -0
@@ 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
*/
M power/mmu.c => power/mmu.c +37 -45
@@ 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; i<NTLBPID; i++){
+ for(i=1; i<NTLBPID; i++) {
sp = pidproc[i];
- if(!sp || sp->pidonmach[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<NTLB; i++)
- if(!pidhere[TLBPID(gettlbvirt(i))])
+ if(pidproc[TLBPID(gettlbvirt(i))] == 0)
puttlbx(i, KZERO | PTEPID(i), 0);
}