From d9b7b9dfe239f61b43d160885811db9e67404560 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 12 Sep 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-09-12 --- boot/settime.c | 9 ++-- port/alloc.c | 5 ++- port/devbit.c | 29 +++++++----- port/devlance.c | 16 +++++-- port/fault.c | 2 - port/portdat.h | 7 +-- port/qlock.c | 4 ++ port/segment.c | 2 +- port/swap.c | 18 +++++--- port/taslock.c | 2 +- ss/compile.c | 11 +---- ss/faultsparc.c | 2 +- ss/fns.h | 5 +-- ss/l.s | 34 ++++++--------- ss/main.c | 5 --- ss/mem.h | 6 +-- ss/mmu.c | 114 +++++++++++++++++++++++++++++++----------------- ss/scsi.c | 1 - 18 files changed, 155 insertions(+), 117 deletions(-) diff --git a/boot/settime.c b/boot/settime.c index f44f216a28f85fb10a34b3c20aa0c39ede2298d7..86e831c85cd4244ac3fe92254e456e0eddfe1eae 100644 --- a/boot/settime.c +++ b/boot/settime.c @@ -40,10 +40,11 @@ settime(int islocal) f = open(timeserver, ORDWR); if(f < 0) return; - if(mount(f, "/n/boot", MREPL, "", sauth) < 0){ - close(f); - return; - } + if(mount(f, "/n/boot", MREPL, "", sauth) < 0) + if(mount(f, "/n/boot", MREPL, "", "any") < 0){ + close(f); + return; + } close(f); if(stat("/n/boot", dirbuf) < 0) fatal("stat"); diff --git a/port/alloc.c b/port/alloc.c index 4ef0b3764004d7a07aa2078283ca19d1c0698168..9b6f96b24ab0406ae11bbfd1eb5e30935b8f6a86 100644 --- a/port/alloc.c +++ b/port/alloc.c @@ -380,7 +380,7 @@ xsummary(void) { Hole *h; Bucket *k; - int i, nfree; + int i, nfree, nused; i = 0; for(h = xlists.flist; h; h = h->link) @@ -393,12 +393,15 @@ xsummary(void) i += h->size; } print("%d bytes free\n", i); + nused = 0; for(i = 3; i < Maxpow; i++) { if(arena.btab[i] == 0 && arena.nbuck[i] == 0) continue; + nused += arena.nbuck[i]*(1<next) nfree++; print("%8d %4d %4d\n", 1< #include "screen.h" -extern GSubfont *defont; - /* * Some monochrome screens are reversed from what we like: * We want 0's bright and 1's dark. @@ -63,6 +61,11 @@ struct BSubfont ulong qid[2]; /* unique id used as a cache tag */ }; +extern GSubfont *defont; + BSubfont *bdefont; + BSubfont bdefont0; + + struct { Ref; @@ -182,7 +185,7 @@ bitfreeup(void) /* free unused subfonts and compact */ for(i=0; iref==0){ + if(s && s!=bdefont && s->ref==0){ s->ref = 1; s->qid[0] = ~0; /* force cleanup */ subfontfree(s, i); @@ -247,6 +250,8 @@ bitreset(void) ulong r; Arena *a; + memmove(&bdefont0, defont, sizeof(*defont)); + bdefont = &bdefont0; if(!conf.monitor) return; bit.map = smalloc(DMAP*sizeof(GBitmap*)); @@ -365,7 +370,7 @@ bitopen(Chan *c, int omode) b = smalloc(sizeof(GBitmap)); *b = gscreen; bit.map[0] = b; /* bitmap 0 is screen */ - bit.subfont[0] = (BSubfont*)defont; /* subfont 0 is default */ + bit.subfont[0] = bdefont; /* subfont 0 is default */ bit.subfont[0]->ref = 1; bit.subfont[0]->qid[0] = 0; bit.subfont[0]->qid[1] = 0; @@ -556,7 +561,7 @@ bitread(Chan *c, void *va, long n, ulong offset) * rectangle 16 * clip rectangle 16 * font info 3*12 - * fontchars 6*(defont->n+1) + * fontchars 6*(bdefont->n+1) */ if(n < 34) error(Ebadblt); @@ -570,19 +575,19 @@ bitread(Chan *c, void *va, long n, ulong offset) BPLONG(p+22, gscreen.clipr.min.y); BPLONG(p+26, gscreen.clipr.max.x); BPLONG(p+30, gscreen.clipr.max.y); - if(n >= 34+3*12+6*(defont->n+1)){ + if(n >= 34+3*12+6*(bdefont->n+1)){ p += 34; - sprint((char*)p, "%11d %11d %11d ", defont->n, - defont->height, defont->ascent); + sprint((char*)p, "%11d %11d %11d ", bdefont->n, + bdefont->height, bdefont->ascent); p += 3*12; - for(i=defont->info,j=0; j<=defont->n; j++,i++,p+=6){ + for(i=bdefont->info,j=0; j<=bdefont->n; j++,i++,p+=6){ BPSHORT(p, i->x); p[2] = i->top; p[3] = i->bottom; p[4] = i->left; p[5] = i->width; } - n = 34+3*12+6*(defont->n+1); + n = 34+3*12+6*(bdefont->n+1); }else n = 34; bit.init = 0; @@ -1259,7 +1264,7 @@ bitwrite(Chan *c, void *va, long n, ulong offset) pt.y = BGLONG(p+7); v = BGSHORT(p+11); if(v<0 || v>=bit.nfont || (ff=bit.font[v])==0) - error(Ebadblt); + error(Ebadfont); l = BGSHORT(p+15)*2; p += 17; m -= 17; @@ -1635,7 +1640,7 @@ fontfree(GFont *f) void subfontfree(BSubfont *s, int i) { - if(s!=defont && s->ref>0){ /* don't free subfont 0, defont */ + if(s!=bdefont && s->ref>0){ /* don't free subfont 0, bdefont */ s->ref--; if(s->ref==0 && s->qid[0]==~0){ /* uncached */ bitfree(s->bits); diff --git a/port/devlance.c b/port/devlance.c index 462b35bd8dba797708ff94f23b639b772a1b855f..32b14a1feefb8f2765b6995df5e7a9cb609abf66 100644 --- a/port/devlance.c +++ b/port/devlance.c @@ -362,10 +362,11 @@ lanceoput(Queue *q, Block *bp) p = &l.tp[l.tc]; if((MPus(m->flags)&LANCEOWNER) != 0) tsleep(&l.tr, isobuf, m, 128); - if(isobuf(m) == 0){ + if(l.wedged || isobuf(m) == 0){ qunlock(&l.tlock); freeb(bp); poperror(); + l.wedged = 0; print("lance wedged, dumping block & restarting\n"); lancestart(0); return; @@ -704,6 +705,15 @@ lanceintr(void) if(csr & (BABL|MISS|MERR)){ if(l.misses++ < 4) print("lance err %ux\n", csr); + else { + l.wedged = 1; + l.misses = 0; + *l.rap = 0; + *l.rdp = STOP; + wakeup(&l.rr); + wakeup(&l.tr); + return; + } } if(csr & IDON){ @@ -737,9 +747,9 @@ lanceintr(void) static void lanceup(Etherpkt *p, int len) { + int t; Block *bp; Ethertype *e; - int t; if(len <= 0) return; @@ -844,8 +854,8 @@ lancekproc(void *arg) * if the lance is wedged, restart it */ if(l.wedged){ - print("lance wedged, restarting\n"); l.wedged = 0; + print("lance wedged, restarting\n"); lancestart(0); } diff --git a/port/fault.c b/port/fault.c index 3e27fffc5838559c4f9b6558cce8ecae842ff7a9..43734a9c4bd9e9b70ca80cba4424cac333f8032c 100644 --- a/port/fault.c +++ b/port/fault.c @@ -184,8 +184,6 @@ pio(Segment *s, ulong addr, ulong soff, Page **p) kaddr = (char*)VA(k); if(loadrec == 0) { /* This is demand load */ -if(u && strcmp(u->p->text, "rc") == 0) -print("dl: %d %s %lux\n", u->p->pid, u->p->text, addr); c = s->image->c; while(waserror()) { if(strcmp(u->error, Eintr) == 0) diff --git a/port/portdat.h b/port/portdat.h index 08e785644447243d542da9dd54ffca356344dc24..878e65176bff0b63e5944bea3023eb04e61d6577 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -355,9 +355,10 @@ struct Swapalloc { Lock; /* Free map lock */ int free; /* Number of currently free swap pages */ - char *swmap; /* Base of swap map in memory */ - char *alloc; /* Round robin allocator */ - char *top; /* Top of swap map */ + uchar *swmap; /* Base of swap map in memory */ + uchar *alloc; /* Round robin allocator */ + uchar *last; /* Speed swap allocation */ + uchar *top; /* Top of swap map */ Rendez r; /* Pager kproc idle sleep */ ulong highwater; /* Threshold beyond which we must page */ ulong headroom; /* Space pager keeps free under highwater */ diff --git a/port/qlock.c b/port/qlock.c index 3ee2d9644ecbba2f2e558b0902e7645eba22765e..8a84ef7423e3fe61bb8bd21f48bee78890eb5e70 100644 --- a/port/qlock.c +++ b/port/qlock.c @@ -39,6 +39,8 @@ canqlock(QLock *q) unlock(&q->use); return 0; } + if(u) + u->p->qlockpc = getcallerpc(((uchar*)&q) - sizeof(q)); q->locked = 1; unlock(&q->use); return 1; @@ -49,6 +51,8 @@ qunlock(QLock *q) { Proc *p; + if(u) + u->p->qlockpc = 0; lock(&q->use); p = q->head; if(p) { diff --git a/port/segment.c b/port/segment.c index ddd554b81b7196d18588c83903a80569da269fc4..183817488e732682567de4fe339b9147f4d7bcb5 100644 --- a/port/segment.c +++ b/port/segment.c @@ -345,7 +345,7 @@ ibrk(ulong addr, int seg) if(newsize > (PTEMAPMEM*SEGMAPSIZE)/BY2PG) { qunlock(&s->lk); - return -1; + error(Enovmem); } s->top = newtop; diff --git a/port/swap.c b/port/swap.c index 75fef4bc4c04999375859194797f24e0a22f9432..f84960d289d00771355991ba1e63c7a75f2e0145 100644 --- a/port/swap.c +++ b/port/swap.c @@ -28,24 +28,25 @@ swapinit(void) swapalloc.swmap = xalloc(conf.nswap); swapalloc.top = &swapalloc.swmap[conf.nswap]; swapalloc.alloc = swapalloc.swmap; - + swapalloc.last = swapalloc.swmap; swapalloc.free = conf.nswap; } ulong newswap(void) { - char *look; + uchar *look; lock(&swapalloc); if(swapalloc.free == 0) panic("out of swap space"); - look = memchr(swapalloc.swmap, 0, conf.nswap); + look = memchr(swapalloc.last, 0, swapalloc.top-swapalloc.last); if(look == 0) - panic("inconsistant swap"); - + panic("inconsistent swap"); + *look = 1; + swapalloc.last = look; swapalloc.free--; unlock(&swapalloc); return (look-swapalloc.swmap) * BY2PG; @@ -54,9 +55,14 @@ newswap(void) void putswap(Page *p) { + uchar *idx; + lock(&swapalloc); - if(--swapalloc.swmap[((ulong)p)/BY2PG] == 0) + idx = &swapalloc.swmap[((ulong)p)/BY2PG]; + if(--(*idx) == 0) swapalloc.free++; + if(idx < swapalloc.last) + swapalloc.last = idx; unlock(&swapalloc); } diff --git a/port/taslock.c b/port/taslock.c index 4fcb2ffdcc4a255adad3b4d2e97f01bc538bb79f..7d046fbce4b92856639e7cb2d36b6d81f7866500 100644 --- a/port/taslock.c +++ b/port/taslock.c @@ -13,7 +13,7 @@ lock(Lock *l) ulong pc; pc = getcallerpc(((uchar*)&l) - sizeof(l)); - for(i = 0; i < 10000000; i++){ + for(i = 0; i < 100000000; i++){ if (tas(&ll->key) == 0){ if(u) u->p->hasspin = 1; diff --git a/ss/compile.c b/ss/compile.c index 567569008a90b682da697de26b1c53b561f147c4..777990f6f3cde46247596619e7a3289a1621236d 100644 --- a/ss/compile.c +++ b/ss/compile.c @@ -21,8 +21,6 @@ ulong (*getsegspace)(ulong); void (*putsegspace)(ulong, ulong); ulong (*getpmegspace)(ulong); void (*putpmegspace)(ulong, ulong); -ulong (*flushcx)(ulong); -ulong (*flushpm)(ulong); ulong (*flushpg)(ulong); /* @@ -180,13 +178,8 @@ compile(void) putsegspace = compilestaddr(STBA, 3); getpmegspace = compileldaddr(LDA, 4); putpmegspace = compilestaddr(STA, 4); - if(conf.ss2){ + if(conf.ss2) flushpg = compile1(BY2PG, 6); - flushpm = compile16(conf.vaclinesize, 5); - flushcx = compile16(conf.vaclinesize, 7); - }else{ + else flushpg = compile16(conf.vaclinesize, 0xD); - flushpm = compile16(conf.vaclinesize, 0xC); - flushcx = compile16(conf.vaclinesize, 0xE); - } } diff --git a/ss/faultsparc.c b/ss/faultsparc.c index 1525f3adb4045824187c52a9933d6bb195c17877..d7a17d42e7d9c77ee3f94df5ad571f7b1ab4a965 100644 --- a/ss/faultsparc.c +++ b/ss/faultsparc.c @@ -33,7 +33,7 @@ faultsparc(Ureg *ur) if(ser&(SE_WRITE|SE_PROT)) read = 0; } -if(u && strcmp(u->p->text, "rc") == 0) +/*if(u && strcmp(u->p->text, "rc") == 0) print("fault pc=%lux addr=%lux %d\n", ur->pc, addr, read);/**/ spllo(); if(u == 0){ diff --git a/ss/fns.h b/ss/fns.h index acbeedd63e0da79e327e3033de31d40db695b083..c5454e52292b9fff756f66338270e4d44cfb8b8d 100644 --- a/ss/fns.h +++ b/ss/fns.h @@ -68,7 +68,8 @@ void trap(Ureg*); void trapinit(void); #define wbflush() /* mips compatibility */ #define waserror() (u->nerrlab++, setlabel(&u->errlab[u->nerrlab-1])) -#define getcallerpc(x) (*(ulong*)(x)) +#define getcallerpc(x) _getcallerpc() +ulong _getcallerpc(void); /* * compiled entry points @@ -85,6 +86,4 @@ extern ulong (*getsegspace)(ulong); extern void (*putsegspace)(ulong, ulong); extern ulong (*getpmegspace)(ulong); extern void (*putpmegspace)(ulong, ulong); -extern ulong (*flushcx)(ulong); extern ulong (*flushpg)(ulong); -extern ulong (*flushpm)(ulong); diff --git a/ss/l.s b/ss/l.s index d8678cee979c3339e15bf4acde1e4dd885002f2e..1bebc2e4805901eea66f28be3b3b0aefcf6d74b6 100644 --- a/ss/l.s +++ b/ss/l.s @@ -1,6 +1,6 @@ #include "mem.h" -#define SYSPSR (SPL(0x0)|PSREF|PSRET|PSRSUPER|SPL(15)|0) +#define SYSPSR (PSREF|PSRET|PSRSUPER|SPL(15)) #define NOOP ORN R0, R0; ORN R0, R0; ORN R0, R0 TEXT start(SB), $-4 @@ -66,32 +66,20 @@ TEXT startvirt(SB), $-4 MOVW (R0), R0 RETURN -TEXT tas(SB), $0 +TEXT oldtas(SB), $0 TAS (R7), R7 /* LDSTUB, thank you ken */ RETURN -TEXT swap1_should_work(SB), $0 +TEXT tas(SB), $0 /* it seems we must be splhi */ - MOVW R7, R8 - MOVW $1, R7 - SWAP (R8), R7 - RETURN - -TEXT swap1x(SB), $0 - - MOVW PSR, R9 - MOVW R9, R10 - AND $~PSRET, R10 /* BUG: book says this is buggy */ - MOVW R10, PSR - NOOP - MOVW (R7), R7 - CMP R7, R0 - BNE was1 - MOVW $1, R10 - MOVW R10, (R8) -was1: + MOVW PSR, R8 + MOVW $SYSPSR, R9 MOVW R9, PSR + NOOP + TAS (R7), R7 /* LDSTUB, thank you ken */ + MOVW R8, PSR + NOOP RETURN TEXT spllo(SB), $0 @@ -465,6 +453,10 @@ TEXT clearftt(SB), $0 FMOVF F0, F0 RETURN +TEXT _getcallerpc(SB), $0 + MOVW 0(R1), R7 + RETURN + GLOBL mach0+0(SB), $MACHSIZE GLOBL fsr+0(SB), $BY2WD diff --git a/ss/main.c b/ss/main.c index 0169291b3f156a1bbc927e46ea9a20dc1a7061db..f52b7eb0375c0d534500d8874d695604ca5569cb 100644 --- a/ss/main.c +++ b/ss/main.c @@ -57,7 +57,6 @@ main(void) active.machs = 1; trapinit(); confinit(); -conf.monitor = 0; xinit(); mmuinit(); kmapinit(); @@ -140,8 +139,6 @@ init0(void) print("Sun Sparcstation %s\n", sparam->name); print("bank 0: %dM 1: %dM\n", bank[0], bank[1]); print("frame buffer id %lux slot %ld %s\n", conf.monitor, fbslot, fbstr); - if(conf.npage1 != conf.base1) - print("kernel mem from second bank: reboot and fix!\n"); u->slash = (*devtab[0].attach)(0); u->dot = clone(u->slash, 0); @@ -447,8 +444,6 @@ confinit(void) conf.frag = 32; if(cpuserver) conf.nproc = 500; - - conf.monitor = 0; } /* diff --git a/ss/mem.h b/ss/mem.h index c75d58ba335bbf7226cb83001031942c01ec0a95..d9a3da9815c630023c87da9cbfa14419642b487e 100644 --- a/ss/mem.h +++ b/ss/mem.h @@ -19,7 +19,7 @@ /* * Time */ -#define HZ 20 /* clock frequency */ +#define HZ 50 /* clock frequency */ #define MS2HZ (1000/HZ) /* millisec per clock tick */ #define TK2SEC(t) ((t)/HZ) /* ticks to seconds */ #define TK2MS(t) ((((ulong)(t))*1000)/HZ) /* ticks to milliseconds */ @@ -86,10 +86,10 @@ #define PTEMAPMEM (1024*1024) #define PTEPERTAB (PTEMAPMEM/BY2PG) -#define SEGMAPSIZE 16 +#define SEGMAPSIZE 128 #define INVALIDPTE 0 -#define PPN(pa) ((pa>>12)&0xFFFF) +#define PPN(pa) (((pa)>>12)&0xFFFF) /* * Weird addresses etc. in System ASI (2) diff --git a/ss/mmu.c b/ss/mmu.c index 585eb288b81463eef0cb9b0a40ef7d1c48a4a6c6..929eb8b93250c3aef4b8b5f28710e75a6879b0c1 100644 --- a/ss/mmu.c +++ b/ss/mmu.c @@ -158,19 +158,6 @@ mkfirst(List **list, List *entry) *list = entry; } -/* - * remove from list - */ -static void -remove(List **list, List *entry) -{ - if(*list == entry) - *list = entry->next; - - entry->prev->next = entry->next; - entry->next->prev = entry->prev; -} - /* * add to list */ @@ -199,13 +186,11 @@ static Pmeg* allocpmeg(ulong virt) { Pmeg *p; - Ctx *c; virt = virt & ~(BY2SEGM-1); for(;;){ p = (Pmeg*)m->plist; - c = p->ctx; - if(c == 0) + if(p->ctx == 0) break; m->needpmeg = 1; sched(); @@ -217,7 +202,7 @@ allocpmeg(ulong virt) p->cnext = m->cctx->pmeg; m->cctx->pmeg = p; p->virt = virt; - p->lo = virt; + p->lo = virt + BY2PG; p->hi = virt; putsegspace(p->virt, p->index); mklast(&m->plist, p); @@ -229,7 +214,7 @@ freepmeg(Pmeg *p, int flush) { ulong x; - /* invalidate any used PTE's, flush cache */ + /* invalidate any used PTE's */ for(x = p->lo; x <= p->hi; x += BY2PG) putpme(x, INVALIDPTE, flush); @@ -241,6 +226,7 @@ freepmeg(Pmeg *p, int flush) p->cnext = 0; p->ctx = 0; p->virt = 0; + mkfirst(&m->plist, p); } /* @@ -253,8 +239,12 @@ allocctx(Proc *proc) c = (Ctx*)m->clist; putctx(c); - if(c->proc) + if(c->proc){ freectx(c, 1); + } + if(c->pmeg) + panic("allocctx c->pmeg %lux\n", c->pmeg); + c->proc = proc; c->proc->ctxonmach[m->machno] = c; mklast(&m->clist, c); @@ -267,12 +257,15 @@ freectx(Ctx *c, int flush) Pmeg *p; putctx(c); + if(c->proc->ctxonmach[m->machno] != c) + panic("freectx %lux %lux\n", c->proc->ctxonmach[m->machno], c); /* give back mappings */ while(p = c->pmeg){ + if(p->ctx != c) + panic("freectx: %lux/%lux\n", p->ctx, c); c->pmeg = p->cnext; freepmeg(p, flush); - mkfirst(&m->plist, p); } /* flush u-> */ @@ -281,6 +274,7 @@ freectx(Ctx *c, int flush) /* detach from process */ c->proc->ctxonmach[m->machno] = 0; c->proc = 0; + mkfirst(&m->clist, c); } static void @@ -302,6 +296,7 @@ flushpage(ulong virt) while(a < evirt); } + /* * stuff an entry into a pmeg */ @@ -330,8 +325,11 @@ putmmu(ulong virt, ulong phys, Page *pg) x = getsegspace(v); if(x == INVALIDPMEG) p = allocpmeg(v); - else + else { p = &m->pmeg[x - m->pfirst]; + if(x != p->index) + panic("putmmu %d/%d\n", x, p->index); + } if(virt < p->lo) p->lo = virt; if(virt > p->hi) @@ -356,7 +354,7 @@ cacheinit(void) /* * Turn cache on */ - putenab(getenab()&~ENABCACHE); + putenab(getenab()|ENABCACHE); } /* @@ -366,17 +364,20 @@ void mmuinit(void) { int c, i, j; - ulong va, ktop, pme; + ulong va, ktop, pme, kbot1, ktop1; int fp; /* first free pmeg */ Pmeg *p; Ctx *ctx; -conf.ncontext = 1; /**/ + /* + * mmuinit is entered with PMEG's 0 & 1 providing mappng + * for virtual addresses KZERO<->KZERO+2*BY2SEGM to physical + * 0<->2*BY2SEGM + */ compile(); /* - * First map kernel text, data, bss, and xalloc regions. - * xinit sets conf.npage0 to end of these. + * map all of kernel region 0. */ ktop = PGROUND(conf.npage0); i = 0; @@ -388,7 +389,7 @@ conf.ncontext = 1; /**/ fp = i; /* - * Make sure cache is turned on for kernel + * Make sure cache is turned on for kernel region 0 */ pme = PTEVALID|PTEWRITE|PTEKERNEL|PTEMAINMEM; i = 0; @@ -396,12 +397,48 @@ conf.ncontext = 1; /**/ putpme(va, pme+i, 1); /* - * invalidate rest of kernel's PMEG + * invalidate rest of kernel's region 0's PMEG's */ va = ROUNDUP(ktop, BY2SEGM); for(; ktop < va; ktop += BY2PG) putpme(ktop, INVALIDPTE, 1); + /* + * Invalidate all entries in all other pmegs + */ + for(j = fp; j < conf.npmeg; j++){ + putsegspace(INVALIDSEGM, j); + for(va = 0; va < BY2SEGM; va += BY2PG) + putpmegspace(INVALIDSEGM+va, INVALIDPTE); + } + + if(conf.base1 < conf.npage1){ + /* + * map kernel region 1, this may overlap kernel region 0's + * PMEG's. + */ + ktop1 = PGROUND(conf.npage1); + kbot1 = conf.base1 & ~(BY2SEGM - 1); + if(kbot1 < ktop) + kbot1 = ktop; + for(c = 0; c < conf.ncontext; c++){ + i = fp; + putcontext(c); + for(va = kbot1; va < ktop1; va += BY2SEGM) + putsegspace(va, i++); + } + fp = i; + + /* + * Make sure cache is turned on for kernel region 1 + */ + kbot1 = conf.base1 & ~(BY2PG - 1); + pme = PTEVALID|PTEWRITE|PTEKERNEL|PTEMAINMEM; + i = PPN(kbot1 & ~KZERO); + for(va = kbot1; va < ktop1; va += BY2PG, i++) + putpme(va, pme+i, 1); + } + /* * allocate pmegs for kmap'ing */ @@ -413,15 +450,6 @@ conf.ncontext = 1; /**/ } fp = i; - /* - * Invalidate all entries in all other pmegs - */ - for(j = fp; j < conf.npmeg; j++){ - putsegspace(INVALIDSEGM, j); - for(va = INVALIDSEGM; va < INVALIDSEGM+BY2SEGM; va += BY2PG) - putpme(va, INVALIDPTE, 1); - } - /* * invalidate everything outside the kernel in every context */ @@ -464,7 +492,6 @@ mmurelease(Proc *p) return; freectx(c, 1); - mkfirst(&m->clist, c); } /* @@ -494,6 +521,8 @@ mapstack(Proc *p) } l = &f->cnext; } + if(f != pm) + panic("mapstack f != pm\n"); /* flush cache & remove mappings */ putctx(c); @@ -513,10 +542,13 @@ mapstack(Proc *p) /* set to this proc's context */ c = p->ctxonmach[m->machno]; if(c == 0) - allocctx(p); + c = allocctx(p); else putctx(c); + if(c->proc != p || p->ctxonmach[m->machno] != c) + panic("mapstack c->proc != p\n"); + /* make sure there's a mapping for u-> */ tlbphys = PPN(p->upage->pa)|PTEVALID|PTEWRITE|PTEKERNEL|PTEMAINMEM; putpmegspace(USERADDR, tlbphys); @@ -536,7 +568,6 @@ flushmmu(void) while(p = c->pmeg){ c->pmeg = p->cnext; freepmeg(p, 1); - mkfirst(&m->plist, p); } spllo(); } @@ -552,6 +583,7 @@ struct Lock; KMap *free; KMap arena[IOSEGSIZE/BY2PG]; + int inited; }kmapalloc; void @@ -566,6 +598,7 @@ kmapinit(void) k->va = va; kunmap(k); } + kmapalloc.inited = 1; } KMap* @@ -632,4 +665,3 @@ kmap(Page *pg) */ return kmappa(pg->pa, PTEMAINMEM|PTENOCACHE); } - diff --git a/ss/scsi.c b/ss/scsi.c index 866e1d563ad3713fe1ae6525edd3574bdd0ee8f4..3864de25a931790cb344ca8668f91d36704973b2 100644 --- a/ss/scsi.c +++ b/ss/scsi.c @@ -16,7 +16,6 @@ Scsibuf * scsialloc(ulong n) { Scsibuf *b; - KMap *k; ulong pa, va; int i;