From 95d0044b7ba24333ebd7192f9ba9e72da75f8644 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 20 Nov 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-11-20 --- port/dev.c | 3 +- port/devdk.c | 12 +++- port/devip.c | 6 -- port/proc.c | 18 +++--- port/stil.c | 15 +++-- port/stip.c | 13 ++++- port/tcpif.c | 22 +++---- power/boot.h | 146 ++++++++++++++++++----------------------------- power/devduart.c | 3 +- 9 files changed, 108 insertions(+), 130 deletions(-) diff --git a/port/dev.c b/port/dev.c index 19f707119a71d87b85dac14f7879431d294491d4..81f401914e4e2b8af85f9522a7604b38cd8c9b54 100644 --- a/port/dev.c +++ b/port/dev.c @@ -127,7 +127,8 @@ devstat(Chan *c, char *db, Dirtab *tab, int ntab, Devgen *gen) convD2M(&dir, db); return; } - print("devstat %c %lux\n", devchar[c->type], c->qid.path); + print("%s %s: devstat %c %lux\n", u->p->text, u->p->user, + devchar[c->type], c->qid.path); error(Enonexist); case 0: break; diff --git a/port/devdk.c b/port/devdk.c index 1dcee34dc97271a420e701431985b14f409b8ed9..2c04cfd64242384a59ff3c78be1267a17ffce952 100644 --- a/port/devdk.c +++ b/port/devdk.c @@ -110,6 +110,7 @@ struct Dk { Chan *csc; Lock; + int ref; int opened; char name[64]; /* dk name */ @@ -240,7 +241,7 @@ dkalloc(char *name, int ncsc, int lines) unlock(&dklock); return dp; } - if(dp->name[0] == 0) + if(dp->name[0] == 0 && dp->ref == 0) freep = dp; } if(freep == 0){ @@ -334,6 +335,7 @@ dkmuxclose(Queue *q) dp = WR(q)->ptr; if(dp == 0) return; + dp->name[0] = 0; /* * disallow new dkstopens() on this line. @@ -454,6 +456,7 @@ dkstopen(Queue *q, Stream *s) q->other->ptr = q->ptr = lp = dp->linep[s->id]; lp->dp = dp; lock(dp); + dp->ref++; if(dp->opened==0 || streamenter(dp->s)<0){ unlock(dp); error(Ehungup); @@ -545,6 +548,12 @@ out: if(lp->lineno == dp->ncsc) dp->csc = 0; netdisown(&dp->net, lp->lineno); + + lock(dp); + dp->ref--; + if(dp->ref == 0) + freeb(dp->alloc); + unlock(dp); } /* @@ -1625,7 +1634,6 @@ dktimer(void *a) } if(c) close(c); - freeb(dp->alloc); return; } diff --git a/port/devip.c b/port/devip.c index 326c8c29c66bdd270fcfc0581e399ac75a2f991f..4a2f4674dc64a6e92d68bc08ffa39c821f67645d 100644 --- a/port/devip.c +++ b/port/devip.c @@ -443,7 +443,6 @@ udpstclose(Queue *q) ipc->psrc = 0; ipc->pdst = 0; ipc->dst = 0; - ipc->ref = 0; closeipifc(ipc->ipinterface); netdisown(&ipc->ipinterface->net, ipc->index); @@ -458,7 +457,6 @@ udpstopen(Queue *q, Stream *s) ipc->ipinterface = newipifc(IP_UDPPROTO, udprcvmsg, ipconv[s->dev], 1500, 512, ETHER_HDR, "UDP"); - ipc->ref = 1; ipc->readq = RD(q); RD(q)->ptr = (void *)ipc; WR(q)->next->ptr = (void *)ipc->ipinterface; @@ -541,8 +539,6 @@ tcpstopen(Queue *q, Stream *s) ipc->ipinterface = newipifc(IP_TCPPROTO, tcp_input, ipconv[s->dev], 1500, 512, ETHER_HDR, "TCP"); - ipc->ref = 1; - ipc->readq = RD(q); ipc->readq->rp = &tcpflowr; @@ -642,8 +638,6 @@ tcpstclose(Queue *q) s = (Ipconv *)(q->ptr); tcb = &s->tcpctl; - s->ref = 0; - /* Not interested in data anymore */ s->readq = 0; diff --git a/port/proc.c b/port/proc.c index 889d22171fe5b0a28d2e1bafe4a7fba7fde49892..42eb66463c2a8bafd7543a2b3dd16b788b148a0a 100644 --- a/port/proc.c +++ b/port/proc.c @@ -380,7 +380,7 @@ postnote(Proc *p, int dolock, char *n, int flag) { User *up; KMap *k; - int s; + int s, ret; Rendez *r; Proc *d, **l; @@ -403,16 +403,14 @@ postnote(Proc *p, int dolock, char *n, int flag) if(flag!=NUser && (up->notify==0 || up->notified)) up->nnote = 0; /* force user's hand */ - else if(up->nnote == NNOTE-1){ - if(up != u) - kunmap(k); - if(dolock) - unlock(&p->debug); - return 0; + + ret = 0; + if(up->nnote < NNOTE){ + strcpy(up->note[up->nnote].msg, n); + up->note[up->nnote++].flag = flag; + ret = 1; } p->notepending = 1; - strcpy(up->note[up->nnote].msg, n); - up->note[up->nnote++].flag = flag; if(up != u) kunmap(k); if(dolock) @@ -450,7 +448,7 @@ postnote(Proc *p, int dolock, char *n, int flag) unlock(p->pgrp); } - return 1; + return ret; } diff --git a/port/stil.c b/port/stil.c index 82edad333b157030f5ad1f8895583d3995c783b0..e63ed8de07521ab2a4852b840639241366a0f199 100644 --- a/port/stil.c +++ b/port/stil.c @@ -11,7 +11,7 @@ #include "arp.h" #include "ipdat.h" -#define DBG if(0)print +#define DBG if(1)print int ilcksum = 1; static int initseq = 25000; static Rendez ilackr; @@ -55,9 +55,6 @@ ilopen(Queue *q, Stream *s) ipc->ipinterface = newipifc(IP_ILPROTO, ilrcvmsg, ipconv[s->dev], 1500, 512, ETHER_HDR, "IL"); - qlock(ipc); - ipc->ref++; - qunlock(ipc); ipc->readq = RD(q); RD(q)->ptr = (void *)ipc; WR(q)->next->ptr = (void *)ipc->ipinterface; @@ -74,7 +71,6 @@ ilclose(Queue *q) s = (Ipconv *)(q->ptr); ic = &s->ilctl; qlock(s); - s->ref--; s->readq = 0; qunlock(s); @@ -161,6 +157,7 @@ iloput(Queue *q, Block *bp) ilackq(ic, bp); delay(100); + print("TX len = %d BLEN = %d IL %d\n", blen(bp), BLEN(bp), dlen+IL_HDRSIZE); PUTNEXT(q, bp); } @@ -231,6 +228,7 @@ ilrcvmsg(Ipconv *ipc, Block *bp) dst = nhgetl(ih->src); if(ilcksum && ptcl_csum(bp, IL_EHSIZE, illen) != 0) { +print("len = %d BLEN = %d IL %d\n", blen(bp), BLEN(bp), illen); st = (ih->iltype < 0 || ih->iltype > Ilclose) ? "?" : iltype[ih->iltype]; print("il: cksum error, pkt(%s id %d ack %d %d.%d.%d.%d/%d->%d)\n", st, nhgetl(ih->ilid), nhgetl(ih->ilack), fmtaddr(dst), sp, dp); @@ -269,8 +267,10 @@ ilrcvmsg(Ipconv *ipc, Block *bp) ic = &new->ilctl; ic->state = Ilsyncee; +/* initseq += TK2MS(MACHP(0)->ticks); - ic->next = initseq; +*/ +initseq =1; ic->next = initseq; ic->start = ic->next; ic->recvd = 0; ic->rstart = nhgetl(ih->ilid); @@ -627,7 +627,10 @@ ilstart(Ipconv *ipc, int type, int window) ic->timeout = 0; ic->unacked = 0; ic->outoforder = 0; +/* initseq += TK2MS(MACHP(0)->ticks); +*/ +initseq = 1; ic->next = initseq; ic->start = ic->next; ic->recvd = 0; diff --git a/port/stip.c b/port/stip.c index 997acd8fdb6713fa656c578c2ef2f4e7a5ef35eb..01d2f55cda0751d0d956443b5a28cd441501110f 100644 --- a/port/stip.c +++ b/port/stip.c @@ -68,6 +68,8 @@ initfrag(int size) static void ipetheropen(Queue *q, Stream *s) { + Ipconv *ipc; + /* First open is by ipconfig and sets up channel * to ethernet */ @@ -75,6 +77,11 @@ ipetheropen(Queue *q, Stream *s) Etherq = WR(q); s->opens++; /* Hold this queue in place */ s->inuse++; + } else { + ipc = &ipconv[s->dev][s->id]; + RD(q)->ptr = (void *)ipc; + WR(q)->ptr = (void *)ipc; + ipc->ref = 1; } DPRINT("ipetheropen EQ %lux dev=%d id=%d RD %lux WR %lux\n", @@ -131,7 +138,11 @@ newipifc(uchar ptcl, void (*recvfun)(Ipconv *, Block *bp), static void ipetherclose(Queue *q) { - USED(q); + Ipconv *ipc; + + ipc = (Ipconv *)(q->ptr); + if(ipc) + ipc->ref = 0; } void diff --git a/port/tcpif.c b/port/tcpif.c index c87314f96a8a34b2020339a2f4aef3d2b3be3766..8dac80674eeff0663b4241bb94d7ceab4471f708 100644 --- a/port/tcpif.c +++ b/port/tcpif.c @@ -15,9 +15,6 @@ state_upcall(Ipconv *s, char oldstate, char newstate) { Block *bp; int len; - char *ptr = 0; - - SET(len); DPRINT("state_upcall: %s -> %s err %d\n", tcpstate[oldstate], tcpstate[newstate], s->err); @@ -33,23 +30,20 @@ state_upcall(Ipconv *s, char oldstate, char newstate) case CLOSE_WAIT: /* Remote closes */ if(s->readq == 0) break; + if(s->err) { - ptr = errstrtab[s->err]; - len = strlen(ptr)+1; + len = strlen(errstrtab[s->err]); bp = allocb(len); + strcpy((char *)bp->wptr, errstrtab[s->err]); + bp->wptr += len; } else bp = allocb(0); - if(bp) { - if(ptr) { - strcpy((char *)bp->wptr, ptr); - bp->wptr += len; - } - bp->flags |= S_DELIM; - bp->type = M_HANGUP; - PUTNEXT(s->readq, bp); - } + bp->flags |= S_DELIM; + bp->type = M_HANGUP; + PUTNEXT(s->readq, bp); + break; } } diff --git a/power/boot.h b/power/boot.h index f74ed9b0e7f3e367fa90576ed8232a88b63296d4..2e1716bb8df9dff98b3175d1763227e09b5bfaca 100644 --- a/power/boot.h +++ b/power/boot.h @@ -1,6 +1,6 @@ ulong bootcode[]={ 0x000000407, - 0x000005c50, + 0x000005bd0, 0x000000718, 0x000001390, 0x000000000, @@ -4295,7 +4295,7 @@ ulong bootcode[]={ 0x025080001, 0x008001473, 0x0afa8001c, - 0x00c001af5, + 0x00c001ad6, 0x0afa80004, 0x08fac0020, 0x08fcb80de, @@ -5145,26 +5145,26 @@ ulong bootcode[]={ 0x0c7a1001c, 0x0c7a00020, 0x000000027, - 0x0463c0080, - 0x0e7a3001c, - 0x0e7a20020, - 0x0c7a3001c, - 0x0c7a20020, - 0x000000027, - 0x04622c001, + 0x0463c0000, 0x0e7a1001c, 0x0e7a00020, 0x0c7a1001c, 0x0c7a00020, + 0x000000027, + 0x04620c081, + 0x0e7a3001c, + 0x0e7a20020, + 0x0c7a1001c, + 0x0c7a00020, 0x08fa20000, 0x000000027, 0x000400008, 0x023bd0018, - 0x0c7a3001c, - 0x0c7a20020, + 0x0c7a1001c, + 0x0c7a00020, 0x023a2001c, - 0x0e7a30004, - 0x0e7a20008, + 0x0e7a10004, + 0x0e7a00008, 0x00c0018e7, 0x0afa2000c, 0x0c7a1001c, @@ -5330,21 +5330,21 @@ ulong bootcode[]={ 0x023bd000c, 0x003e00008, 0x04620c006, - 0x0288307ff, - 0x014600004, + 0x0288207ff, + 0x014400004, 0x000000027, 0x023bd000c, 0x003e00008, 0x04620c006, - 0x08fa30004, - 0x000041500, + 0x08fa20004, + 0x000041d00, 0x03c1c800f, 0x0379cffff, - 0x0007c1824, - 0x0afa30004, - 0x08fa30004, + 0x0005c1024, + 0x0afa20004, + 0x08fa20004, 0x000000027, - 0x000621025, + 0x000431025, 0x0afa20004, 0x0c7a10004, 0x0c7a00008, @@ -5380,8 +5380,8 @@ ulong bootcode[]={ 0x000a31807, 0x0201cffff, 0x0007c1826, - 0x000831824, - 0x0afa30008, + 0x000832024, + 0x0afa40008, 0x0afa0000c, 0x0c7a10008, 0x0c7a0000c, @@ -5404,9 +5404,9 @@ ulong bootcode[]={ 0x0005c1026, 0x08fa4000c, 0x000000027, - 0x000821024, + 0x000822024, 0x008001908, - 0x0afa2000c, + 0x0afa4000c, 0x023bdfff0, 0x08fa3001c, 0x08fa40014, @@ -5727,37 +5727,30 @@ ulong bootcode[]={ 0x020030081, 0x000021600, 0x000021603, - 0x0304200ff, - 0x000023c00, - 0x000073c03, - 0x030e2ffff, - 0x00062202a, - 0x014800042, + 0x0304700ff, + 0x00067202a, + 0x014800037, 0x000000027, - 0x010430027, + 0x010e30021, 0x000000027, - 0x010400016, + 0x010e00012, 0x000000027, 0x020030080, - 0x010430009, + 0x010e30008, 0x000000027, 0x010a00003, 0x000000027, 0x020030001, 0x0aca30000, - 0x030e1ffff, 0x023bd000c, 0x003e00008, - 0x03021ffff, + 0x000070825, 0x080c20001, 0x000000027, 0x000021600, 0x000021603, - 0x0304200ff, - 0x000023400, - 0x000063403, - 0x030c3ffff, - 0x014600007, + 0x0304600ff, + 0x014c00007, 0x000000027, 0x010a00002, 0x000000027, @@ -5769,22 +5762,17 @@ ulong bootcode[]={ 0x000000027, 0x020020002, 0x0aca20000, - 0x030c1ffff, - 0x03021ffff, 0x023bd000c, 0x003e00008, - 0x000010a00, + 0x000060a00, 0x080c20001, 0x000000027, 0x000021600, 0x000021603, - 0x0304200ff, - 0x000023400, - 0x000063403, - 0x030c3ffff, - 0x014600007, + 0x0304600ff, + 0x014c00007, 0x000000027, - 0x010a0ffe9, + 0x010a0ffee, 0x000000027, 0x000000825, 0x023bd000c, @@ -5794,55 +5782,43 @@ ulong bootcode[]={ 0x000000027, 0x020020002, 0x0aca20000, - 0x030c1ffff, - 0x03021ffff, 0x023bd000c, 0x003e00008, - 0x024210100, + 0x024c10100, 0x020030082, - 0x01043001f, + 0x010e30018, 0x000000027, 0x020030083, - 0x010430003, + 0x010e30003, 0x000000027, - 0x008001a6e, + 0x008001a6b, 0x000000027, 0x080c30001, 0x000000027, 0x000031e00, 0x000031e03, - 0x0306300ff, - 0x000033400, - 0x000063403, - 0x030c2ffff, - 0x00002182b, - 0x01060ffc6, + 0x0306600ff, + 0x018c0ffd1, 0x000000027, - 0x030c3ffff, 0x020020004, - 0x00043202b, - 0x01480ffc1, + 0x00046202a, + 0x01480ffcd, 0x000000027, 0x010a00003, 0x000000027, 0x020030002, 0x0aca30000, - 0x030c1ffff, - 0x03021ffff, 0x023bd000c, 0x003e00008, - 0x02421007f, + 0x024c1007f, 0x080c20001, 0x000000027, 0x000021600, 0x000021603, - 0x0304200ff, - 0x000023c00, - 0x000073c03, - 0x030e3ffff, - 0x014600007, + 0x0304700ff, + 0x014e00007, 0x000000027, - 0x010a0ffaf, + 0x010a0ffc0, 0x000000027, 0x000000825, 0x023bd000c, @@ -5852,13 +5828,10 @@ ulong bootcode[]={ 0x000000027, 0x000021600, 0x000021603, - 0x0304200ff, - 0x000023400, - 0x000063403, - 0x030c3ffff, - 0x014600007, + 0x0304600ff, + 0x014c00007, 0x000000027, - 0x010a0ff9f, + 0x010a0ffb3, 0x000000027, 0x000000825, 0x023bd000c, @@ -5868,14 +5841,10 @@ ulong bootcode[]={ 0x000000027, 0x020020003, 0x0aca20000, - 0x030c1ffff, - 0x03021ffff, - 0x030e2ffff, - 0x03042ffff, - 0x000021200, + 0x000070a00, 0x023bd000c, 0x003e00008, - 0x000220821, + 0x000260821, 0x023bdffe8, 0x0afbf0000, 0x08fa6001c, @@ -5906,7 +5875,7 @@ ulong bootcode[]={ 0x000400008, 0x000070825, 0x024e70001, - 0x008001afa, + 0x008001adb, 0x0afa70010, 0x014a0fffc, 0x024c60001, @@ -5916,7 +5885,6 @@ ulong bootcode[]={ 0x000070825, 0x000000000, 0x000000000, - 0x000000000, 0x07072696e, 0x074206572, 0x0726f7273, @@ -6369,6 +6337,6 @@ ulong bootcode[]={ 0x06f740023, 0x0632f7469, 0x06d650000, - 0x00006388, + 0x00006308, 0x0, }; diff --git a/power/devduart.c b/power/devduart.c index f7fe772b35576c81105c1291fc13e08dc79ea0c4..b38e6240a65146d3526e491a4b982a74f233cbac 100644 --- a/power/devduart.c +++ b/power/devduart.c @@ -4,6 +4,7 @@ #include "dat.h" #include "fns.h" #include "io.h" +#include "errno.h" int duartacr; int duartimr; @@ -779,7 +780,7 @@ duartopen(Chan *c, int omode) void duartcreate(Chan *c, char *name, int omode, ulong perm) { - errors(Eperm); + error(Eperm); } void