From 4923930c097ce32b1415b3df535d4241fd5a87c9 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 16 Mar 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-03-16 --- port/devlance.c | 18 ++---------------- port/devnonet.c | 2 +- port/stream.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ power/devhotrod.c | 1 + power/trap.c | 18 +++++++++++++++++- 5 files changed, 65 insertions(+), 18 deletions(-) diff --git a/port/devlance.c b/port/devlance.c index 330e1f9278178c7f0da6522ef027050caf36ae20..feb8372c141db7a52c324c07097eb466904f4585 100644 --- a/port/devlance.c +++ b/port/devlance.c @@ -549,16 +549,12 @@ lanceinit(void) Chan* lanceattach(char *spec) { - Chan *c; - if(l.kstarted == 0){ kproc("lancekproc", lancekproc, 0);/**/ l.kstarted = 1; lancestart(); } - c = devattach('l', spec); - c->dev = 0; - return c; + return devattach('l', spec); } Chan* @@ -595,8 +591,6 @@ lancestat(Chan *c, char *dp) Chan* lanceopen(Chan *c, int omode) { - extern Qinfo nonetinfo; - switch(c->qid.path){ case CHDIR: case Ltraceqid: @@ -623,16 +617,8 @@ lancecreate(Chan *c, char *name, int omode, ulong perm) void lanceclose(Chan *c) { - /* real closing happens in lancestclose */ - switch(c->qid.path){ - case CHDIR: - case Ltraceqid: - case Lstatsqid: - break; - default: + if(c->stream) streamclose(c); - break; - } } static long diff --git a/port/devnonet.c b/port/devnonet.c index 48d27c1485e0cad3135d35a4050b5736f8a168a6..c8a12c5ad794032ff05f562096099149c9936495 100644 --- a/port/devnonet.c +++ b/port/devnonet.c @@ -276,7 +276,7 @@ nonetopen(Chan *c, int omode) line = STREAMID(c->qid.path); ifc = &noifc[c->dev]; if(ifc->conv[line].state != Cannounced) - error(Enoannounce); + errors("channel not announced"); nolisten(c, ifc); break; case Nraddrqid: diff --git a/port/stream.c b/port/stream.c index d073ac1d6f8addd556b7b4f23746088d7afe55dd..56baf6c2a51172464f97fd8797fa042ed57a5e4a 100644 --- a/port/stream.c +++ b/port/stream.c @@ -441,6 +441,49 @@ putq(Queue *q, Block *bp) unlock(q); return delim; } + +int +blen(Block *bp) +{ + int len; + + len = 0; + while(bp) { + len += BLEN(bp); + bp = bp->next; + } + + return len; +} + +/* + * bround - round a block to chain to some 2^n number of bytes + */ +int +bround(Block *bp, int amount) +{ + Block *last; + int len, pad; + + len = 0; + SET(last); + while(bp) { + len += BLEN(bp); + last = bp; + bp = bp->next; + } + + pad = ((len + amount) & ~amount) - len; + if(pad) { + last->next = allocb(pad); + memset(last->next->rptr, 0, pad); + last->next->flags |= S_DELIM; + last->flags &= ~S_DELIM; + } + + return len + pad; +} + int putb(Blist *q, Block *bp) { @@ -597,6 +640,7 @@ prepend(Block *bp, int n) } } + /* * put a block into the bit bucket */ diff --git a/power/devhotrod.c b/power/devhotrod.c index 888a3d44252a19a9bdb9e1a6b8c6c3cbcbd8c8ae..8b1bfcc6e1c0861640afe1499ab8247c209b05b6 100644 --- a/power/devhotrod.c +++ b/power/devhotrod.c @@ -13,6 +13,7 @@ /* * If defined, ENABMEMTEST causes memory test to be run at device open */ +#define ENABMEMTEST #ifdef ENABMEMTEST void mem(Hot*, ulong*, ulong); #define NTESTBUF 256 diff --git a/power/trap.c b/power/trap.c index 9d121ff787b28264b716c74e10830747f8cadb32..ca98e0d52abafe95c7d2a44d10c4f39896270e0f 100644 --- a/power/trap.c +++ b/power/trap.c @@ -176,6 +176,7 @@ void intr(Ureg *ur) { int i, any; + uchar xxx; uchar pend, npend; long v; ulong cause; @@ -215,7 +216,8 @@ intr(Ureg *ur) /* * 3. read pending interrupts */ - npend = pend = SBCCREG->fintpending; + pend = SBCCREG->fintpending; + npend = pend; /* * 4. clear pending register @@ -223,6 +225,20 @@ intr(Ureg *ur) i = SBCCREG->flevel; USED(i); + /* + * 4a. attempt to fix problem + */ + if(!(*INTPENDREG & (1<<5))) + print("pause again\n"); + while(!(*INTPENDREG & (1<<5))) + ; + xxx = SBCCREG->fintpending; + if(xxx){ + print("new pend %ux\n", xxx); + npend = pend |= xxx; + i = SBCCREG->flevel; + } + /* * 5a. process lance, scsi */