From 6aa28cf4f6ee6395829add3697e808886bbfee4d Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 31 Oct 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-10-31 --- port/devlance.c | 4 ++-- port/portdat.h | 1 + port/stil.c | 56 +++++++++++++++++++++++++++++++------------------ power/devrtc.c | 16 +++++++------- power/trap.c | 4 ++-- 5 files changed, 50 insertions(+), 31 deletions(-) diff --git a/port/devlance.c b/port/devlance.c index 8d5f25bbf95b97c08b988c79b2dc32551a550939..e8c3b9e8c4fc3781d10277af737fb1b22abe4201 100644 --- a/port/devlance.c +++ b/port/devlance.c @@ -719,8 +719,8 @@ lancekproc(void *arg) for(; l.rl!=l.rc && (MPus(lm->rmr[l.rl].flags) & OWN)==0 ; l.rl=RSUCC(l.rl)){ l.inpackets++; m = &(lm->rmr[l.rl]); - if(MPus(m->flags) & ERR){ - t = MPus(m->flags); + t = MPus(m->flags); + if(t & ERR){ if(t & FRAM) l.frames++; if(t & OFLO) diff --git a/port/portdat.h b/port/portdat.h index 48f7045d8155e06fbf0a32f592c8f2bd93e3c01b..8395c31a2b260847b0ef1ef7f85fd4f0ac07d220 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -95,6 +95,7 @@ struct Alarms struct Block { Block *next; + Block *list; /* chain of block lists */ uchar *rptr; /* first unconsumed byte */ uchar *wptr; /* first empty byte */ uchar *lim; /* 1 past the end of the buffer */ diff --git a/port/stil.c b/port/stil.c index 059e43348642fb6e3d8e4083e6de78abedd36f10..c866b3a2b9f93ffba546a605d61d604a162103f3 100644 --- a/port/stil.c +++ b/port/stil.c @@ -36,7 +36,7 @@ ilopen(Queue *q, Stream *s) if(ilkproc == 0) { ilkproc = 1; - kproc("ilack", ilackproc, 0); + kproc("ilack", ilackproc, ipconv[s->dev]); } ipc = &ipconv[s->dev][s->id]; @@ -71,7 +71,7 @@ iloput(Queue *q, Block *bp) Ilhdr *ih; Ilcb *ic; int dlen; - Block *np; + Block *np, *f; ipc = (Ipconv *)(q->ptr); if(ipc->psrc == 0) @@ -90,7 +90,9 @@ iloput(Queue *q, Block *bp) } /* Only allow atomic Il writes to form datagrams */ - if(!(bp->flags & S_DELIM)) { + for(f = bp; f && (f->flags&S_DELIM) == 0; f = f->next) + ; + if(f ==0 || (f->flags & S_DELIM) == 0) { freeb(bp); error(Emsgsize); } @@ -139,11 +141,11 @@ ilackq(Ilcb *ic, Block *bp) np = copyb(bp, blen(bp)); if(ic->unacked) - ic->unackedtail->next = np; + ic->unackedtail->list = np; else ic->unacked = np; ic->unackedtail = np; - np->next = 0; + np->list = 0; } void @@ -157,10 +159,11 @@ ilackto(Ilcb *ic, ulong ackto) if(ackto < nhgetl(h->ilack)) break; bp = ic->unacked; - ic->unacked = bp->next; - bp->next = 0; + ic->unacked = bp->list; + bp->list = 0; freeb(bp); } + if(ic->unacked == 0) print("ack empty: %d\n", ackto); } void @@ -284,7 +287,7 @@ ilprocess(Ipconv *s, Ilhdr *h, Block *bp) freeb(bp); break; case Ilack: - ilackto(&s->ilctl, ack); + ilackto(ic, ack); freeb(bp); break; case Ilquerey: @@ -294,15 +297,15 @@ ilprocess(Ipconv *s, Ilhdr *h, Block *bp) case Ildataquery: sendack = 1; case Ildata: - ilackto(&s->ilctl, ack); - switch(s->ilctl.state) { + ilackto(ic, ack); + switch(ic->state) { default: iloutoforder(s, h, bp); break; case Ilestablished: if(id < s->ilctl.recvd) freeb(bp); - else if(id > s->ilctl.recvd) + else if(s->readq == 0 || id > ic->recvd) iloutoforder(s, h, bp); else { s->ilctl.recvd++; @@ -313,7 +316,7 @@ ilprocess(Ipconv *s, Ilhdr *h, Block *bp) } break; case Ilreset: - s->ilctl.state = Ilclosed; + ic->state = Ilclosed; hungup: if(s->readq) { nb = allocb(0); @@ -334,14 +337,14 @@ print("recvd = %d outoforder = %d\n", ic->recvd, oid); if(oid > ic->recvd) break; if(oid < ic->recvd) { - ic->outoforder = bp->next; + ic->outoforder = bp->list; freeb(bp); } if(oid == ic->recvd) { print("outoforder %d\n", oid); ic->recvd++; - ic->outoforder = bp->next; - bp->next = 0; + ic->outoforder = bp->list; + bp->list = 0; dlen = nhgets(oh->illen)-IL_HDRSIZE; bp = btrim(bp, IL_EHSIZE+IL_HDRSIZE, dlen); PUTNEXT(s->readq, bp); @@ -367,18 +370,18 @@ iloutoforder(Ipconv *s, Ilhdr *h, Block *bp) ic = &s->ilctl; if(ic->outoforder == 0) { ic->outoforder = bp; - bp->next = 0; + bp->list = 0; } else { id = nhgetl(h->id); l = &ic->outoforder; - for(f = *l; f; f = f->next) { + for(f = *l; f; f = f->list) { lid = ((Ilhdr*)(bp->rptr))->ilid; if(id > nhgetl(lid)) break; - l = &f->next; + l = &f->list; } - bp->next = *l; + bp->list = *l; *l = bp; } } @@ -432,8 +435,21 @@ ilsendctl(Ipconv *ipc, Ilhdr *inih, int type, int ack) } void -ilackproc(void *junk) +ilackproc(void *a) { + Rendez wait; + Ipconv *base, *end, *s; + + base = (Ipconv*)a; + end = &base[conf.ip]; + + for(;;) { + tsleep(&wait, return0, 0, 250); + for(s = base; s < end; s++) { + if(s->ilctl.state == Ilclosed) + continue; + } + } } void diff --git a/power/devrtc.c b/power/devrtc.c index e606df54f4d84fdbfd972a91ec001470b5dfd5d9..73bf385e08d94a6d4c8c7abc2a59d8e321c039eb 100644 --- a/power/devrtc.c +++ b/power/devrtc.c @@ -44,7 +44,7 @@ QLock rtclock; /* mutex on nvram operations */ static Dirtab rtcdir[]={ "rtc", {Qrtc, 0}, 0, 0644, -/* "nvram", {Qnvram, 0}, 0, 0644,/**/ + "nvram", {Qnvram, 0}, 0, 0644, }; #define NRTC (sizeof(rtcdir)/sizeof(rtcdir[0])) @@ -97,10 +97,12 @@ rtcstat(Chan *c, char *dp) Chan* rtcopen(Chan *c, int omode) { - if(c->qid.path==1 && (omode&(OWRITE|OTRUNC))){ - if(strcmp(u->p->pgrp->user, "bootes")) /* BUG */ - error(Eperm); - } + if(c->qid.path==Qrtc && (omode&(OWRITE|OTRUNC))) + if(strcmp(u->p->pgrp->user, "bootes") != 0) /* BUG */ + error(Eperm); + if(c->qid.path == Qnvram) + if(strcmp(u->p->pgrp->user, "bootes") != 0) /* BUG */ + error(Eperm); return devopen(c, omode, rtcdir, NRTC, devgen); } @@ -290,7 +292,7 @@ rtctime(void) /* * read out the clock one bit at a time */ - for (i = 0; i < Nbcd; i++){ + for(i = 0; i < Nbcd; i++){ ch = 0; for (j = 0; j < 8; j++) ch |= ((*nv & 0x1) << j); @@ -350,7 +352,7 @@ setrtc(Rtc *rtc) * write the clock one bit at a time */ nv = &((Nvram*)NVRAM)[NVRTC].val; - for (i = 0; i < Nbcd; i++){ + for(i = 0; i < Nbcd; i++){ ch = bcdclock[i]; for (j = 0; j < 8; j++){ *nv = ch & 1; diff --git a/power/trap.c b/power/trap.c index 720a01b92bcd21069617825951e35e063ee9fec2..28583fbf03d583bf88d988d3f49637fb376c2421 100644 --- a/power/trap.c +++ b/power/trap.c @@ -298,9 +298,9 @@ intr(Ureg *ur) } } /* - * if nothing else, assume bus error + * if nothing else, what the hell? */ - if(!any && bogies++<100){ + if(!any && bogies++<10){ print("bogus intr lvl 5 pend %lux on %d\n", npend, m->machno); delay(100); }