From c43acebc91ec92bef17dc5f8145277f13890a945 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 26 Mar 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-03-26 --- port/devscc.c | 28 ++++++++++++++++++++++++++ port/portdat.h | 2 -- port/stip.c | 19 +++++++++++++++++- port/stream.c | 53 +------------------------------------------------- 4 files changed, 47 insertions(+), 55 deletions(-) diff --git a/port/devscc.c b/port/devscc.c index 5593dcb9e0a0c2bd8ec184db676abca52e41bb69..9ef67bbf59f085ac91bde6d9479ee13dddb20396 100644 --- a/port/devscc.c +++ b/port/devscc.c @@ -33,6 +33,10 @@ enum Rx8bits= 3<<6, /* wr 4 */ + ParEven= 3<<0, + ParOdd= 1<<0, + ParOff= 0<<0, + ParMask= 3<<0, SyncMode= 0<<2, Rx1stop= 1<<2, Rx1hstop= 2<<2, @@ -163,6 +167,26 @@ sccsetbaud(SCC *sp, int rate) sccwrreg(sp, 13, (brconst>>8) & 0xff); } +void +sccparity(SCC *sp, char type) +{ + int val; + + switch(type){ + case 'e': + val = ParEven; + break; + case 'o': + val = ParOdd; + break; + default: + val = ParOff; + break; + } + sp->sticky[4] = (sp->sticky[4] & ~ParMask) | val; + sccwrreg(sp, 4, 0); +} + /* * toggle DTR */ @@ -508,6 +532,10 @@ sccoput(Queue *q, Block *bp) case 'd': sccdtr(sp, n); break; + case 'P': + case 'p': + sccparity(sp, *(bp->rptr+1)); + break; case 'K': case 'k': sccbreak(sp, n); diff --git a/port/portdat.h b/port/portdat.h index e4d0ffc5aa2485f85aa9325651843782594d8410..74f9a467b0b1a8853a4c3788e378dd4f06ab491a 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -603,8 +603,6 @@ struct Queue Rendez r; /* standard place to wait for flow control */ Rendez *rp; /* where flow control wakeups go to */ void *ptr; /* private info for the queue */ - Proc *pp; - Proc *pg; }; struct Stream diff --git a/port/stip.c b/port/stip.c index 9ab8748f3ad240d2086d12ffb4aaff3b1aa74a1c..f91676e7f75cd101470bc51966ae45ad980b1aef 100644 --- a/port/stip.c +++ b/port/stip.c @@ -415,6 +415,9 @@ ip_reassemble(int offset, Block *bp, Etherhdr *ip) dst = nhgetl(ip->dst); id = nhgets(ip->id); + /* + * find a reassembly queue for this fragment + */ qlock(&fraglock); for(f = flisthead; f; f = f->next) { if(f->src == src) @@ -424,6 +427,11 @@ ip_reassemble(int offset, Block *bp, Etherhdr *ip) } qunlock(&fraglock); + /* + * if this isn't a fragmented packet, accept it + * and get rid of any fragments that might go + * with it. + */ if(!ip->tos && (offset & ~(IP_MF|IP_DF)) == 0) { if(f != 0) { qlock(f); @@ -451,6 +459,9 @@ ip_reassemble(int offset, Block *bp, Etherhdr *ip) } qlock(f); + /* + * find the new fragment's position in the queue + */ prev = 0; l = &f->blist; for(bl = f->blist; bl && BLKFRAG(bp)->foff > BLKFRAG(bl)->foff; bl = bl->next) { @@ -469,7 +480,7 @@ ip_reassemble(int offset, Block *bp, Etherhdr *ip) qunlock(f); return 0; } - BLKFRAG(bp)->flen -= ovlap; + BLKFRAG(prev)->flen -= ovlap; } } @@ -490,15 +501,21 @@ ip_reassemble(int offset, Block *bp, Etherhdr *ip) if(ovlap < BLKFRAG(*l)->flen) { fragstat.succall++; BLKFRAG(*l)->flen -= ovlap; + BLKFRAG(*l)->foff += ovlap; (*l)->rptr += ovlap; break; } last = (*l)->next; + (*l)->next = 0; freeb(*l); *l = last; } } + /* + * look for a complete packet. if we get to a fragment + * without IP_MF set, we're done. + */ pktposn = 0; for(bl = f->blist; bl; bl = bl->next) { if(BLKFRAG(bl)->foff != pktposn) diff --git a/port/stream.c b/port/stream.c index 3bca08a35924108707046824867f8a7c1959261d..3e850080a34ef05e4fc819502e6d76518252950a 100644 --- a/port/stream.c +++ b/port/stream.c @@ -8,8 +8,6 @@ #include "devtab.h" #include "fcall.h" -ulong fpcs[100], refsa[100], refsf[100], apcs[100]; - enum { Nclass=4, /* number of block classes */ }; @@ -186,9 +184,6 @@ allocb(ulong size) { Block *bp; Bclass *bcp; - ulong pc; - - pc = getcallerpc(((uchar*)&size) - sizeof(size)); /* * map size to class @@ -212,25 +207,6 @@ allocb(ulong size) bcp->first = bp->next; if(bcp->first == 0) bcp->last = 0; - - if(bcp->size == 68) { - int i, hole, fnd; - fnd = 0; - hole = -1; - for(i = 0; i < 100; i++) { - if(apcs[i] == pc) { - refsa[i]++; - fnd = 1; - break; - } - if(refsa[i] == 0 && hole<0) - hole = i; - } - if(fnd == 0 && hole>=0) { - refsa[hole] = 1; - apcs[hole] = pc; - } - } qunlock(bcp); /* @@ -245,7 +221,6 @@ allocb(ulong size) if(bp->lim-bp->rptrlim, bp->rptr, size, bp->flags, bcp-bclass); - bp->pc = pc; return bp; } @@ -261,21 +236,10 @@ freeb(Block *bp) Bclass *bcp; int x; ulong pc; -int i; pc = getcallerpc(((uchar*)&bp) - sizeof(bp)); if((bp->flags&S_CLASS) >= Nclass) /* Check for double free */ panic("freeb class last(%lux) this(%lux)", bp->pc, pc); - - bcp = &bclass[bp->flags & S_CLASS]; - if(bcp->size == 68) { - for(i = 0; i < 100; i++) - if(apcs[i] == bp->pc) { - refsf[i]++; - fpcs[i] = pc; - } - } - bp->pc = pc; for(; bp; bp = nbp){ @@ -460,7 +424,6 @@ putq(Queue *q, Block *bp) int delim; lock(q); - q->pp = u->p; if(q->first) q->last->next = bp; else @@ -573,7 +536,6 @@ getq(Queue *q) Block *bp; lock(q); - q->pg = u->p; bp = q->first; if(bp) { q->first = bp->next; @@ -1076,7 +1038,6 @@ stputq(Queue *q, Block *bp) delim = 1; } else { lock(q); - q->pp = u->p; if(q->first) q->last->next = bp; else @@ -1523,7 +1484,7 @@ dumpqueues(void) int count, qcount; Block *bp; Bclass *bcp; -int i; + print("\n"); qcount = 0; for(q = qlist; q < qlist + conf.nqueue; q++, q++){ @@ -1533,17 +1494,9 @@ int i; print("%10s %ux R n %d l %d f %ux r %ux ", q->info->name, q, q->nb, q->len, q->flag, &(q->r)); - if(q->pg) - print("get %d %s ", q->pg->pid, q->pg->text); - if(q->pp) - print("put %d %s ", q->pp->pid, q->pp->text); print(" W n %d l %d f %ux r %ux next %lux put %lux Rz %lux", WR(q)->nb, WR(q)->len, WR(q)->flag, &(WR(q)->r), q->next, q->put, q->rp); - if(q->pg) - print("get %d %s ", q->pg->pid, q->pg->text); - if(q->pp) - print("put %d %s ", q->pp->pid, q->pp->text); print("\n"); dumpblocks(q, 'R'); dumpblocks(WR(q), 'W'); @@ -1558,8 +1511,4 @@ int i; bcp->made, count); } print("\n"); - for(i = 0; i < 100; i++) { - if(refsa[i] != refsf[i]) - print("%d alloc %lux %d free %lux\n", refsa[i], apcs[i], refsf[i], fpcs[i]); - } }