From 22c3b720ac168e9417d1521c395ac0cb936bb63b Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 19 Nov 1993 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1993-11-19 --- pc/devether.c | 5 ++--- pc/ether509.c | 13 +++---------- pc/ether8003.c | 5 +++++ pc/ether8390.c | 27 ++++++++++++--------------- pc/etherif.h | 3 +-- port/devcons.c | 4 +++- 6 files changed, 26 insertions(+), 31 deletions(-) diff --git a/pc/devether.c b/pc/devether.c index 3940785040bbcba9183d27f5f43497d90cdf519f..67b2cb891e4b26c7346aff7772e7ff8d74bebae8 100644 --- a/pc/devether.c +++ b/pc/devether.c @@ -138,18 +138,17 @@ etherintr(Ureg *ur) } } -#define NCARD 32 static struct { char *type; int (*reset)(Ether*); -} cards[NCARD+1]; +} cards[MaxEther+1]; void addethercard(char *t, int (*r)(Ether*)) { static int ncard; - if(ncard == NCARD) + if(ncard == MaxEther) panic("too many ether cards"); cards[ncard].type = t; cards[ncard].reset = r; diff --git a/pc/ether509.c b/pc/ether509.c index e0b1f2819ebe32a2a062357a8e1334223df1893c..12fb8c0dec998cd0e1f0a6ccdd8768a80c36b4de 100644 --- a/pc/ether509.c +++ b/pc/ether509.c @@ -221,17 +221,13 @@ write(Ether *ether, void *buf, long n) port = ether->port; - qlock(ðer->tlock); - if(waserror()) { - qunlock(ðer->tlock); - nexterror(); - } - ether->tlen = n; len = ROUNDUP(ether->tlen, 4); tsleep(ðer->tr, istxfifo, ether, 10000); - if(len+4 > ins(port+TxFreeBytes)) + if(len+4 > ins(port+TxFreeBytes)){ print("ether509: transmitter jammed\n"); + return 0; + } /* * We know there's room, copy the packet to the FIFO. @@ -247,9 +243,6 @@ write(Ether *ether, void *buf, long n) outss(port+Fifo, ether->ea, Eaddrlen/2); outss(port+Fifo, (uchar*)buf+2*Eaddrlen, (len-2*Eaddrlen)/2); - poperror(); - qunlock(ðer->tlock); - return n; } diff --git a/pc/ether8003.c b/pc/ether8003.c index ae899a15491b70bc3b1dd9662a5a6a20c59c2554..19bc824a1f62799cb645bb76ac4d2863769b48c2 100644 --- a/pc/ether8003.c +++ b/pc/ether8003.c @@ -57,6 +57,10 @@ static int intrmap[] = { 9, 3, 5, 7, 10, 11, 15, 4, }; +static uchar debugea[6] = { + 0x00, 0x60, 0x8c, 0x00, 0x1a, 0x42, +}; + /* * Get configuration parameters, enable memory. * There are opportunities here for buckets of code. @@ -184,6 +188,7 @@ reset(Ether *ether) * ethernet address. */ dp8390reset(ether); +memmove(ether->ea, debugea, 6); dp8390setea(ether); return 0; diff --git a/pc/ether8390.c b/pc/ether8390.c index 21997919a27209c31033923851487cc14d1490c2..d020be67cd3ed252f6b48fa6202e25d52d19bbaf 100644 --- a/pc/ether8390.c +++ b/pc/ether8390.c @@ -446,7 +446,10 @@ receive(Ether *ether) for(fp = ether->f; fp < ep; fp++) { f = *fp; if(f && (f->type == type || f->type < 0)) +{ +print("Q%d|", len); qproduce(f->in, ðer->rpkt, len); +} } } @@ -464,9 +467,9 @@ receive(Ether *ether) } static int -istxbusy(void *arg) +istxavail(void *arg) { - return ((Dp8390*)arg)->busy == 0; + return ((Ether*)arg)->tlen == 0; } static long @@ -478,16 +481,12 @@ write(Ether *ether, void *buf, long n) dp8390 = ether->private; port = dp8390->dp8390; - qlock(ðer->tlock); - if(waserror()) { - qunlock(ðer->tlock); - nexterror(); - } - - tsleep(ðer->tr, istxbusy, dp8390, 10000); - if(dp8390->busy) + tsleep(ðer->tr, istxavail, ether, 10000); + if(ether->tlen){ print("dp8390: transmitter jammed\n"); - dp8390->busy = 1; + return 0; + } + ether->tlen = n; if(dp8390->ram) memmove((void*)(ether->mem+dp8390->tstart*Dp8390BufSz), buf, n); @@ -498,9 +497,6 @@ write(Ether *ether, void *buf, long n) dp8390outb(port+Tbcr1, (n>>8) & 0xFF); dp8390outb(port+Cr, Page0|RDMAabort|Txp|Sta); - poperror(); - qunlock(ðer->tlock); - return n; } @@ -555,6 +551,7 @@ interrupt(Ether *ether) */ dp8390outb(port+Imr, 0x00); while(isr = dp8390inb(port+Isr)){ +print("I%2.2ux|", isr); if(isr & Ovw){ overflow(ether); @@ -588,7 +585,7 @@ interrupt(Ether *ether) if(isr & Ptx) ether->outpackets++; - dp8390->busy = 0; + ether->tlen = 0; wakeup(ðer->tr); } diff --git a/pc/etherif.h b/pc/etherif.h index 2cc48ea9f7abc6b9dd7869eae8cdf6f455f7ed0e..364f94fbc21cdfbf16d01928931e7005cdb1d2c5 100644 --- a/pc/etherif.h +++ b/pc/etherif.h @@ -17,7 +17,7 @@ struct Ether { QLock tlock; /* lock for grabbing transmitter queue */ Rendez tr; /* wait here for free xmit buffer */ - long tlen; /* length of data in tb for txfifo management */ + long tlen; /* length of data in tpkt */ Netif; }; @@ -30,7 +30,6 @@ typedef struct { ulong data; /* I/O data port if no shared memory */ uchar nxtpkt; /* receive: software bndry */ - uchar busy; /* transmit: busy */ uchar tstart; /* 8390 ring addresses */ uchar pstart; uchar pstop; diff --git a/port/devcons.c b/port/devcons.c index 83d7e48d32ba8a0ba2776214a82136a5cd8df988..18922b8cc0a784ee58e60f10dabfef5bd9474a14 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -313,7 +313,9 @@ kbdclock(void) int consactive(void) { - return qlen(printq) > 0; + if(printq) + return qlen(printq) > 0; + return 0; } enum{