From 04f457b5821b6e62fed65b5ef0baaf3a7e44a23c Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 15 Jun 2002 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2002-06-15 --- alphapc/trap.c | 1 + bitsy/dat.h | 2 +- bitsy/devether.c | 12 ++++-- bitsy/devpcmcia.c | 2 +- bitsy/etherif.h | 1 + bitsy/fns.h | 2 +- bitsy/sdata.c | 4 +- bitsy/trap.c | 106 +++++++++++++++++++++++++++++++++++++++++++--- ip/ip.c | 2 +- ip/ipifc.c | 9 ++-- ip/netlog.c | 2 +- ip/udp.c | 4 +- pc/etherif.h | 1 + pc/trap.c | 1 + pc/vgamach64xx.c | 4 +- pc/wavelan.c | 33 ++++++++++++++- pc/wavelan.h | 2 + port/devmnt.c | 6 +-- 18 files changed, 166 insertions(+), 28 deletions(-) diff --git a/alphapc/trap.c b/alphapc/trap.c index 716d68aae1cc2ce140d21f261458239958edbd46..69593d4b82225db050b2f82d649308c796eb2ada 100644 --- a/alphapc/trap.c +++ b/alphapc/trap.c @@ -782,6 +782,7 @@ linkproc(void) { spllo(); up->kpfun(up->kparg); + pexit("kproc exiting", 0); } void diff --git a/bitsy/dat.h b/bitsy/dat.h index 9e3f03b60637a88ab04b0c85c10caefd2ff1f90d..cfcdeca5ebbdd781f341319c5e81d3fca1df175b 100644 --- a/bitsy/dat.h +++ b/bitsy/dat.h @@ -260,6 +260,6 @@ struct DevConf ulong port; /* mapped i/o regs */ int size; /* access size */ int itype; /* type of interrupt */ - ulong interrupt; /* interrupt number */ + ulong intnum; /* interrupt number */ char *type; /* card type, mallocated */ }; diff --git a/bitsy/devether.c b/bitsy/devether.c index 9593bae5ef575a6d80bc1b720ae42875f803a2e4..5cb6100e6e09f2deafcb994018f0eca882568f52 100644 --- a/bitsy/devether.c +++ b/bitsy/devether.c @@ -39,6 +39,7 @@ etherconfig(int on, char *spec, DevConf *cf) char *p, *e; ctlrno = atoi(spec); + sprint(name, "ether%d", ctlrno); if(on == 0){ ether = etherxx[ctlrno]; @@ -52,6 +53,13 @@ print("unconfigure\n"); } if(ether == &noether) error(Enodev); + + if(ether->detach) + ether->detach(ether); + + if(ether->interrupt != nil) + intrdisable(ether->itype, ether->intnum, ether->interrupt, ether, name); + etherxx[ctlrno] = &noether; wunlock(ether); poperror(); @@ -65,7 +73,6 @@ print("unconfigure: done\n"); ether = malloc(sizeof(Ether)); if(ether == nil) panic("etherconfig"); - memset(ether, 0, sizeof(Ether)); *(DevConf*)ether = *cf; for(n = 0; cards[n].type; n++){ @@ -73,7 +80,6 @@ print("unconfigure: done\n"); continue; if(cards[n].reset(ether)) break; - sprint(name, "ether%d", ctlrno); if(ether->mbps >= 100){ netifinit(ether, name, Ntypes, 256*1024); @@ -95,7 +101,7 @@ print("unconfigure: done\n"); ether->maxmtu = ETHERMAXTU; if(ether->interrupt != nil) - intrenable(cf->itype, cf->interrupt, ether->interrupt, ether, name); + intrenable(cf->itype, cf->intnum, ether->interrupt, ether, name); p = buf; e = buf+sizeof(buf); diff --git a/bitsy/devpcmcia.c b/bitsy/devpcmcia.c index 8f3d227f055762e47ac758796ce7240fc2e0429b..abaf2860b5f35595104fcc23cf59d233d05cb7dd 100644 --- a/bitsy/devpcmcia.c +++ b/bitsy/devpcmcia.c @@ -353,7 +353,7 @@ pcmctlwrite(char *p, long n, ulong, PCMslot *sp) cf.mem = (ulong)sp->mem; cf.port = (ulong)sp->regs; cf.itype = GPIOfalling; - cf.interrupt = bitno(sp == slot ? GPIO_CARD_IRQ0_i : GPIO_CARD_IRQ1_i); + cf.intnum = bitno(sp == slot ? GPIO_CARD_IRQ0_i : GPIO_CARD_IRQ1_i); if(devtab[dtx]->config(1, p, &cf) < 0) error("couldn't configure device"); diff --git a/bitsy/etherif.h b/bitsy/etherif.h index 4ec82d303c0694d12fd985ab7933b6e07872f4e7..90b957db8f284e199a119ba087a9351d4d61f08a 100644 --- a/bitsy/etherif.h +++ b/bitsy/etherif.h @@ -16,6 +16,7 @@ struct Ether { int encry; void (*attach)(Ether*); /* filled in by reset routine */ + void (*detach)(Ether*); void (*transmit)(Ether*); void (*interrupt)(Ureg*, void*); long (*ifstat)(Ether*, void*, long, ulong); diff --git a/bitsy/fns.h b/bitsy/fns.h index d63e150fd4fc457b0b8d7b49b01914789caede37..77318e0ac0a0aeb2b35f7df9f8c75df33cc04691 100644 --- a/bitsy/fns.h +++ b/bitsy/fns.h @@ -39,7 +39,6 @@ ulong getttb(void); void* getlink(void); #define getpgcolor(a) 0 ulong getsp(void); -void gpiointrenable(ulong, int, void (*)(Ureg*, void*), void*, char*); void h3650uartsetup(void); int havetimer(void); void _hibernate(void); @@ -51,6 +50,7 @@ uchar inb(ulong); ushort ins(ulong); void inss(ulong, void*, int); ulong inl(ulong); +void intrdisable(int, int, void (*)(Ureg*, void*), void*, char*); void intrenable(int, int, void (*)(Ureg*, void*), void*, char*); void irpower(int); #define kmapinval() diff --git a/bitsy/sdata.c b/bitsy/sdata.c index bca2748d55552d7c771fd8d1f9ed368131abd668..94a9d968766a1a9d24ee11831551737dcb0777a9 100644 --- a/bitsy/sdata.c +++ b/bitsy/sdata.c @@ -2054,10 +2054,10 @@ ataconfig(int on, char *, void *pf) rc = nil; for (try = &tries[0]; try->p != 0 || try->c != 0; try++){ ataitype = cf->itype; - atairq = cf->interrupt; + atairq = cf->intnum; cmdport = cf->port + try->p; ctlport = cmdport + try->c; - irq = cf->interrupt; + irq = cf->intnum; rc = ataprobe(cmdport, ctlport, irq); if (rc) break; diff --git a/bitsy/trap.c b/bitsy/trap.c index dd423a471f57ed66e16973c7b25b07dcdcac40be..ef87dccce07646d4727db459154ec9f6ace6f9e6 100644 --- a/bitsy/trap.c +++ b/bitsy/trap.c @@ -119,7 +119,7 @@ warnregs(Ureg *ur, char *tag) /* * enable an irq interrupt */ -void +static void irqenable(int irq, IntrHandler *f, void* a, char *name) { Vctl *v; @@ -127,7 +127,9 @@ irqenable(int irq, IntrHandler *f, void* a, char *name) if(irq >= nelem(vctl) || irq < 0) panic("intrenable"); - v = xalloc(sizeof(Vctl)); + print("irqenable %s, handler 0x%p\n", name, f); + + v = malloc(sizeof(Vctl)); v->f = f; v->a = a; v->name = xalloc(strlen(name)+1); @@ -140,6 +142,34 @@ irqenable(int irq, IntrHandler *f, void* a, char *name) unlock(&vctllock); } +/* + * disable an irq interrupt + */ +static void +irqdisable(int irq, IntrHandler *f, void* a, char *name) +{ + Vctl **vp, *v; + + if(irq >= nelem(vctl) || irq < 0) + panic("intrdisable"); + + lock(&vctllock); + for(vp = &vctl[irq]; v = *vp; vp = &v->next) + if (v->f == f && v->a == a && strcmp(v->name, name) == 0){ + print("irqdisable: remove %s\n", name); + *vp = v->next; + free(v); + break; + } + if (v == nil) + print("irqdisable: irq %d, name %s not enabled\n", irq, name); + if (vctl[irq] == nil){ + print("irqdisable: clear icmr bit %d\n", irq); + intrregs->icmr &= ~(1<= nelem(gpiovctl) || which < 0) - panic("gpiointrenable"); + panic("intrenable"); if(which > 11) irq = 11; /* the pin had better be configured as input */ if((1<direction) - panic("gpiointrenable of output pin %d", which); + panic("intrenable of output pin %d", which); /* create a second level vctl for the gpio edge interrupt */ - v = xalloc(sizeof(Vctl)); + v = malloc(sizeof(Vctl)); v->f = f; v->a = a; v->name = xalloc(strlen(name)+1); @@ -175,7 +207,6 @@ intrenable(int type, int which, IntrHandler *f, void* a, char *name) lock(&vctllock); v->next = gpiovctl[which]; gpiovctl[which] = v; - unlock(&vctllock); /* set edge register to enable interrupt */ switch(type){ @@ -190,12 +221,72 @@ intrenable(int type, int which, IntrHandler *f, void* a, char *name) gpioregs->rising |= 1<= nelem(gpiovctl) || which < 0) + panic("intrdisable"); + if(which > 11) + irq = 11; + + lock(&vctllock); + for(vp = &gpiovctl[which]; v = *vp; vp = &v->next) + if (v->f == f && v->a == a && strcmp(v->name, name) == 0){ + break; + } + if (gpiovctl[which] == nil){ + /* set edge register to enable interrupt */ + switch(type){ + case GPIOboth: + print("intrdisable: gpio-rising+falling clear bit %d\n", which); + gpioregs->rising &= ~(1<falling &= ~(1<falling &= ~(1<rising &= ~(1<next; + }else + print("intrdisable: which %d, name %s not enabled\n", which, name); + unlock(&vctllock); + /* disable the gpio interrupt handler if necessary */ + if(--gpioirqref[irq] == 0){ + print("intrdisable: inrqdisable gpiointr\n"); + irqdisable(irq, gpiointr, nil, "gpio edge"); + } + free(v); +} + /* * called by trap to handle access faults */ @@ -679,6 +770,7 @@ linkproc(void) { spllo(); up->kpfun(up->kparg); + pexit("kproc exiting", 0); } /* diff --git a/ip/ip.c b/ip/ip.c index 097467d983558bc58b47c09dedfc070a68eb7538..33a8a7849db4387739157c3b406c0b739cc6d9da 100644 --- a/ip/ip.c +++ b/ip/ip.c @@ -21,7 +21,7 @@ enum IP_DF = 0x4000, /* Don't fragment */ IP_MF = 0x2000, /* More fragments */ IP6FHDR = 8, /* sizeof(Fraghdr6) */ - IP_MAX = (32*1024), /* Maximum Internet packet size */ + IP_MAX = 64*1024, /* Maximum Internet packet size */ }; #define BLKIPVER(xp) (((Ip4hdr*)((xp)->rp))->vihl&0xF0) diff --git a/ip/ipifc.c b/ip/ipifc.c index 567d57dd09ae9619fc61cf30829ea05b974f123c..100d330cb3dd297b7daac1cc14fb5aaa1574a1a3 100644 --- a/ip/ipifc.c +++ b/ip/ipifc.c @@ -168,6 +168,7 @@ ipifcunbind(Ipifc *ifc) char *av[4]; char ip[32]; char mask[32]; + char *err; if(waserror()){ wunlock(ifc); @@ -202,7 +203,8 @@ ipifcunbind(Ipifc *ifc) else sprint(ip, "%I", ifc->lifc->local); sprint(mask, "%M", ifc->lifc->mask); - ipifcrem(ifc, av, 3, 0); + if (err = ipifcrem(ifc, av, 3, 0)) + print("ipifcunbind, addr %s, mask %s: %s\n", ip, mask, err); } ifc->m = nil; @@ -573,8 +575,8 @@ ipifcrem(Ipifc *ifc, char **argv, int argc, int dolock) addr = lifc->local; if(type == Rptpt) addr = lifc->remote; - if(memcmp(ip, addr, IPaddrlen) == 0) - if(memcmp(mask, lifc->mask, IPaddrlen) == 0) { + if (memcmp(ip, addr, IPaddrlen) == 0 + && memcmp(mask, lifc->mask, IPaddrlen) == 0) { *l = lifc->next; break; } @@ -584,6 +586,7 @@ ipifcrem(Ipifc *ifc, char **argv, int argc, int dolock) if(lifc == nil){ if(dolock) wunlock(ifc); + print("ipifcrem: wrong address\n"); return "address not on this interface"; } diff --git a/ip/netlog.c b/ip/netlog.c index 90da1774000df2567ebc4c22a99d6573e1f079c1..3ae36f3425e266325a8c23f18b545e1ae071f754 100644 --- a/ip/netlog.c +++ b/ip/netlog.c @@ -207,7 +207,7 @@ netlogctl(Fs *f, char* s, int n) cmderror(cb, "unknown ip control message"); } - for(i = 1; i < n; i++){ + for(i = 1; i < cb->nf; i++){ for(fp = flags; fp->name; fp++) if(strcmp(fp->name, cb->f[i]) == 0) break; diff --git a/ip/udp.c b/ip/udp.c index 80882c7874a4d00641f30a6f85512ac01119eed4..d1e804f4e3c26823526c15fe7640d2a1781f3060 100644 --- a/ip/udp.c +++ b/ip/udp.c @@ -146,8 +146,8 @@ udpannounce(Conv *c, char** argv, int argc) static void udpcreate(Conv *c) { - c->rq = qopen(64*1024, 1, 0, 0); - c->wq = qopen(64*1024, 0, 0, 0); + c->rq = qopen(128*1024, 1, 0, 0); + c->wq = qopen(128*1024, 0, 0, 0); } static void diff --git a/pc/etherif.h b/pc/etherif.h index 988ee178c73939a50358edd12280f5e227949e91..e100f73933475b36ee2cc60776e48f7ee5ae5d5c 100644 --- a/pc/etherif.h +++ b/pc/etherif.h @@ -15,6 +15,7 @@ struct Ether { uchar ea[Eaddrlen]; void (*attach)(Ether*); /* filled in by reset routine */ + void (*detach)(Ether*); void (*transmit)(Ether*); void (*interrupt)(Ureg*, void*); long (*ifstat)(Ether*, void*, long, ulong); diff --git a/pc/trap.c b/pc/trap.c index d5c7076c1561be3a76f9ed793e01f656b0ada27c..2a52c96c34cc46f007662245cb6877c1dccb7e88 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -819,6 +819,7 @@ linkproc(void) { spllo(); up->kpfun(up->kparg); + pexit("kproc dying", 0); } void diff --git a/pc/vgamach64xx.c b/pc/vgamach64xx.c index 907a17e3763cd9027367501a82069e50f83f7367..7225085bc9c408623fab41338408bb0121078f5c 100644 --- a/pc/vgamach64xx.c +++ b/pc/vgamach64xx.c @@ -118,8 +118,8 @@ static int mach64revb; /* Revision B or greater? */ static ulong mach64overlay; /* Overlay buffer */ static mach64types mach64s[] = { - ('C'<<8)|'T', 0, 0, 0, /* 4354: CT */ - ('E'<<8)|'T', 0, 0, 0, /* 4554: ET */ + ('C'<<8)|'T', 0, 1350000, /*?*/ 0, /* 4354: CT */ + ('E'<<8)|'T', 0, 1350000, /*?*/ 0, /* 4554: ET */ ('G'<<8)|'B', 1, 1250000, 1, /* 4742: 264GT PRO */ ('G'<<8)|'D', 1, 1250000, 1, /* 4744: 264GT PRO */ ('G'<<8)|'I', 1, 1250000, 1, /* 4749: 264GT PRO */ diff --git a/pc/wavelan.c b/pc/wavelan.c index 2fc657f054c45455475e3f58e787d9df7173be3d..bfe0482ef28109bec7c1b0932b322f981567ef44 100644 --- a/pc/wavelan.c +++ b/pc/wavelan.c @@ -609,6 +609,11 @@ w_timer(void* arg) Ether* ether = (Ether*) arg; Ctlr* ctlr = (Ctlr*)ether->ctlr; + if (waserror()){ + print("timerporc dying\n"); + pexit("aaargh!", 0); + } + ctlr->timerproc = up; for(;;){ tsleep(&ctlr->timer, return0, 0, 50); ctlr = (Ctlr*)ether->ctlr; @@ -655,7 +660,8 @@ w_timer(void* arg) } iunlock(ctlr); } - pexit("terminated",0); + poperror(); + pexit("terminated", 0); } void @@ -688,6 +694,30 @@ w_attach(Ether* ether) } } +void +w_detach(Ether* ether) +{ + Ctlr* ctlr; + char name[64]; + + if (ether->ctlr == 0) + return; + + snprint(name, sizeof(name), "#l%dtimer", ether->ctlrno); + ctlr = (Ctlr*) ether->ctlr; + if (ctlr->attached){ + ilock(ctlr); + w_intdis(ctlr); + if (ctlr->timerproc){ + if (!postnote(ctlr->timerproc, 1, "kill", NExit)) + print("timerproc note not posted\n"); + print("w_detach, killing 0x%p\n", ctlr->timerproc); + } + ctlr->attached = 0; + iunlock(ctlr); + } +} + #define PRINTSTAT(fmt,val) l += snprint(p+l, READSTR-l, (fmt), (val)) #define PRINTSTR(fmt) l += snprint(p+l, READSTR-l, (fmt)) @@ -1049,6 +1079,7 @@ wavelanreset(Ether* ether, Ctlr *ctlr) ether->ctlr = ctlr; ether->mbps = 10; ether->attach = w_attach; + ether->detach = w_detach; ether->interrupt = w_interrupt; ether->transmit = w_transmit; ether->ifstat = w_ifstat; diff --git a/pc/wavelan.h b/pc/wavelan.h index 58a8069fac4e507482c7120ef2638f4bc804b0a4..b61e2e5721a118fc415cf071c4fca71764786528 100644 --- a/pc/wavelan.h +++ b/pc/wavelan.h @@ -260,6 +260,8 @@ struct Ctlr int pmena; int pmwait; + Proc *timerproc; + char netname[WNameLen]; char wantname[WNameLen]; char nodename[WNameLen]; diff --git a/port/devmnt.c b/port/devmnt.c index f862c313c8f08f9279c8aef46c6172946e89ac36..2bbf0a3d11be16d694548dd349cfb13941c2bf54 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -83,7 +83,7 @@ mntreset(void) mntalloc.rpctag = Tagspace; fmtinstall('F', fcallfmt); fmtinstall('D', dirfmt); - fmtinstall('M', dirmodefmt); +/* fmtinstall('M', dirmodefmt); No! Clashes with eipfmt [sape] */ cinit(); } @@ -836,7 +836,7 @@ mntrpcread(Mnt *m, Mntrpc *r) /* read at least length, type, and tag and pullup to a single block */ while(qlen(m->q) < BIT32SZ+BIT8SZ+BIT16SZ){ - b = devtab[m->c->type]->bread(m->c, 2*MAXRPC, 0); + b = devtab[m->c->type]->bread(m->c, m->msize, 0); if(b == nil) return -1; qaddlist(m->q, b); @@ -846,7 +846,7 @@ mntrpcread(Mnt *m, Mntrpc *r) /* read in the rest of the message */ while(qlen(m->q) < len){ - b = devtab[m->c->type]->bread(m->c, 2*MAXRPC, 0); + b = devtab[m->c->type]->bread(m->c, m->msize, 0); if(b == nil) return -1; qaddlist(m->q, b);