From cbdd3ea5e9f4f4cc52ec2de15341ba00cb84f1df Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 11 Apr 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-04-11 --- pc/devether.c | 52 +++++++++++++++++++++++++++++++++++++------------- pc/main.c | 3 +-- port/devcons.c | 3 +++ port/portfns.h | 1 + 4 files changed, 44 insertions(+), 15 deletions(-) diff --git a/pc/devether.c b/pc/devether.c index 45c20be5511fe8256bab4f7b5a1eadcc151f2cbc..c92a34ac3bfaa702fe06a30139760f82cd1b353f 100644 --- a/pc/devether.c +++ b/pc/devether.c @@ -26,7 +26,7 @@ typedef struct Ring Ring; enum { IObase = 0x360, - RAMbase = 0xD0000, + RAMbase = 0xC8000, RAMsize = 8*1024, BUFsize = 256, @@ -143,6 +143,30 @@ struct Ctlr { }; static Ctlr ctlr[Nctlr]; +static Etherpkt txpkt; + +static void +xmemmove(void *to, void *from, long len) +{ + ushort *t, *f; + int s; + Ctlr *cp = &ctlr[0]; + uchar reg; + + t = to; + f = from; + len = (len+1)/2; + s = splhi(); + reg = inb(cp->iobase+0x05); + outb(cp->iobase+Imr, 0); + outb(cp->iobase+0x05, 0x80|reg); + while(len--) + *t++ = *f++; + outb(cp->iobase+0x05, reg); + outb(cp->iobase+Imr, 0x1F); + splx(s); +} + static int isxfree(void *arg) { @@ -208,6 +232,7 @@ etheroput(Queue *q, Block *bp) */ qlock(&cp->xl); if(waserror()){ + freeb(bp); qunlock(&cp->xl); nexterror(); } @@ -215,8 +240,10 @@ etheroput(Queue *q, Block *bp) /* * Wait till we get an output buffer */ - sleep(&cp->xr, isxfree, cp); - p = cp->xpkt; + tsleep(&cp->xr, isxfree, cp, 1000); + if(isxfree(cp) == 0) + print("Tx wedged\n"); + p = &txpkt; /* * copy message into buffer @@ -244,6 +271,7 @@ etheroput(Queue *q, Block *bp) * give packet a local address */ memmove(p->s, cp->ea, sizeof(cp->ea)); + xmemmove(cp->xpkt, p, len); /* * start the transmission @@ -445,18 +473,16 @@ etherreset(void) { Ctlr *cp = &ctlr[0]; int i; - uchar msr; + uchar reg; cp->iobase = IObase; - msr = 0x40|inb(cp->iobase); - outb(cp->iobase, msr); -msr=0x40|inb(cp->iobase+0x05); -outb(cp->iobase+0x05, msr); + reg = 0x40|inb(cp->iobase); + outb(cp->iobase, reg); + reg = 0x40|inb(cp->iobase+0x05); + outb(cp->iobase+0x05, reg); for(i = 0; i < 0x10; i++) print("#%2.2ux ", inb(cp->iobase+i)); print("\n"); -msr=0x40|inb(cp->iobase+0x05); -outb(cp->iobase+0x05, msr); for(i = 0; i < sizeof(cp->ea); i++) cp->ea[i] = inb(cp->iobase+EA+i); init(cp); @@ -512,9 +538,9 @@ etherup(Ctlr *cp, uchar *d0, int len0, uchar *d1, int len1) } if(waserror() == 0){ bp = allocb(len0+len1); - memmove(bp->rptr, d0, len0); + xmemmove(bp->rptr, d0, len0); if(len1) - memmove(bp->rptr+len0, d1, len1); + xmemmove(bp->rptr+len0, d1, len1); bp->wptr += len0+len1; bp->flags |= S_DELIM; PUTNEXT(tp->q, bp); @@ -683,7 +709,7 @@ etherwrite(Chan *c, char *a, long n, ulong offset) } void -etherdump(void) +consdebug(void) { Ctlr *cp = &ctlr[0]; uchar bnry, curr, isr; diff --git a/pc/main.c b/pc/main.c index 07e8aa5323360d6348141086407a9c0f5c11e1dd..a95c1276713be6efdca8337b74cb1c3b9b0a4084 100644 --- a/pc/main.c +++ b/pc/main.c @@ -422,8 +422,6 @@ exit(void) { int i; -etherdump(); -return; u = 0; print("exiting\n"); switch(machtype){ @@ -431,6 +429,7 @@ return; headreset(); /* via headland chip */ break; case At: + print("hit the button..."); for(;;); putcr3(0); /* crash and burn */ } diff --git a/port/devcons.c b/port/devcons.c index f45e6d262a640a8c1f70dfb58d95d075318bb507..d50cf17f7e6f0832197738acee5c1d4000f68e1b 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -229,6 +229,9 @@ echo(Rune r, char *buf, int n) switch(r){ case 0x14: break; /* pass it on */ + case 'd': + consdebug(); + return; case 'm': mntdump(); return; diff --git a/port/portfns.h b/port/portfns.h index 5ff73307e0841bc194553cbe858ad002ea896c75..8d6ea8bb5bb635cbd47a12a5789843328b6856e9 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -29,6 +29,7 @@ void closepgrp(Pgrp*); long clrfpintr(void); void confinit(void); int consactive(void); +void consdebug(void); Block *copyb(Block*, int); Env* copyenv(Env*, int); void copypage(Page*, Page*);