M carrera/devether.c => carrera/devether.c +19 -21
@@ 75,7 75,7 @@ typedef struct
enum
{
Nrb = 16, /* receive buffers */
- Ntb = 8, /* transmit buffers */
+ Ntb = 16, /* transmit buffers */
};
enum
@@ 425,6 425,14 @@ sonicpkt(Ether *ctlr, RXpkt *r, Pbuf *p)
}
}
+static int
+isoutbuf(void *arg)
+{
+ Ether *ctlr = arg;
+
+ return ctlr->tda[ctlr->th].status == Host;
+}
+
void
etherintr(void)
{
@@ 462,7 470,8 @@ etherintr(void)
txpkt = &c->tda[c->ti];
}
status &= ~(Txdn|Txer);
- wakeup(&c->tr);
+ if(isoutbuf(c))
+ wakeup(&c->tr);
}
if((status & (Pktrx|Rde)) == 0)
@@ 514,7 523,7 @@ etherintr(void)
status &= ~Lcd;
/*
- * Warnings that something is afoot.
+ * Warnings that something is atoe.
*/
if(status & Hbl){
print("sonic: cd heartbeat lost\n");
@@ 675,14 684,6 @@ etherread(Chan *c, void *buf, long n, ulong offset)
}
static int
-isoutbuf(void *arg)
-{
- Ether *ctlr = arg;
-
- return ctlr->tda[ctlr->th].status == Host;
-}
-
-static int
etherloop(Etherpkt *p, long n)
{
int s, different;
@@ 722,13 723,13 @@ etherwrite(Chan *c, void *buf, long n, ulong offset)
USED(offset);
- if(n > ETHERMAXTU)
- error(Ebadarg);
-
/* etherif.c handles structure */
if(NETTYPE(c->qid.path) != Ndataqid)
return netifwrite(ether[0], c, buf, n);
+ if(n > ETHERMAXTU)
+ error(Ebadarg);
+
/* we handle data */
if(etherloop(buf, n))
return n;
@@ 739,15 740,12 @@ etherwrite(Chan *c, void *buf, long n, ulong offset)
nexterror();
}
- tsleep(&ctlr->tr, isoutbuf, ctlr, 1000);
+ tsleep(&ctlr->tr, isoutbuf, ctlr, 10000);
- if(!isoutbuf(ctlr)) {
- print("ether transmitter jammed\n");
- reset(ctlr);
- WR(cr, Rxen);
- }
+ if(!isoutbuf(ctlr))
+ print("ether transmitter jammed cr #%lux\n", RD(cr));
else {
- p =(Pbuf*)ctlr->tb[ctlr->th];
+ p = (Pbuf*)ctlr->tb[ctlr->th];
memmove(p->d, buf, n);
if(n < 60) {
memset(p->d+n, 0, 60-n);
M carrera/l.s => carrera/l.s +0 -25
@@ 432,31 432,6 @@ wasuser:
BNE R26, notsys
JAL syscall(SB)
- MOVW R0, R2
- MOVW R0, R3
- MOVW R0, R4
- MOVW R0, R5
- MOVW R0, R6
- MOVW R0, R7
- MOVW R0, R8
- MOVW R0, R9
- MOVW R0, R10
- MOVW R0, R11
- MOVW R0, R12
- MOVW R0, R13
- MOVW R0, R14
- MOVW R0, R15
- MOVW R0, R16
- MOVW R0, R17
- MOVW R0, R18
- MOVW R0, R19
- MOVW R0, R20
- MOVW R0, R21
- MOVW R0, R22
- MOVW R0, R23
- MOVW R0, R24
- MOVW R0, R25
- MOVW R0, R27
sysrestore:
MOVW 0x28(SP), R31
M carrera/mmu.c => carrera/mmu.c +10 -4
@@ 287,13 287,19 @@ putmmu(ulong tlbvirt, ulong tlbphys, Page *pg)
puttlb(entry->virt, entry->phys0, entry->phys1);
ctl = &pg->cachectl[m->machno];
- if(*ctl == PG_DATFLUSH) {
+ switch(*ctl) {
+ case PG_TXTFLUSH:
+ icflush((void*)pg->va, BY2PG);
+ *ctl = PG_NOFLUSH;
+ break;
+ case PG_DATFLUSH:
dcflush((void*)pg->va, BY2PG);
*ctl = PG_NOFLUSH;
- }else
- if(*ctl == PG_TXTFLUSH) {
- icflush((void*)pg->va, BY2PG);
+ break;
+ case PG_NEWCOL:
+ cleancache(); /* Too expensive */
*ctl = PG_NOFLUSH;
+ break;
}
splx(s);
}
M carrera/trap.c => carrera/trap.c +1 -9
@@ 201,13 201,6 @@ trap(Ureg *ur)
case CTLBM:
case CTLBL:
case CTLBS:
-{
-((ulong*)0xA0090000)[0] = ur->pc;
-((ulong*)0xA0090000)[1] = ur->badvaddr;
-((ulong*)0xA0090000)[2] = ur->cause;
-((ulong*)0xA0090000)[3] = 0x12345678;
-((ulong*)0xA0090000)[4] = 0x87654321;
-}
if(up == 0)
kernfault(ur, ecode);
@@ 299,7 292,6 @@ intr(Ureg *ur)
switch(devint) {
default:
panic("unknown devint=#%lux", devint);
-
case 0x28: /* Serial 1 */
NS16552intr(0);
break;
@@ 329,7 321,7 @@ intr(Ureg *ur)
}
if(cause & INTR4) {
devint = IO(uchar, I386ack);
- iprint("i386ack=#%lux\n", devint);
+ iprint("i386ACK #%lux\n", devint);
cause &= ~INTR4;
}
M port/devproc.c => port/devproc.c +1 -8
@@ 697,8 697,8 @@ procstopwait(Proc *p, int ctl)
void
procctlreq(Proc *p, char *va, int n)
{
- int i;
char buf[NAMELEN];
+ extern int pfthreshold;
if(n > NAMELEN)
n = NAMELEN;
@@ 746,13 746,6 @@ procctlreq(Proc *p, char *va, int n)
ready(p);
}
else
- if(strncmp(buf, "cpu ", 4) == 0) {
- i = strtoul(buf+4, 0, 0);
- if(i < 0 || i >= conf.nmach)
- error(Ebadctl);
- p->mp = MACHP(i);
- }
- else
error(Ebadctl);
}
M port/fault.c => port/fault.c +13 -14
@@ 43,7 43,7 @@ fault(ulong addr, int read)
int
fixfault(Segment *s, ulong addr, int read, int doputmmu)
{
- int i, type;
+ int type;
Pte **p, *etp;
ulong mmuphys=0, soff;
Page **pg, *lkp, *new;
@@ 69,15 69,15 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
panic("fault");
break;
- case SG_TEXT:
- if(pagedout(*pg)) /* Demand load */
+ case SG_TEXT: /* Demand load */
+ if(pagedout(*pg))
pio(s, addr, soff, pg);
mmuphys = PPN((*pg)->pa) | PTERONLY|PTEVALID;
(*pg)->modref = PG_REF;
break;
- case SG_SHDATA: /* Shared data */
+ case SG_SHDATA: /* Shared data */
if(pagedout(*pg))
pio(s, addr, soff, pg);
@@ 89,7 89,7 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
goto done;
case SG_BSS:
- case SG_SHARED: /* Zero fill on demand */
+ case SG_SHARED: /* Zero fill on demand */
case SG_STACK:
if(*pg == 0) {
new = newpage(1, &s, addr);
@@ 100,7 100,7 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
}
/* NO break */
- case SG_DATA: /* Demand load/pagein/copy on write */
+ case SG_DATA: /* Demand load/pagein/copy on write */
if(pagedout(*pg))
pio(s, addr, soff, pg);
@@ 108,7 108,7 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
goto done;
if(read && conf.copymode == 0) {
- mmuphys = PPN((*pg)->pa) | /*PTERONLY|*/PTEVALID;
+ mmuphys = PPN((*pg)->pa)|PTERONLY|PTEVALID;
(*pg)->modref |= PG_REF;
break;
}
@@ 125,7 125,9 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
putpage(lkp);
}
else {
- /* put a duplicate of a text page back onto the free list */
+ /* put a duplicate of a text page back onto
+ * the free list
+ */
if(lkp->image)
duppage(lkp);
@@ 152,15 154,9 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
mmuphys = PPN((*pg)->pa) |PTEWRITE|PTEUNCACHED|PTEVALID;
(*pg)->modref = PG_MOD|PG_REF;
-/* print("v %lux p %lux\n", addr, mmuphys); /**/
break;
}
- if(s->flushme) {
- for(i = 0; i < MAXMACH; i++)
- (*pg)->cachectl[i] = PG_TXTFLUSH;
- }
-
qunlock(&s->lk);
if(doputmmu)
@@ 262,6 258,9 @@ pio(Segment *s, ulong addr, ulong soff, Page **p)
else
putpage(new);
}
+
+ if(s->flushme)
+ memset((*p)->cachectl, PG_TXTFLUSH, sizeof((*p)->cachectl));
}
void
M port/page.c => port/page.c +2 -2
@@ 112,7 112,7 @@ retry:
lock(&palloc);
}
- /* First try for out colour */
+ /* First try for our colour */
for(p = palloc.head; p; p = p->next)
if(p->color == color)
break;
@@ 120,7 120,7 @@ retry:
if(p == 0) {
print("! ");
p = palloc.head;
- memset(p->cachectl, PG_DATFLUSH, sizeof(p->cachectl));
+ memset(p->cachectl, PG_NEWCOL, sizeof(p->cachectl));
p->color = color;
}
M port/portdat.h => port/portdat.h +3 -1
@@ 247,6 247,7 @@ enum
PG_NOFLUSH = 0,
PG_TXTFLUSH = 1, /* flush icache */
PG_DATFLUSH = 2, /* flush both i & d caches */
+ PG_NEWCOL = 3, /* page has been recolored */
PG_MOD = 0x01, /* software modified bit */
PG_REF = 0x02, /* software referenced bit */
@@ 554,7 555,8 @@ struct Proc
Note lastnote;
int (*notify)(void*, char*);
- Mach *mp; /* machine this process is tied to */
+ Mach *mp; /* machine this process last ran on */
+ ulong mpfault; /* page faults on that mach at sched time */
void *ureg; /* User registers for notes */
void *dbgreg; /* User registers for devproc */
M port/proc.c => port/proc.c +11 -14
@@ 79,10 79,13 @@ sched(void)
{
if(up) {
splhi();
+
+ /* statistics */
m->cs++;
up->counter[CSCNTR]++;
-up->counter[TLBCNTR] += m->tlbfault - m->otlbfault;
-m->otlbfault = m->tlbfault;
+ up->counter[TLBCNTR] += m->tlbfault - m->otlbfault;
+ m->otlbfault = m->tlbfault;
+
procsave(up);
if(setlabel(&up->sched)) {
procrestore(up);
@@ 102,7 105,7 @@ m->otlbfault = m->tlbfault;
int
anyready(void)
{
- return runloq.head != 0 || runhiq.head != 0 || m->runq.head != 0;
+ return runhiq.head != 0 || runloq.head != 0;
}
void
@@ 113,12 116,10 @@ ready(Proc *p)
s = splhi();
- rq = &runhiq;
- if(p->mp)
- rq = &p->mp->runq;
- else
if(p->state == Running)
rq = &runloq;
+ else
+ rq = &runhiq;
lock(&runhiq);
p->rnext = 0;
@@ 142,21 143,16 @@ runproc(void)
loop:
spllo();
- while(runhiq.head == 0 && runloq.head == 0 && m->runq.head == 0)
+ while(runhiq.head == 0 && runloq.head == 0)
;
-
splhi();
- lock(&runhiq);
-
- if(m->runq.head)
- rq = &m->runq;
- else
if(runhiq.head)
rq = &runhiq;
else
rq = &runloq;
+ lock(&runhiq);
p = rq->head;
/* p->mach==0 only when process state is saved */
if(p == 0 || p->mach){
@@ 170,6 166,7 @@ loop:
if(p->state != Ready)
print("runproc %s %d %s\n", p->text, p->pid, statename[p->state]);
unlock(&runhiq);
+
p->state = Scheding;
return p;
}
M port/sysproc.c => port/sysproc.c +0 -1
@@ 160,7 160,6 @@ sysrfork(ulong *arg)
p->time[TReal] = MACHP(0)->ticks;
memmove(p->text, up->text, NAMELEN);
memmove(p->user, up->user, NAMELEN);
- p->mp = up->mp;
/*
* since the bss/data segments are now shareable,
* any mmu info about this process is now stale