From d3db1bf97a4e521134c671db345ddb13dc2c262e Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 7 Jan 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-01-07 --- carrera/devether.c | 56 ++++++++++++++++++------------- port/devmnt.c | 82 ---------------------------------------------- port/devproc.c | 2 +- 3 files changed, 34 insertions(+), 106 deletions(-) diff --git a/carrera/devether.c b/carrera/devether.c index 9f6fe34b80c38d27e261fbce82b169cb20349fda..778739305dfaf053310fffed5f960d79c01b7d27 100644 --- a/carrera/devether.c +++ b/carrera/devether.c @@ -271,6 +271,7 @@ reset(Ether *ctlr) */ WR(cr, Rst); WR(dcr, 0x2423); /* 5-19 Carrera manual */ + WR(cr, 0); /* * Initialise the receive resource area (RRA) and @@ -379,11 +380,8 @@ reset(Ether *ctlr) WR(cdc, 1); /* - * End the reset * Load the Resource Descriptors and Cam contents */ - WR(cr, 0); - WR(cr, Rrra); while(RD(cr) & Rrra) ; @@ -397,7 +395,7 @@ reset(Ether *ctlr) * and interrupt-mask registers. * The SONIC is now initialised, but not enabled. */ - WR(rcr, Err|Rnt|Brd); + WR(rcr, Brd); WR(tcr, 0); WR(imr, AllIntr); } @@ -437,6 +435,7 @@ void etherintr(void) { Ether *c; + ushort *s; ulong status; TXpkt *txpkt; RXpkt *rxpkt; @@ -448,8 +447,20 @@ etherintr(void) if(status == 0) break; - /* Clear the interrupt cause */ - WR(isr, status); + /* + * Warnings that something is atoe. + */ + if(status & Hbl){ + WR(isr, Hbl); + status &= ~Hbl; + print("sonic: cd heartbeat lost\n"); + } + if(status & Br){ +WR(cr, Rst); + print("sonic: bus retry occurred\n"); +(*(void(*)(void))0xA001C020)(); + status &= ~Br; + } /* * Transmission complete, for good or bad. @@ -470,6 +481,7 @@ etherintr(void) c->ti = NEXT(c->ti, Ntb); txpkt = &c->tda[c->ti]; } + WR(isr, status & (Txdn|Txer)); status &= ~(Txdn|Txer); if(isoutbuf(c)) wakeup(&c->tr); @@ -500,19 +512,22 @@ etherintr(void) else c->buffs++; + rxpkt->status = 0; /* * Finished with this packet, it becomes the * last free packet in the ring, so give it Eol, * and take the Eol bit off the previous packet. * Move the ring index on. */ - rxpkt->link |= Eol; + wus(&rxpkt->link, rxpkt->link|Eol); rxpkt->owner = Interface; - c->rda[PREV(c->rh, Nrb)].link &= ~Eol; + s = &c->rda[PREV(c->rh, Nrb)].link; + wus(s, *s & ~Eol); c->rh = NEXT(c->rh, Nrb); rxpkt = &c->rda[c->rh]; } + WR(isr, status & (Pktrx|Rde)); status &= ~(Pktrx|Rde); noinput: @@ -520,23 +535,15 @@ etherintr(void) * We get a 'load CAM done' interrupt * after initialisation. Ignore it. */ - if(status & Lcd) + if(status & Lcd) { + WR(isr, Lcd); status &= ~Lcd; - - /* - * Warnings that something is atoe. - */ - if(status & Hbl){ - print("sonic: cd heartbeat lost\n"); - status &= ~Hbl; - } - if(status & Br){ - print("sonic: bus retry occurred\n"); - status &= ~Br; } - if(status & AllIntr) + if(status & AllIntr) { + WR(isr, status); print("sonic #%lux\n", status); + } } } @@ -716,6 +723,7 @@ long etherwrite(Chan *c, void *buf, long n, ulong offset) { Pbuf *p; + ushort *s; TXpkt *txpkt; Ether *ctlr = ether[0]; @@ -733,6 +741,7 @@ etherwrite(Chan *c, void *buf, long n, ulong offset) return n; qlock(&ctlr->tlock); + ctlr->outpackets++; if(waserror()) { qunlock(&ctlr->tlock); nexterror(); @@ -755,9 +764,10 @@ etherwrite(Chan *c, void *buf, long n, ulong offset) txpkt = &ctlr->tda[ctlr->th]; txpkt->size = n; txpkt->fsize = n; - txpkt->link |= Eol; + wus(&txpkt->link, txpkt->link|Eol); txpkt->status = Interface; - ctlr->tda[PREV(ctlr->th, Ntb)].link &= ~Eol; + s = &ctlr->tda[PREV(ctlr->th, Ntb)].link; + wus(s, *s & ~Eol); ctlr->th = NEXT(ctlr->th, Ntb); WR(cr, Txp); diff --git a/port/devmnt.c b/port/devmnt.c index e9b6400a39e2b10d50caa45b55bc4e91ea1956ec..f65d184caa4cad6d54bae3a1fa6c29106d48d045 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -53,7 +53,6 @@ int rpcattn(Mntrpc*); void mclose(Mnt*, Chan*); void mntrecover(Mnt*, Mntrpc*); Chan* mntchan(void); -int mntrpclen(char*, int); enum { @@ -1014,84 +1013,3 @@ mntrepl(char *buf) unlock(m); } - -static uchar -msglen[256] = -{ - [Tnop] 3, - [Rnop] 3, - [Tsession] 3+CHALLEN, - [Rsession] 3+NAMELEN+DOMLEN+CHALLEN, - [Terror] 0, - [Rerror] 67, - [Tflush] 5, - [Rflush] 3, - [Tattach] 5+2*NAMELEN+TICKETLEN+AUTHENTLEN, - [Rattach] 13+AUTHENTLEN, - [Tclone] 7, - [Rclone] 5, - [Twalk] 33, - [Rwalk] 13, - [Topen] 6, - [Ropen] 13, - [Tcreate] 38, - [Rcreate] 13, - [Tread] 15, - [Rread] 8, - [Twrite] 16, - [Rwrite] 7, - [Tclunk] 5, - [Rclunk] 5, - [Tremove] 5, - [Rremove] 5, - [Tstat] 5, - [Rstat] 121, - [Twstat] 121, - [Rwstat] 5, - [Tclwalk] 35, - [Rclwalk] 13, -}; - -enum -{ - Twritehdr = 16, /* Min bytes for Twrite */ - Rreadhdr = 8, /* Min bytes for Rread */ - Twritecnt = 13, /* Offset in byte stream of write count */ - Rreadcnt = 5, /* Offset for Readcnt */ -}; - -int -mntrpclen(char *d, int n) -{ - char t; - int len, off; - - if(n < 1) - return 0; - - t = d[0]; - switch(t) { /* This is the type */ - default: - len = msglen[t]; - if(len == 0) /* Illegal type so consume */ - return n; - if(n < len) - return 0; - return len; - case Twrite: /* Fmt: TGGFFOOOOOOOOCC */ - len = Twritehdr; /* T = type, G = tag, F = fid */ - off = Twritecnt; /* O = offset, C = count */ - break; - case Rread: /* Fmt: TGGFFCC */ - len = Rreadhdr; - off = Rreadcnt; - break; - } - if(n < off+2) - return 0; - - len += d[off]+(d[off+1]<<8); - if(n < len) - return 0; - return len; -} diff --git a/port/devproc.c b/port/devproc.c index c6dc6cf545794bdabe0ad914b9d1347def62444b..0c4ce2a08dca61947d2c2ade93993f33e0755dfe 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -1,4 +1,4 @@ - #include "u.h" +#include "u.h" #include "../port/lib.h" #include "mem.h" #include "dat.h"