M carrera/dat.h => carrera/dat.h +1 -1
@@ 113,7 113,6 @@ struct Mach
Ureg* ur;
KMap* kactive; /* active on this machine */
int knext;
- uchar ktlbx[NTLB]; /* tlb index used for kmap */
uchar ktlbnext;
int speed; /* cpu speed */
ulong delayloop; /* for the delay() routine */
@@ 138,6 137,7 @@ struct KMap
ulong phys1;
KMap* next;
KMap* konmach[MAXMACH];
+ int tlbi[MAXMACH];
Page* pg;
};
M carrera/devether.c => carrera/devether.c +14 -6
@@ 15,8 15,8 @@
#define SONICADDR ((Sonic*)Sonicbase)
-#define RD(rn) (delay(0), *(ulong*)((ulong)&SONICADDR->rn^4))
-#define WR(rn, v) (delay(0), *(ulong*)((ulong)&SONICADDR->rn^4) = (v))
+#define RD(rn) (sncdly(), *(ulong*)((ulong)&SONICADDR->rn^4))
+#define WR(rn, v) (sncdly(), *(ulong*)((ulong)&SONICADDR->rn^4) = (v))
#define ISquad(s) if((ulong)s & 0x7) panic("sonic: Quad alignment");
typedef struct Pbuf Pbuf;
@@ 74,7 74,7 @@ typedef struct
enum
{
- Nrb = 8, /* receive buffers */
+ Nrb = 16, /* receive buffers */
Ntb = 8, /* transmit buffers */
};
@@ 251,6 251,16 @@ Ether *ether[Nether];
void sonicswap(void*, int);
static void
+sncdly(void)
+{
+ int i, j, *pj;
+
+ pj = &j;
+ for(i = 0; i < 200; i++)
+ *pj++;
+}
+
+static void
wus(ushort *a, ushort v)
{
a[0] = v;
@@ 530,10 540,8 @@ etherintr(void)
status &= ~Hbl;
}
if(status & Br){
- WR(cr, 0);
- iprint("sonic: bus retry occurred\n");
+ print("sonic: bus retry occurred\n");
status &= ~Br;
- for(;;);
}
if(status & AllIntr)
M carrera/io.h => carrera/io.h +3 -0
@@ 58,6 58,9 @@ enum
Intenareg = 0xE0200004, /* Device interrupt enable */
Intcause = 0xE0200007, /* Decice interrupt cause register */
+ Promvirt = 0xE1000000, /* From ARCS chipset */
+ Promphys = 0x1FC00000, /* MIPs processors */
+
Ttbr = 0x8000001C, /* Translation table base address */
Tlrb = 0x80000024, /* Translation table limit address */
Tir = 0x8000002c, /* Translation invalidate register */
M carrera/main.c => carrera/main.c +5 -4
@@ 37,7 37,6 @@ extern ulong rdbglen;
void
main(void)
{
- rdbginit();
tlbinit();
ioinit(1); /* Very early to establish IO mappings */
arginit();
@@ 173,7 172,7 @@ serialinit(void)
void
ioinit(int mapeisa)
{
- ulong devphys, isaphys, intphys, isamphys;
+ ulong devphys, isaphys, intphys, isamphys, promphys;
/*
* If you want to segattach the eisa space these
@@ 206,8 205,10 @@ ioinit(int mapeisa)
/* Enable all device interrupts */
IO(ushort, Intenareg) = 0xffff;
- /* Look at the first 16M of Eisa memory */
-/* IO(uchar, EisaLatch) = 0; /**/
+ /* Map the rom back into Promvirt to allow NMI handling */
+ promphys = IOPTE|PPN(Promphys);
+
+ puttlbx(3, Promvirt, promphys, PTEGLOBL, PGSZ1M);
}
/*
M carrera/mem.h => carrera/mem.h +1 -1
@@ 116,7 116,7 @@
#define PIDXSHFT 12
#define PIDX (0x7<<PIDXSHFT)
-#define KMAPADDR 0xE1000000
+#define KMAPADDR 0xE2000000
#define KMAPMASK 0xFF000000
#define KMAPSHIFT 15
#define NCOLOR 8
M carrera/mmu.c => carrera/mmu.c +11 -15
@@ 108,8 108,8 @@ kmap(Page *pg)
}
x = m->ktlbnext;
- puttlbx(x, (virt & ~BY2PG)|TLBPID(tlbvirt()), k->phys0, k->phys1, PGSZ4K);
- m->ktlbx[x] = 1;
+ k->tlbi[m->machno] = x;
+ puttlbx(x, (virt&~BY2PG)|TLBPID(tlbvirt()), k->phys0, k->phys1, PGSZ4K);
if(++x >= NTLB)
m->ktlbnext = TLBROFF;
else
@@ 144,11 144,14 @@ kunmap(KMap *k)
void
kfault(Ureg *ur)
{
+ int mno;
KMap *k, *f;
ulong x, index, virt, addr;
+ mno = m->machno;
addr = ur->badvaddr;
index = (addr & ~KMAPADDR) >> KMAPSHIFT;
+
if(index >= KPTESIZE)
panic("kmapfault: %lux", addr);
@@ 156,20 159,21 @@ kfault(Ureg *ur)
if(k->virt == 0)
panic("kmapfault: unmapped %lux", addr);
- for(f = m->kactive; f; f = f->konmach[m->machno])
+ for(f = m->kactive; f; f = f->konmach[mno])
if(f == k)
break;
+
if(f == 0) {
incref(k);
- k->konmach[m->machno] = m->kactive;
+ k->konmach[mno] = m->kactive;
m->kactive = k;
}
x = m->ktlbnext;
virt = (k->virt&~BY2PG)|TLBPID(tlbvirt());
puttlbx(x, virt, k->phys0, k->phys1, PGSZ4K);
+ k->tlbi[mno] = x;
- m->ktlbx[x] = 1;
if(++x >= NTLB)
m->ktlbnext = TLBROFF;
else
@@ 179,25 183,17 @@ kfault(Ureg *ur)
void
kmapinval()
{
- int mno, i, curpid;
+ int mno, curpid;
KMap *k, *next;
- uchar *ktlbx;
if(m->kactive == 0)
return;
curpid = PTEPID(TLBPID(tlbvirt()));
- ktlbx = m->ktlbx+TLBROFF;
- for(i = TLBROFF; i < NTLB; i++, ktlbx++) {
- if(*ktlbx == 0)
- continue;
- TLBINVAL(i, curpid);
- *ktlbx = 0;
- }
-
mno = m->machno;
for(k = m->kactive; k; k = next) {
next = k->konmach[mno];
+ TLBINVAL(k->tlbi[mno], curpid);
kunmap(k);
}
m->kactive = 0;
M port/devproc.c => port/devproc.c +6 -1
@@ 809,12 809,17 @@ procctlmemio(Proc *p, ulong offset, int n, void *va, int read)
kunmap(k);
+ /* Ensure the process sees text page changes */
+ if(s->flushme)
+ memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+
s->steal--;
- qunlock(&s->lk);
if(read == 0)
p->newtlb = 1;
+ qunlock(&s->lk);
+
return n;
}