From 82c8bd9155eb43b22edb049dfa12fa196a2917fe Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 9 Apr 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-04-09 --- pc/devether.c | 57 ++++++++++++++++++++++++++------------------------ pc/devuart.c | 8 +++++-- pc/fns.h | 1 + pc/kbd.c | 2 -- pc/main.c | 4 +++- pc/trap.c | 1 - pc/vga.c | 1 - port/devcons.c | 2 +- port/devdk.c | 29 ++++++++++++++++++++++++- port/portdat.h | 4 ++-- port/sturp.c | 2 +- power/trap.c | 3 ++- ss/trap.c | 3 ++- 13 files changed, 76 insertions(+), 41 deletions(-) diff --git a/pc/devether.c b/pc/devether.c index 994af466fd2af2bedc118f0cc0476b65356765d6..2d5690bb00cad8d2320ba854c181e9e00c3cc566 100644 --- a/pc/devether.c +++ b/pc/devether.c @@ -111,7 +111,6 @@ struct Ctlr { Queue rq; uchar bnry; uchar curr; - uchar ovw; Etherpkt *xpkt; QLock xl; @@ -145,7 +144,7 @@ isxfree(void *arg) { Ctlr *cp = arg; - return cp->xbusy == 0 && cp->ovw == 0; + return cp->xbusy == 0; } static void @@ -378,22 +377,8 @@ intr(Ureg *ur) cp->xbusy = 0; wakeup(&cp->xr); } - /* - * the receive ring is full. - * put the NIC into loopback mode to give - * kproc a chance to process some packets. - */ - if(isr & Ovw){ - outb(cp->iobase+Cr, 0x21); /* Page0, RD2|STP */ - outb(cp->iobase+Rbcr0, 0); - outb(cp->iobase+Rbcr1, 0); - while((inb(cp->iobase+Isr) & Rst) == 0) - delay(1); - outb(cp->iobase+Tcr, 0x20); /* LB0 */ - outb(cp->iobase+Cr, 0x22); /* Page0, RD2|STA */ - cp->ovw = 1; + if(isr & Ovw) cp->overflows++; - } /* * we have received packets. * this is the only place, other than the init code, @@ -404,6 +389,8 @@ intr(Ureg *ur) if(isr & (Ovw|Prx)){ outb(cp->iobase+Cr, 0x62); /* Page1, RD2|STA */ cp->curr = inb(cp->iobase+Curr); +if(cp->curr == 0) + print("C0: b%d i%ux\n", cp->bnry, isr); outb(cp->iobase+Cr, 0x22); /* Page0, RD2|STA */ wakeup(&cp->rr); } @@ -451,8 +438,14 @@ etherreset(void) { Ctlr *cp = &ctlr[0]; int i; + uchar msr; cp->iobase = IObase; + msr = 0x40|inb(cp->iobase); + outb(cp->iobase, msr); +for(i = 0; i < 0x10; i++) + print("#%2.2ux ", inb(cp->iobase+i)); +print("\n"); for(i = 0; i < sizeof(cp->ea); i++) cp->ea[i] = inb(cp->iobase+EA+i); init(cp); @@ -574,16 +567,6 @@ etherkproc(void *arg) cp->bnry = PREV(bnry, 32); outb(cp->iobase+Bnry, cp->bnry); } - - /* - * if we idled input because of overflow, - * restart - */ - if(cp->ovw){ - cp->ovw = 0; - outb(cp->iobase+Tcr, 0); - wakeup(&cp->xr); - } } } @@ -669,3 +652,23 @@ etherwrite(Chan *c, char *a, long n, ulong offset) { return streamwrite(c, a, n, 0); } + +void +etherdump(void) +{ + Ctlr *cp = &ctlr[0]; + uchar bnry, curr, isr; + int s; + + s = splhi(); + bnry = inb(cp->iobase+Bnry); + outb(cp->iobase+Cr, 0x62); /* Page1, RD2|STA */ + curr = inb(cp->iobase+Curr); + outb(cp->iobase+Cr, 0x22); /* Page0, RD2|STA */ + isr = inb(cp->iobase+Isr); + print("b%d c%d x%d B%d C%d I%ux", + cp->bnry, cp->curr, cp->xbusy, bnry, curr, isr); + print("\t%d %d %d %d %d %d %d\n", cp->inpackets, cp->opackets, + cp->crcs, cp->oerrs, cp->frames, cp->overflows, cp->buffs); + splx(s); +} diff --git a/pc/devuart.c b/pc/devuart.c index c03f27dcb4a16f863476e9d57c44e5ddb6472851..a26ad64def7efa6d117f29a7757bbff56e2c4a22 100644 --- a/pc/devuart.c +++ b/pc/devuart.c @@ -236,8 +236,10 @@ uartintr(Uart *up) break; case 4: /* received data available */ - cq = up->iq; ch = uartrdreg(up, Data) & 0xff; + cq = up->iq; + if(cq == 0) + break; if(cq->putc) (*cq->putc)(cq, ch); else @@ -246,6 +248,8 @@ uartintr(Uart *up) case 2: /* transmitter empty */ cq = up->oq; + if(cq == 0) + break; lock(cq); ch = getc(cq); if(ch < 0){ @@ -263,7 +267,7 @@ uartintr(Uart *up) default: if(s&1) return; -/* print("weird modem interrupt\n");/**/ + print("weird modem interrupt\n"); break; } } diff --git a/pc/fns.h b/pc/fns.h index 7f1eb4a7509042be70e134925528becab6c47a36..598720c59171c5b8af415782abcbba750d5c7706 100644 --- a/pc/fns.h +++ b/pc/fns.h @@ -61,6 +61,7 @@ void trapinit(void); int tas(void*); void uartclock(void); void uartintr0(Ureg*); +void uartspecial(int, IOQ*, IOQ*, int); void vgainit(void); #define waserror() (u->nerrlab++, setlabel(&u->errlab[u->nerrlab-1])) #define kmapperm(x) kmap(x) diff --git a/pc/kbd.c b/pc/kbd.c index 87ca9db5a1d77055b715f681e0c0acd06a5679bf..607b9348809bcd9b444ee99a01c1d7364ad701bf 100644 --- a/pc/kbd.c +++ b/pc/kbd.c @@ -223,8 +223,6 @@ kbdinit(void) /* set up /dev/eia0 as the mouse */ uartspecial(0, 0, &mouseq, 1200); -print("uartspecial done\n"); -delay(1000); break; } } diff --git a/pc/main.c b/pc/main.c index 3f3deb28fd8acad4f7a81c6a33bd1d514ae9366d..07e8aa5323360d6348141086407a9c0f5c11e1dd 100644 --- a/pc/main.c +++ b/pc/main.c @@ -25,9 +25,9 @@ main(void) mmuinit(); trapinit(); mathinit(); - kbdinit(); clockinit(); faultinit(); + kbdinit(); procinit0(); initseg(); grpinit(); @@ -422,6 +422,8 @@ exit(void) { int i; +etherdump(); +return; u = 0; print("exiting\n"); switch(machtype){ diff --git a/pc/trap.c b/pc/trap.c index 03c838198bdf6f74d4dd55e4cf2148e51a41f370..b409fda97f0ceff7c7f6d3a52f5687f6a4a1280f 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -253,7 +253,6 @@ trap(Ureg *ur) void dumpregs(Ureg *ur) { -splhi(); if(u) print("registers for %s %d\n", u->p->text, u->p->pid); else diff --git a/pc/vga.c b/pc/vga.c index 8bcd7a49d04933b2e3a5093d16feed6929230e60..d3a8f204e08614f342c33be762b24401dc0a55d1 100644 --- a/pc/vga.c +++ b/pc/vga.c @@ -174,7 +174,6 @@ screeninit(void) ulong *l; setmode(&mode12); - bigcursor(); /* * swizzle the font longs. diff --git a/port/devcons.c b/port/devcons.c index 321c1843af1f953727167aaa9f2c8ab39d5998a5..f45e6d262a640a8c1f70dfb58d95d075318bb507 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -13,9 +13,9 @@ struct { QLock; /* qlock to getc */ }klogq; +IOQ mouseq; IOQ lineq; /* lock to getc; interrupt putc's */ IOQ printq; -IOQ mouseq; KIOQ kbdq; static Ref ctl; /* number of opens to the control file */ diff --git a/port/devdk.c b/port/devdk.c index 44f25fccb4b4bb1ddb3f31329ba3f66808639275..b1a0b7aee79abb1e7109038760caeb916b6c59fb 100644 --- a/port/devdk.c +++ b/port/devdk.c @@ -95,6 +95,7 @@ struct Line { char addr[64]; char raddr[64]; char ruser[32]; + char other[32]; Dk *dp; /* interface contianing this line */ }; @@ -200,6 +201,7 @@ static int dklisten(Chan*); static void dkfilladdr(Chan*, char*, int); static void dkfillraddr(Chan*, char*, int); static void dkfillruser(Chan*, char*, int); +static void dkfillother(Chan*, char*, int); extern Qinfo dkinfo; @@ -293,7 +295,7 @@ dkalloc(char *name, int ncsc, int lines) dp->net.listen = dklisten; dp->net.clone = dkcloneline; dp->net.prot = dp->prot; - dp->net.ninfo = 4; + dp->net.ninfo = 5; dp->net.info[0].name = "addr"; dp->net.info[0].fill = dkfilladdr; dp->net.info[1].name = "raddr"; @@ -302,6 +304,8 @@ dkalloc(char *name, int ncsc, int lines) dp->net.info[2].fill = dkfillruser; dp->net.info[3].name = "stats"; dp->net.info[3].fill = urpfillstats; + dp->net.info[4].name = "other"; + dp->net.info[4].fill = dkfillother; unlock(&dklock); return dp; @@ -545,6 +549,7 @@ out: if(lp->lineno == dp->ncsc) dp->csc = 0; netdisown(&dp->net, lp->lineno); + lp->window = 0; lock(dp); dp->ref--; @@ -945,6 +950,11 @@ dkfillruser(Chan *c, char *buf, int len) { strncpy(buf, dk[c->dev].linep[STREAMID(c->qid.path)]->ruser, len); } +void +dkfillother(Chan *c, char *buf, int len) +{ + strncpy(buf, dk[c->dev].linep[STREAMID(c->qid.path)]->other, len); +} /* * send a message to the datakit on the common signaling line @@ -1152,6 +1162,7 @@ dkcall(int type, Chan *c, char *addr, char *nuser, char *machine) */ strncpy(lp->addr, addr, sizeof(lp->addr)-1); strncpy(lp->raddr, addr, sizeof(lp->raddr)-1); + sprint(lp->other, "w=%d", lp->window); /* * reset the protocol @@ -1366,6 +1377,22 @@ dkanswer(Chan *c, int line, int code) streamwrite(dc, reply, strlen(reply), 1); close(dc); poperror(); + + /* + * set window size + */ + if(code == 0){ + if(waserror()){ + close(dc); + nexterror(); + } + sprint(reply, "init %d %d", lp->window, Streamhi); + dc = dkopenline(dp, line); + dc->qid.path = STREAMQID(line, Sctlqid); + streamwrite(dc, reply, strlen(reply), 1); + close(dc); + poperror(); + } } /* diff --git a/port/portdat.h b/port/portdat.h index 74f9a467b0b1a8853a4c3788e378dd4f06ab491a..f61ff891b3c41126e2c46b9901931dff68888d67 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -642,8 +642,8 @@ enum { Sdataqid = Shighqid, Sctlqid = Sdataqid-1, Slowqid = Sctlqid, - Streamhi= (9*1024), /* byte count high water mark */ - Streambhi= 32, /* block count high water mark */ + Streamhi= (32*1024), /* byte count high water mark */ + Streambhi= 128, /* block count high water mark */ }; /* diff --git a/port/sturp.c b/port/sturp.c index c854bb6fe29dbd8117142f643868218f2be72bd9..600141ab2eca6a51ecd1ebf539eb41341fe918f3 100644 --- a/port/sturp.c +++ b/port/sturp.c @@ -943,7 +943,7 @@ initoutput(Urp *up, int window) if(up->maxblock < 64) up->maxblock = 64; up->maxblock -= 4; - up->maxout = 3; + up->maxout = 4; /* * set sequence varialbles diff --git a/power/trap.c b/power/trap.c index e92437fe55c60687424e16f7319abe5589189ef7..ec664d0b477e18b3b038dbbce38a7cf555b6957e 100644 --- a/power/trap.c +++ b/power/trap.c @@ -421,6 +421,7 @@ notify(Ureg *ur) memmove((char*)sp, u->note[0].msg, ERRLEN); sp -= 3*BY2WD; *(ulong*)(sp+2*BY2WD) = sp+3*BY2WD; /* arg 2 is string */ + u->svr1 = ur->r1; /* save away r1 */ ur->r1 = (ulong)u->ureg; /* arg 1 is ureg* */ *(ulong*)(sp+0*BY2WD) = 0; /* arg 0 is pc */ ur->usp = sp; @@ -550,7 +551,7 @@ syscall(Ureg *aur) noted(&aur, *(ulong*)(sp+BY2WD)); /* doesn't return */ splhi(); if(r1!=FORK && (u->nnote || p->procctl)){ - u->svr1 = ret; + ur->r1 = ret; /* load up for noted() */ if(notify(ur)) return ur->r1; } diff --git a/ss/trap.c b/ss/trap.c index 83a86e56f277bc6849a7ae695bec88a43f027c77..dc79fdf97d9d15c1028853ef0cb2d962e2f39ceb 100644 --- a/ss/trap.c +++ b/ss/trap.c @@ -278,6 +278,7 @@ notify(Ureg *ur) sp -= 3*BY2WD; *(ulong*)(sp+2*BY2WD) = sp+3*BY2WD; /* arg 2 is string */ *(ulong*)(sp+1*BY2WD) = (ulong)u->ureg; /* arg 1 is ureg* (compat) */ + u->svr7 = ur->r7; /* save away r7 */ ur->r7 = (ulong)u->ureg; /* arg 1 is ureg* */ *(ulong*)(sp+0*BY2WD) = 0; /* arg 0 is pc */ ur->usp = sp; @@ -410,7 +411,7 @@ syscall(Ureg *aur) splhi(); if(r7!=FORK && (u->p->procctl || u->nnote)){ - u->svr7 = ret; + ur->r7 = ret; /* load up for noted() */ if(notify(ur)) return ur->r7; }