usb: avoid closing -1. [rsc] --rw-rw-r-- M 779778 sape sys 3073 Apr 13 01:11 sys/src/cmd/usb/lib/device.c /n/sourcesdump/2006/0413/plan9/sys/src/cmd/usb/lib/device.c:37,44 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/usb/lib/device.c:37,45 sprint(name, "/dev/usb%d/new", ctlrno); if((d->ctl = open(name, ORDWR)) < 0){ Error0: - close(d->ctl); werrstr("open %s: %r", name); + if(d->ctl >= 0) + close(d->ctl); free(d); /* return nil; */ sysfatal("%r"); /n/sourcesdump/2006/0413/plan9/sys/src/cmd/usb/lib/device.c:58,64 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/usb/lib/device.c:59,66 strcpy(p, "setup"); if((d->setup = open(name, ORDWR)) < 0){ Error1: - close(d->setup); + if(d->setup >= 0) + close(d->setup); goto Error0; } dns: fix deadlock race [rsc] --rw-rw-r-- M 779778 glenda sys 28763 Apr 13 14:23 sys/src/cmd/ndb/dn.c /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dn.c:448,460 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dn.c:448,464 * garbage collect. block while garbage collecting. */ int - getactivity(Request *req) + getactivity(Request *req, int recursive) { int rv; - if(traceactivity) syslog(0, "dns", "get %d by %d", dnvars.active, getpid()); + if(traceactivity) syslog(0, "dns", "get %d by %d from %p", dnvars.active, getpid(), getcallerpc(&req)); lock(&dnvars); - while(dnvars.mutex){ + /* + * can't block here if we're already holding one + * of the dnvars.active (recursive). will deadlock. + */ + while(!recursive && dnvars.mutex){ unlock(&dnvars); sleep(200); lock(&dnvars); /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dn.c:467,473 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dn.c:471,477 return rv; } void - putactivity(void) + putactivity(int recursive) { static ulong lastclean; /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dn.c:478,485 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dn.c:482,491 /* * clean out old entries and check for new db periodicly + * can't block here if being called to let go a "recursive" lock + * or we'll deadlock waiting for ourselves to give up the dnvars.active. */ - if(dnvars.mutex || (needrefresh == 0 && dnvars.active > 0)){ + if(recursive || dnvars.mutex || (needrefresh == 0 && dnvars.active > 0)){ unlock(&dnvars); return; } /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dn.c:1234,1254 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dn.c:1240,1272 slave(Request *req) { static int slaveid; + int ppid; if(req->isslave) return; /* we're already a slave process */ + /* + * These calls to putactivity cannot block. + * After getactivity(), the current process is counted + * twice in dnvars.active (one will pass to the child). + * If putactivity tries to wait for dnvars.active == 0, + * it will never happen. + */ + /* limit parallelism */ - if(getactivity(req) > Maxactive){ - putactivity(); + if(getactivity(req, 1) > Maxactive){ + if(traceactivity) syslog(0, "dns", "[%d] too much activity", getpid()); + putactivity(1); return; } + ppid = getpid(); switch(rfork(RFPROC|RFNOTEG|RFMEM|RFNOWAIT)){ case -1: - putactivity(); + putactivity(1); break; case 0: + if(traceactivity) syslog(0, "dns", "[%d] take activity from %d", ppid, getpid()); req->isslave = 1; break; default: [rsc] --rw-rw-r-- M 779778 rsc sys 3066 Apr 13 14:23 sys/src/cmd/ndb/dnnotify.c /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dnnotify.c:150,158 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dnnotify.c:150,158 req.isslave = 1; /* son't fork off subprocesses */ for(;;){ - getactivity(&req); + getactivity(&req, 0); notify_areas(owned, &req); - putactivity(); + putactivity(0); sleep(60*1000); } } [rsc] --rw-rw-r-- M 779778 glenda sys 15346 Apr 13 14:23 sys/src/cmd/ndb/dnresolve.c /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dnresolve.c:94,100 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dnresolve.c:94,100 char *cp; if(debug) - syslog(0, LOG, "dnresolve1 %s %d %d", name, type, class); + syslog(0, LOG, "[%d] dnresolve1 %s %d %d", getpid(), name, type, class); /* only class Cin implemented so far */ if(class != Cin) [rsc] --rw-rw-r-- M 779778 glenda sys 15308 Apr 13 14:23 sys/src/cmd/ndb/dns.c /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dns.c:376,382 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dns.c:376,382 * through 'mret'. */ if(setjmp(req.mret)) - putactivity(); + putactivity(0); req.isslave = 0; for(;;){ n = read9pmsg(mfd[0], mdata, sizeof mdata); /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dns.c:393,399 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dns.c:393,399 if(debug) syslog(0, logfile, "%F", &job->request); - getactivity(&req); + getactivity(&req, 0); req.aborttime = now + 60; /* don't spend more than 60 seconds */ switch(job->request.type){ /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dns.c:447,457 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dns.c:447,457 * slave processes die after replying */ if(req.isslave){ - putactivity(); + putactivity(0); _exits(0); } - putactivity(); + putactivity(0); } } /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dns.c:871,878 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dns.c:871,878 { char buf[12]; - syslog(0, LOG, "%d.%d: sending to %I/%s %s %s", - id, subid, addr, sname, rname, rrname(type, buf, sizeof buf)); + syslog(0, LOG, "[%d] %d.%d: sending to %I/%s %s %s", + getpid(), id, subid, addr, sname, rname, rrname(type, buf, sizeof buf)); } RR* [rsc] --rw-rw-r-- M 779778 glenda sys 8492 Apr 13 14:23 sys/src/cmd/ndb/dnsdebug.c /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dnsdebug.c:414,420 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dnsdebug.c:414,420 return; } - getactivity(&req); + getactivity(&req, 0); req.isslave = 1; req.aborttime = now + 60; /* don't spend more than 60 seconds */ rr = dnresolve(buf, Cin, type, &req, 0, 0, Recurse, rooted, 0); /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dnsdebug.c:426,432 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dnsdebug.c:426,432 } rrfreelist(rr); - putactivity(); + putactivity(0); } void [rsc] --rw-rw-r-- M 779778 glenda sys 7349 Apr 13 14:23 sys/src/cmd/ndb/dnstcp.c [diffs elided - too long] [diff -c /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dnstcp.c /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dnstcp.c] [rsc] --rw-rw-r-- M 779778 glenda sys 5337 Apr 13 18:58 sys/src/cmd/ndb/dnudpserver.c /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dnudpserver.c:97,107 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dnudpserver.c:97,107 while((fd = udpannounce(mntpt)) < 0) sleep(5000); if(setjmp(req.mret)) - putactivity(); + putactivity(0); req.isslave = 0; /* loop on requests */ - for(;; putactivity()){ + for(;; putactivity(0)){ memset(&repmsg, 0, sizeof(repmsg)); memset(&reqmsg, 0, sizeof(reqmsg)); alarm(60*1000); /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dnudpserver.c:111,117 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dnudpserver.c:111,117 goto restart; uh = (OUdphdr*)buf; len -= OUdphdrsize; - getactivity(&req); + getactivity(&req, 0); req.aborttime = now + 30; /* don't spend more than 30 seconds */ err = convM2DNS(&buf[OUdphdrsize], len, &reqmsg); if(err){ /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dnudpserver.c:174,180 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dnudpserver.c:174,180 rrfreelist(reqmsg.ar); if(req.isslave){ - putactivity(); + putactivity(0); _exits(0); } /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dnudpserver.c:190,195 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dnudpserver.c:190,196 static int udpannounce(char *mntpt) { + static int whined; int data, ctl; char dir[64]; char datafile[64+6]; /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dnudpserver.c:198,204 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dnudpserver.c:199,206 sprint(datafile, "%s/udp!*!dns", mntpt); ctl = announce(datafile, dir); if(ctl < 0){ - warning("can't announce on dns udp port"); + if(!whined++) + warning("can't announce on dns udp port"); return -1; } snprint(datafile, sizeof(datafile), "%s/data", dir); /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dnudpserver.c:210,216 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dnudpserver.c:212,219 data = open(datafile, ORDWR); if(data < 0){ close(ctl); - warning("can't announce on dns udp port"); + if(!whined++) + warning("can't announce on dns udp port"); return -1; } [rsc] --rw-rw-r-- M 779778 glenda sys 10171 Apr 13 18:58 sys/src/cmd/ndb/dns.h /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ndb/dns.h:370,377 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ndb/dns.h:370,377 extern char* rrname(int, char*, int); extern int tsame(int, int); extern void dndump(char*); - extern int getactivity(Request*); - extern void putactivity(void); + extern int getactivity(Request*, int); + extern void putactivity(int); extern void abort(); /* char*, ... */; extern void warning(char*, ...); extern void slave(Request*); [rsc] --rw-rw-r-- M 779778 glenda sys 5337 Apr 13 18:58 sys/src/cmd/ndb/dnudpserver.c snoopy: add dns [rsc] --rw-rw-r-- M 779778 rsc sys 14815 Apr 13 15:32 sys/src/cmd/ip/snoopy/dns.c [rsc] --rw-rw-r-- M 779778 glenda sys 889 Apr 13 15:14 sys/src/cmd/ip/snoopy/mkfile /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ip/snoopy/mkfile:5,10 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ip/snoopy/mkfile:5,11 arp\ bootp\ dhcp\ + dns\ dump\ eap\ eap_identity\ /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ip/snoopy/mkfile:46,51 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ip/snoopy/mkfile:47,53 protos.h\ y.tab.h\ + YFILES=filter.y BIN=/$objtype/bin UPDATE=\ /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ip/snoopy/mkfile:79,82 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ip/snoopy/mkfile:81,83 echo '};' } > protos.c - y.tab.c: filter.y [rsc] --rw-rw-r-- M 779778 glenda sys 2015 Apr 13 15:14 sys/src/cmd/ip/snoopy/udp.c /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ip/snoopy/udp.c:39,44 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ip/snoopy/udp.c:39,45 static Mux p_mux[] = { + {"dns", 53, }, {"bootp", 67, }, {"ninep", 6346, }, /* tvs */ {"rtp", ANYPORT, }, [rsc] --rw-rw-r-- M 779778 rsc sys 14815 Apr 13 15:32 sys/src/cmd/ip/snoopy/dns.c [rsc] --rw-rw-r-- M 779778 glenda sys 3618 Apr 13 15:33 sys/src/cmd/ip/snoopy/tcp.c /n/sourcesdump/2006/0413/plan9/sys/src/cmd/ip/snoopy/tcp.c:50,55 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/ip/snoopy/tcp.c:50,56 static Mux p_mux[] = { + {"dns", 53, }, {"ninep", 17007, }, /* exportfs */ {"ninep", 564, }, /* 9fs */ {"ninep", 17005, }, /* ocpu */ 9load: merge in current cardslot code, attempt to fix 3com [jmk] --rw-rw-r-- M 779778 jmk sys 9232 Apr 13 16:46 sys/src/boot/pc/cis.c [jmk] --rw-rw-r-- M 779778 glenda sys 3597 Apr 13 16:46 sys/src/boot/pc/dat.h /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/dat.h:112,117 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/dat.h:112,118 typedef struct Pcidev Pcidev; typedef struct PCMmap PCMmap; + typedef struct PCMslot PCMslot; #define BOOTLINE ((char*)CONFADDR) [jmk] --rw-rw-r-- M 779778 glenda sys 15051 Apr 13 16:46 sys/src/boot/pc/devi82365.c [diffs elided - too long] [diff -c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/devi82365.c /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/devi82365.c] [jmk] --rw-rw-r-- M 779778 glenda sys 33938 Apr 13 16:46 sys/src/boot/pc/devpccard.c [diffs elided - too long] [diff -c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/devpccard.c /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/devpccard.c] [jmk] --rw-rw-r-- M 779778 glenda sys 4624 Apr 13 16:46 sys/src/boot/pc/ether589.c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/ether589.c:155,161 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/ether589.c:155,161 if(memcmp(ea, ether->ea, 6) == 0 && strcmp(type, "3C562") == 0) { if(debug) print("read 562..."); - if(pcmcistuple(slot, 0x88, ea, 6) == 6) { + if(pcmcistuple(slot, 0x88, -1, ea, 6) == 6) { for(i = 0; i < 6; i += 2){ t = ea[i]; ea[i] = ea[i+1]; [jmk] --rw-rw-r-- M 779778 jmk sys 18634 Apr 13 16:49 sys/src/boot/pc/ether8169.c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/ether8169.c:22,29 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/ether8169.c:22,27 #define qlock(i) while(0) #define qunlock(i) while(0) #define iallocb allocb - extern void mb386(void); - #define coherence() mb386() #define iprint print #define mallocalign(n, a, o, s) ialloc((n), (a)) [jmk] --rw-rw-r-- M 779778 glenda sys 21993 Apr 13 16:46 sys/src/boot/pc/ether83815.c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/ether83815.c:301,311 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/ether83815.c:301,306 #define csr16w(c, r, l) (outs((c)->port+(r), (ulong)(l))) static void - coherence(void) - { - } - - static void dumpcregs(Ctlr *ctlr) { int i; [jmk] --rw-rw-r-- M 779778 glenda sys 44662 Apr 13 16:46 sys/src/boot/pc/etherelnk3.c [diffs elided - too long] [diff -c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/etherelnk3.c /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/etherelnk3.c] [jmk] --rw-rw-r-- M 779778 jmk sys 12383 Apr 13 16:46 sys/src/boot/pc/etherrhine.c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/etherrhine.c:18,24 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/etherrhine.c:18,23 typedef struct QLock { int r; } QLock; #define qlock(i) while(0) #define qunlock(i) while(0) - #define coherence() #define iprint print #include "etherif.h" [jmk] --rw-rw-r-- M 779778 glenda sys 4457 Apr 13 16:46 sys/src/boot/pc/fns.h /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/fns.h:15,20 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/fns.h:15,21 void changeconf(char*, ...); void checkalarms(void); void clockinit(void); + #define coherence() mb386() void consdrain(void); void consinit(char*, char*); void consputs(char*, int); /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/fns.h:53,63 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/fns.h:54,67 void insb(int, void*, int); void inss(int, void*, int); void insl(int, void*, int); + #define ioalloc(addr, len, align, name) (addr) + #define iofree(addr) void iunlock(Lock*); int isaconfig(char*, int, ISAConf*); void kbdinit(void); void kbdchar(int); void machinit(void); + void mb386(void); void meminit(ulong); void microdelay(int); void mmuinit(void); /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/fns.h:83,89 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/fns.h:87,95 uchar pciipin(Pcidev *, uchar); void pcireset(void); void pcisetbme(Pcidev*); - int pcmcistuple(int, int, void*, int); + void pcmcisread(PCMslot*); + int pcmcistuple(int, int, int, void*, int); + PCMmap* pcmmap(int, ulong, int, int); int pcmspecial(char*, ISAConf*); void pcmspecialclose(int); void pcmunmap(int, PCMmap*); [jmk] --rw-rw-r-- M 779778 glenda sys 6821 Apr 13 16:46 sys/src/boot/pc/io.h [diffs elided - too long] [diff -c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/io.h /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/io.h] [jmk] --rw-rw-r-- M 779778 glenda sys 3112 Apr 13 16:46 sys/src/boot/pc/mkfile /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/mkfile:33,41 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/mkfile:33,42 8250.$O\ apm.$O\ boot.$O\ - devpccard.$O\ + cis.$O\ conf.$O\ devi82365.$O\ + devpccard.$O\ devsd.$O\ inflate.$O\ load.$O\ /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/mkfile:166,173 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/mkfile:167,174 mk $MKFLAGS $i.install %.install:V: $BIN/% - #import lookout / /n/lookout - #cp $prereq /n/lookout/$prereq + import lookout / /n/lookout + cp $prereq /n/lookout/$prereq $BIN/%: % cp $stem $BIN/$stem [jmk] --rw-rw-r-- M 779778 glenda sys 52127 Apr 13 16:46 sys/src/boot/pc/sd53c8xx.c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/sd53c8xx.c:1869,1891 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/sd53c8xx.c:1869,1896 static int xfunc(Controller *c, enum na_external x, unsigned long *v) { - switch (x) - { + switch (x) { + default: + print("xfunc: can't find external %d\n", x); + return 0; case X_scsi_id_buf: - *v = offsetof(Dsa, scsi_id_buf[0]); return 1; + *v = offsetof(Dsa, scsi_id_buf[0]); + break; case X_msg_out_buf: - *v = offsetof(Dsa, msg_out_buf); return 1; + *v = offsetof(Dsa, msg_out_buf); + break; case X_cmd_buf: - *v = offsetof(Dsa, cmd_buf); return 1; + *v = offsetof(Dsa, cmd_buf); + break; case X_data_buf: - *v = offsetof(Dsa, data_buf); return 1; + *v = offsetof(Dsa, data_buf); + break; case X_status_buf: - *v = offsetof(Dsa, status_buf); return 1; + *v = offsetof(Dsa, status_buf); + break; case X_dsa_head: - *v = DMASEG(&c->dsalist.head[0]); return 1; - default: - print("xfunc: can't find external %d\n", x); - return 0; + *v = DMASEG(&c->dsalist.head[0]); + break; } return 1; } /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/sd53c8xx.c:1960,1966 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/sd53c8xx.c:1965,1971 } if(v >= &variant[nelem(variant)]) continue; - print("sd53c8xx: %s rev. 0x%2.2x intr=%d command=%4.4luX\n", + print("sd53c8xx: %s rev. 0x%2.2x intr=%d command=%4.4uX\n", v->name, p->rid, p->intl, p->pcr); regpa = p->mem[1].bar; [jmk] --rw-rw-r-- M 779778 glenda sys 38221 Apr 13 16:46 sys/src/boot/pc/sdata.c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/sdata.c:1465,1471 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/sdata.c:1465,1471 case (0x4D69<<16)|0x105A: /* Promise Ultra/133 TX2 */ case (0x3373<<16)|0x105A: /* Promise 20378 RAID */ case (0x3149<<16)|0x1106: /* VIA VT8237 SATA/RAID */ - case (0x3112<<16)|0x1095: /* SiL 3112 SATA (DMA busted?) */ + case (0x3112<<16)|0x1095: /* SiL 3112 SATA (DMA busted?) */ case (0x3114<<16)|0x1095: /* SiL 3114 SATA/RAID */ pi = 0x85; break; [jmk] --rw-rw-r-- M 779778 glenda sys 28693 Apr 13 16:46 sys/src/boot/pc/sdmylex.c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/sdmylex.c:26,33 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/sdmylex.c:26,31 typedef struct Rendez{ int r; } Rendez; #define intrenable(irq, f, c, tbdf, name) setvec(VectorPIC+(irq), f, c);\ USED(tbdf); - #define ioalloc(p, b, c, d) (1) - #define iofree(p) #define K2BPA(va, tbdf) PADDR(va) #define BPA2K(pa, tbdf) KADDR(pa) [jmk] --rw-rw-r-- M 779778 glenda sys 7006 Apr 13 16:47 sys/src/boot/pc/sdscsi.c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/sdscsi.c:133,139 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/sdscsi.c:133,139 // cgascreenputs("C", 1); switch(r->unit->dev->ifc->rio(r)){ default: - return -1; + break; case SDcheck: if(!(r->flags & SDvalidsense)) return -1; /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/sdscsi.c:151,157 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/sdscsi.c:151,157 return 2; if(r->sense[12] == 0x29) return 2; - return -1; + break; case 0x02: /* not ready */ /* * If no medium present, bail out. /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/sdscsi.c:166,174 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/sdscsi.c:166,174 scsitest(r); return 2; default: - return -1; + break; } - return -1; + break; case SDok: return 0; } [jmk] --rw-rw-r-- M 779778 glenda sys 7499 Apr 13 16:46 sys/src/boot/pc/trap.c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/trap.c:182,188 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/trap.c:182,188 */ outb(Int0ctl, Icw1|0x01); /* ICW1 - edge triggered, master, ICW4 will be sent */ - outb(Int0aux, VectorPIC); /* ICW2 - interrupt vector offset */ + outb(Int0aux, VectorPIC); /* ICW2 - interrupt vector offset */ outb(Int0aux, 0x04); /* ICW3 - have slave on level 2 */ outb(Int0aux, 0x01); /* ICW4 - 8086 mode, not buffered */ /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/trap.c:194,200 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/trap.c:194,200 */ outb(Int1ctl, Icw1|0x01); /* ICW1 - edge triggered, master, ICW4 will be sent */ - outb(Int1aux, VectorPIC+8); /* ICW2 - interrupt vector offset */ + outb(Int1aux, VectorPIC+8); /* ICW2 - interrupt vector offset */ outb(Int1aux, 0x02); /* ICW3 - I am a slave on level 2 */ outb(Int1aux, 0x01); /* ICW4 - 8086 mode, not buffered */ outb(Int1aux, int1mask); [jmk] --rw-rw-r-- M 779778 glenda sys 38028 Apr 13 21:17 sys/src/boot/pc/ether2114x.c /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/ether2114x.c:186,191 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/ether2114x.c:186,193 Tulip3 = (0x0019<<16)|0x1011, Pnic = (0x0002<<16)|0x11AD, Pnic2 = (0xC115<<16)|0x11AD, + CentaurP = (0x0985<<16)|0x1317, + CentaurPcb = (0x1985<<16)|0x1317, }; typedef struct Ctlr Ctlr; /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/ether2114x.c:1372,1377 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/ether2114x.c:1374,1386 ctlr->srom[20+i+1] = ctlr->srom[i]; } } + if(ctlr->id == CentaurP || ctlr->id == CentaurPcb){ + memmove(&ctlr->srom[20], leafpnic, sizeof(leafpnic)); + for(i = 0; i < Eaddrlen; i += 2){ + ctlr->srom[20+i] = ctlr->srom[8+i]; + ctlr->srom[20+i+1] = ctlr->srom[8+i+1]; + } + } /* * Next, try to find the info leaf in the SROM for media detection. /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/ether2114x.c:1453,1458 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/ether2114x.c:1462,1469 if(phy){ x = 0; for(k = 0; k < nelem(ctlr->phy); k++){ + if((ctlr->id == CentaurP || ctlr->id == CentaurPcb) && k != 1) + continue; if((oui = miir(ctlr, k, 2)) == -1 || oui == 0) continue; if(DEBUG){ /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/ether2114x.c:1497,1506 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/ether2114x.c:1508,1519 pcicfgw32(p, 0x40, x); /*FALLTHROUGH*/ - case Pnic: /* PNIC */ - case Pnic2: /* PNIC-II */ case Tulip0: /* 21140 */ case Tulip1: /* 21041 */ + case Pnic: /* PNIC */ + case Pnic2: /* PNIC-II */ + case CentaurP: /* ADMtek */ + case CentaurPcb: /* ADMtek CardBus */ break; } /n/sourcesdump/2006/0413/plan9/sys/src/boot/pc/ether2114x.c:1531,1542 - /n/sourcesdump/2006/0414/plan9/sys/src/boot/pc/ether2114x.c:1544,1569 switch(ctlr->id){ default: break; - case Pnic: /* PNIC */ /* * Turn off the jabber timer. */ csr32w(ctlr, 15, 0x00000001); + break; + case CentaurP: + case CentaurPcb: + /* + * Nice - the register offsets change from *8 to *4 + * for CSR16 and up... + * CSR25/26 give the MAC address read from the SROM. + * Don't really need to use this other than as a check, + * the SROM will be read in anyway so the value there + * can be used directly. + */ + debug("csr25 %8.8luX csr26 %8.8luX\n", + inl(ctlr->port+0xA4), inl(ctlr->port+0xA8)); + debug("phyidr1 %4.4luX phyidr2 %4.4luX\n", + inl(ctlr->port+0xBC), inl(ctlr->port+0xC0)); break; } kernels: add new admtek cardbus controller [jmk] --rw-rw-r-- M 779778 glenda sys 41694 Apr 13 17:30 sys/src/9/pc/ether2114x.c /n/sourcesdump/2006/0413/plan9/sys/src/9/pc/ether2114x.c:190,195 - /n/sourcesdump/2006/0414/plan9/sys/src/9/pc/ether2114x.c:190,196 Pnic = (0x0002<<16)|0x11AD, Pnic2 = (0xC115<<16)|0x11AD, CentaurP = (0x0985<<16)|0x1317, + CentaurPcb = (0x1985<<16)|0x1317, }; typedef struct Ctlr Ctlr; /n/sourcesdump/2006/0413/plan9/sys/src/9/pc/ether2114x.c:1515,1521 - /n/sourcesdump/2006/0414/plan9/sys/src/9/pc/ether2114x.c:1516,1522 ctlr->srom[20+i+1] = ctlr->srom[i]; } } - if(ctlr->id == CentaurP){ + if(ctlr->id == CentaurP || ctlr->id == CentaurPcb){ memmove(&ctlr->srom[20], leafpnic, sizeof(leafpnic)); for(i = 0; i < Eaddrlen; i += 2){ ctlr->srom[20+i] = ctlr->srom[8+i]; /n/sourcesdump/2006/0413/plan9/sys/src/9/pc/ether2114x.c:1603,1609 - /n/sourcesdump/2006/0414/plan9/sys/src/9/pc/ether2114x.c:1604,1610 if(phy){ x = 0; for(k = 0; k < nelem(ctlr->phy); k++){ - if(ctlr->id == CentaurP && k != 1) + if((ctlr->id == CentaurP || ctlr->id == CentaurPcb) && k != 1) continue; if((oui = miir(ctlr, k, 2)) == -1 || oui == 0) continue; /n/sourcesdump/2006/0413/plan9/sys/src/9/pc/ether2114x.c:1655,1660 - /n/sourcesdump/2006/0414/plan9/sys/src/9/pc/ether2114x.c:1656,1662 case Pnic: /* PNIC */ case Pnic2: /* PNIC-II */ case CentaurP: /* ADMtek */ + case CentaurPcb: /* ADMtek CardBus */ break; } /n/sourcesdump/2006/0413/plan9/sys/src/9/pc/ether2114x.c:1698,1703 - /n/sourcesdump/2006/0414/plan9/sys/src/9/pc/ether2114x.c:1700,1706 csr32w(ctlr, 15, 0x00000001); break; case CentaurP: + case CentaurPcb: /* * Nice - the register offsets change from *8 to *4 * for CSR16 and up... /n/sourcesdump/2006/0413/plan9/sys/src/9/pc/ether2114x.c:1823,1828 - /n/sourcesdump/2006/0414/plan9/sys/src/9/pc/ether2114x.c:1826,1831 void ether2114xlink(void) { - addethercard("21140", reset); addethercard("2114x", reset); + addethercard("21140", reset); }