From 12762acd8943f4b34c08c087f2d2bf8fdf89ae4a Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 8 Jun 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-06-08 --- gnot/dat.h | 1 + gnot/devcons.c | 715 ----------------------------------------------- gnot/devduart.c | 6 +- gnot/l.s | 5 + gnot/lock.c | 5 + gnot/main.c | 15 +- gnot/mem.h | 1 + port/devcons.c | 11 +- port/devnonet.c | 18 +- port/fault.c | 30 +- port/portfns.h | 3 + port/proc.c | 2 +- port/stnoether.c | 12 +- power/conf.h | 1 + power/dat.h | 2 +- power/main.c | 1 + ss/dat.h | 1 + ss/main.c | 17 +- 18 files changed, 88 insertions(+), 758 deletions(-) delete mode 100644 gnot/devcons.c diff --git a/gnot/dat.h b/gnot/dat.h index ef8f4216056beeb588923a6eddef0f182e7f08e5..34fdf9a72e32056fb4aac3f1ca6a785e628aea96 100644 --- a/gnot/dat.h +++ b/gnot/dat.h @@ -103,6 +103,7 @@ struct Conf ulong maxialloc; /* maximum bytes used by ialloc */ int copymode; /* 0 is copy on write, 1 is copy on reference */ int portispaged; /* ??? */ + int cntrlp; /* panic on ^P */ }; #include "../port/portdat.h" diff --git a/gnot/devcons.c b/gnot/devcons.c deleted file mode 100644 index 616ea30b61237fe4c2aaaceacf1f017516241c0a..0000000000000000000000000000000000000000 --- a/gnot/devcons.c +++ /dev/null @@ -1,715 +0,0 @@ -#include "u.h" -#include "lib.h" -#include "mem.h" -#include "dat.h" -#include "fns.h" -#include "io.h" -#include "errno.h" - -#include "devtab.h" - -struct { - IOQ; /* lock to klogputs */ - QLock; /* qlock to getc */ -} klogq; - -IOQ lineq; /* lock to getc; interrupt putc's */ -IOQ printq; -IOQ mouseq; -KIOQ kbdq; - -Ref raw; /* whether kbd i/o is raw (rcons is open) */ - -/* - * init the queues and set the output routine - */ -void -printinit(void) -{ - initq(&printq); - initq(&lineq); - initq(&kbdq); - initq(&klogq); - initq(&mouseq); - mouseq.putc = mouseputc; -} - -/* - * Print a string on the console. Convert \n to \r\n - */ -void -putstrn(char *str, int n) -{ - int s, c, m; - char *t; - - while(n > 0){ - if(printq.puts && *str=='\n') - (*printq.puts)(&printq, "\r", 1); - m = n; - t = memchr(str+1, '\n', m-1); - if(t) - if(t-str < m) - m = t - str; - if(printq.puts) - (*printq.puts)(&printq, str, m); - screenputs(str, m); - n -= m; - str += m; - } -} - -/* - * Print a string in the kernel log. Ignore overflow. - */ -void -klogputs(char *str, long n) -{ - int s, m; - uchar *nextin; - - s = splhi(); - lock(&klogq); - while(n){ - m = &klogq.buf[NQ] - klogq.in; - if(m > n) - m = n; - memmove(klogq.in, str, m); - n -= m; - str += m; - nextin = klogq.in + m; - if(nextin >= &klogq.buf[NQ]) - klogq.in = klogq.buf; - else - klogq.in = nextin; - } - unlock(&klogq); - splx(s); - wakeup(&klogq.r); -} - -int -isbrkc(KIOQ *q) -{ - uchar *p; - - for(p=q->out; p!=q->in; ){ - if(raw.ref) - return 1; - if(*p==0x04 || *p=='\n') - return 1; - p++; - if(p >= q->buf+sizeof(q->buf)) - p = q->buf; - } - return 0; -} - -int -sprint(char *s, char *fmt, ...) -{ - return doprint(s, s+PRINTSIZE, fmt, (&fmt+1)) - s; -} - -int -print(char *fmt, ...) -{ - char buf[PRINTSIZE]; - int n; - - n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; - putstrn(buf, n); - return n; -} - -int -kprint(char *fmt, ...) -{ - char buf[PRINTSIZE]; - int n; - - n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; - klogputs(buf, n); - return n; -} - -void -panic(char *fmt, ...) -{ - char buf[PRINTSIZE]; - int n; - - strcpy(buf, "panic: "); - n = doprint(buf+7, buf+sizeof(buf), fmt, (&fmt+1)) - buf; - buf[n] = '\n'; - putstrn(buf, n+1); - dumpstack(); - for(;;); -} - -int -pprint(char *fmt, ...) -{ - char buf[2*PRINTSIZE]; - Chan *c; - int n; - - c = u->fd[2]; - if(c==0 || (c->mode!=OWRITE && c->mode!=ORDWR)) - return 0; - n = sprint(buf, "%s %d: ", u->p->text, u->p->pid); - n = doprint(buf+n, buf+sizeof(buf), fmt, (&fmt+1)) - buf; - qlock(&c->wrl); - if(waserror()){ - qunlock(&c->wrl); - return 0; - } - (*devtab[c->type].write)(c, buf, n, c->offset); - c->offset += n; - qunlock(&c->wrl); - poperror(); - return n; -} - -void -prflush(void) -{ - while(printq.in != printq.out) ; -} - -void -echo(int c) -{ - char ch; - static int ctrlt; - - /* - * ^t hack BUG - */ - if(ctrlt == 2){ - ctrlt = 0; - switch(c){ - case 0x14: - break; /* pass it on */ - case 'm': - mntdump(); - return; - case 'p': - DEBUG(); - return; - case 'q': - dumpqueues(); - return; - case 'r': - firmware(); - break; - } - }else if(c == 0x14){ - ctrlt++; - return; - } - ctrlt = 0; - if(raw.ref) - return; - if(c == 0x15) - putstrn("^U\n", 3); - else{ - ch = c; - putstrn(&ch, 1); - } -} - -/* - * Put character into read queue at interrupt time. - * Always called splhi from proc 0. - */ -int -kbdputc(IOQ *q, int ch) -{ - echo(ch); - kbdq.c = ch; - *kbdq.in++ = ch; - if(kbdq.in == kbdq.buf+sizeof(kbdq.buf)) - kbdq.in = kbdq.buf; - if(raw.ref || ch=='\n' || ch==0x04) - wakeup(&kbdq.r); - return 0; -} - -void -kbdrepeat(int rep) -{ - kbdq.repeat = rep; - kbdq.count = 0; -} - -void -kbdclock(void) -{ - if(kbdq.repeat == 0) - return; - if(kbdq.repeat==1 && ++kbdq.count>HZ){ - kbdq.repeat = 2; - kbdq.count = 0; - return; - } - if(++kbdq.count&1) - kbdputc(&kbdq, kbdq.c); -} - -int -consactive(void) -{ - return printq.in != printq.out; -} - -/* - * I/O interface - */ -enum{ - Qdir, - Qcons, - Qcputime, - Qlights, - Qnoise, - Qnull, - Qpgrpid, - Qpid, - Qppid, - Qrcons, - Qtime, - Quser, - Qklog, - Qmsec, - Qclock, - Qsysstat, -}; - -Dirtab consdir[]={ - "cons", {Qcons}, 0, 0600, - "cputime", {Qcputime}, 6*NUMSIZE, 0600, - "lights", {Qlights}, 0, 0600, - "noise", {Qnoise}, 0, 0600, - "null", {Qnull}, 0, 0600, - "pgrpid", {Qpgrpid}, NUMSIZE, 0600, - "pid", {Qpid}, NUMSIZE, 0600, - "ppid", {Qppid}, NUMSIZE, 0600, - "rcons", {Qrcons}, 0, 0600, - "time", {Qtime}, NUMSIZE, 0600, - "user", {Quser}, 0, 0600, - "klog", {Qklog}, 0, 0400, - "msec", {Qmsec}, NUMSIZE, 0400, - "clock", {Qclock}, 2*NUMSIZE, 0400, - "sysstat", {Qsysstat}, 0, 0600, -}; - -#define NCONS (sizeof consdir/sizeof(Dirtab)) - -ulong boottime; /* seconds since epoch at boot */ - -long -seconds(void) -{ - return boottime + TK2SEC(MACHP(0)->ticks); -} - -int -readnum(ulong off, char *buf, ulong n, ulong val, int size) -{ - char tmp[64]; - Op op = (Op){ tmp, tmp+sizeof(tmp), &val, size-1, 0, FUNSIGN|FLONG }; - - numbconv(&op, 10); - tmp[size-1] = ' '; - if(off >= size) - return 0; - if(off+n > size) - n = size-off; - memmove(buf, tmp+off, n); - return n; -} - -int -readstr(ulong off, char *buf, ulong n, char *str) -{ - int size; - - size = strlen(str); - if(off >= size) - return 0; - if(off+n > size) - n = size-off; - memmove(buf, str+off, n); - return n; -} - -void -consreset(void) -{ -} - -void -consinit(void) -{ -} - -Chan* -consattach(char *spec) -{ - return devattach('c', spec); -} - -Chan* -consclone(Chan *c, Chan *nc) -{ - return devclone(c, nc); -} - -int -conswalk(Chan *c, char *name) -{ - return devwalk(c, name, consdir, NCONS, devgen); -} - -void -consstat(Chan *c, char *dp) -{ - devstat(c, dp, consdir, NCONS, devgen); -} - -Chan* -consopen(Chan *c, int omode) -{ - int ch; - - switch(c->qid.path){ - case Quser: - if(omode==(OWRITE|OTRUNC)){ - /* truncate? */ - if(strcmp(u->p->pgrp->user, "bootes") == 0) /* BUG */ - u->p->pgrp->user[0] = 0; - else - error(Eperm); - } - break; - case Qrcons: - if(incref(&raw) == 1){ - lock(&lineq); - while((ch=getc(&kbdq)) != -1){ - *lineq.in++ = ch; - if(lineq.in == lineq.buf+sizeof(lineq.buf)) - lineq.in = lineq.buf; - } - unlock(&lineq); - } - break; - } - return devopen(c, omode, consdir, NCONS, devgen); -} - -void -conscreate(Chan *c, char *name, int omode, ulong perm) -{ - error(Eperm); -} - -void -consclose(Chan *c) -{ - if(c->qid.path==Qrcons && (c->flag&COPEN)) - decref(&raw); -} - - -long -consread(Chan *c, void *buf, long n, ulong offset) -{ - int ch, i, j, k, id; - ulong l; - uchar *out; - char *cbuf = buf; - char *user; - int userlen; - char tmp[6*NUMSIZE], xbuf[1024]; - Mach *mp; - - if(n <= 0) - return n; - switch(c->qid.path & ~CHDIR){ - case Qdir: - return devdirread(c, buf, n, consdir, NCONS, devgen); - - case Qrcons: - case Qcons: - qlock(&kbdq); - if(waserror()){ - qunlock(&kbdq); - nexterror(); - } - while(!cangetc(&lineq)){ - sleep(&kbdq.r, isbrkc, &kbdq); - do{ - lock(&lineq); - ch = getc(&kbdq); - if(raw.ref){ - unlock(&lineq); - goto Default; - } - switch(ch){ - case '\b': - if(lineq.in != lineq.out){ - if(lineq.in == lineq.buf) - lineq.in = lineq.buf+sizeof(lineq.buf); - lineq.in--; - } - break; - case 0x15: - lineq.in = lineq.out; - break; - Default: - default: - *lineq.in = ch; - if(lineq.in >= lineq.buf+sizeof(lineq.buf)-1) - lineq.in = lineq.buf; - else - lineq.in++; - } - unlock(&lineq); - }while(raw.ref==0 && ch!='\n' && ch!=0x04); - } - i = 0; - while(n > 0){ - ch = getc(&lineq); - if(ch==-1 || (raw.ref==0 && ch==0x04)) - break; - i++; - *cbuf++ = ch; - --n; - } - qunlock(&kbdq); - return i; - - case Qcputime: - k = offset; - if(k >= sizeof tmp) - return 0; - if(k+n > sizeof tmp) - n = sizeof tmp - k; - /* easiest to format in a separate buffer and copy out */ - for(i=0; i<6 && NUMSIZE*ip->time[i]; - if(i == TReal) - l = MACHP(0)->ticks - l; - l = TK2MS(l); - readnum(0, tmp+NUMSIZE*i, NUMSIZE, l, NUMSIZE); - } - memmove(buf, tmp+k, n); - return n; - - case Qpgrpid: - return readnum(offset, buf, n, u->p->pgrp->pgrpid, NUMSIZE); - - case Qpid: - return readnum(offset, buf, n, u->p->pid, NUMSIZE); - - case Qppid: - return readnum(offset, buf, n, u->p->parentpid, NUMSIZE); - - case Qtime: - return readnum(offset, buf, n, boottime+TK2SEC(MACHP(0)->ticks), 12); - - case Qclock: - k = offset; - if(k >= 2*NUMSIZE) - return 0; - if(k+n > 2*NUMSIZE) - n = 2*NUMSIZE - k; - readnum(0, tmp, NUMSIZE, MACHP(0)->ticks, NUMSIZE); - readnum(0, tmp+NUMSIZE, NUMSIZE, HZ, NUMSIZE); - memmove(buf, tmp+k, n); - return n; - - case Quser: - return readstr(offset, buf, n, u->p->pgrp->user); - - case Qnull: - return 0; - - case Qklog: - qlock(&klogq); - if(waserror()){ - qunlock(&klogq); - nexterror(); - } - while(!cangetc(&klogq)) - sleep(&klogq.r, cangetc, &klogq); - for(i=0; iticks), NUMSIZE); - - case Qsysstat: - j = 0; - for(id = 0; id < 32; id++) { - if(active.machs & (1<cs, mp->intr, mp->syscall, mp->pfault, - mp->tlbfault, mp->tlbpurge, m->spinlock); - } - } - return readstr(offset, buf, n, xbuf); - - default: - panic("consread %lux\n", c->qid); - return 0; - } -} - -void -conslights(char *a, int n) -{ - int l; - char line[128]; - char *lp; - int c; - - lp = line; - while(n--){ - *lp++ = c = *a++; - if(c=='\n' || n==0 || lp==&line[sizeof(line)-1]) - break; - } - *lp = 0; - lights(strtoul(line, 0, 0)); -} - -void -consnoise(char *a, int n) -{ - int freq; - int duration; - char line[128]; - char *lp; - int c; - - lp = line; - while(n--){ - *lp++ = c = *a++; - if(c=='\n' || n==0 || lp==&line[sizeof(line)-1]){ - *lp = 0; - freq = strtoul(line, &lp, 0); - while(*lp==' ' || *lp=='\t') - lp++; - duration = strtoul(lp, &lp, 0); - buzz(freq, duration); - lp = line; - } - } -} - -long -conswrite(Chan *c, void *va, long n, ulong offset) -{ - char cbuf[64]; - char buf[256]; - long l, m; - char *a = va; - Mach *mp; - int id; - - switch(c->qid.path){ - case Qrcons: - case Qcons: - /* - * Damn. Can't page fault in putstrn, so copy the data locally. - */ - l = n; - while(l > 0){ - m = l; - if(m > sizeof buf) - m = sizeof buf; - memmove(buf, a, m); - putstrn(a, m); - a += m; - l -= m; - } - break; - - case Qtime: - if(n<=0 || boottime!=0) /* only one write please */ - return 0; - if(n >= sizeof cbuf) - n = sizeof cbuf - 1; - memmove(cbuf, a, n); - cbuf[n-1] = 0; - boottime = strtoul(a, 0, 0); - break; - - case Quser: - if(u->p->pgrp->user[0]) /* trying to overwrite /dev/user */ - error(Eperm); - if(offset >= NAMELEN-1) - return 0; - if(offset+n >= NAMELEN-1) - n = NAMELEN-1 - offset; - memmove(u->p->pgrp->user+offset, a, n); - u->p->pgrp->user[offset+n] = 0; - break; - - case Qcputime: - case Qpgrpid: - case Qpid: - case Qppid: - error(Eperm); - - case Qnull: - break; - - case Qnoise: - consnoise(a, n); - break; - - case Qlights: - conslights(a, n); - break; - - case Qsysstat: - for(id = 0; id < 32; id++) { - if(active.machs & (1<cs = 0; - mp->intr = 0; - mp->syscall = 0; - mp->pfault = 0; - mp->tlbfault = 0; - mp->tlbpurge = 0; - mp->spinlock = 0; - } - } - break; - - default: - error(Egreg); - } - return n; -} - -void -consremove(Chan *c) -{ - error(Eperm); -} - -void -conswstat(Chan *c, char *dp) -{ - error(Eperm); -} diff --git a/gnot/devduart.c b/gnot/devduart.c index bbdac1fefc43e398fb28eec39cddb4c0783d65d0..48b1f86986ea0bb733c8f8853a342b6c81dfdb55 100644 --- a/gnot/devduart.c +++ b/gnot/devduart.c @@ -578,7 +578,7 @@ duartputs(IOQ *cq, char *s, int n) } void -duartdevice(Duartport *dp) +duartenable(Duartport *dp) { /* * set up i/o routines @@ -602,7 +602,7 @@ duartspecial(int port, IOQ *oq, IOQ *iq, int baud) dp->nostream = 1; dp->oq = oq; dp->iq = iq; - duartdevice(dp); + duartenable(dp); duartbaud(baud); } @@ -805,7 +805,7 @@ duartreset(void) initq(dp->iq); dp->oq = ialloc(sizeof(IOQ), 0); initq(dp->oq); - duartdevice(dp); + duartenable(dp); } Chan* diff --git a/gnot/l.s b/gnot/l.s index 8fbf5fd62842ee9757922a8cf447f713d0e39be0..fd4173f7ab0b43b6d770aa161f7cf78e0d74a093 100644 --- a/gnot/l.s +++ b/gnot/l.s @@ -45,6 +45,11 @@ TEXT touser(SB), $-4 MOVL R0, CACR RTE +TEXT firmware(SB), $0 + + MOVL $0x40000090, A0 + JMP (A0) + TEXT splhi(SB), $0 MOVL m(SB), A0 diff --git a/gnot/lock.c b/gnot/lock.c index 5b3d41cba6e5156c6f32e7abbedd1287e8f734b3..f46a7e1b54130c0df4e38da824026c991d429557 100644 --- a/gnot/lock.c +++ b/gnot/lock.c @@ -64,3 +64,8 @@ mklockseg(Seg *s) { error(Esegaddr); } + +Page* +lkpage(Orig* o, ulong va) +{ +} diff --git a/gnot/main.c b/gnot/main.c index 97463580f05aef8729b694d85652052b33b29b07..620bea0fb406f909add03a5ea4f13adfc40e2e61 100644 --- a/gnot/main.c +++ b/gnot/main.c @@ -196,10 +196,12 @@ exit(void) int i; u = 0; + spllo(); + while(consactive()) + for(i=0; i<1000; i++) + ; splhi(); - print("exiting\n"); - for(;;) - ; + firmware(); } /* @@ -342,6 +344,7 @@ confinit(void) conf.nfsyschan = 31 + conf.nchan/20; conf.copymode = 0; /* copy on write */ conf.portispaged = 0; + conf.cntrlp = 0; } /* @@ -422,9 +425,3 @@ void lights(int val) { } - -void -firmware(void) -{ - panic("you asked for it"); -} diff --git a/gnot/mem.h b/gnot/mem.h index ec984e98f9c8391242e13c39d9f0f3f962e519b3..e7225a815e75cbd13e22e04554f8202f419322fb 100644 --- a/gnot/mem.h +++ b/gnot/mem.h @@ -72,6 +72,7 @@ #define PTEWRITE 0 #define PTERONLY (1<<14) #define PTEKERNEL (1<<15) +#define PTEUNCACHED 0 #define INVALIDPTE 0 #define PPN(pa) ((pa>>13)&0x1FFF) diff --git a/port/devcons.c b/port/devcons.c index 1c0a461f64bb6745092095d5ed34c2090175b740..3ffcd37f75e0331391ecfeff0b3c0b63fa2c1926 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -27,6 +27,7 @@ void printinit(void) { initq(&printq); + printq.puts = 0; initq(&lineq); initq(&kbdq); kbdq.putc = kbdputc; @@ -145,7 +146,10 @@ panic(char *fmt, ...) buf[n] = '\n'; putstrn(buf, n+1); dumpstack(); - exit(); + if(conf.cntrlp) + exit(); + else + for(;;); } int @@ -187,8 +191,9 @@ echo(int c) /* * ^p hack */ - if(c == 0x10) + if(c==0x10 && conf.cntrlp) panic("^p"); + /* * ^t hack BUG */ @@ -201,7 +206,7 @@ echo(int c) mntdump(); return; case 'p': - DEBUG(); + procdump(); return; case 'q': dumpqueues(); diff --git a/port/devnonet.c b/port/devnonet.c index cff60a7708e4a78dc837d11a7b00ad1001746ec7..bd8da4c3ce43f39b8bd082732080bea3bbffc633 100644 --- a/port/devnonet.c +++ b/port/devnonet.c @@ -912,7 +912,6 @@ noreset(Noconv *cp) case Cconnected: case Cconnecting: case Chungup: - print("resetting connection\n"); cp->state = Creset; cp->rcvcircuit = -1; bp = allocb(0); @@ -1162,7 +1161,7 @@ nonetrcvmsg(Noconv *cp, Block *bp) * Obey reset even if the message id is bogus */ if(f & NO_RESET){ - print("reset received\n"); + DPRINT("reset received\n"); noreset(cp); freeb(bp); return; @@ -1181,17 +1180,19 @@ nonetrcvmsg(Noconv *cp, Block *bp) case Copen: case Cannounced: case Creset: - panic("nonetrcvmsg %d %d\n", cp->rcvcircuit, cp - cp->ifc->conv); + DPRINT("nonetrcvmsg %d %d\n", cp->rcvcircuit, cp - cp->ifc->conv); + freeb(bp); + return; case Chungup: case Cconnected: - print("Nonet call on connected/hanging-up circ %d conv %d\n", + DPRINT("Nonet call on connected/hanging-up circ %d conv %d\n", cp->rcvcircuit, cp - cp->ifc->conv); freeb(bp); noreset(cp); return; case Cconnecting: if(h->mid != mp->mid){ - print("Nonet call on connecting circ %d conv %d\n", + DPRINT("Nonet call on connecting circ %d conv %d\n", cp->rcvcircuit, cp - cp->ifc->conv); freeb(bp); noreset(cp); @@ -1266,6 +1267,7 @@ nonetrcvmsg(Noconv *cp, Block *bp) if(mp->rem == 0){ cp->hdr->flag &= ~(NO_NEWCALL|NO_SERVICE); norack(cp, h->ack); + noqack(cp, h->mid); if(f & NO_ACKME) noqack(cp, h->mid); mp->last->flags |= S_DELIM; @@ -1457,10 +1459,10 @@ loop: */ if(cp->first!=cp->next && NOW>=cp->out[cp->first].time){ mp = &(cp->out[cp->first]); -/* if(cp->rexmit++ > 15){ + if(cp->rexmit++ > 15){ norack(cp, mp->mid); noreset(cp); - } else /**/ + } else nosend(cp, mp); } @@ -1469,7 +1471,7 @@ loop: */ while(cp->afirst!=cp->anext && cp->rq->next->len<16*1024){ DPRINT("sending ack %d\n", cp->ack[cp->afirst]); - nosendctl(cp, NO_NULL, 0); + nosendctl(cp, /*NO_NULL*/0, 0); } qunlock(cp); } diff --git a/port/fault.c b/port/fault.c index 3a9c145887a794f82eb8c513a3534f5e7e6d7402..fd6e061c56ad60eadb35e3091e932ae04bd66b2e 100644 --- a/port/fault.c +++ b/port/fault.c @@ -9,7 +9,7 @@ int fault(ulong addr, int read) { - ulong mmuvirt, mmuphys, uncache = 0, n; + ulong mmuvirt, mmuphys, n; Seg *s; PTE *opte, *pte, *npte; Orig *o; @@ -71,7 +71,6 @@ fault(ulong addr, int read) unlock(o); return -1; } - uncache = PTEUNCACHED; } else pte->page = newpage(0, o, addr); @@ -116,12 +115,19 @@ fault(ulong addr, int read) } } } - /* - * Copy on reference (conf.copymode==1) or write (conf.copymode==0) - */ - if((o->flag & (OWRPERM|OSHARED))==OWRPERM && (conf.copymode || !read) + + if(o->flag&OSHARED) { + /* BUG: Does not cover enough flag options to shared data */ + mmuphys = PTERONLY; + if(o->flag & OWRPERM) + mmuphys = PTEWRITE; + } + else if((o->flag&OWRPERM) && (conf.copymode || !read) && ((head && ((o->flag&OPURE) || o->nproc>1)) || (!head && pte->page->ref>1))){ + /* + * Copy on reference (conf.copymode==1) or write (conf.copymode==0) + */ if(!(o->flag&OISMEM)) panic("copy on ref/wr to non memory"); @@ -199,9 +205,13 @@ fault(ulong addr, int read) mmuphys = PTEWRITE; } mmuvirt = addr; - mmuphys |= PPN(pte->page->pa) | PTEVALID | uncache; - if(o->flag&OISMEM) + + /* Non memory is always uncached */ + if(o->flag&OISMEM) { + mmuphys |= PPN(pte->page->pa) | PTEVALID; usepage(pte->page, 1); + }else + mmuphys |= PPN(pte->page->pa) | PTEVALID | PTEUNCACHED; if(pte->page->va != addr) panic("wrong addr in tail %lux %lux", pte->page->va, addr); @@ -216,6 +226,10 @@ fault(ulong addr, int read) m->tlbfault++; putmmu(mmuvirt, mmuphys); +/* + if(s - u->p->seg == LSEG) + print("%d: f %lux v %lux p %lux\n", u->p->pid, o->flag, mmuvirt, mmuphys); +*/ return 0; } diff --git a/port/portfns.h b/port/portfns.h index 35e914d54010a565e9de02cc4edda9c764c76ce2..418a2906d3d56404f40f6df12eaeda19f1fcd3bc 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -26,6 +26,7 @@ void closepgrp(Pgrp*); long clrfpintr(void); int compactpte(Orig*, ulong); void confinit(void); +int consactive(void); Env* copyenv(Env*, int); int decref(Ref*); void delay(int); @@ -94,6 +95,7 @@ Orig* lookorig(ulong, ulong, int, Chan*); void machinit(void); void mapstack(Proc*); void mklockseg(Seg*); +void mntdump(void); void mmurelease(Proc*); int mount(Chan*, Chan*, int); int mouseputc(IOQ*, int); @@ -129,6 +131,7 @@ void putstr(char*); void putstrn(char*, long); void puts(IOQ*, void*, int); ulong procalarm(ulong); +void procdump(void); void procinit0(void); Proc* proctab(int); Block* pullup(Block *, int); diff --git a/port/proc.c b/port/proc.c index 032ed66b5b34a9c909dbc2a323a7bcda11e738f3..1e0dba1e2db3e815fc22ea8ad64595d1d4b252f2 100644 --- a/port/proc.c +++ b/port/proc.c @@ -564,7 +564,7 @@ proctab(int i) #include void -DEBUG(void) +procdump(void) { int i; Proc *p; diff --git a/port/stnoether.c b/port/stnoether.c index eff320897bcf3775a507319ebc7338af57d910c8..c748e85b0b0ebd08865bb9061ca8db4909fdd932 100644 --- a/port/stnoether.c +++ b/port/stnoether.c @@ -270,13 +270,13 @@ etherparse(uchar *to, char *from) error(Ebadnet); for(i = 0; i < 6; i++){ - fdig = *from++; - tdig = fdig > 'a' ? (fdig - 'a' + 10) - : (fdig > 'A' ? (fdig - 'A' + 10) : (fdig - '0')); - fdig = *from++; + fdig = (*from++)&0x7f; + tdig = fdig >= 'a' ? ((fdig - 'a') + 10) + : (fdig >= 'A' ? ((fdig - 'A') + 10) : (fdig - '0')); + fdig = (*from++)&0x7f; tdig <<= 4; - tdig |= fdig > 'a' ? (fdig - 'a' + 10) - : (fdig > 'A' ? (fdig - 'A' + 10) : (fdig - '0')); + tdig |= fdig >= 'a' ? ((fdig - 'a') + 10) + : (fdig >= 'A' ? ((fdig - 'A') + 10) : (fdig - '0')); *to++ = tdig; } } diff --git a/power/conf.h b/power/conf.h index 0ec75659080993e5b400fbc4db86ef3b264bc457..9877b5ce3e3f1451fe980329e1378ec6a4cdcace 100644 --- a/power/conf.h +++ b/power/conf.h @@ -34,6 +34,7 @@ Conftab conftab[] = { {"ip", &conf.ip }, {"arp", &conf.arp }, {"frag", &conf.frag }, + {"cntrlp", &conf.cntrlp }, { 0, 0 }, }; diff --git a/power/dat.h b/power/dat.h index d2706ffbc4c4b1bfec68ec7f5326dd4c126e7c88..ca9575bc0269a3c6a72e97d328818e3d16169f4a 100644 --- a/power/dat.h +++ b/power/dat.h @@ -71,7 +71,7 @@ struct Conf ulong ip; /* Ip conversations per interface */ ulong arp; /* Arp table size */ ulong frag; /* Ip fragment assemble queue size */ - + ulong cntrlp; /* panic on ^P */ }; /* diff --git a/power/main.c b/power/main.c index a44adeed67bf95f3b0c35533bdb3cb355e185e26..4fb3932d94526bbc546096d3efa92bb22b503c49 100644 --- a/power/main.c +++ b/power/main.c @@ -645,6 +645,7 @@ confinit(void) conf.ip = 64; conf.arp = 32; conf.frag = 32; + conf.cntrlp = 1; confread(); diff --git a/ss/dat.h b/ss/dat.h index 13e9bc1fcdd2aa9bca9ec2721dbbf7ad24605f22..2c7baa6a773cf23ee594b3c0b2aba2c23844f511 100644 --- a/ss/dat.h +++ b/ss/dat.h @@ -93,6 +93,7 @@ struct Conf int nfsyschan; /* number of filsys open channels */ ulong maxialloc; /* maximum bytes used by ialloc */ int copymode; /* 0 is copy on write, 1 is copy on reference */ + int cntrlp; /* panic on ^P */ }; /* diff --git a/ss/main.c b/ss/main.c index b0e682241e8aee8989f7a6cd7925c5d2b26b9280..bb0960e7129eaae45c6ab7af6df7f1a82a2d2547 100644 --- a/ss/main.c +++ b/ss/main.c @@ -81,11 +81,16 @@ ioinit(void) { KMap *k; + /* tell scc driver it's address */ k = kmappa(KMDUART, PTEIO|PTENOCACHE); sccsetup((void*)(k->va)); - sccspecial(0, 0, &kbdq, 2400); /* scc port 0 is the keyboard */ + + /* scc port 0 is the keyboard */ + sccspecial(0, 0, &kbdq, 2400); kbdq.putc = kbdstate; - sccspecial(1, 0, &mouseq, 2400); /* scc port 1 is the mouse */ + + /* scc port 1 is the mouse */ + sccspecial(1, 0, &mouseq, 2400); } void @@ -170,9 +175,12 @@ exit(void) int i; u = 0; + spllo(); + print("cpu %d exiting\n", m->machno); + while(consactive()) + for(i=0; i<1000; i++) + ; splhi(); - print("exiting\n"); - delay(30*1000); reset(); } @@ -291,6 +299,7 @@ confinit(void) conf.nservice = 3*mul; /* was conf.nproc/5 */ conf.nfsyschan = 31 + conf.nchan/20; conf.copymode = 0; /* copy on write */ + conf.cntrlp = 0; } /*