From 57b38cc43c2b461c0b72870c4d59edcf99fe6f22 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 11 Aug 1993 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1993-08-11 --- port/fault.c | 4 ++-- port/page.c | 9 ++++---- port/portdat.h | 6 ++--- port/portfns.h | 59 +++++++++++++++++++++++++------------------------- port/qio.c | 20 ++++++++++++++--- 5 files changed, 56 insertions(+), 42 deletions(-) diff --git a/port/fault.c b/port/fault.c index 747604620ec8f50ab47dfbe27eb74787d63ff93a..583b21c6422bb6cbe5ca24ad583e5ba5f59a2193 100644 --- a/port/fault.c +++ b/port/fault.c @@ -150,9 +150,9 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu) break; } - if(s->flushme){ + if(s->flushme) { for(i = 0; i < MAXMACH; i++) - (*pg)->cachectl[i] |= PG_TXTFLUSH; + (*pg)->cachectl[i] = PG_TXTFLUSH; } qunlock(&s->lk); diff --git a/port/page.c b/port/page.c index 0acebfb782e430349f1886646793f75e56eb6412..045cb28a06ba367f30ed6ff7ddd6a4a9cbd4ca6a 100644 --- a/port/page.c +++ b/port/page.c @@ -59,7 +59,7 @@ newpage(int clear, Segment **s, ulong va) { Page *p; KMap *k; - int hw, dontalloc, fc; + int i, hw, dontalloc, fc; retry: lock(&palloc); @@ -118,7 +118,8 @@ retry: p->ref++; p->va = va; p->modref = 0; - memset(p->cachectl, PG_DATINVALID, sizeof(p->cachectl)); + for(i = 0; i < MAXMACH; i++) + p->cachectl[i] = PG_NOFLUSH; unlock(p); if(clear) { @@ -150,6 +151,7 @@ putpage(Page *p) unlock(p); return; } + vcacheinval(p); lock(&palloc); if(p->image && p->image != &swapimage) { @@ -186,7 +188,6 @@ void duppage(Page *p) /* Always call with p locked */ { Page *np; - int i; /* No dup for swap pages */ if(p->image == &swapimage) { @@ -231,8 +232,6 @@ duppage(Page *p) /* Always call with p locked */ uncachepage(np); np->va = p->va; np->daddr = p->daddr; - for(i = 0; i < MAXMACH; i++) - np->cachectl[i] |= PG_DATINVALID; copypage(p, np); cachepage(np, p->image); unlock(np); diff --git a/port/portdat.h b/port/portdat.h index 297da6b28bf15ae4eb290bfd74a8a58454af0352..84245f6de1ccabadf88151b2f8188f364b5aea8f 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -290,9 +290,9 @@ struct Note enum { - PG_TXTFLUSH = 1<<1, /* flush icache */ - PG_DATFLUSH = 1<<2, /* flush both i & d caches */ - PG_DATINVALID = 1<<3, /* invalidate d cache */ + PG_NOFLUSH = 0, + PG_TXTFLUSH = 1, /* flush icache */ + PG_DATFLUSH = 2, /* flush both i & d caches */ PG_MOD = 0x01, /* software modified bit */ PG_REF = 0x02, /* software referenced bit */ diff --git a/port/portfns.h b/port/portfns.h index c8ab4a3f75cb6eb4428466d52b10a5ff89cb9f97..8ad0eca6c0aa24dc6f16026f1b854fc245df60dd 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -2,13 +2,14 @@ void addrootfile(char*, uchar*, ulong); void alarmkproc(void*); int anyready(void); Image* attachimage(int, Chan*, ulong, ulong); -long authentwrite(Chan*, char*, int); +long authcheck(Chan*, char*, int); +void authclose(Chan*); long authentread(Chan*, char*, int); +long authentwrite(Chan*, char*, int); long authread(Chan*, char*, int); -long authwrite(Chan*, char*, int); -long authcheck(Chan*, char*, int); -ulong authrequest(Session*, Fcall*); void authreply(Session*, ulong, Fcall*); +ulong authrequest(Session*, Fcall*); +long authwrite(Chan*, char*, int); void bitdebug(void); void bitdepth(void); void bitreverse(uchar*, int); @@ -38,9 +39,8 @@ void confinit1(int); int consactive(void); void consdebug(void); void copypage(Page*, Page*); -void cursoron(int); void cursoroff(int); -Segment* data2txt(Segment*); +void cursoron(int); int decref(Ref*); int decrypt(void*, void*, int); void delay(int); @@ -53,6 +53,7 @@ int devno(int, int); Chan* devopen(Chan*, int, Dirtab*, int, Devgen*); void devstat(Chan*, char*, Dirtab*, int, Devgen*); int devwalk(Chan*, char*, Dirtab*, int, Devgen*); +Chan* domount(Chan*); void dumpqueues(void); void dumpregs(Ureg*); void dumpstack(void); @@ -84,6 +85,8 @@ void getcolor(ulong, ulong*, ulong*, ulong*); int getfields(char*, char**, int, char); void gotolabel(Label*); int haswaitq(void*); +long hostdomainwrite(char*, int); +long hostownerwrite(char*, int); int hwcursmove(int, int); int hwcursset(uchar*, uchar*, int, int); void iallocinit(void); @@ -93,11 +96,14 @@ void initscsi(void); void initseg(void); void invalidateu(void); void isdir(Chan*); +int iseve(void); int ispages(void*); void kbdclock(void); int kbdcr2nl(Queue*, int); int kbdputc(Queue*, int); void kbdrepeat(int); +long keyread(char*, int, long); +long keywrite(char*, int); void kickpager(void); int kprint(char*, ...); void kproc(char*, void(*)(void*), void*); @@ -111,17 +117,18 @@ void lockinit(void); Page* lookpage(Image*, ulong); void machinit(void); void* malloc(ulong); -void mmuswitch(Proc*); void mbbpt(Point); void mbbrect(Rectangle); void mfreeseg(Segment*, ulong, int); void mmurelease(Proc*); +void mmuswitch(Proc*); void mntdump(void); +void mntrepl(char*); int mount(Chan*, Chan*, int, char*); void mountfree(Mount*); void mousebuttons(int); -void mousectl(char*); void mouseclock(void); +void mousectl(char*); void mousescreenupdate(void); int msize(void*); Chan* namec(char*, int, int, ulong); @@ -131,7 +138,6 @@ Mount* newmount(Mhead*, Chan*, int, char*); Page* newpage(int, Segment **, ulong); Pgrp* newpgrp(void); Proc* newproc(void); -Segment* newseg(int, ulong, ulong); char* nextelem(char*, char*); void nexterror(void); int notify(Ureg*); @@ -155,8 +161,12 @@ void procctl(Proc*); void procdump(void); void procinit0(void); Proc* proctab(int); +void ptclone(Chan*, int, int); +void ptclose(Pthash*); Pte* ptealloc(void); Pte* ptecpy(Pte*); +Path* ptenter(Pthash*, Path*, char*); +int ptpath(Path*, char*, int); void putimage(Image*); void putmmu(ulong, ulong, Page*); void putpage(Page*); @@ -187,8 +197,9 @@ void resetscsi(void); void resrcwait(char*); int return0(void*); void rlock(RWlock*); -void rootreq(Chan*, Mnt*); void rootfiles(void); +void rootrecover(Path*, char*); +void rootreq(Chan*, Mnt*); void runlock(RWlock*); Proc* runproc(void); void savefpregs(FPsave*); @@ -199,9 +210,7 @@ void sched(void); void schedinit(void); int screenbits(void); void screenupdate(void); -Scsibuf* scsialloc(ulong); int scsibread(int, Scsibuf*, long, long, long); -Scsibuf* scsibuf(void); void scsibufreset(ulong); int scsibwrite(int, Scsibuf*, long, long, long); int scsicap(int, void*); @@ -211,8 +220,8 @@ void scsifree(Scsibuf*); int scsiinquiry(int, void*, int); int scsimodesense(int, int, void*, int); int scsiready(int); -int scsistartstop(int, int); int scsisense(int, void*); +int scsistartstop(int, int); int scsiwp(int); long seconds(void); ulong segattach(Proc*, ulong, char *, ulong, ulong); @@ -228,6 +237,7 @@ void* smalloc(ulong); int splhi(void); int spllo(void); void splx(int); +void srvrecover(Chan*, Chan*); void swapinit(void); long syscall(Ureg*); void tsleep(Rendez*, int (*)(void*), void*, int); @@ -240,9 +250,12 @@ void unmount(Chan*, Chan*); void urpfillstats(Chan*, char*, int); void userinit(void); ulong userpc(void); +long userwrite(char*, int); void validaddr(ulong, ulong, int); +void vcacheinval(Page*); void* vmemchr(void*, int, int); void wakeup(Rendez*); +Chan* walk(Chan*, char*, int); void wlock(RWlock*); void wunlock(RWlock*); void* xalloc(ulong); @@ -251,21 +264,9 @@ void xhole(ulong, ulong); void xinit(void); void* xspanalloc(ulong, int, ulong); void xsummary(void); +Segment* data2txt(Segment*); Segment* dupseg(Segment**, int, int); +Segment* newseg(int, ulong, ulong); +Scsibuf* scsialloc(ulong); +Scsibuf* scsibuf(void); Segment* seg(Proc*, ulong, int); -Path* ptenter(Pthash*, Path*, char*); -void ptclose(Pthash*); -int ptpath(Path*, char*, int); -void ptclone(Chan*, int, int); -Chan* walk(Chan*, char*, int); -Chan* domount(Chan*); -void rootrecover(Path*, char*); -void mntrepl(char*); -void srvrecover(Chan*, Chan*); -int iseve(void); -void authclose(Chan*); -long keyread(char*, int, long); -long keywrite(char*, int); -long userwrite(char*, int); -long hostownerwrite(char*, int); -long hostdomainwrite(char*, int); diff --git a/port/qio.c b/port/qio.c index e1731e5fe86df7872918117a7dac9948d03de235..14a9104df9948e2907ef2348429610614cd0706d 100644 --- a/port/qio.c +++ b/port/qio.c @@ -91,6 +91,16 @@ enum Qflow= (1<<3), }; +void +poison(Block *b) +{ + b->next = (void*)0xdeadbabe; + b->rp = (void*)0xdeadbabe; + b->wp = (void*)0xdeadbabe; + b->lim = (void*)0xdeadbabe; + b->base = (void*)0xdeadbabe; +} + /* * Manage interrupt level memory allocation. */ @@ -298,9 +308,10 @@ qconsume(Queue *q, void *vp, int len) wakeup(&q->wr); /* discard the block if we're done with it */ - if((q->state & Qmsg) || len == n) + if((q->state & Qmsg) || len == n) { + poison(b); ifree(b); - + } return len; } @@ -447,8 +458,10 @@ qread(Queue *q, void *vp, int len) b->rp += n; /* free it or put what's left on the queue */ - if(b->rp >= b->wp || (q->state&Qmsg)) + if(b->rp >= b->wp || (q->state&Qmsg)) { + poison(b); free(b); + } else { x = splhi(); lock(q); @@ -557,6 +570,7 @@ qclose(Queue *q) /* free queued blocks */ while(bfirst){ b = bfirst->next; + poison(bfirst); free(bfirst); bfirst = b; }