| plan 9 kernel history: overview | file list | diff list |
1990/0419/port/devlance.c (diff list | history)
| 1990/0227/sys/src/9/port/devlance.c:750,756 – 1990/03011/sys/src/9/port/devlance.c:750,756 (short | long) | ||
| 1990/0227 | * See if a queue exists for this packet type. */ p = l.rp[l.rl]; | |
| 1990/03011 | t = (p->type[0]<<8) | p->type[1]; | |
| 1990/0227 | len = m->cntflags - 4; lancedebq("in", p, len); for(e = &l.e[0]; e < &l.e[Ntypes]; e++){ | |
| 1990/03011/sys/src/9/port/devlance.c:11,25 – 1990/03042/sys/src/9/port/devlance.c:11,28 (short | long) | ||
| 1990/0227 | */ enum { Ntypes= 8, /* max number of ethernet packet types */ | |
| 1990/03042 | Ndir= Ntypes+1, /* entries in top level directory */ | |
| 1990/0227 | LogNrrb= 7, /* log of number of receive buffers */ Nrrb= (1<<LogNrrb), /* number of recieve buffers */ LogNtrb= 7, /* log of number of transmit buffers */ Ntrb= (1<<LogNtrb), /* number of transmit buffers */ | |
| 1990/03042 | Ndpkt= 1000, /* number of debug packets */ | |
| 1990/0227 | }; #define RSUCC(x) (((x)+1)%Nrrb) #define TSUCC(x) (((x)+1)%Ntrb) | |
| 1990/03042 | #define NOW (MACHP(0)->ticks) | |
| 1990/0227 | /* * Communication with the lance is via a transmit and receive ring of * message descriptors. The Initblock contains pointers to and sizes of | |
| 1990/03011/sys/src/9/port/devlance.c:102,112 – 1990/03042/sys/src/9/port/devlance.c:105,119 | ||
| 1990/0227 | uchar data[40]; } Dpkt; typedef struct { | |
| 1990/03042 | ulong ticks; char tag; int len; Dpkt p; } Trace; typedef struct { | |
| 1990/0227 | Lock; int next; | |
| 1990/03042 | Trace t[Ndpkt]; | |
| 1990/0227 | } Debqueue; /* | |
| 1990/03011/sys/src/9/port/devlance.c:136,142 – 1990/03042/sys/src/9/port/devlance.c:143,148 | ||
| 1990/0227 | Ethertype e[Ntypes]; int debug; | |
| 1990/03011/sys/src/9/port/devlance.c:215,228 – 1990/03042/sys/src/9/port/devlance.c:221,236 | ||
| 1990/0227 | /* * print a packet preceded by a message */ | |
| 1990/03042 | sprintpacket(char *buf, Trace *t) | |
| 1990/0227 | { | |
| 1990/03042 | Dpkt *p = &t->p; sprint(buf, "%c: %.8ud %.4d d(%.2ux%.2ux%.2ux%.2ux%.2ux%.2ux)s(%.2ux%.2ux%.2ux%.2ux%.2ux%.2ux)t(%.2ux %.2ux)d(%.2ux%.2ux%.2ux%.2ux%.2ux%.2ux%.2ux%.2ux%.2ux%.2ux%.2ux%.2ux)\n", t->tag, t->ticks, t->len, p->d[0], p->d[1], p->d[2], p->d[3], p->d[4], p->d[5], p->s[0], p->s[1], p->s[2], p->s[3], p->s[4], p->s[5], p->type[0],p->type[1], p->data[0], p->data[1], p->data[2], p->data[3], p->data[4], p->data[5], p->data[6], p->data[7], p->data[8], p->data[9], p->data[10], p->data[11]); | |
| 1990/0227 | } /* | |
| 1990/03011/sys/src/9/port/devlance.c:229,240 – 1990/03042/sys/src/9/port/devlance.c:237,252 | ||
| 1990/0227 | * save a message in a circular queue for later debugging */ void | |
| 1990/03042 | lancedebq(char tag, Pkt *p, int len) | |
| 1990/0227 | { | |
| 1990/03042 | Trace *t; | |
| 1990/0227 | lock(&l.dq); | |
| 1990/03042 | t = &l.dq.t[l.dq.next]; t->ticks = NOW; t->tag = tag; t->len = len; memcpy(&(t->p), p, sizeof(Dpkt)); | |
| 1990/0227 | l.dq.next = (l.dq.next+1) % Ndpkt; unlock(&l.dq); } | |
| 1990/03011/sys/src/9/port/devlance.c:351,357 – 1990/03042/sys/src/9/port/devlance.c:363,369 | ||
| 1990/0227 | len = 0; while(bp = getq(q)){ if(sizeof(Pkt) - len >= (n = bp->wptr - bp->rptr)){ | |
| 1990/03042 | memcpy(((uchar *)p)+len, bp->rptr, n); | |
| 1990/0227 | len += n; } else print("no room damn it\n"); | |
| 1990/03011/sys/src/9/port/devlance.c:373,379 – 1990/03042/sys/src/9/port/devlance.c:385,391 | ||
| 1990/0227 | if(len < 60) len = 60; | |
| 1990/03042 | lancedebq('o', p, len); | |
| 1990/0227 | /* * set up the ring descriptor and hand to lance | |
| 1990/03011/sys/src/9/port/devlance.c:392,400 – 1990/03042/sys/src/9/port/devlance.c:404,413 | ||
| 1990/0227 | * lance directory */ enum { | |
| 1990/03042 | Lchanqid = 1, Ltraceqid = 2, | |
| 1990/0227 | }; | |
| 1990/03042 | Dirtab lancedir[Ndir]; | |
| 1990/0227 | /* | |
| 1990/03011/sys/src/9/port/devlance.c:549,554 – 1990/03042/sys/src/9/port/devlance.c:562,571 | ||
| 1990/0227 | lancedir[i].length = 0; lancedir[i].perm = 0600; } | |
| 1990/03042 | strcpy(lancedir[Ntypes].name, "trace"); lancedir[Ntypes].qid = Ltraceqid; lancedir[Ntypes].length = 0; lancedir[Ntypes].perm = 0600; | |
| 1990/0227 | } Chan* | |
| 1990/03011/sys/src/9/port/devlance.c:580,586 – 1990/03042/sys/src/9/port/devlance.c:597,603 | ||
| 1990/0227 | lancewalk(Chan *c, char *name) { if(c->qid == CHDIR) | |
| 1990/03042 | return devwalk(c, name, lancedir, Ndir, devgen); | |
| 1990/0227 | else return devwalk(c, name, 0, 0, streamgen); } | |
| 1990/03011/sys/src/9/port/devlance.c:589,595 – 1990/03042/sys/src/9/port/devlance.c:606,612 | ||
| 1990/0227 | lancestat(Chan *c, char *dp) { if(c->qid == CHDIR) | |
| 1990/03042 | devstat(c, dp, lancedir, Ndir, devgen); | |
| 1990/0227 | else devstat(c, dp, 0, 0, streamgen); } | |
| 1990/03011/sys/src/9/port/devlance.c:602,612 – 1990/03042/sys/src/9/port/devlance.c:619,634 | ||
| 1990/0227 | { extern Qinfo nonetinfo; | |
| 1990/03042 | switch(c->qid){ case CHDIR: case Ltraceqid: | |
| 1990/0227 | if(omode != OREAD) error(0, Eperm); | |
| 1990/03042 | break; default: | |
| 1990/0227 | streamopen(c, &lanceinfo); | |
| 1990/03042 | break; } | |
| 1990/0227 | c->mode = openmode(omode); c->flag |= COPEN; c->offset = 0; | |
| 1990/03011/sys/src/9/port/devlance.c:623,639 – 1990/03042/sys/src/9/port/devlance.c:645,704 | ||
| 1990/0227 | lanceclose(Chan *c) { /* real closing happens in lancestclose */ | |
| 1990/03042 | switch(c->qid){ case CHDIR: case Ltraceqid: break; default: | |
| 1990/0227 | streamclose(c); | |
| 1990/03042 | break; } | |
| 1990/0227 | } | |
| 1990/03042 | static long lancetraceread(Chan *c, void *a, long n) { char buf[512]; long rv; int i; char *ca = a; int offset; Trace *t; int plen; rv = 0; sprintpacket(buf, l.dq.t); plen = strlen(buf); offset = c->offset % plen; for(t = &l.dq.t[c->offset/plen]; n && t < &l.dq.t[Ndpkt]; t++){ if(t->tag == 0) break; lock(&l.dq); sprintpacket(buf, t); unlock(&l.dq); i = plen - offset; if(i > n) i = n; memcpy(ca, buf + offset, i); n -= i; ca += i; rv += i; offset = 0; } return rv; } | |
| 1990/0227 | long lanceread(Chan *c, void *a, long n) { | |
| 1990/03042 | switch(c->qid){ case CHDIR: return devdirread(c, a, n, lancedir, Ndir, devgen); case Ltraceqid: return lancetraceread(c, a, n); default: | |
| 1990/0227 | return streamread(c, a, n); | |
| 1990/03042 | } | |
| 1990/0227 | } long | |
| 1990/03011/sys/src/9/port/devlance.c:752,758 – 1990/03042/sys/src/9/port/devlance.c:817,823 | ||
| 1990/0227 | p = l.rp[l.rl]; | |
| 1990/03011 | t = (p->type[0]<<8) | p->type[1]; | |
| 1990/0227 | len = m->cntflags - 4; | |
| 1990/03042 | lancedebq('i', p, len); | |
| 1990/0227 | for(e = &l.e[0]; e < &l.e[Ntypes]; e++){ if(!canqlock(e)) continue; | |
| 1990/03011/sys/src/9/port/devlance.c:779,785 – 1990/03042/sys/src/9/port/devlance.c:844,850 | ||
| 1990/0227 | * The lock on e makes sure the queue is still there. */ bp = allocb(len); | |
| 1990/03042 | memcpy(bp->rptr, (uchar *)p, len); | |
| 1990/0227 | bp->wptr += len; bp->flags |= S_DELIM; PUTNEXT(e->q, bp); | |
| 1990/03011/sys/src/9/port/devlance.c:797,814 – 1990/03042/sys/src/9/port/devlance.c:862,867 | ||
| 1990/0227 | m->flags = OWN|HADDR(l.rp[l.rc]); l.rc = RSUCC(l.rc); } | |
| 1990/03011/sys/src/9/port/devlance.c:819,838 – 1990/03042/sys/src/9/port/devlance.c:872,875 | ||
| 1990/0227 | print("lance DRAM parity error lmp=%ux\n", l.lmp); MODEREG->promenet &= ~4; MODEREG->promenet |= 4; | |
| 1990/03042/sys/src/9/port/devlance.c:362,368 – 1990/0312/sys/src/9/port/devlance.c:362,368 (short | long) | ||
| 1990/0227 | */ len = 0; while(bp = getq(q)){ | |
| 1990/0312 | if(sizeof(Pkt) - len >= (n = BLEN(bp))){ | |
| 1990/03042 | memcpy(((uchar *)p)+len, bp->rptr, n); | |
| 1990/0227 | len += n; } else | |
| 1990/03042/sys/src/9/port/devlance.c:704,710 – 1990/0312/sys/src/9/port/devlance.c:704,710 | ||
| 1990/0227 | long lancewrite(Chan *c, void *a, long n) { | |
| 1990/0312 | return streamwrite(c, a, n, 0); | |
| 1990/0227 | } void | |
| 1990/0312/sys/src/9/port/devlance.c:605,611 – 1990/0319/sys/src/9/port/devlance.c:605,611 (short | long) | ||
| 1990/0227 | void lancestat(Chan *c, char *dp) { | |
| 1990/0319 | if(c->qid==CHDIR || c->qid==Ltraceqid) | |
| 1990/03042 | devstat(c, dp, lancedir, Ndir, devgen); | |
| 1990/0227 | else devstat(c, dp, 0, 0, streamgen); | |
| 1990/0319/sys/src/9/port/devlance.c:16,22 – 1990/0409/sys/src/9/port/devlance.c:16,22 (short | long) | ||
| 1990/0227 | Nrrb= (1<<LogNrrb), /* number of recieve buffers */ LogNtrb= 7, /* log of number of transmit buffers */ Ntrb= (1<<LogNtrb), /* number of transmit buffers */ | |
| 1990/03042 |
| |
| 1990/0409 | Ndpkt= 200, /* number of debug packets */ | |
| 1990/0227 | }; #define RSUCC(x) (((x)+1)%Nrrb) #define TSUCC(x) (((x)+1)%Ntrb) | |
| 1990/0319/sys/src/9/port/devlance.c:102,108 – 1990/0409/sys/src/9/port/devlance.c:102,108 | ||
| 1990/0227 | uchar d[6]; uchar s[6]; uchar type[2]; | |
| 1990/0409 | uchar data[60]; | |
| 1990/0227 | } Dpkt; typedef struct { | |
| 1990/03042 | ulong ticks; | |
| 1990/0319/sys/src/9/port/devlance.c:224,236 – 1990/0409/sys/src/9/port/devlance.c:224,239 | ||
| 1990/03042 | sprintpacket(char *buf, Trace *t) | |
| 1990/0227 | { | |
| 1990/03042 | Dpkt *p = &t->p; | |
| 1990/0409 | int i; | |
| 1990/03042 |
| |
| 1990/0409 | sprint(buf, "%c: %.8ud %.4d d(%.2ux%.2ux%.2ux%.2ux%.2ux%.2ux)s(%.2ux%.2ux%.2ux%.2ux%.2ux%.2ux)t(%.2ux %.2ux)d(", t->tag, t->ticks, t->len, p->d[0], p->d[1], p->d[2], p->d[3], p->d[4], p->d[5], p->s[0], p->s[1], p->s[2], p->s[3], p->s[4], p->s[5], p->type[0], p->type[1]); for(i=0; i<41; i++) sprint(buf+strlen(buf), "%.2ux", p->data[i]); sprint(buf+strlen(buf), ")\n"); | |
| 1990/0227 | } /* | |
| 1990/0409/sys/src/9/port/devlance.c:477,482 – 1990/0419/sys/src/9/port/devlance.c:477,486 (short | long) | ||
| 1990/0227 | l.ea[3] = LANCEID[8]>>8; l.ea[4] = LANCEID[4]>>8; l.ea[5] = LANCEID[0]>>8; | |
| 1990/0419 | /* print("lance addr = %.4ux %.4ux %.4ux\n", lm->etheraddr[0], lm->etheraddr[1], lm->etheraddr[2]); /**/ | |
| 1990/0227 | /* * ignore multicast addresses | |
| 1990/0419/sys/src/9/port/devlance.c:252,257 – 1990/0427/sys/src/9/port/devlance.c:252,264 (short | long) | ||
| 1990/03042 | memcpy(&(t->p), p, sizeof(Dpkt)); | |
| 1990/0227 | l.dq.next = (l.dq.next+1) % Ndpkt; unlock(&l.dq); | |
| 1990/0427 | /* { char buf[1024]; if(p->d[0] != 0xff){ sprintpacket(buf, t); print("%s\n", buf); } } /**/ | |
| 1990/0227 | } /* | |
| 1990/0427/sys/src/9/port/devlance.c:21,27 – 1990/0707/sys/src/9/port/devlance.c:21,27 (short | long) | ||
| 1990/0227 | #define RSUCC(x) (((x)+1)%Nrrb) #define TSUCC(x) (((x)+1)%Ntrb) | |
| 1990/03042 |
| |
| 1990/0707 | #define NOW (MACHP(0)->ticks*MS2HZ) | |
| 1990/03042 | ||
| 1990/0227 | /* * Communication with the lance is via a transmit and receive ring of | |
| 1990/0427/sys/src/9/port/devlance.c:580,585 – 1990/0707/sys/src/9/port/devlance.c:580,586 | ||
| 1990/03042 | lancedir[Ntypes].qid = Ltraceqid; lancedir[Ntypes].length = 0; lancedir[Ntypes].perm = 0600; | |
| 1990/0707 | ||
| 1990/0227 | } Chan* | |
| 1990/0707/sys/src/9/port/devlance.c:313,320 – 1990/0721/sys/src/9/port/devlance.c:313,320 (short | long) | ||
| 1990/0227 | { Ethertype *et; | |
| 1990/0721 | qlock(et); | |
| 1990/0227 | et->type = 0; et->q = 0; qunlock(et); | |
| 1990/0721/sys/src/9/port/devlance.c:589,595 – 1990/0722/sys/src/9/port/devlance.c:589,595 (short | long) | ||
| 1990/0227 | Chan *c; if(l.kstarted == 0){ | |
| 1990/0722 | kproc("lancekproc", lancekproc, 0); | |
| 1990/0227 | l.kstarted = 1; lancestart(); } | |
| 1990/0722/sys/src/9/port/devlance.c:888,890 – 1990/0826/sys/src/9/port/devlance.c:888,896 (short | long) | ||
| 1990/0227 | MODEREG->promenet &= ~4; MODEREG->promenet |= 4; } | |
| 1990/0826 | void lance3intr(void) { panic("lance3 interrupt\n"); } | |
| 1990/0826/sys/src/9/port/devlance.c:11,17 – 1990/0911/sys/src/9/port/devlance.c:11,17 (short | long) | ||
| 1990/0227 | */ enum { Ntypes= 8, /* max number of ethernet packet types */ | |
| 1990/03042 |
| |
| 1990/0911 | Ndir= Ntypes+2, /* entries in top level directory */ | |
| 1990/0227 | LogNrrb= 7, /* log of number of receive buffers */ Nrrb= (1<<LogNrrb), /* number of recieve buffers */ LogNtrb= 7, /* log of number of transmit buffers */ | |
| 1990/0826/sys/src/9/port/devlance.c:24,29 – 1990/0911/sys/src/9/port/devlance.c:24,40 | ||
| 1990/0707 | #define NOW (MACHP(0)->ticks*MS2HZ) | |
| 1990/03042 | ||
| 1990/0227 | /* | |
| 1990/0911 | * Ethernet packet buffers. These must also be in lance addressible RAM. */ typedef struct { uchar d[6]; uchar s[6]; uchar type[2]; uchar data[1500]; uchar crc[4]; } Pkt; /* | |
| 1990/0227 | * Communication with the lance is via a transmit and receive ring of * message descriptors. The Initblock contains pointers to and sizes of * these rings. The rings must be in RAM addressible by the lance | |
| 1990/0826/sys/src/9/port/devlance.c:36,90 – 1990/0911/sys/src/9/port/devlance.c:47,90 | ||
| 1990/0227 | } Msg; /* | |
| 1990/0911 | typedef struct Lancemem | |
| 1990/0227 | { /* * initialization block */ | |
| 1990/0911 | ushort mode; /* chip control (see below) */ ushort etheraddr[3]; /* the ethernet physical address */ ushort multi[4]; /* multicast addresses, 1 bit for each of 64 */ ushort rdralow; /* receive buffer ring */ ushort rdrahigh; /* (top three bits define size of ring) */ ushort tdralow; /* transmit buffer ring */ ushort tdrahigh; /* (top three bits define size of ring) */ | |
| 1990/0227 | /* | |
| 1990/0911 | * ring buffers * first receive, then transmit | |
| 1990/0227 | */ Msg rmr[Nrrb]; /* recieve message ring */ Msg tmr[Ntrb]; /* transmit message ring */ /* | |
| 1990/0911 | * packet buffers (for IO2 version) | |
| 1990/0227 | */ | |
| 1990/0911 | Pkt rp[Nrrb]; Pkt tp[Ntrb]; | |
| 1990/0227 | } Lancemem; | |
| 1990/0911 | #define LANCEMEM ((Lancemem*)0) | |
| 1990/0227 | /* * Some macros for dealing with lance memory addresses. The lance splits * its 24 bit addresses across two 16 bit registers. */ | |
| 1990/0911 | #define HADDR(a) ((((ulong)(a))>>16)&0xFF) | |
| 1990/0227 | #define LADDR(a) (((ulong)a)&0xFFFF) | |
| 1990/0911 | #define MPs(a) (*(short *)(l.lanceram + l.sep*((ushort*)&a - (ushort*)0))) #define MPus(a) (*(ushort *)(l.lanceram + l.sep*((ushort*)&a - (ushort*)0))) | |
| 1990/0227 | /* * one per ethernet packet type | |
| 1990/0826/sys/src/9/port/devlance.c:127,150 – 1990/0911/sys/src/9/port/devlance.c:127,166 | ||
| 1990/0227 | uchar *lmp; /* location of parity test */ ushort *rap; /* lance address register */ ushort *rdp; /* lance data register */ | |
| 1990/0911 | int sep; /* separaqtion between shorts in lance ram as seen by host */ ushort *lanceram; /* start of lance ram as seen by host */ ushort *lanceend; /* end of lance ram as seen by host */ Lancemem *lm; /* start of lance memory as seen by lance */ | |
| 1990/0227 | Rendez rr; /* rendezvous for an input buffer */ ushort rl; /* first rcv Message belonging to Lance */ ushort rc; /* first rcv Message belonging to CPU */ | |
| 1990/0911 | Pkt *rp; /* receive buffers */ Pkt *tp; /* transmit buffers */ uchar *rpa[Nrrb]; /* receive buffer address in lance space */ uchar *tpa[Ntrb]; /* transmit buffer address in lance space */ /* sadistics */ int inpackets; int outpackets; int crcs; /* input crc errors */ int oerrs; /* output erros */ int frames; /* framing errors */ int overflows; /* packet overflows */ int buffs; /* buffering errors */ | |
| 1990/0227 | } Lance; static Lance l; | |
| 1990/0826/sys/src/9/port/devlance.c:231,237 – 1990/0911/sys/src/9/port/devlance.c:247,253 | ||
| 1990/0409 | p->d[0], p->d[1], p->d[2], p->d[3], p->d[4], p->d[5], p->s[0], p->s[1], p->s[2], p->s[3], p->s[4], p->s[5], p->type[0], p->type[1]); | |
| 1990/0911 | for(i=0; i<16; i++) | |
| 1990/0409 | sprint(buf+strlen(buf), "%.2ux", p->data[i]); sprint(buf+strlen(buf), ")\n"); | |
| 1990/0227 | } | |
| 1990/0826/sys/src/9/port/devlance.c:262,280 – 1990/0911/sys/src/9/port/devlance.c:278,283 | ||
| 1990/0227 | } /* | |
| 1990/0826/sys/src/9/port/devlance.c:365,371 – 1990/0911/sys/src/9/port/devlance.c:368,374 | ||
| 1990/0227 | sleep(&l.tr, isobuf, (void *)0); print("done"); } | |
| 1990/0911 | p = &l.tp[l.tc]; | |
| 1990/0227 | /* * copy message into lance RAM | |
| 1990/0826/sys/src/9/port/devlance.c:395,410 – 1990/0911/sys/src/9/port/devlance.c:398,414 | ||
| 1990/0227 | if(len < 60) len = 60; | |
| 1990/03042 |
| |
| 1990/0911 | lancedebq('o', p, len);/**/ | |
| 1990/0227 | /* * set up the ring descriptor and hand to lance */ | |
| 1990/0911 | l.outpackets++; | |
| 1990/0227 | m = &(LANCEMEM->tmr[l.tc]); | |
| 1990/0911 | MPs(m->size) = -len; MPus(m->cntflags) = 0; MPus(m->laddr) = LADDR(l.tpa[l.tc]); MPus(m->flags) = OWN|STP|ENP|HADDR(l.tpa[l.tc]); | |
| 1990/0227 | l.tc = TSUCC(l.tc); *l.rdp = INEA|TDMD; /**/ qunlock(&l.tlock); | |
| 1990/0826/sys/src/9/port/devlance.c:416,425 – 1990/0911/sys/src/9/port/devlance.c:420,429 | ||
| 1990/0227 | enum { | |
| 1990/03042 | Lchanqid = 1, Ltraceqid = 2, | |
| 1990/0911 | Lstatsqid = 3, | |
| 1990/0227 | }; | |
| 1990/03042 | Dirtab lancedir[Ndir]; | |
| 1990/0227 |
| |
| 1990/0826/sys/src/9/port/devlance.c:426,455 – 1990/0911/sys/src/9/port/devlance.c:430,512 | ||
| 1990/0227 | void lancereset(void) { | |
| 1990/0911 | ushort *sp; ulong x; int index; static int already; | |
| 1990/0227 | /* | |
| 1990/0911 | * so that we don't have to indirect through constants | |
| 1990/0227 | */ | |
| 1990/0911 | l.rap = LANCERAP; l.rdp = LANCERDP; | |
| 1990/0227 | /* | |
| 1990/0911 | * allocate the send and receive buffers and map them into * the lance's address space. | |
| 1990/0227 | */ | |
| 1990/0911 | if(already == 0){ already = 1; if(ioid < IO3R1){ /* * toggle lance's reset line */ MODEREG->promenet &= ~1; MODEREG->promenet |= 1; | |
| 1990/0227 | ||
| 1990/0911 | l.lanceram = LANCERAM; l.lanceend = LANCEEND; l.lm = (Lancemem *)0; l.sep = 1; /* * allocate packet buffers in lance memory */ for(i = 0; i < Nrrb; i++) l.rpa[i] = (uchar *)&l.lm->rp[i]; for(i = 0; i < Ntrb; i++) l.tpa[i] = (uchar *)&l.lm->tp[i]; } else { /* * toggle lance's reset line */ MODEREG->promenet |= 1; MODEREG->promenet &= ~1; l.lanceram = LANCE3RAM; l.lanceend = LANCE3END; l.lm = (Lancemem *)0x800000; l.sep = 4; /* * allocate packet buffers in MP bus memory * and map it into lance space */ l.rp = (Pkt *)ialloc((Nrrb + Ntrb)*sizeof(Pkt), 1); l.tp = l.rp + Nrrb; index = 0x1E00; for(i = 0; i < Nrrb; i++){ x = (ulong)&l.rp[i]; *WRITEMAP = (index<<16) | (x>>12)&0xFFFF; l.rpa[i] = (uchar *)((i<<12) | (x & 0xFFF)); index++; } for(i = 0; i < Ntrb; i++){ x = (ulong)&l.tp[i]; *WRITEMAP = (index<<16) | (x>>12)&0xFFFF; l.tpa[i] = (uchar *)(((i+Nrrb)<<12) | (x & 0xFFF)); index++; } } } | |
| 1990/0227 | /* * run through all lance memory to set parity */ | |
| 1990/0911 | for(sp = l.lanceram; sp < l.lanceend; sp += l.sep) *sp = 0; | |
| 1990/0227 | } /* | |
| 1990/0826/sys/src/9/port/devlance.c:459,467 – 1990/0911/sys/src/9/port/devlance.c:516,525 | ||
| 1990/0227 | static void lancestart(void) { | |
| 1990/0911 | Lancemem *lm = LANCEMEM; Msg *m; | |
| 1990/0227 | lancereset(); | |
| 1990/0826/sys/src/9/port/devlance.c:468,474 – 1990/0911/sys/src/9/port/devlance.c:526,532 | ||
| 1990/0227 | /* * create the initialization block */ | |
| 1990/0911 | MPus(lm->mode) = 0; | |
| 1990/0227 | /* * set ether addr from the value in the id prom. | |
| 1990/0826/sys/src/9/port/devlance.c:475,483 – 1990/0911/sys/src/9/port/devlance.c:533,541 | ||
| 1990/0227 | * the id prom has them in reverse order, the init * structure wants them in byte swapped order */ | |
| 1990/0911 | MPus(lm->etheraddr[0]) = (LANCEID[16]&0xff00)|((LANCEID[20]>>8)&0xff); MPus(lm->etheraddr[1]) = (LANCEID[8]&0xff00)|((LANCEID[12]>>8)&0xff); MPus(lm->etheraddr[2]) = (LANCEID[0]&0xff00)|((LANCEID[4]>>8)&0xff); | |
| 1990/0227 | l.ea[0] = LANCEID[20]>>8; l.ea[1] = LANCEID[16]>>8; l.ea[2] = LANCEID[12]>>8; | |
| 1990/0826/sys/src/9/port/devlance.c:484,548 – 1990/0911/sys/src/9/port/devlance.c:542,599 | ||
| 1990/0227 | l.ea[3] = LANCEID[8]>>8; l.ea[4] = LANCEID[4]>>8; l.ea[5] = LANCEID[0]>>8; | |
| 1990/0419 |
| |
| 1990/0227 | /* * ignore multicast addresses */ | |
| 1990/0911 | MPus(lm->multi[0]) = 0; MPus(lm->multi[1]) = 0; MPus(lm->multi[2]) = 0; MPus(lm->multi[3]) = 0; | |
| 1990/0227 | /* * set up rcv message ring */ | |
| 1990/0911 | m = lm->rmr; for(i = 0; i < Nrrb; i++, m++){ MPs(m->size) = -sizeof(Pkt); MPus(m->cntflags) = 0; MPus(m->laddr) = LADDR(l.rpa[i]); MPus(m->flags) = HADDR(l.rpa[i]); | |
| 1990/0227 | } | |
| 1990/0911 | MPus(lm->rdralow) = LADDR(l.lm->rmr); MPus(lm->rdrahigh) = (LogNrrb<<13)|HADDR(l.lm->rmr); | |
| 1990/0227 | ||
| 1990/0911 | ||
| 1990/0227 | /* * give the lance all the rcv buffers except one (as a sentinel) */ l.rc = Nrrb - 1; | |
| 1990/0911 | m = lm->rmr; for(i = 0; i < l.rc; i++, m++) MPus(m->flags) |= OWN; | |
| 1990/0227 | /* * set up xmit message ring */ | |
| 1990/0911 | m = lm->tmr; for(i = 0; i < Ntrb; i++, m++){ MPs(m->size) = 0; MPus(m->cntflags) = 0; MPus(m->laddr) = LADDR(l.tpa[i]); MPus(m->flags) = HADDR(l.tpa[i]); | |
| 1990/0227 | } | |
| 1990/0911 | MPus(lm->tdralow) = LADDR(l.lm->tmr); MPus(lm->tdrahigh) = (LogNtrb<<13)|HADDR(l.lm->tmr); | |
| 1990/0227 | /* | |
| 1990/0911 | *l.rdp = LADDR(l.lm); | |
| 1990/0227 | wbflush(); *l.rap = 2; | |
| 1990/0911 | *l.rdp = HADDR(l.lm); | |
| 1990/0227 | /* * The lance byte swaps the ethernet packet unless we tell it not to | |
| 1990/0826/sys/src/9/port/devlance.c:580,586 – 1990/0911/sys/src/9/port/devlance.c:631,640 | ||
| 1990/03042 | lancedir[Ntypes].qid = Ltraceqid; lancedir[Ntypes].length = 0; lancedir[Ntypes].perm = 0600; | |
| 1990/0707 | ||
| 1990/0911 | strcpy(lancedir[Ntypes+1].name, "stats"); lancedir[Ntypes+1].qid = Lstatsqid; lancedir[Ntypes+1].length = 0; lancedir[Ntypes+1].perm = 0600; | |
| 1990/0227 | } Chan* | |
| 1990/0826/sys/src/9/port/devlance.c:589,595 – 1990/0911/sys/src/9/port/devlance.c:643,649 | ||
| 1990/0227 | Chan *c; if(l.kstarted == 0){ | |
| 1990/0722 |
| |
| 1990/0911 | kproc("lancekproc", lancekproc, 0);/**/ | |
| 1990/0227 | l.kstarted = 1; lancestart(); } | |
| 1990/0826/sys/src/9/port/devlance.c:620,626 – 1990/0911/sys/src/9/port/devlance.c:674,680 | ||
| 1990/0227 | void lancestat(Chan *c, char *dp) { | |
| 1990/0319 |
| |
| 1990/0911 | if(c->qid==CHDIR || c->qid==Ltraceqid || c->qid==Lstatsqid) | |
| 1990/03042 | devstat(c, dp, lancedir, Ndir, devgen); | |
| 1990/0227 | else devstat(c, dp, 0, 0, streamgen); | |
| 1990/0826/sys/src/9/port/devlance.c:637,642 – 1990/0911/sys/src/9/port/devlance.c:691,697 | ||
| 1990/03042 | switch(c->qid){ case CHDIR: case Ltraceqid: | |
| 1990/0911 | case Lstatsqid: | |
| 1990/0227 | if(omode != OREAD) error(0, Eperm); | |
| 1990/03042 | break; | |
| 1990/0826/sys/src/9/port/devlance.c:663,668 – 1990/0911/sys/src/9/port/devlance.c:718,724 | ||
| 1990/03042 | switch(c->qid){ case CHDIR: case Ltraceqid: | |
| 1990/0911 | case Lstatsqid: | |
| 1990/03042 | break; default: | |
| 1990/0227 | streamclose(c); | |
| 1990/0826/sys/src/9/port/devlance.c:706,714 – 1990/0911/sys/src/9/port/devlance.c:762,777 | ||
| 1990/0227 | long lanceread(Chan *c, void *a, long n) { | |
| 1990/0911 | char buf[256]; | |
| 1990/03042 | switch(c->qid){ case CHDIR: return devdirread(c, a, n, lancedir, Ndir, devgen); | |
| 1990/0911 | case Lstatsqid: sprint(buf, "in: %d\nout: %d\ncrc errs %d\noverflows: %d\nframe errs %d\nbuff errs: %d\noerrs %d\n", l.inpackets, l.outpackets, l.crcs, l.overflows, l.frames, l.buffs, l.oerrs); return stringread(c, a, n, buf); | |
| 1990/03042 | case Ltraceqid: return lancetraceread(c, a, n); default: | |
| 1990/0826/sys/src/9/port/devlance.c:754,764 – 1990/0911/sys/src/9/port/devlance.c:817,826 | ||
| 1990/0227 | void lanceintr(void) { | |
| 1990/0911 | int i; | |
| 1990/0227 | ushort csr; | |
| 1990/0911 | Lancemem *lm = LANCEMEM; | |
| 1990/0227 |
| |
| 1990/0826/sys/src/9/port/devlance.c:778,784 – 1990/0911/sys/src/9/port/devlance.c:840,846 | ||
| 1990/0227 | /* * look for rcv'd packets, just wakeup the input process */ | |
| 1990/0911 | if(l.rl!=l.rc && (MPus(lm->rmr[l.rl].flags) & OWN)==0) | |
| 1990/0227 | wakeup(&l.rr); /* | |
| 1990/0826/sys/src/9/port/devlance.c:785,794 – 1990/0911/sys/src/9/port/devlance.c:847,855 | ||
| 1990/0227 | * look for xmitt'd packets, wake any process waiting for a * transmit buffer */ | |
| 1990/0911 | while(l.tl!=l.tc && (MPus(lm->tmr[l.tl].flags) & OWN)==0){ if(MPus(lm->tmr[l.tl].flags) & ERR) l.oerrs++; | |
| 1990/0227 | l.tl = TSUCC(l.tl); wakeup(&l.tr); } | |
| 1990/0826/sys/src/9/port/devlance.c:800,828 – 1990/0911/sys/src/9/port/devlance.c:861,895 | ||
| 1990/0227 | static int isinput(void *arg) { | |
| 1990/0911 | Lancemem *lm = LANCEMEM; return l.rl!=l.rc && (MPus(lm->rmr[l.rl].flags) & OWN)==0; | |
| 1990/0227 | } void lancekproc(void *arg) { Block *bp; | |
| 1990/0911 | Lancemem *lm = LANCEMEM; Msg *m; | |
| 1990/0227 |
| |
| 1990/0911 | for(; l.rl!=l.rc && (MPus(lm->rmr[l.rl].flags) & OWN)==0 ; l.rl=RSUCC(l.rl)){ | |
| 1990/0227 | l.inpackets++; m = &(lm->rmr[l.rl]); | |
| 1990/0911 | if(MPus(m->flags) & ERR){ t = MPus(m->flags); if(t & FRAM) l.frames++; if(t & OFLO) l.overflows++; if(t & CRC) l.crcs++; if(t & BUFF) l.buffs++; | |
| 1990/0227 | goto stage; } | |
| 1990/0826/sys/src/9/port/devlance.c:829,838 – 1990/0911/sys/src/9/port/devlance.c:896,905 | ||
| 1990/0227 | /* * See if a queue exists for this packet type. */ | |
| 1990/0911 | p = &l.rp[l.rl]; | |
| 1990/03011 | t = (p->type[0]<<8) | p->type[1]; | |
| 1990/0227 |
| |
| 1990/03042 |
| |
| 1990/0911 | len = MPus(m->cntflags) - 4; lancedebq('i', p, len);/**/ | |
| 1990/0227 | for(e = &l.e[0]; e < &l.e[Ntypes]; e++){ if(!canqlock(e)) continue; | |
| 1990/0826/sys/src/9/port/devlance.c:854,860 – 1990/0911/sys/src/9/port/devlance.c:921,927 | ||
| 1990/0227 | qunlock(e); } } | |
| 1990/0911 | if(e!=&l.e[Ntypes] && e->q->next->len<=Streamhi){ | |
| 1990/0227 | /* * The lock on e makes sure the queue is still there. */ | |
| 1990/0826/sys/src/9/port/devlance.c:871,880 – 1990/0911/sys/src/9/port/devlance.c:938,947 | ||
| 1990/0227 | * stage the next input buffer */ m = &(lm->rmr[l.rc]); | |
| 1990/0911 | MPs(m->size) = -sizeof(Pkt); MPus(m->cntflags) = 0; MPus(m->laddr) = LADDR(l.rpa[l.rc]); MPus(m->flags) = OWN|HADDR(l.rpa[l.rc]); | |
| 1990/0227 | l.rc = RSUCC(l.rc); } sleep(&l.rr, isinput, 0); | |
| 1990/0826/sys/src/9/port/devlance.c:887,896 – 1990/0911/sys/src/9/port/devlance.c:954,957 | ||
| 1990/0227 | print("lance DRAM parity error lmp=%ux\n", l.lmp); MODEREG->promenet &= ~4; MODEREG->promenet |= 4; | |
| 1990/0826 |
| |
| 1990/0911/sys/src/9/port/devlance.c:467,472 – 1990/0912/sys/src/9/port/devlance.c:467,475 (short | long) | ||
| 1990/0911 | l.rpa[i] = (uchar *)&l.lm->rp[i]; for(i = 0; i < Ntrb; i++) l.tpa[i] = (uchar *)&l.lm->tp[i]; | |
| 1990/0912 | l.rp = ((Lancemem *)LANCERAM)->rp; l.tp = ((Lancemem *)LANCERAM)->tp; | |
| 1990/0911 | } else { /* * toggle lance's reset line | |
| 1990/0912/sys/src/9/port/devlance.c:626,641 – 1990/11211/sys/src/9/port/devlance.c:626,642 (short | long) | ||
| 1990/0227 | */ for(i=0; i<Ntypes; i++) { sprint(lancedir[i].name, "%d", i); | |
| 1990/11211 | lancedir[i].qid.path = CHDIR|STREAMQID(i, Lchanqid); lancedir[i].qid.vers = 0; | |
| 1990/0227 | lancedir[i].length = 0; lancedir[i].perm = 0600; } | |
| 1990/03042 | strcpy(lancedir[Ntypes].name, "trace"); | |
| 1990/11211 | lancedir[Ntypes].qid.path = Ltraceqid; | |
| 1990/03042 | lancedir[Ntypes].length = 0; lancedir[Ntypes].perm = 0600; | |
| 1990/0911 | strcpy(lancedir[Ntypes+1].name, "stats"); | |
| 1990/11211 | lancedir[Ntypes+1].qid.path = Lstatsqid; | |
| 1990/0911 | lancedir[Ntypes+1].length = 0; lancedir[Ntypes+1].perm = 0600; | |
| 1990/0227 | } | |
| 1990/0912/sys/src/9/port/devlance.c:668,674 – 1990/11211/sys/src/9/port/devlance.c:669,675 | ||
| 1990/0227 | int lancewalk(Chan *c, char *name) { | |
| 1990/11211 | if(c->qid.path == CHDIR) | |
| 1990/03042 | return devwalk(c, name, lancedir, Ndir, devgen); | |
| 1990/0227 | else return devwalk(c, name, 0, 0, streamgen); | |
| 1990/0912/sys/src/9/port/devlance.c:677,683 – 1990/11211/sys/src/9/port/devlance.c:678,684 | ||
| 1990/0227 | void lancestat(Chan *c, char *dp) { | |
| 1990/0911 |
| |
| 1990/11211 | if(c->qid.path==CHDIR || c->qid.path==Ltraceqid || c->qid.path==Lstatsqid) | |
| 1990/03042 | devstat(c, dp, lancedir, Ndir, devgen); | |
| 1990/0227 | else devstat(c, dp, 0, 0, streamgen); | |
| 1990/0912/sys/src/9/port/devlance.c:691,702 – 1990/11211/sys/src/9/port/devlance.c:692,703 | ||
| 1990/0227 | { extern Qinfo nonetinfo; | |
| 1990/03042 |
| |
| 1990/11211 | switch(c->qid.path){ | |
| 1990/03042 | case CHDIR: case Ltraceqid: | |
| 1990/0911 | case Lstatsqid: | |
| 1990/0227 | if(omode != OREAD) | |
| 1990/11211 | error(Eperm); | |
| 1990/03042 | break; default: | |
| 1990/0227 | streamopen(c, &lanceinfo); | |
| 1990/0912/sys/src/9/port/devlance.c:711,717 – 1990/11211/sys/src/9/port/devlance.c:712,718 | ||
| 1990/0227 | void lancecreate(Chan *c, char *name, int omode, ulong perm) { | |
| 1990/11211 | error(Eperm); | |
| 1990/0227 | } void | |
| 1990/0912/sys/src/9/port/devlance.c:718,724 – 1990/11211/sys/src/9/port/devlance.c:719,725 | ||
| 1990/0227 | lanceclose(Chan *c) { /* real closing happens in lancestclose */ | |
| 1990/03042 |
| |
| 1990/11211 | switch(c->qid.path){ | |
| 1990/03042 | case CHDIR: case Ltraceqid: | |
| 1990/0911 | case Lstatsqid: | |
| 1990/0912/sys/src/9/port/devlance.c:767,773 – 1990/11211/sys/src/9/port/devlance.c:768,774 | ||
| 1990/0227 | { | |
| 1990/0911 | char buf[256]; | |
| 1990/03042 |
| |
| 1990/11211 | switch(c->qid.path){ | |
| 1990/03042 | case CHDIR: return devdirread(c, a, n, lancedir, Ndir, devgen); | |
| 1990/0911 | case Lstatsqid: | |
| 1990/0912/sys/src/9/port/devlance.c:791,815 – 1990/11211/sys/src/9/port/devlance.c:792,804 | ||
| 1990/0227 | void lanceremove(Chan *c) { | |
| 1990/11211 | error(Eperm); | |
| 1990/0227 | } void lancewstat(Chan *c, char *dp) { | |
| 1990/11211 | error(Eperm); | |
| 1990/0227 | } /* | |
| 1990/11211/sys/src/9/port/devlance.c:24,40 – 1990/1228/sys/src/9/port/devlance.c:24,29 (short | long) | ||
| 1990/0707 | #define NOW (MACHP(0)->ticks*MS2HZ) | |
| 1990/03042 | ||
| 1990/0227 | /* | |
| 1990/0911 |
| |
| 1990/0227 | * Communication with the lance is via a transmit and receive ring of * message descriptors. The Initblock contains pointers to and sizes of * these rings. The rings must be in RAM addressible by the lance | |
| 1990/11211/sys/src/9/port/devlance.c:70,81 – 1990/1228/sys/src/9/port/devlance.c:59,69 | ||
| 1990/0227 | Msg tmr[Ntrb]; /* transmit message ring */ /* | |
| 1990/0911 |
| |
| 1990/1228 | * packet buffers (for SGI IO2 version only) | |
| 1990/0227 | */ | |
| 1990/0911 |
| |
| 1990/1228 | Etherpkt rp[Nrrb]; Etherpkt tp[Ntrb]; | |
| 1990/0227 | } Lancemem; | |
| 1990/0911 |
| |
| 1990/0227 | /* * Some macros for dealing with lance memory addresses. The lance splits | |
| 1990/11211/sys/src/9/port/devlance.c:83,88 – 1990/1228/sys/src/9/port/devlance.c:71,86 | ||
| 1990/0227 | */ | |
| 1990/0911 | #define HADDR(a) ((((ulong)(a))>>16)&0xFF) | |
| 1990/0227 | #define LADDR(a) (((ulong)a)&0xFFFF) | |
| 1990/1228 | /* * The following functions exist to sidestep a quirk in the SGI IO3 lance * interface. In all other processors, the lance's initialization block and * descriptor rings look like normal memory. In the SGI IO3, the CPU sees a * 6 byte pad twixt all lance memory shorts. Therefore, we use the following * macros to compute the address whenever accessing the lance memory to make * the code portable. Sic transit gloria. */ #define LANCEMEM ((Lancemem*)0) | |
| 1990/0911 | #define MPs(a) (*(short *)(l.lanceram + l.sep*((ushort*)&a - (ushort*)0))) #define MPus(a) (*(ushort *)(l.lanceram + l.sep*((ushort*)&a - (ushort*)0))) | |
| 1990/0227 | ||
| 1990/11211/sys/src/9/port/devlance.c:147,154 – 1990/1228/sys/src/9/port/devlance.c:145,152 | ||
| 1990/0227 | int kstarted; Debqueue dq; | |
| 1990/0911 |
| |
| 1990/1228 | Etherpkt *rp; /* receive buffers */ Etherpkt *tp; /* transmit buffers */ | |
| 1990/0911 | uchar *rpa[Nrrb]; /* receive buffer address in lance space */ uchar *tpa[Ntrb]; /* transmit buffer address in lance space */ | |
| 1990/11211/sys/src/9/port/devlance.c:256,262 – 1990/1228/sys/src/9/port/devlance.c:254,260 | ||
| 1990/0227 | * save a message in a circular queue for later debugging */ void | |
| 1990/03042 |
| |
| 1990/1228 | lancedebq(char tag, Etherpkt *p, int len) | |
| 1990/0227 | { | |
| 1990/03042 | Trace *t; | |
| 1990/11211/sys/src/9/port/devlance.c:338,344 – 1990/1228/sys/src/9/port/devlance.c:336,342 | ||
| 1990/0227 | lanceoput(Queue *q, Block *bp ) { int n, len; | |
| 1990/1228 | Etherpkt *p; | |
| 1990/0227 | Msg *m; if(bp->type == M_CTL){ | |
| 1990/11211/sys/src/9/port/devlance.c:375,381 – 1990/1228/sys/src/9/port/devlance.c:373,379 | ||
| 1990/0227 | */ len = 0; while(bp = getq(q)){ | |
| 1990/0312 |
| |
| 1990/1228 | if(sizeof(Etherpkt) - len >= (n = BLEN(bp))){ | |
| 1990/03042 | memcpy(((uchar *)p)+len, bp->rptr, n); | |
| 1990/0227 | len += n; } else | |
| 1990/11211/sys/src/9/port/devlance.c:425,430 – 1990/1228/sys/src/9/port/devlance.c:423,444 | ||
| 1990/03042 | Dirtab lancedir[Ndir]; | |
| 1990/0227 | /* | |
| 1990/1228 | * configure the lance */ void lanceconfig(void *ramstart, void *ramend, void *rap, void *rdp, int sep, void *lancemem, uchar* ea) { l.lanceram = ramstart; l.lanceend = ramend; l.rap = rap; l.rdp = rdp; l.sep = sep; l.lm = lancemem; /* where lance sees its memory start */ memcpy(l.ea, ea, 6); } /* | |
| 1990/0227 | * stop the lance, disable all ring buffers, and free all staged rcv buffers */ void | |
| 1990/11211/sys/src/9/port/devlance.c:431,466 – 1990/1228/sys/src/9/port/devlance.c:445,464 | ||
| 1990/0227 | lancereset(void) { int i; | |
| 1990/0911 |
| |
| 1990/0227 | /* | |
| 1990/0911 |
| |
| 1990/1228 | * stop the lance | |
| 1990/0227 | */ | |
| 1990/0911 |
| |
| 1990/1228 | *l.rap = 0; *l.rdp = STOP; | |
| 1990/0227 |
| |
| 1990/0911 |
| |
| 1990/0227 |
| |
| 1990/0911 | if(already == 0){ already = 1; if(ioid < IO3R1){ /* | |
| 1990/0227 | ||
| 1990/0911 |
| |
| 1990/11211/sys/src/9/port/devlance.c:468,492 – 1990/1228/sys/src/9/port/devlance.c:466,479 | ||
| 1990/0911 | for(i = 0; i < Ntrb; i++) l.tpa[i] = (uchar *)&l.lm->tp[i]; | |
| 1990/0912 |
| |
| 1990/1228 | l.rp = ((Lancemem *)l.lanceram)->rp; l.tp = ((Lancemem *)l.lanceram)->tp; | |
| 1990/0911 | } else { /* | |
| 1990/1228 | l.rp = (Etherpkt *)ialloc((Nrrb + Ntrb)*sizeof(Etherpkt), 1); | |
| 1990/0911 | l.tp = l.rp + Nrrb; index = 0x1E00; for(i = 0; i < Nrrb; i++){ | |
| 1990/11211/sys/src/9/port/devlance.c:504,515 – 1990/1228/sys/src/9/port/devlance.c:491,496 | ||
| 1990/0911 | } } | |
| 1990/0227 |
| |
| 1990/0911 |
| |
| 1990/0227 | } /* | |
| 1990/11211/sys/src/9/port/devlance.c:520,526 – 1990/1228/sys/src/9/port/devlance.c:501,507 | ||
| 1990/0227 | lancestart(void) { int i; | |
| 1990/1228 | Etherpkt *p; | |
| 1990/0911 | Lancemem *lm = LANCEMEM; Msg *m; | |
| 1990/0227 | ||
| 1990/11211/sys/src/9/port/devlance.c:536,550 – 1990/1228/sys/src/9/port/devlance.c:517,525 | ||
| 1990/0227 | * the id prom has them in reverse order, the init * structure wants them in byte swapped order */ | |
| 1990/0911 |
| |
| 1990/0227 |
| |
| 1990/1228 | MPus(lm->etheraddr[0]) = (l.ea[1]<<8) | l.ea[0]; MPus(lm->etheraddr[1]) = (l.ea[3]<<8) | l.ea[2]; MPus(lm->etheraddr[2]) = (l.ea[5]<<8) | l.ea[4]; | |
| 1990/0227 | /* * ignore multicast addresses | |
| 1990/11211/sys/src/9/port/devlance.c:559,565 – 1990/1228/sys/src/9/port/devlance.c:534,540 | ||
| 1990/0227 | */ | |
| 1990/0911 | m = lm->rmr; for(i = 0; i < Nrrb; i++, m++){ | |
| 1990/1228 | MPs(m->size) = -sizeof(Etherpkt); | |
| 1990/0911 | MPus(m->cntflags) = 0; MPus(m->laddr) = LADDR(l.rpa[i]); MPus(m->flags) = HADDR(l.rpa[i]); | |
| 1990/11211/sys/src/9/port/devlance.c:860,866 – 1990/1228/sys/src/9/port/devlance.c:835,841 | ||
| 1990/0227 | lancekproc(void *arg) { Block *bp; | |
| 1990/1228 | Etherpkt *p; | |
| 1990/0227 | Ethertype *e; int t; int len; | |
| 1990/11211/sys/src/9/port/devlance.c:930,936 – 1990/1228/sys/src/9/port/devlance.c:905,911 | ||
| 1990/0227 | * stage the next input buffer */ m = &(lm->rmr[l.rc]); | |
| 1990/0911 |
| |
| 1990/1228 | MPs(m->size) = -sizeof(Etherpkt); | |
| 1990/0911 | MPus(m->cntflags) = 0; MPus(m->laddr) = LADDR(l.rpa[l.rc]); MPus(m->flags) = OWN|HADDR(l.rpa[l.rc]); | |
| 1990/1228/sys/src/9/port/devlance.c:23,28 – 1990/1229/sys/src/9/port/devlance.c:23,30 (short | long) | ||
|
Created.
rsc Fri Mar 4 12:44:25 2005 | ||
| 1990/0227 | ||
| 1990/0707 | #define NOW (MACHP(0)->ticks*MS2HZ) | |
| 1990/03042 | ||
| 1990/1229 | int plance; | |
| 1990/0227 | /* * Communication with the lance is via a transmit and receive ring of * message descriptors. The Initblock contains pointers to and sizes of | |
| 1990/1228/sys/src/9/port/devlance.c:57,68 – 1990/1229/sys/src/9/port/devlance.c:59,64 | ||
| 1990/0227 | */ Msg rmr[Nrrb]; /* recieve message ring */ Msg tmr[Ntrb]; /* transmit message ring */ | |
| 1990/1228 |
| |
| 1990/0227 |
| |
| 1990/1228 |
| |
| 1990/0227 | } Lancemem; /* | |
| 1990/1228/sys/src/9/port/devlance.c:128,134 – 1990/1229/sys/src/9/port/devlance.c:124,129 | ||
| 1990/0911 | int sep; /* separaqtion between shorts in lance ram as seen by host */ ushort *lanceram; /* start of lance ram as seen by host */ | |
| 1990/0227 | Rendez rr; /* rendezvous for an input buffer */ | |
| 1990/1228/sys/src/9/port/devlance.c:145,154 – 1990/1229/sys/src/9/port/devlance.c:140,149 | ||
| 1990/0227 | int kstarted; Debqueue dq; | |
| 1990/0911 | ||
| 1990/1228 |
| |
| 1990/0911 |
| |
| 1990/1229 | Etherpkt *rp; /* receive buffers (host address) */ Etherpkt *tp; /* transmit buffers (host address) */ Etherpkt *lrp; /* receive buffers (lance address) */ Etherpkt *ltp; /* transmit buffers (lance address) */ | |
| 1990/0911 | /* sadistics */ | |
| 1990/1228/sys/src/9/port/devlance.c:266,272 – 1990/1229/sys/src/9/port/devlance.c:261,267 | ||
| 1990/03042 | memcpy(&(t->p), p, sizeof(Dpkt)); | |
| 1990/0227 | l.dq.next = (l.dq.next+1) % Ndpkt; unlock(&l.dq); | |
| 1990/0427 |
| |
| 1990/1229 | if(plance){ | |
| 1990/0427 | char buf[1024]; if(p->d[0] != 0xff){ sprintpacket(buf, t); | |
| 1990/1228/sys/src/9/port/devlance.c:405,414 – 1990/1229/sys/src/9/port/devlance.c:400,410 | ||
| 1990/0227 | m = &(LANCEMEM->tmr[l.tc]); | |
| 1990/0911 | MPs(m->size) = -len; MPus(m->cntflags) = 0; | |
| 1990/1229 | MPus(m->laddr) = LADDR(&l.ltp[l.tc]); MPus(m->flags) = OWN|STP|ENP|HADDR(&l.ltp[l.tc]); | |
| 1990/0227 | l.tc = TSUCC(l.tc); *l.rdp = INEA|TDMD; /**/ | |
| 1990/1229 | wbflush(); | |
| 1990/0227 | qunlock(&l.tlock); } | |
| 1990/1228/sys/src/9/port/devlance.c:423,447 – 1990/1229/sys/src/9/port/devlance.c:419,427 | ||
| 1990/03042 | Dirtab lancedir[Ndir]; | |
| 1990/0227 | /* | |
| 1990/1228 |
| |
| 1990/1229 | * stop the lance and allocate buffers | |
| 1990/1228 | */ void | |
| 1990/0227 |
| |
| 1990/1228/sys/src/9/port/devlance.c:448,454 – 1990/1229/sys/src/9/port/devlance.c:428,439 | ||
| 1990/0911 | ulong x; int index; static int already; | |
| 1990/1229 | ushort *lanceaddr; ushort *hostaddr; | |
| 1990/0227 | ||
| 1990/1229 | l.rap = LANCERAP; l.rdp = LANCERDP; | |
| 1990/0227 | /* | |
| 1990/1228 | * stop the lance | |
| 1990/0227 | */ | |
| 1990/1228/sys/src/9/port/devlance.c:457,494 – 1990/1229/sys/src/9/port/devlance.c:442,473 | ||
| 1990/0227 | ||
| 1990/0911 | if(already == 0){ already = 1; | |
| 1990/0912 | ||
| 1990/1228 |
| |
| 1990/0911 |
| |
| 1990/1228 |
| |
| 1990/0911 |
| |
| 1990/1229 | /* * lance ethernet address */ lanceeaddr(l.ea); /* * lance init block and descriptor rings */ lancectlmem(&hostaddr, &lanceaddr, &l.sep, sizeof(Lancemem)); l.lanceram = hostaddr; l.lm = (Lancemem*)lanceaddr; /* * lance receive buffers */ lancepktmem(&hostaddr, &lanceaddr, Nrrb*sizeof(Etherpkt)); l.rp = (Etherpkt*)hostaddr; l.lrp = (Etherpkt*)lanceaddr; /* * lance xmt buffers */ lancepktmem(&hostaddr, &lanceaddr, Ntrb*sizeof(Etherpkt)); l.tp = (Etherpkt*)hostaddr; l.ltp = (Etherpkt*)lanceaddr; | |
| 1990/0911 | } | |
| 1990/0227 | } | |
| 1990/1228/sys/src/9/port/devlance.c:536,543 – 1990/1229/sys/src/9/port/devlance.c:515,522 | ||
| 1990/0911 | for(i = 0; i < Nrrb; i++, m++){ | |
| 1990/1228 | MPs(m->size) = -sizeof(Etherpkt); | |
| 1990/0911 | MPus(m->cntflags) = 0; | |
| 1990/1229 | MPus(m->laddr) = LADDR(&l.lrp[i]); MPus(m->flags) = HADDR(&l.lrp[i]); | |
| 1990/0227 | } | |
| 1990/0911 | MPus(lm->rdralow) = LADDR(l.lm->rmr); MPus(lm->rdrahigh) = (LogNrrb<<13)|HADDR(l.lm->rmr); | |
| 1990/1228/sys/src/9/port/devlance.c:558,565 – 1990/1229/sys/src/9/port/devlance.c:537,544 | ||
| 1990/0911 | for(i = 0; i < Ntrb; i++, m++){ MPs(m->size) = 0; MPus(m->cntflags) = 0; | |
| 1990/1229 | MPus(m->laddr) = LADDR(&l.ltp[i]); MPus(m->flags) = HADDR(&l.ltp[i]); | |
| 1990/0227 | } | |
| 1990/0911 | MPus(lm->tdralow) = LADDR(l.lm->tmr); MPus(lm->tdrahigh) = (LogNtrb<<13)|HADDR(l.lm->tmr); | |
| 1990/1228/sys/src/9/port/devlance.c:583,588 – 1990/1229/sys/src/9/port/devlance.c:562,568 | ||
| 1990/0227 | /* * initialize lance, turn on interrupts, turn on transmit and rcv. */ | |
| 1990/1229 | wbflush(); | |
| 1990/0227 | *l.rap = 0; *l.rdp = INEA|INIT|STRT; /**/ } | |
| 1990/1228/sys/src/9/port/devlance.c:807,814 – 1990/1229/sys/src/9/port/devlance.c:787,795 | ||
| 1990/0227 | /* * look for rcv'd packets, just wakeup the input process */ | |
| 1990/0911 |
| |
| 1990/1229 | if(l.rl!=l.rc && (MPus(lm->rmr[l.rl].flags) & OWN)==0){ | |
| 1990/0227 | wakeup(&l.rr); | |
| 1990/1229 | } | |
| 1990/0227 | /* * look for xmitt'd packets, wake any process waiting for a | |
| 1990/1228/sys/src/9/port/devlance.c:907,924 – 1990/1229/sys/src/9/port/devlance.c:888,903 | ||
| 1990/0227 | m = &(lm->rmr[l.rc]); | |
| 1990/1228 | MPs(m->size) = -sizeof(Etherpkt); | |
| 1990/0911 | MPus(m->cntflags) = 0; | |
| 1990/1229 | MPus(m->laddr) = LADDR(&l.lrp[l.rc]); MPus(m->flags) = OWN|HADDR(&l.lrp[l.rc]); | |
| 1990/0227 | l.rc = RSUCC(l.rc); | |
| 1990/1229 | wbflush(); | |
| 1990/0227 | } sleep(&l.rr, isinput, 0); } } | |
| 1990/1229 | lancetoggle() | |
| 1990/0227 | { | |
| 1990/1229 | plance ^= 1; | |
| 1990/0826 | } | |
| 1990/1229/sys/src/9/port/devlance.c:6,25 – 1990/1231/sys/src/9/port/devlance.c:6,20 (short | long) | ||
| 1990/0227 | #include "io.h" #include "errno.h" #include "devtab.h" | |
| 1990/1231 | ||
| 1990/0227 | enum { Ntypes= 8, /* max number of ethernet packet types */ | |
| 1990/0911 | Ndir= Ntypes+2, /* entries in top level directory */ | |
| 1990/0227 |
| |
| 1990/0409 | Ndpkt= 200, /* number of debug packets */ | |
| 1990/1231 | Maxrb= 128, /* max buffers in a ring */ | |
| 1990/0227 | }; | |
| 1990/1231 | #define RSUCC(x) (((x)+1)%l.nrrb) #define TSUCC(x) (((x)+1)%l.ntrb) | |
| 1990/0227 | ||
| 1990/0707 | #define NOW (MACHP(0)->ticks*MS2HZ) | |
| 1990/03042 | ||
| 1990/1229/sys/src/9/port/devlance.c:40,46 – 1990/1231/sys/src/9/port/devlance.c:35,41 | ||
| 1990/0227 | /* * lance memory map */ | |
| 1990/0911 |
| |
| 1990/1231 | struct Lancemem | |
| 1990/0227 | { /* * initialization block | |
| 1990/1229/sys/src/9/port/devlance.c:57,65 – 1990/1231/sys/src/9/port/devlance.c:52,60 | ||
| 1990/0911 | * ring buffers * first receive, then transmit | |
| 1990/0227 | */ | |
| 1990/1231 | Msg rmr[Maxrb]; /* recieve message ring */ Msg tmr[Maxrb]; /* transmit message ring */ }; | |
| 1990/0227 | /* * Some macros for dealing with lance memory addresses. The lance splits | |
| 1990/1229/sys/src/9/port/devlance.c:116,130 – 1990/1231/sys/src/9/port/devlance.c:111,120 | ||
| 1990/0227 | typedef struct { QLock; | |
| 1990/1231 | Lance; /* host dependent lance params */ | |
| 1990/0227 | int inited; | |
| 1990/0911 |
| |
| 1990/0227 | Rendez rr; /* rendezvous for an input buffer */ ushort rl; /* first rcv Message belonging to Lance */ | |
| 1990/1229/sys/src/9/port/devlance.c:140,150 – 1990/1231/sys/src/9/port/devlance.c:130,135 | ||
| 1990/0227 | int kstarted; Debqueue dq; | |
| 1990/0911 | ||
| 1990/1229 |
| |
| 1990/0911 |
| |
| 1990/1229/sys/src/9/port/devlance.c:154,161 – 1990/1231/sys/src/9/port/devlance.c:139,146 | ||
| 1990/0911 | int frames; /* framing errors */ int overflows; /* packet overflows */ int buffs; /* buffering errors */ | |
| 1990/0227 |
| |
| 1990/1231 | } SoftLance; static SoftLance l; | |
| 1990/0227 | /* * mode bits in the lance initialization block | |
| 1990/1229/sys/src/9/port/devlance.c:431,438 – 1990/1231/sys/src/9/port/devlance.c:416,425 | ||
| 1990/1229 | ushort *lanceaddr; ushort *hostaddr; | |
| 1990/0227 | ||
| 1990/1229 |
| |
| 1990/1231 | if(already == 0){ already = 1; lancesetup(&l); } | |
| 1990/1229 | ||
| 1990/0227 | /* | |
| 1990/1228 | * stop the lance | |
| 1990/1229/sys/src/9/port/devlance.c:439,475 – 1990/1231/sys/src/9/port/devlance.c:426,431 | ||
| 1990/0227 | */ | |
| 1990/1228 | *l.rap = 0; *l.rdp = STOP; | |
| 1990/0227 | ||
| 1990/0911 |
| |
| 1990/0912 | ||
| 1990/1229 |
| |
| 1990/0911 |
| |
| 1990/0227 | } /* | |
| 1990/1229/sys/src/9/port/devlance.c:512,518 – 1990/1231/sys/src/9/port/devlance.c:468,474 | ||
| 1990/0227 | * set up rcv message ring */ | |
| 1990/0911 | m = lm->rmr; | |
| 1990/1231 | for(i = 0; i < l.nrrb; i++, m++){ | |
| 1990/1228 | MPs(m->size) = -sizeof(Etherpkt); | |
| 1990/0911 | MPus(m->cntflags) = 0; | |
| 1990/1229 | MPus(m->laddr) = LADDR(&l.lrp[i]); | |
| 1990/1229/sys/src/9/port/devlance.c:519,531 – 1990/1231/sys/src/9/port/devlance.c:475,487 | ||
| 1990/1229 | MPus(m->flags) = HADDR(&l.lrp[i]); | |
| 1990/0227 | } | |
| 1990/0911 | MPus(lm->rdralow) = LADDR(l.lm->rmr); | |
| 1990/1231 | MPus(lm->rdrahigh) = (l.lognrrb<<13)|HADDR(l.lm->rmr); | |
| 1990/0227 | ||
| 1990/0911 | ||
| 1990/0227 | /* * give the lance all the rcv buffers except one (as a sentinel) */ | |
| 1990/1231 | l.rc = l.nrrb - 1; | |
| 1990/0911 | m = lm->rmr; for(i = 0; i < l.rc; i++, m++) MPus(m->flags) |= OWN; | |
| 1990/1229/sys/src/9/port/devlance.c:534,540 – 1990/1231/sys/src/9/port/devlance.c:490,496 | ||
| 1990/0227 | * set up xmit message ring */ | |
| 1990/0911 | m = lm->tmr; | |
| 1990/1231 | for(i = 0; i < l.ntrb; i++, m++){ | |
| 1990/0911 | MPs(m->size) = 0; MPus(m->cntflags) = 0; | |
| 1990/1229 | MPus(m->laddr) = LADDR(&l.ltp[i]); | |
| 1990/1229/sys/src/9/port/devlance.c:541,547 – 1990/1231/sys/src/9/port/devlance.c:497,503 | ||
| 1990/1229 | MPus(m->flags) = HADDR(&l.ltp[i]); | |
| 1990/0227 | } | |
| 1990/0911 | MPus(lm->tdralow) = LADDR(l.lm->tmr); | |
| 1990/1231 | MPus(lm->tdrahigh) = (l.logntrb<<13)|HADDR(l.lm->tmr); | |
| 1990/0227 | /* * point lance to the initialization block | |
| 1990/1229/sys/src/9/port/devlance.c:563,570 – 1990/1231/sys/src/9/port/devlance.c:519,528 | ||
| 1990/0227 | * initialize lance, turn on interrupts, turn on transmit and rcv. */ | |
| 1990/1229 | wbflush(); | |
| 1990/1231 | print("starting lance\n"); | |
| 1990/0227 | *l.rap = 0; *l.rdp = INEA|INIT|STRT; /**/ | |
| 1990/1231 | print("lance started\n"); | |
| 1990/0227 | } /* | |
| 1990/1229/sys/src/9/port/devlance.c:781,788 – 1990/1231/sys/src/9/port/devlance.c:739,748 | ||
| 1990/0227 | if(csr & (BABL|MISS|MERR)) print("lance err %ux\n", csr); | |
| 1990/1231 | if(csr & IDON){ print("lance inited\n"); | |
| 1990/0227 | l.inited = 1; | |
| 1990/1231 | } | |
| 1990/0227 | /* * look for rcv'd packets, just wakeup the input process | |
| 1990/1231/sys/src/9/port/devlance.c:416,426 – 1991/0108/sys/src/9/port/devlance.c:416,434 (short | long) | ||
| 1990/1229 | ushort *lanceaddr; ushort *hostaddr; | |
| 1990/0227 | ||
| 1991/0108 | ||
| 1990/1231 | if(already == 0){ already = 1; lancesetup(&l); } | |
| 1990/1229 | ||
| 1991/0108 | *l.rap = 0; print("csr0 %lux\n", *l.rdp); *l.rap = 1; print("csr1 %lux\n", *l.rdp); *l.rap = 2; print("csr2 %lux\n", *l.rdp); | |
| 1990/0227 | /* | |
| 1990/1228 | * stop the lance | |
| 1990/0227 | */ | |
| 1990/1231/sys/src/9/port/devlance.c:736,743 – 1991/0108/sys/src/9/port/devlance.c:744,762 | ||
| 1990/0227 | /* * see if an error occurred */ | |
| 1991/0108 | if(csr & (BABL|MISS|MERR)){ | |
| 1990/0227 | print("lance err %ux\n", csr); | |
| 1991/0108 | print("aser %lux asevar %lux\n", getw2(0x60000008), getw2(0x6000000C)); *l.rap = 0; *l.rdp = STOP; delay(100); *l.rap = 0; print("csr0 %lux\n", *l.rdp); *l.rap = 1; print("csr1 %lux\n", *l.rdp); *l.rap = 2; print("csr2 %lux\n", *l.rdp); } | |
| 1990/0227 | ||
| 1990/1231 | if(csr & IDON){ print("lance inited\n"); | |
| 1991/0108/sys/src/9/port/devlance.c:176,188 – 1991/0109/sys/src/9/port/devlance.c:176,181 (short | long) | ||
| 1990/0227 | #define INIT 0x1 /* | |
| 1991/0108/sys/src/9/port/devlance.c:342,350 – 1991/0109/sys/src/9/port/devlance.c:335,341 | ||
| 1990/0227 | * Wait till we get an output buffer */ if(TSUCC(l.tc) == l.tl){ | |
| 1990/0911 | p = &l.tp[l.tc]; | |
| 1990/0227 | ||
| 1991/0108/sys/src/9/port/devlance.c:422,434 – 1991/0109/sys/src/9/port/devlance.c:413,418 | ||
| 1990/1231 | lancesetup(&l); } | |
| 1990/1229 | ||
| 1991/0108 |
| |
| 1990/0227 | /* | |
| 1990/1228 | * stop the lance | |
| 1990/0227 | */ | |
| 1991/0108/sys/src/9/port/devlance.c:521,536 – 1991/0109/sys/src/9/port/devlance.c:505,518 | ||
| 1990/0227 | */ wbflush(); *l.rap = 3; | |
| 1991/0109 | *l.rdp = l.busctl; | |
| 1990/0227 | /* * initialize lance, turn on interrupts, turn on transmit and rcv. */ | |
| 1990/1229 | wbflush(); | |
| 1990/1231 |
| |
| 1990/0227 | *l.rap = 0; *l.rdp = INEA|INIT|STRT; /**/ | |
| 1990/1231 |
| |
| 1990/0227 | } /* | |
| 1991/0108/sys/src/9/port/devlance.c:746,761 – 1991/0109/sys/src/9/port/devlance.c:728,733 | ||
| 1990/0227 | */ | |
| 1991/0108 | if(csr & (BABL|MISS|MERR)){ | |
| 1990/0227 | print("lance err %ux\n", csr); | |
| 1991/0108 |
| |
| 1990/0227 | ||
| 1990/1231 | if(csr & IDON){ | |
| 1991/0109/sys/src/9/port/devlance.c:848,854 – 1991/01151/sys/src/9/port/devlance.c:848,855 (short | long) | ||
| 1990/0227 | } } | |
| 1990/1229 |
| |
| 1991/01151 | void lancetoggle(void) | |
| 1990/0227 | { | |
| 1990/1229 | plance ^= 1; | |
| 1990/0826 | } | |
| 1991/01151/sys/src/9/port/devlance.c:218,224 – 1991/0118/sys/src/9/port/devlance.c:218,224 (short | long) | ||
| 1990/0409 | p->d[0], p->d[1], p->d[2], p->d[3], p->d[4], p->d[5], p->s[0], p->s[1], p->s[2], p->s[3], p->s[4], p->s[5], p->type[0], p->type[1]); | |
| 1990/0911 |
| |
| 1991/0118 | for(i=0; i<sizeof(p->data); i++) | |
| 1990/0409 | sprint(buf+strlen(buf), "%.2ux", p->data[i]); sprint(buf+strlen(buf), ")\n"); | |
| 1990/0227 | } | |
| 1991/01151/sys/src/9/port/devlance.c:362,371 – 1991/0118/sys/src/9/port/devlance.c:362,373 | ||
| 1990/0227 | memcpy(p->s, l.ea, sizeof(l.ea)); /* | |
| 1991/0118 | * pad the packet (zero the pad) | |
| 1990/0227 | */ | |
| 1991/0118 | if(len < 60){ memset(((char*)p)+len, 0, 60-len); | |
| 1990/0227 | len = 60; | |
| 1991/0118 | } | |
| 1990/0227 | ||
| 1990/0911 | lancedebq('o', p, len);/**/ | |
| 1990/0227 | ||
| 1991/01151/sys/src/9/port/devlance.c:636,642 – 1991/0118/sys/src/9/port/devlance.c:638,644 | ||
| 1990/03042 | static long lancetraceread(Chan *c, void *a, long n) { | |
| 1991/0118 | char buf[1024]; | |
| 1990/03042 | long rv; int i; char *ca = a; | |
| 1991/0118/sys/src/9/port/devlance.c:826,836 – 1991/0313/sys/src/9/port/devlance.c:826,839 (short | long) | ||
| 1990/0227 | /* * The lock on e makes sure the queue is still there. */ | |
| 1990/03042 |
| |
| 1990/0227 |
| |
| 1991/0313 | if(!waserror()){ bp = allocb(len); memcpy(bp->rptr, (uchar *)p, len); bp->wptr += len; bp->flags |= S_DELIM; PUTNEXT(e->q, bp); poperror(); } | |
| 1990/0227 | qunlock(e); } | |
| 1991/0313/sys/src/9/port/devlance.c:802,808 – 1991/0314/sys/src/9/port/devlance.c:802,808 (short | long) | ||
| 1990/0911 | len = MPus(m->cntflags) - 4; lancedebq('i', p, len);/**/ | |
| 1990/0227 | for(e = &l.e[0]; e < &l.e[Ntypes]; e++){ | |
| 1991/0314 | if(e->q==0 || t!=e->type || !canqlock(e)) | |
| 1990/0227 | continue; if(e->q && t == e->type) break; | |
| 1991/0313/sys/src/9/port/devlance.c:815,821 – 1991/0314/sys/src/9/port/devlance.c:815,821 | ||
| 1990/0227 | */ if(e == &l.e[Ntypes]){ for(e = &l.e[0]; e < &l.e[Ntypes]; e++){ | |
| 1991/0314 | if(e->q==0 || e->type!=-1 || !canqlock(e)) | |
| 1990/0227 | continue; if(e->q && e->type == -1) break; | |
| 1991/0313/sys/src/9/port/devlance.c:822,832 – 1991/0314/sys/src/9/port/devlance.c:822,832 | ||
| 1990/0227 | qunlock(e); } } | |
| 1990/0911 |
| |
| 1990/0227 |
| |
| 1991/0313 |
| |
| 1991/0314 | /* * The lock on e makes sure the queue is still there. */ if(e!=&l.e[Ntypes]){ if(e->q->next->len<=Streamhi && !waserror()){ | |
| 1991/0313 | bp = allocb(len); memcpy(bp->rptr, (uchar *)p, len); bp->wptr += len; | |
| 1991/0314/sys/src/9/port/devlance.c:549,564 – 1991/0316/sys/src/9/port/devlance.c:549,560 (short | long) | ||
| 1990/0227 | Chan* lanceattach(char *spec) { | |
| 1990/0911 | kproc("lancekproc", lancekproc, 0);/**/ | |
| 1990/0227 | l.kstarted = 1; lancestart(); } | |
| 1991/0316 | return devattach('l', spec); | |
| 1990/0227 | } Chan* | |
| 1991/0314/sys/src/9/port/devlance.c:595,602 – 1991/0316/sys/src/9/port/devlance.c:591,596 | ||
| 1990/0227 | Chan* lanceopen(Chan *c, int omode) { | |
| 1990/11211 | switch(c->qid.path){ | |
| 1990/03042 | case CHDIR: case Ltraceqid: | |
| 1991/0314/sys/src/9/port/devlance.c:623,638 – 1991/0316/sys/src/9/port/devlance.c:617,624 | ||
| 1990/0227 | void lanceclose(Chan *c) { | |
| 1990/11211 |
| |
| 1990/03042 |
| |
| 1990/0911 |
| |
| 1990/03042 |
| |
| 1991/0316 | if(c->stream) | |
| 1990/0227 | streamclose(c); | |
| 1990/03042 |
| |
| 1990/0227 | } | |
| 1990/03042 | static long | |
| 1991/0316/sys/src/9/port/devlance.c:236,242 – 1991/0318/sys/src/9/port/devlance.c:236,242 (short | long) | ||
| 1990/03042 | t->ticks = NOW; t->tag = tag; t->len = len; | |
| 1991/0318 | memmove(&(t->p), p, sizeof(Dpkt)); | |
| 1990/0227 | l.dq.next = (l.dq.next+1) % Ndpkt; unlock(&l.dq); | |
| 1990/1229 | if(plance){ | |
| 1991/0316/sys/src/9/port/devlance.c:345,351 – 1991/0318/sys/src/9/port/devlance.c:345,351 | ||
| 1990/0227 | len = 0; while(bp = getq(q)){ | |
| 1990/1228 | if(sizeof(Etherpkt) - len >= (n = BLEN(bp))){ | |
| 1990/03042 |
| |
| 1991/0318 | memmove(((uchar *)p)+len, bp->rptr, n); | |
| 1990/0227 | len += n; } else print("no room damn it\n"); | |
| 1991/0316/sys/src/9/port/devlance.c:359,365 – 1991/0318/sys/src/9/port/devlance.c:359,365 | ||
| 1990/0227 | /* * give packet a local address */ | |
| 1991/0318 | memmove(p->s, l.ea, sizeof(l.ea)); | |
| 1990/0227 | /* | |
| 1991/0118 | * pad the packet (zero the pad) | |
| 1991/0316/sys/src/9/port/devlance.c:544,549 – 1991/0318/sys/src/9/port/devlance.c:544,550 | ||
| 1990/11211 | lancedir[Ntypes+1].qid.path = Lstatsqid; | |
| 1990/0911 | lancedir[Ntypes+1].length = 0; lancedir[Ntypes+1].perm = 0600; | |
| 1991/0318 | ||
| 1990/0227 | } Chan* | |
| 1991/0316/sys/src/9/port/devlance.c:645,651 – 1991/0318/sys/src/9/port/devlance.c:646,652 | ||
| 1990/03042 | i = plen - offset; if(i > n) i = n; | |
| 1991/0318 | memmove(ca, buf + offset, i); | |
| 1990/03042 | n -= i; ca += i; rv += i; | |
| 1991/0316/sys/src/9/port/devlance.c:814,820 – 1991/0318/sys/src/9/port/devlance.c:815,821 | ||
| 1991/0314 | if(e!=&l.e[Ntypes]){ if(e->q->next->len<=Streamhi && !waserror()){ | |
| 1991/0313 | bp = allocb(len); | |
| 1991/0318 | memmove(bp->rptr, (uchar *)p, len); | |
| 1991/0313 | bp->wptr += len; bp->flags |= S_DELIM; PUTNEXT(e->q, bp); | |
| Too many diffs (26 > 25). Stopping. | ||