#!/bin/rc # # command: /bin/boddle /n/juke/plan_9/sys/src/boot/pc /sys/lib/pcdist/src/b # srcdir: /n/juke/plan_9/sys/src/boot/pc # version: 874002976 # date: Thu Sep 11 14:36:16 EDT 1997 # myname=$0 doextract=no fn usage{ echo $myname: usage: $myname '[-X] [src-directory]' >[1=2] exit usage } fn sigint{ rm -rf 874002976 exit interrupt } while(~ $1 -*){ switch($1){ case -X doextract=yes case -* usage } shift } switch($#*){ case 0 srcdir=/sys/src/boot/pc case 1 srcdir=$1 case * usage } if(! ~ $doextract yes){ echo This shell file contains a bundle of diffs representing changes echo to original source files in the Plan 9 distribution. It will run echo against the files in echo ' ' $srcdir echo '(unless overridden by the optional source directory argument)' echo and create a directory 874002976 containing the updated files. echo It will NOT automatically update the original files. echo echo Invoke with argument -X to perform the actual extraction. exit 0 } rm -rf 874002976 mkdir 874002976 target=874002976/bb.s echo -n '874002976/bb.s: ' if(! test -f $srcdir/bb.s || ! test -r $srcdir/bb.s){ echo $srcdir/bb.s unreadable exit unreadable } sum=`{sum < $srcdir/bb.s} if(! ~ 181bd8af10652 $sum(1)^$sum(2)){ echo $srcdir/bb.s is not the original distribution file exit original } cp $srcdir/bb.s 874002976/bb.s ed 874002976/bb.s >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM bb.s' 108c * If you're still reading, you have a . wq //GO.SYSIN DD VADIM bb.s sum=`{sum < 874002976/bb.s} if(~ fa2e3ee410651 $sum(1)^$sum(2)) echo if not{ echo 874002976/bb.s checksum error creating updated file exit checksum } target=874002976/bootp.c echo -n '874002976/bootp.c: ' if(! test -f $srcdir/bootp.c || ! test -r $srcdir/bootp.c){ echo $srcdir/bootp.c unreadable exit unreadable } sum=`{sum < $srcdir/bootp.c} if(! ~ d1c05fba9121 $sum(1)^$sum(2)){ echo $srcdir/bootp.c is not the original distribution file exit original } cp $srcdir/bootp.c 874002976/bootp.c ed 874002976/bootp.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM bootp.c' 482c nak(ctlrno, &server, 3, "ok", 0); /* tftpclose */ . 434a server.ip = nhgetl(rep.siaddr); . 431c print("%s ", rep.sname); print("(%d.%d.%d.%d!%d): %s\n", rep.siaddr[0], rep.siaddr[1], rep.siaddr[2], rep.siaddr[3], server.port, filename); . 429a . 412c memmove(server.ea, broadcast, sizeof(server.ea)); . 407c memmove(myaddr.ea, ea, Eaddrlen); . 363,368d 278a rxactive = 1; . 256d 230c continue; . 227,228c if(rxactive == 0) timo = 1000; else timo = Timeout; timo += TK2MS(m->ticks); while(timo > TK2MS(m->ticks)){ n = etherrxpkt(ctlrno, &pkt, timo-TK2MS(m->ticks)); . 225a static int rxactive; . 224c ulong addr, timo; . 210,217d 9a uchar broadcast[Eaddrlen] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }; . wq //GO.SYSIN DD VADIM bootp.c sum=`{sum < 874002976/bootp.c} if(~ e76b89639264 $sum(1)^$sum(2)) echo if not{ echo 874002976/bootp.c checksum error creating updated file exit checksum } target=874002976/cga.c echo -n '874002976/cga.c: ' if(! test -f $srcdir/cga.c || ! test -r $srcdir/cga.c){ echo $srcdir/cga.c unreadable exit unreadable } sum=`{sum < $srcdir/cga.c} if(! ~ e6b483691391 $sum(1)^$sum(2)){ echo $srcdir/cga.c is not the original distribution file exit original } cp $srcdir/cga.c 874002976/cga.c ed 874002976/cga.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM cga.c' 99c cgascreenputc(*s++); . 97a if(screeninitdone == 0) screeninit(); . 96c cgascreenputs(char* s, int n) . 94a static void screeninit(void) { if(screeninitdone == 0){ pos = cgaregr(0x0E)<<8; pos |= cgaregr(0x0F); pos *= 2; screeninitdone = 1; } } . 91a if(pos >= Width*Height){ memmove(CGASCREENBASE, &CGASCREENBASE[Width], Width*(Height-1)); memset(&CGASCREENBASE[Width*(Height-1)], 0, Width); pos = Width*(Height-1); } . 87,90c else{ CGASCREENBASE[pos++] = c; CGASCREENBASE[pos++] = Attr; . 83,85d 81c cgascreenputc(' '); . 77,78c cgascreenputc(' '); } else if(c == '\b'){ . 66,75c pos = pos/Width; pos = (pos+1)*Width; } else if(c == '\t'){ i = 8 - ((pos/2)&7); . 61c cgascreenputc(int c) . 49,59d 46a CGASCREENBASE[pos+1] = Attr; . 30,42d 25,26c outb(0x3D4, index); outb(0x3D4+1, data); . 23c cgaregw(int index, int data) . 18,19c outb(0x3D4, index); return inb(0x3D4+1) & 0xFF; . 16c cgaregr(int index) . 13a static int screeninitdone; . 12c Attr = 7, /* white on black */ }; #define CGASCREENBASE ((uchar*)KADDR(0xB8000)) . 7,10c enum { Width = 160, Height = 25, . 1,5c #include "u.h" #include "lib.h" #include "mem.h" #include "dat.h" #include "fns.h" . wq //GO.SYSIN DD VADIM cga.c sum=`{sum < 874002976/cga.c} if(~ 7c568dc11362 $sum(1)^$sum(2)) echo if not{ echo 874002976/cga.c checksum error creating updated file exit checksum } target=874002976/clock.c echo -n '874002976/clock.c: ' if(! test -f $srcdir/clock.c || ! test -r $srcdir/clock.c){ echo $srcdir/clock.c unreadable exit unreadable } sum=`{sum < $srcdir/clock.c} if(! ~ 616855092125 $sum(1)^$sum(2)){ echo $srcdir/clock.c is not the original distribution file exit original } cp $srcdir/clock.c 874002976/clock.c ed 874002976/clock.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM clock.c' 121c cpumhz = (cpufreq + cpufreq/500)/1000000; . 119c * add in possible .2% error and convert to MHz . 115,116c cpufreq = loops*((t->aalcycles*Freq)/x); loopconst = (cpufreq/1000)/t->aalcycles; /* AAM+LOOP's for 1 ms */ . 85,104c if(x > Freq/(3*HZ)) break; } . 83a /* find biggest loop that doesn't wrap */ incr = 16000000/(t->aalcycles*HZ*2); x = 2000; for(loops = incr; loops < 64*1024; loops += incr) { /* * measure time for the loop * * MOVL loops,CX * aaml1: AAM * LOOP aaml1 * * the time for the loop should be independent of external * cache and memory system since it fits in the execution * prefetch buffer. * */ outb(Tmode, Latch0); x = inb(T0cntr); x |= inb(T0cntr)<<8; aamloop(loops); outb(Tmode, Latch0); y = inb(T0cntr); y |= inb(T0cntr)<<8; x -= y; if(x < 0) x += Freq/HZ; . 77a * figure out what we are */ x86cpuid(&cpuidax, &cpuiddx); family = FAMILY(cpuidax); model = MODEL(cpuidax); for(t = x86type; t->name; t++) if((t->family == family && t->model == model) || (t->family == family && t->model == -1) || (t->family == -1)) break; cputype = t; /* . 75c setvec(Clockvec, clockintr, 0); . 57,71d 54,55c int x, y; /* change in counter */ int family, model, loops, incr; X86type *t; . 47,48c l *= loopconst; l /= 1000; if(l <= 0) l = 1; aamloop(l); . 44,45c void microdelay(int l) . 41c l *= loopconst; if(l <= 0) l = 1; aamloop(l); . 33a static void clockintr(Ureg*, void*) { m->ticks++; checkalarms(); } #define STEPPING(x) ((x)&0xf) #define MODEL(x) (((x)>>4)&0xf) #define FAMILY(x) (((x)>>8)&0xf) enum { /* flags */ CpuidFPU = 0x001, /* on-chip floating point unit */ CpuidMCE = 0x080, /* machine check exception */ CpuidCX8 = 0x100, /* CMPXCHG8B instruction */ }; typedef struct { int family; int model; int aalcycles; char *name; } X86type; X86type x86type[] = { /* from the cpuid instruction */ { 4, 0, 22, "Intel486DX", }, { 4, 1, 22, "Intel486DX", }, { 4, 2, 22, "Intel486SX", }, { 4, 3, 22, "Intel486DX2", }, { 4, 4, 22, "Intel486DX2", }, { 4, 5, 22, "Intel486SL", }, { 4, 8, 22, "IntelDX4", }, { 5, 1, 23, "Pentium510", }, { 5, 2, 23, "Pentium735", }, /* family defaults */ { 3, -1, 32, "Intel386", }, { 4, -1, 22, "Intel486", }, { 5, -1, 23, "Pentium", }, /* total default */ { -1, -1, 23, "unknown", }, }; static X86type *cputype; . 32a static int cpuidax, cpuiddx; . 31d wq //GO.SYSIN DD VADIM clock.c sum=`{sum < 874002976/clock.c} if(~ 732966ba3495 $sum(1)^$sum(2)) echo if not{ echo 874002976/clock.c checksum error creating updated file exit checksum } target=874002976/conf.c echo -n '874002976/conf.c: ' if(! test -f $srcdir/conf.c || ! test -r $srcdir/conf.c){ echo $srcdir/conf.c unreadable exit unreadable } sum=`{sum < $srcdir/conf.c} if(! ~ 516f3fb72501 $sum(1)^$sum(2)){ echo $srcdir/conf.c is not the original distribution file exit original } cp $srcdir/conf.c 874002976/conf.c ed 874002976/conf.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM conf.c' 132a } else if(isa->nopt < NISAOPT){ r = isa->opt[isa->nopt]; while(*p && *p != ' ' && *p != '\t'){ *r++ = *p++; if(r-isa->opt[isa->nopt] >= ISAOPTLEN-1) break; } *r = '\0'; isa->nopt++; . 106a isa->nopt = 0; . 100c char cc[NAMELEN], *p, *q, *r; . 56,58d 53,54c memmove(BOOTARGS, cp, n+1); /* * Strip out '\r', change '\t' -> ' '. */ p = cp; for(q = cp; *q; q++){ if(*q == '\r') continue; if(*q == '\t') *q = ' '; *p++ = *q; } *p = 0; n = getcfields(cp, line, MAXCONF, "\n"); . 51a if(strncmp(cp, id, sizeof(id))){ memmove(BOOTARGS, id, sizeof(id)); if(n+1+sizeof(id) >= BOOTARGSLEN) n -= sizeof(id); memmove(BOOTARGS+sizeof(id), cp, n+1); } else . 48,49c * Keep a pristine copy. * Should change this to pass the parsed strings . 40c cp = inibuf; . 35c char *cp, *p, *q, *line[MAXCONF]; . 29a static char inibuf[BOOTARGSLEN]; static char id[8] = "ZORT 0\r\n"; . wq //GO.SYSIN DD VADIM conf.c sum=`{sum < 874002976/conf.c} if(~ 31901e223096 $sum(1)^$sum(2)) echo if not{ echo 874002976/conf.c checksum error creating updated file exit checksum } target=874002976/console.c echo -n '874002976/console.c: ' if(! test -f $srcdir/console.c || ! test -r $srcdir/console.c){ echo $srcdir/console.c unreadable exit unreadable } sum=`{sum < $srcdir/console.c} if(! ~ 1048f6722693 $sum(1)^$sum(2)){ echo $srcdir/console.c is not the original distribution file exit original } cp $srcdir/console.c 874002976/console.c ed 874002976/console.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM console.c' 159,164c consputs("panic: ", 7); n = donprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; consputs(buf, n); consputs("\n", 1); . 149c consputs(buf, n); . 146,147d 117c consputs("\n", 1); . 110c len = getline(buf, size, dotimeout); . 104a if(isdefault == 0) dotimeout = 0; . 99c getstr(char *prompt, char *buf, int size, char *def, int dotimeout) . 77c consputs(&echo, 1); . 54a static void consputs(char* s, int n) { cgascreenputs(s, n); if(useuart) uartputs(&consoq, s, n); } . 37a useuart = 1; . 29d 26d 21,24c if((p = getconf("console")) == 0 || strcmp(p, "cga") == 0) . 19a kbdinit(); . 11c static int useuart; . wq //GO.SYSIN DD VADIM console.c sum=`{sum < 874002976/console.c} if(~ 1d1de5152633 $sum(1)^$sum(2)) echo if not{ echo 874002976/console.c checksum error creating updated file exit checksum } target=874002976/dat.h echo -n '874002976/dat.h: ' if(! test -f $srcdir/dat.h || ! test -r $srcdir/dat.h){ echo $srcdir/dat.h unreadable exit unreadable } sum=`{sum < $srcdir/dat.h} if(! ~ 7de11b532953 $sum(1)^$sum(2)){ echo $srcdir/dat.h is not the original distribution file exit original } cp $srcdir/dat.h 874002976/dat.h ed 874002976/dat.h >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM dat.h' 161a typedef struct PCIcfg PCIcfg; . 160a int nopt; char opt[NISAOPT][ISAOPTLEN]; . 153a /* * a parsed plan9.ini line */ #define ISAOPTLEN 16 #define NISAOPT 8 . 151a /* * These are the current Brazil values: #define CONFADDR 0x80001200 #define BOOTLINE ((char *)CONFADDR) #define BOOTLINELEN 64 #define BOOTARGS ((char*)(CONFADDR+BOOTLINELEN)) #define BOOTARGSLEN (4096-0x200-BOOTLINELEN) */ . 149a #define BOOTLINE ((char *)0x80000100) . 148c * These are the old Plan9 values: . 145,146d 143a * and where we leave configuration info. . 40a extern uchar broadcast[Eaddrlen]; . wq //GO.SYSIN DD VADIM dat.h sum=`{sum < 874002976/dat.h} if(~ 3ac44ac53405 $sum(1)^$sum(2)) echo if not{ echo 874002976/dat.h checksum error creating updated file exit checksum } target=874002976/donprint.c echo -n '874002976/donprint.c: ' if(! test -f $srcdir/donprint.c || ! test -r $srcdir/donprint.c){ echo $srcdir/donprint.c unreadable exit unreadable } sum=`{sum < $srcdir/donprint.c} if(! ~ c0b310423903 $sum(1)^$sum(2)){ echo $srcdir/donprint.c is not the original distribution file exit original } cp $srcdir/donprint.c 874002976/donprint.c ed 874002976/donprint.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM donprint.c' 307a } static int Xconv(Op *op) { int r; ucase = 1; r = numbconv(op, 16); ucase = 0; return r; . 231a if(ucase) n += 'A'-'a'; } . 230c if(n > '9'){ . 60a static int convcount = { 11 }; static int ucase; . 58c ['X'] 9, ['%'] 10, . 45c Xconv, percent, . 36a static int Xconv(Op*); . 11,12d wq //GO.SYSIN DD VADIM donprint.c sum=`{sum < 874002976/donprint.c} if(~ 7238b0e24095 $sum(1)^$sum(2)) echo if not{ echo 874002976/donprint.c checksum error creating updated file exit checksum } target=874002976/dosboot.c echo -n '874002976/dosboot.c: ' if(! test -f $srcdir/dosboot.c || ! test -r $srcdir/dosboot.c){ echo $srcdir/dosboot.c unreadable exit unreadable } sum=`{sum < $srcdir/dosboot.c} if(! ~ c39a436d11245 $sum(1)^$sum(2)){ echo $srcdir/dosboot.c is not the original distribution file exit original } cp $srcdir/dosboot.c 874002976/dosboot.c ed 874002976/dosboot.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM dosboot.c' 515c print(premature); . 504c print(premature); . 489c print(premature); . 393a if(chatty == 0) return; . 350c bootdump(b); . 345c /*print("no dos file system\n");*/ . 339a if(i != 4 || offset != 0xFFFFFFFF){ dos->start = mbroffset+offset; p = getclust(dos, 0); if(p == 0 || p->iobuf[0x1FE] != 0x55 || p->iobuf[0x1FF] != 0xAA) return -1; } . 332,338c } if(GLONG(dp->start) < offset) offset = GLONG(dp->start); . 323,330c if(ishard && b->mediadesc != 0xF8){ dp = (Dospart*)&p->iobuf[0x1BE]; offset = 0xFFFFFFFF; for(i = 0; i < 4; i++, dp++){ if(dp->type == DMDDO){ mbroffset = 63; goto dmddo; } if(dp->type != FAT12 && dp->type != FAT16 && dp->type != FATHUGE) continue; if(dp->flag & 0x80){ offset = GLONG(dp->start); . 321c /* * If it's a hard disc then look for an MBR and pick either an * active partition or the FAT with the lowest starting LBA. * Things are tricky because we could be pointing to, amongst others: * 1) a floppy BPB; * 2) a hard disc MBR; * 3) a hard disc extended partition table; * 4) a logical drive on a hard disc; * 5) a disc-manager boot block. * They all have the same magic at the end of the block. */ if(p->iobuf[0x1FE] != 0x55 || p->iobuf[0x1FF] != 0xAA) return -1; p->dos = 0; . 319d 314c p = getclust(dos, mbroffset); . 312a dmddo: . 311a mbroffset = 0; . 309c dos->start = start; . 307d 305a ulong mbroffset, offset; . 300c dosinit(Dos *dos, int start, int ishard) . 18,19c #define chatty 0 #define chat if(chatty)print . 7a extern char *premature; . wq //GO.SYSIN DD VADIM dosboot.c sum=`{sum < 874002976/dosboot.c} if(~ e66b2f1d11919 $sum(1)^$sum(2)) echo if not{ echo 874002976/dosboot.c checksum error creating updated file exit checksum } target=874002976/dosfs.h echo -n '874002976/dosfs.h: ' if(! test -f $srcdir/dosfs.h || ! test -r $srcdir/dosfs.h){ echo $srcdir/dosfs.h unreadable exit unreadable } sum=`{sum < $srcdir/dosfs.h} if(! ~ 8f6224352258 $sum(1)^$sum(2)){ echo $srcdir/dosfs.h is not the original distribution file exit original } cp $srcdir/dosfs.h 874002976/dosfs.h ed 874002976/dosfs.h >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM dosfs.h' 100c extern int dosinit(Dos*, int, int); . 18a #define FAT12 0x01 #define FAT16 0x04 #define FATHUGE 0x06 #define DMDDO 0x54 . wq //GO.SYSIN DD VADIM dosfs.h sum=`{sum < 874002976/dosfs.h} if(~ 259f09212347 $sum(1)^$sum(2)) echo if not{ echo 874002976/dosfs.h checksum error creating updated file exit checksum } target=874002976/ether.c echo -n '874002976/ether.c: ' if(! test -f $srcdir/ether.c || ! test -r $srcdir/ether.c){ echo $srcdir/ether.c unreadable exit unreadable } sum=`{sum < $srcdir/ether.c} if(! ~ d06f47a13089 $sum(1)^$sum(2)){ echo $srcdir/ether.c is not the original distribution file exit original } cp $srcdir/ether.c 874002976/ether.c ed 874002976/ether.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM ether.c' 164,168c splx(s); . 162a s = splhi(); . 154a if(wait(ring, Interface, 1000) == 0){ print("ether%d: tx buffer timeout\n", ctlrno); return 0; } memmove(pkt->s, ctlr->card.ea, Eaddrlen); . 149a int s; . 146c ethertxpkt(int ctlrno, Etherpkt *pkt, int len, int) . 133a */ . 132a /* . 52c print(" %2.2uX", ctlr->card.ea[i]); . 48,50c print("ether%d: %s: port 0x%luX irq %d", ctlr->ctlrno, ctlr->card.type, ctlr->card.port, ctlr->card.irq); if(ctlr->card.mem) print(" addr 0x%luX", ctlr->card.mem & ~KZERO); if(ctlr->card.size) print(" size 0x%luX", ctlr->card.size); print(":"); . 19a /* { "AMD79C970", amd79c970reset, },*/ . 18a { "elnk3", tcm509reset, }, . wq //GO.SYSIN DD VADIM ether.c sum=`{sum < 874002976/ether.c} if(~ 009873d33311 $sum(1)^$sum(2)) echo if not{ echo 874002976/ether.c checksum error creating updated file exit checksum } target=874002976/ether.h echo -n '874002976/ether.h: ' if(! test -f $srcdir/ether.h || ! test -r $srcdir/ether.h){ echo $srcdir/ether.h unreadable exit unreadable } sum=`{sum < $srcdir/ether.h} if(! ~ 5a39a0553186 $sum(1)^$sum(2)){ echo $srcdir/ether.h is not the original distribution file exit original } cp $srcdir/ether.h 874002976/ether.h ed 874002976/ether.h >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM ether.h' 126a extern int amd79c970reset(Ctlr*); . 52c Ntb = 2, /* default number of transmit buffers */ . 34a uchar dummyrr; /* do dummy remote read */ . wq //GO.SYSIN DD VADIM ether.h sum=`{sum < 874002976/ether.h} if(~ e687092c3265 $sum(1)^$sum(2)) echo if not{ echo 874002976/ether.h checksum error creating updated file exit checksum } target=874002976/ether2000.c echo -n '874002976/ether2000.c: ' if(! test -f $srcdir/ether2000.c || ! test -r $srcdir/ether2000.c){ echo $srcdir/ether2000.c unreadable exit unreadable } sum=`{sum < $srcdir/ether2000.c} if(! ~ 86e179412717 $sum(1)^$sum(2)){ echo $srcdir/ether2000.c is not the original distribution file exit original } cp $srcdir/ether2000.c 874002976/ether2000.c ed 874002976/ether2000.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM ether2000.c' 69a delay(2); . 62a ctlr->card.dummyrr = 1; for(i = 0; i < ctlr->card.nopt; i++){ if(strcmp(ctlr->card.opt[i], "nodummyrr")) continue; ctlr->card.dummyrr = 0; break; } . 23c Reset = 0x1F, /* offset from I/O base of reset port */ . wq //GO.SYSIN DD VADIM ether2000.c sum=`{sum < 874002976/ether2000.c} if(~ 6e359b3b2889 $sum(1)^$sum(2)) echo if not{ echo 874002976/ether2000.c checksum error creating updated file exit checksum } target=874002976/ether509.c echo -n '874002976/ether509.c: ' if(! test -f $srcdir/ether509.c || ! test -r $srcdir/ether509.c){ echo $srcdir/ether509.c unreadable exit unreadable } sum=`{sum < $srcdir/ether509.c} if(! ~ f6e46d8014453 $sum(1)^$sum(2)){ echo $srcdir/ether509.c is not the original distribution file exit original } cp $srcdir/ether509.c 874002976/ether509.c ed 874002976/ether509.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM ether509.c' 602,603c outb(port+MediaStatus, x|LinkBeatEna|JabberEna); . 594a COMMAND(port, SelectWindow, 4); x = ins(port+MediaStatus) & ~(LinkBeatEna|JabberEna); outs(port+MediaStatus, x); . 588d 585a COMMAND(port, SelectWindow, 2); . 579a case 0x000000: acr = Xcvr10BaseT; break; case 0x300000: acr = XcvrBNC; break; } /*free(pcicfg);lost*/ } else acr = ins(port+AddressConfig); . 578c if(pcicfg){ ctlr->card.irq = pcicfg->irq; COMMAND(port, SelectWindow, 3); acr = XcvrAUI; l = inl(port+InternalCgf); switch(l & 0x700000){ . 566a COMMAND(port, SelectWindow, 0); . 557,558d 551a if(port == 0 && (pcicfg = tcm590(&ctlr->card))) port = pcicfg->baseaddr[0] & ~0x01; . 546a pcicfg = ap->pcicfg; . 543a pcicfg = 0; . 533a PCIcfg *pcicfg; . 532c ulong l, port; . 519a PCIcfg pcicfg, *pcip; static int devno = 0; ulong port; Adapter *ap; for(;;){ pcicfg.vid = 0x10B7; pcicfg.did = 0; if((devno = pcimatch(0, devno, &pcicfg)) == -1) break; pcip = ialloc(sizeof(PCIcfg), 0); memmove(pcip, &pcicfg, sizeof(PCIcfg)); port = pcip->baseaddr[0] & ~0x01; COMMAND(port, GlobalReset, 0); while(ins(port+Status) & CmdInProgress) ; if(isa->port == 0 || isa->port == port) return pcip; ap = ialloc(sizeof(Adapter), 0); ap->pcicfg = pcip; ap->port = port; ap->next = adapter; adapter = ap; } . 517,518c static PCIcfg* tcm590(ISAConf *isa) . 419,454d 416,417c COMMAND(port, TxReset, 0); COMMAND(port, RxReset, 0); COMMAND(port, AckIntr, 0xFF); . 414d 412a while(ins(port+Status) & CmdInProgress) ; COMMAND(port, SelectWindow, 0); . 408,409c * 8. Can now talk to the adapter's I/O base addresses. * Use the I/O base address from the acr just read. . 405a delay(20); . 404d 400a */ outb(IDport, 0xD1); delay(20); if(port == 0x3F0) continue; /* . 398c return (acr & 0x1F)*0x10 + 0x200; } static ulong tcm509(ISAConf *isa) { ulong port; Adapter *ap; /* * Attempt to activate adapters until one matches the * address criteria. If adapter is set for EISA mode (0x3F0), * tag it and ignore. Otherwise, activate it fully. */ while(port = activate()){ . 396d 379c delay(20); . 377a delay(20); . 358d 354c activate(void) . 350a /* * One time only: * write ID sequence to get the attention of all adapters; * untag all adapters. * If we do a global reset here on all adapters we'll confuse any * ISA cards configured for EISA mode. */ if(untag == 0){ outb(IDport, 0xD0); delay(20); untag = 1; } . 339a /* * One time only: * reset any adapters listening */ if(reset == 0){ outb(IDport, 0); outb(IDport, 0); outb(IDport, 0xC0); delay(20); reset = 1; } . 338a static int reset, untag; . 324,325c Adapter* next; ulong port; PCIcfg* pcicfg; . 299,319d 287,297c if(status & AllIntr) panic("ether%d interrupt: #%lux, #%ux\n", ctlr->ctlrno, status, getdiag(ctlr)); . 282,285c * Panic if there are any interrupt bits on we haven't * dealt with. . 269,280c if(status & Update){ statistics(ctlr); status &= ~Update; } . 263,266c if(status & (TxAvailable|TxComplete)){ /* * Reset the Tx FIFO threshold. */ if(status & TxAvailable) COMMAND(port, AckIntr, TxAvailable); transmit(ctlr); status &= ~(TxAvailable|TxComplete); . 261a ctlr->oerrs++; . 256,260c COMMAND(port, AckIntr, Latch); status = ins(port+Status); if((status & AllIntr) == 0) break; if(status & Failure){ /* * Adapter failure, try to find out why. * Reset if necessary. * What happens if Tx is active and we reset, * need to retransmit? * This probably isn't right. */ diag = getdiag(ctlr); print("ether%d: status #%ux, diag #%ux\n", ctlr->ctlrno, status, diag); if(diag & TxOverrun){ COMMAND(port, TxReset, 0); COMMAND(port, TxEnable, 0); } if(diag & RxUnderrun){ COMMAND(port, RxReset, 0); attach(ctlr); } if(diag & TxOverrun) transmit(ctlr); return; } if(status & RxComplete){ receive(ctlr); status &= ~RxComplete; } if(status & TxComplete){ /* * Pop the TX Status stack, accumulating errors. * If there was a Jabber or Underrun error, reset * the transmitter. For all conditions enable * the transmitter. */ txstatus = 0; do{ if(x = inb(port+TxStatus)) outb(port+TxStatus, 0); txstatus |= x; }while(ins(port+Status) & TxComplete); if(txstatus & (TxJabber|TxUnderrun)) COMMAND(port, TxReset, 0); . 250,254c * Clear the interrupt latch. * It's possible to receive a packet and for another * to become complete before we exit the interrupt * handler so this must be done first to ensure another * interrupt will occur. . 248c for(;;){ . 246d 244c . 238a statistics(Ctlr *ctlr) { int i, port; port = ctlr->card.port; COMMAND(port, SelectWindow, 6); for(i = 0; i < 0x0A; i++) inb(port+i); ins(port+0x0A); ins(port+0x0C); COMMAND(port, SelectWindow, 1); } static void . 177,178c pkt = (Etherpkt*)rb->pkt; if(memcmp(pkt->d, ctlr->card.ea, Eaddrlen) == 0){ rb->owner = Host; ctlr->ri = NEXT(ctlr->ri, ctlr->nrb); } . 175c * Update the ring if it's really intended * for us. . 133a Etherpkt *pkt; . 118a * Disable Update interrupts for now. . 88a InternalCgf = 0x00, /* window 3 */ . 68a Update = 0x0080, /* Update Statistics */ . wq //GO.SYSIN DD VADIM ether509.c sum=`{sum < 874002976/ether509.c} if(~ 4692342416606 $sum(1)^$sum(2)) echo if not{ echo 874002976/ether509.c checksum error creating updated file exit checksum } target=874002976/ether8003.c echo -n '874002976/ether8003.c: ' if(! test -f $srcdir/ether8003.c || ! test -r $srcdir/ether8003.c){ echo $srcdir/ether8003.c unreadable exit unreadable } sum=`{sum < $srcdir/ether8003.c} if(! ~ c84016135800 $sum(1)^$sum(2)){ echo $srcdir/ether8003.c is not the original distribution file exit original } cp $srcdir/ether8003.c 874002976/ether8003.c ed 874002976/ether8003.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM ether8003.c' 193a } static void reset8216(Ctlr *ctlr, uchar[8]) { uchar hcr, irq, x; ulong addr, wd8003; wd8003 = ctlr->card.port; ctlr->card.bit16 = 1; /* * Switch to the alternate register set and retrieve the memory * and irq information. */ hcr = inb(wd8003+Hcr); outb(wd8003+Hcr, 0x80|hcr); addr = inb(wd8003+0x0B) & 0xFF; irq = inb(wd8003+0x0D); outb(wd8003+Hcr, hcr); ctlr->card.mem = KZERO|(0xC0000+((((addr>>2) & 0x30)|(addr & 0x0F))<<13)); ctlr->card.size = 8192*(1<<((addr>>4) & 0x03)); ctlr->card.irq = irq8216[((irq>>4) & 0x04)|((irq>>2) & 0x03)]; /* * Enable interface RAM, set interface width, * and enable interrupts. */ x = inb(wd8003+Msr) & ~Rst; outb(wd8003+Msr, Menb|x); x = inb(wd8003+Laar); outb(wd8003+Laar, M16en|x); outb(wd8003+Ijr, Ienable); } /* * Get configuration parameters, enable memory. * There are opportunities here for buckets of code. * We'll try to resist. */ int wd8003reset(Ctlr *ctlr) { int i; uchar ea[Eaddrlen], ic[8], id, sum; ulong wd8003; /* * Set up the software configuration. * Use defaults for port, irq, mem and size if not specified. * Defaults are set for the dumb 8003E which can't be * autoconfigured. */ if(ctlr->card.port == 0) ctlr->card.port = 0x280; if(ctlr->card.irq == 0) ctlr->card.irq = 3; if(ctlr->card.mem == 0) ctlr->card.mem = 0xD0000; if(ctlr->card.size == 0) ctlr->card.size = 8*1024; ctlr->card.reset = wd8003reset; ctlr->card.attach = dp8390attach; ctlr->card.read = read; ctlr->card.write = write; ctlr->card.receive = dp8390receive; ctlr->card.transmit = dp8390transmit; ctlr->card.intr = dp8390intr; ctlr->card.ram = 1; wd8003 = ctlr->card.port; /* * Look for the interface. We read the LAN address ROM * and validate the checksum - the sum of all 8 bytes * should be 0xFF. * While we're at it, get the (possible) interface chip * registers, we'll use them to check for aliasing later. */ sum = 0; for(i = 0; i < sizeof(ea); i++){ ea[i] = inb(wd8003+Lar+i); sum += ea[i]; ic[i] = inb(wd8003+i); } id = inb(wd8003+Id); sum += id; sum += inb(wd8003+Cksum); if(sum != 0xFF) return -1; if((id & 0xFE) == 0x2A) reset8216(ctlr, ic); else reset8003(ctlr, ea, ic); . 159c ctlr->card.irq = irq8003[((ic[Irr]>>5) & 0x3)|(ic[Icr] & 0x4)]; . 115,131d 90,113d 86,87d 78,84c static void reset8003(Ctlr *ctlr, uchar ea[Eaddrlen], uchar ic[8]) . 57a static int irq8216[8] = { 0, 9, 3, 5, 7, 10, 11, 15, }; . 54c static int irq8003[8] = { . 50a enum { /* Ijr */ Ienable = 0x01, /* 8216 interrupt enable */ }; . 20a Hcr = 0x04, /* 8216 hardware control */ . 11a * Also handles 8216 cards (Elite Ultra). . wq //GO.SYSIN DD VADIM ether8003.c sum=`{sum < 874002976/ether8003.c} if(~ 1d9f71ac7015 $sum(1)^$sum(2)) echo if not{ echo 874002976/ether8003.c checksum error creating updated file exit checksum } target=874002976/ether8390.c echo -n '874002976/ether8390.c: ' if(! test -f $srcdir/ether8390.c || ! test -r $srcdir/ether8390.c){ echo $srcdir/ether8390.c unreadable exit unreadable } sum=`{sum < $srcdir/ether8390.c} if(! ~ 385f869f15973 $sum(1)^$sum(2)){ echo $srcdir/ether8390.c is not the original distribution file exit original } cp $srcdir/ether8390.c 874002976/ether8390.c ed 874002976/ether8390.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM ether8390.c' 581c while(isr = (dp8390inb(dp8390+Isr) & (Cnte|Ovwe|Txee|Rxee|Ptxe|Prxe))){ . 396a else{ dp8390outb(dp8390+Rsar0, to & 0xFF); dp8390outb(dp8390+Rsar1, (to>>8) & 0xFF); dp8390outb(dp8390+Rbcr0, len & 0xFF); dp8390outb(dp8390+Rbcr1, (len>>8) & 0xFF); dp8390outb(dp8390+Cr, Page0|RDMAwrite|Sta); } . 391,394c if(crda == to){ /* * Start the remote DMA write and make sure * the registers are correct. */ dp8390outb(dp8390+Cr, Page0|RDMAwrite|Sta); crda = dp8390inb(dp8390+Crda0); crda |= dp8390inb(dp8390+Crda1)<<8; if(crda != to) panic("crda write %d to %d\n", crda, to); break; } . 372,388c if(ctlr->card.dummyrr){ crda = to-1-ctlr->card.bit16; dp8390outb(dp8390+Rbcr0, (len+1+ctlr->card.bit16) & 0xFF); dp8390outb(dp8390+Rbcr1, ((len+1+ctlr->card.bit16)>>8) & 0xFF); dp8390outb(dp8390+Rsar0, crda & 0xFF); dp8390outb(dp8390+Rsar1, (crda>>8) & 0xFF); dp8390outb(dp8390+Cr, Page0|RDMAread|Sta); for(;;){ . wq //GO.SYSIN DD VADIM ether8390.c sum=`{sum < 874002976/ether8390.c} if(~ 7e55e19b16286 $sum(1)^$sum(2)) echo if not{ echo 874002976/ether8390.c checksum error creating updated file exit checksum } target=874002976/floppy.c echo -n '874002976/floppy.c: ' if(! test -f $srcdir/floppy.c || ! test -r $srcdir/floppy.c){ echo $srcdir/floppy.c unreadable exit unreadable } sum=`{sum < $srcdir/floppy.c} if(! ~ 1b44aea713048 $sum(1)^$sum(2)){ echo $srcdir/floppy.c is not the original distribution file exit original } cp $srcdir/floppy.c 874002976/floppy.c ed 874002976/floppy.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM floppy.c' 708c dp->maxtries = 20; . 650a if((fl.stat[0]&Codemask)==Cmdexec && fl.stat[1]==Overrun){ DPRINT("DMA overrun: retry\n"); return 0; } . 459c if(m->ticks > end) . 457c end = m->ticks + 1 + MS2TK(750); while(m->ticks < end && fl.intr == 0) . 455c ulong end; . 393,404c for(tries = 0; tries < 1000; tries++){ if((inb(Pmsr)&(Ffrom|Fready)) == (Ffrom|Fready)) return inb(Pdata)&0xff; microdelay(1); . 370,382c for(tries = 0; tries < 1000; tries++){ if((inb(Pmsr)&(Ffrom|Fready)) == Fready){ outb(Pdata, data); return 0; } microdelay(1); . 368d 347d 292a dp->lasttouched = m->ticks; . 279c alarm(5*1000, floppyalarm, 0); . 276c fl.ccache = ialloc(18*2*512, BY2PG); . 236d 230d 225d 58a Cmdexec= 1<<6, /* status 1 byte */ Overrun= 0x10, . 10c #define DPRINT if(0)print . wq //GO.SYSIN DD VADIM floppy.c sum=`{sum < 874002976/floppy.c} if(~ b640825b12932 $sum(1)^$sum(2)) echo if not{ echo 874002976/floppy.c checksum error creating updated file exit checksum } target=874002976/fns.h echo -n '874002976/fns.h: ' if(! test -f $srcdir/fns.h || ! test -r $srcdir/fns.h){ echo $srcdir/fns.h unreadable exit unreadable } sum=`{sum < $srcdir/fns.h} if(! ~ dc5e2e622169 $sum(1)^$sum(2)){ echo $srcdir/fns.h is not the original distribution file exit original } cp $srcdir/fns.h 874002976/fns.h ed 874002976/fns.h >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM fns.h' 72c int x86cpuid(int*, int*); . 55a void pcicfgr(int, int, int, int, void*, int); int pcimatch(int, int, PCIcfg*); int plan9boot(int, long (*)(int, long), long (*)(int, void*, long)); . 54d 45a void microdelay(int); . 25d 20a int getcfields(char*, char**, int, char*); . 6,7c void cgascreenputs(char*, int); . wq //GO.SYSIN DD VADIM fns.h sum=`{sum < 874002976/fns.h} if(~ 1497a7b12264 $sum(1)^$sum(2)) echo if not{ echo 874002976/fns.h checksum error creating updated file exit checksum } target=874002976/hard.c echo -n '874002976/hard.c: ' if(! test -f $srcdir/hard.c || ! test -r $srcdir/hard.c){ echo $srcdir/hard.c unreadable exit unreadable } sum=`{sum < $srcdir/hard.c} if(! ~ 4a791bea14626 $sum(1)^$sum(2)){ echo $srcdir/hard.c is not the original distribution file exit original } cp $srcdir/hard.c 874002976/hard.c ed 874002976/hard.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM hard.c' 690a else cp->cmd = 0; inb(cp->pbase+Pstatus); . 687,689c if(cp->cmd == Cident && (cp->status & Sready) == 0) . 647,667d 614c if(getcfields(line[i], field, 3, " ") != 3) . 606a else{ strcpy(cp->buf, p); n = getcfields(cp->buf, line, Npart+1, "\n"); } . 605c n = getcfields(cp->buf, line, Npart+1, "\n"); if(n == 0 || strncmp(line[0], MAGIC, sizeof(MAGIC)-1)){ dp->p[0].end--; dp->p[1].start--; dp->p[1].end--; hardxfer(dp, pp, Cread, 0, dp->bytes); cp->buf[dp->bytes-1] = 0; n = getcfields(cp->buf, line, Npart+1, "\n"); } . 596,602c sprint(buf, "hd%dpartition", dp->driveno); if((p = getconf(buf)) == 0){ /* * read last sector from disk, null terminate. This used * to be the sector we used for the partition tables. * However, this sector is special on some PC's so we've * started to use the second last sector as the partition * table instead. To avoid reconfiguring all our old systems * we first look to see if there is a valid partition * table in the last sector. If so, we use it. Otherwise * we switch to the second last. */ . 587,594c * Check if the partitions are described in plan9.ini. * If not, read the disc. . 565,566c char *field[3], *line[Npart+1], *p, buf[NAMELEN]; . 531c for(i = 0; i < 64; i++) . 527c dp->lba = 0; for(i = 0; i < 16; i++) . 485c outb(cp->pbase+Pdh, dp->dh | (dp->lba<<6) | head); . 472c if(cmdreadywait(dp) < 0) . 447c /*print("\nata%d model %s with default %d cyl %d head %d sec\n", dp->driveno, . 439c /*print("\nata%d model %s with %d lba sectors\n", dp->driveno, id, dp->sectors);/**/ . 434a DPRINT("LBA%d: %lud\n", ip->capabilities & (1<<9) == 1, (ip->lbasecs[0]) | (ip->lbasecs[1]<<16)); DPRINT("DEF: %ud/%ud/%ud\nMAP %ud/%ud/%ud\n", ip->cyls, ip->heads, ip->s2t, ip->ccyls, ip->cheads, ip->cs2t); . 424c outb(cp->pbase+Pdh, dp->dh); . 417c if(isatapi(dp) || cmdreadywait(dp) < 0) . 404a static int isatapi(Drive *drive) { Controller *cp; cp = drive->cp; outb(cp->pbase+Pdh, drive->dh); microdelay(1); if(inb(cp->pbase+Pstatus)) return 0; if(inb(cp->pbase+Pcylmsb) != 0xEB || inb(cp->pbase+Pcyllsb) != 0x14) return 0; return 1; } . 399c outb(cp->pbase+Pdh, dp->dh); . 393c if(cmdreadywait(dp) < 0) . 375c dp->driveno, cp->status, cp->error); . 363,370d 358c outb(cp->pbase+Pdh, dp->dh | (dp->lba<<6) | cp->thead); . 344c if(cmdreadywait(dp) < 0) . 309a if(cmd == Cwrite) return -1; . 303d 291c if(status & Sready) return 0; } USED(status); DPRINT("hd%d: cmdreadywait failed %uX\n", drive->driveno, status); outb(ctlr->pbase+Pdh, DHmagic); return -1; . 285,289c ctlr = drive->cp; end = m->ticks+MS2TK(10)+1; dh = (inb(ctlr->pbase+Pdh) & DHslave)^(drive->dh & DHslave); status = 0; while(m->ticks < end){ status = inb(ctlr->pbase+Pstatus); if(status & Sbusy) continue; if(dh){ outb(ctlr->pbase+Pdh, drive->dh); dh = 0; continue; . 283c ulong end; uchar dh, status; Controller *ctlr; . 281c cmdreadywait(Drive *drive) . 253c if((dp = atadriveprobe(driveno)) == 0) return 0; . 244c hardread(int driveno, void *a, long n) . 234c if((dp = atadriveprobe(driveno)) == 0) return 0; . 229c sethardpart(int driveno, char *p) . 204,205c Drive *drive; if((drive = atadriveprobe(driveno)) == 0) return -1; drive->offset = offset; return offset; . 202c hardseek(int driveno, long offset) . 200a int hardinit(void) { atactlrprobe(0, ATAvec0); return 0xFF; } . 198c return drive; . 186,196c drive = atadrive[driveno]; if(drive->online == 0){ if(atadrivemask & (1<lba) print("hd%d: LBA %d sectors, %d bytes\n", drive->driveno, drive->sectors, drive->cap); else print("hd%d: CHS %d/%d/%d %d bytes\n", drive->driveno, drive->cyl, drive->heads, drive->sectors, drive->cap); drive->online = 1; hardpart(drive); hardsetbuf(drive, 1); . 178,184d 161,176c atactlr[ctlrno] = ialloc(sizeof(Controller), 0); ctlr = atactlr[ctlrno]; ctlr->pbase = port; ctlr->ctlrno = ctlrno; ctlr->buf = ialloc(Maxxfer, 0); inb(ctlr->pbase+Pstatus); setvec(irq, hardintr, ctlr); driveno = ctlrno*2; atadrive[driveno] = ialloc(sizeof(Drive), 0); drive = atadrive[driveno]; drive->cp = ctlr; drive->driveno = driveno; drive->dh = DHmagic; driveno++; atadrive[driveno] = ialloc(sizeof(Drive), 0); drive = atadrive[driveno]; drive->cp = ctlr; drive->driveno = driveno; drive->dh = DHmagic|DHslave; } static Drive* atadriveprobe(int driveno) { Drive *drive; int ctlrno; ISAConf isa; ctlrno = driveno/2; if(atactlr[ctlrno] == 0){ if(atactlrmask & (1</dev/null >[2=1] <<'//GO.SYSIN DD VADIM io.h' 35a /* * PCI Local Bus support. * Quick hack until we figure out how to * deal with EISA, PCI, PCMCIA, PnP, etc. */ enum { /* configuration mechanism #1 */ PCIaddr = 0xCF8, /* CONFIG_ADDRESS */ PCIdata = 0xCFC, /* CONFIG_DATA */ /* configuration mechanism #2 */ PCIcse = 0xCF8, /* configuration space enable */ PCIforward = 0xCFA, /* which bus */ MaxPCI = 32, /* 16 for mechanism #2 */ }; typedef struct PCIcfg { ushort vid; /* vendor ID */ ushort did; /* device ID */ ushort command; ushort status; uchar rid; /* revision ID */ uchar loclass; /* specific register-level programming interface */ uchar subclass; uchar baseclass; uchar clsize; /* cache line size */ uchar latency; /* latency timer */ uchar header; /* header type */ uchar bist; /* built-in self-test */ ulong baseaddr[6]; /* memory or I/O base address registers */ ulong reserved28[2]; ulong romaddr; /* expansion ROM base address */ ulong reserved34[2]; uchar irq; /* interrupt line */ uchar irp; /* interrupt pin */ uchar mingnt; /* burst period length */ uchar maxlat; /* maximum latency between bursts */ } PCIcfg; . 26,27c ATAvec0= Int0vec+14, /* ATA controller #1 */ ATAvec1= Int0vec+15, /* ATA controller #2 */ . wq //GO.SYSIN DD VADIM io.h sum=`{sum < 874002976/io.h} if(~ 382929002274 $sum(1)^$sum(2)) echo if not{ echo 874002976/io.h checksum error creating updated file exit checksum } target=874002976/ip.h echo -n '874002976/ip.h: ' if(! test -f $srcdir/ip.h || ! test -r $srcdir/ip.h){ echo $srcdir/ip.h unreadable exit unreadable } sum=`{sum < $srcdir/ip.h} if(! ~ 3a52f3d02427 $sum(1)^$sum(2)){ echo $srcdir/ip.h is not the original distribution file exit original } cp $srcdir/ip.h 874002976/ip.h ed 874002976/ip.h >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM ip.h' 97c char ea[Eaddrlen]; . wq //GO.SYSIN DD VADIM ip.h sum=`{sum < 874002976/ip.h} if(~ 337b526a2434 $sum(1)^$sum(2)) echo if not{ echo 874002976/ip.h checksum error creating updated file exit checksum } target=874002976/kbd.c echo -n '874002976/kbd.c: ' if(! test -f $srcdir/kbd.c || ! test -r $srcdir/kbd.c){ echo $srcdir/kbd.c unreadable exit unreadable } sum=`{sum < $srcdir/kbd.c} if(! ~ eb00981a9936 $sum(1)^$sum(2)){ echo $srcdir/kbd.c is not the original distribution file exit original } cp $srcdir/kbd.c 874002976/kbd.c ed 874002976/kbd.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM kbd.c' 483c print(initfailed); . 480c print(initfailed); . 477c print(initfailed); . 454a static char *initfailed = "kbd init failed\n"; . wq //GO.SYSIN DD VADIM kbd.c sum=`{sum < 874002976/kbd.c} if(~ 4ec645609957 $sum(1)^$sum(2)) echo if not{ echo 874002976/kbd.c checksum error creating updated file exit checksum } target=874002976/l.s echo -n '874002976/l.s: ' if(! test -f $srcdir/l.s || ! test -r $srcdir/l.s){ echo $srcdir/l.s unreadable exit unreadable } sum=`{sum < $srcdir/l.s} if(! ~ f174535b11742 $sum(1)^$sum(2)){ echo $srcdir/l.s is not the original distribution file exit original } cp $srcdir/l.s 874002976/l.s ed 874002976/l.s >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM l.s' 736,739c GLOBL hello(SB), $0x20 DATA hello+0x00(SB)/8, $"Protecte" DATA hello+0x08(SB)/8, $"d-mode b" DATA hello+0x10(SB)/8, $"ootstrap" DATA hello+0x18(SB)/8, $"\r\n\z\z\z\z\z\z" . 694a POPL BX . 693c MOVL a+0(FP),CX MOVL AX,0(CX) MOVL d+4(FP),CX MOVL DX,0(CX) . 691c MOVL $(3<<8),AX MOVL $0,DX . 688c MOVL $(4<<8),AX MOVL $0,DX . 681,685d 662c TEXT x86cpuid(SB),$0 . 139c MFCR(rCR0, rAX) /* are we in protected mode? */ . 135c * to real mode before trying any privileged operations . 106a #ifdef ResetDiscs XORL AX, AX /* reset disc system */ XORL DX, DX MOVB $0x80, DL INT $0x13 #endif /* ResetDiscs */ . 88a #endif /* NoScreenBlank */ . 82a * Well, no. Windows95 won't co-operate here so we have * to explicitly set mode 3. . 79a #ifdef NoScreenBlank . 2a #define NoScreenBlank 1 /*#define ResetDiscs 1*/ . wq //GO.SYSIN DD VADIM l.s sum=`{sum < 874002976/l.s} if(~ 9cf007ce12126 $sum(1)^$sum(2)) echo if not{ echo 874002976/l.s checksum error creating updated file exit checksum } target=874002976/main.c echo -n '874002976/main.c: ' if(! test -f $srcdir/main.c || ! test -r $srcdir/main.c){ echo $srcdir/main.c unreadable exit unreadable } sum=`{sum < $srcdir/main.c} if(! ~ 310b20c67812 $sum(1)^$sum(2)){ echo $srcdir/main.c is not the original distribution file exit original } cp $srcdir/main.c 874002976/main.c ed 874002976/main.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM main.c' 447c if((p <= 640*1024) && (p+n > 640*1024)) p = 2*1024*1024; palloc = p+n; return memset((void*)(p|KZERO), 0, n); . 441,445c p = palloc; if(align <= 0) align = 4; if(a = n % align) n += align - a; if(a = p % align) p += align - a; . 434,439c if(palloc == 0) palloc = ((ulong)&end)&~KZERO; . 432a int a; . 429,431c static ulong palloc; . 421a . 420a } . 418,419c fields[i] = lp; while(*lp && strchr(sep, *lp) == 0){ if(*lp == '\\' && *(lp+1) == '\n') *lp++ = ' '; . 413,415c for(i = 0; lp && *lp && i < n; i++){ while(*lp && strchr(sep, *lp) != 0) *lp++ = 0; . 409c getcfields(char* lp, char** fields, int n, char* sep) . 398c if(getstr("boot from", line, sizeof(line), def, mode != Manual) >= 0){ . 344a /* * Look for special options on the command line, * e.g. -scsi0=0x334 */ if(p){ while(*p){ while(*p == ' ' || *p == '\t') p++; if(*p != '-') break; if(strncmp(p, "-scsi0=", 7) == 0) scsi0port = strtoul(p+7, &p, 0); while(*p && *p != ' ' && *p != '\t') p++; } } . 315d 290c if((flag & mp->flag) && (dev == Dany || dev == i)) . 277,278c if(mp->flag & Fdos){ start = 0; dombr = (mp->type->type != Tfloppy); if(mp->type->setpart){ if(pp = (*mp->type->setpart)(i, "dos")){ if(start = pp->start) dombr = 0; } (*tp->setpart)(i, "disk"); } if(dosinit(mp, start, dombr) < 0) mp->flag &= ~(Fini|Fdos); } . 274c (*tp->setpart)(i, "disk"); . 272c if((mp->partition = (*tp->setpart)(i, "boot")) == 0) . 265c mp->dev = i; . 260c tp->mask &= ~(1<mask & (1</dev/null >[2=1] <<'//GO.SYSIN DD VADIM mkfile' 63,66d 33,47d 25a pci.$O\ . wq //GO.SYSIN DD VADIM mkfile sum=`{sum < 874002976/mkfile} if(~ 5afbe03a935 $sum(1)^$sum(2)) echo if not{ echo 874002976/mkfile checksum error creating updated file exit checksum } target=874002976/plan9boot.c echo -n '874002976/plan9boot.c: ' if(! test -f $srcdir/plan9boot.c || ! test -r $srcdir/plan9boot.c){ echo $srcdir/plan9boot.c unreadable exit unreadable } sum=`{sum < $srcdir/plan9boot.c} if(! ~ f9a2a0a11590 $sum(1)^$sum(2)){ echo $srcdir/plan9boot.c is not the original distribution file exit original } cp $srcdir/plan9boot.c 874002976/plan9boot.c ed 874002976/plan9boot.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM plan9boot.c' 75c print(premature); . 64c print(premature); . 49c print(premature); . 33c plan9boot(int dev, long (*seek)(int, long), long (*read)(int, void*, long)) . 11c readseg(int dev, long (*read)(int, void*, long), long len, long addr) . 6a char *premature = "premature EOF\n"; . wq //GO.SYSIN DD VADIM plan9boot.c sum=`{sum < 874002976/plan9boot.c} if(~ 85b20c0b1606 $sum(1)^$sum(2)) echo if not{ echo 874002976/plan9boot.c checksum error creating updated file exit checksum } target=874002976/scsi.c echo -n '874002976/scsi.c: ' if(! test -f $srcdir/scsi.c || ! test -r $srcdir/scsi.c){ echo $srcdir/scsi.c unreadable exit unreadable } sum=`{sum < $srcdir/scsi.c} if(! ~ 8988bd117234 $sum(1)^$sum(2)){ echo $srcdir/scsi.c is not the original distribution file exit original } cp $srcdir/scsi.c 874002976/scsi.c ed 874002976/scsi.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM scsi.c' 374c memset(&isa, 0, sizeof(isa)); if(scsi0port) port = scsi0port; else if(isaconfig("scsi", 0, &isa)) port = isa.port; else port = 0; if((exec = ultra14freset(port)) == 0 && (exec = aha1542reset(port)) == 0) . 372a ISAConf isa; . 371c int i, online, port; . 367a extern int scsi0port; . 355,356c extern int (*aha1542reset(int))(Scsi*, int); extern int (*ultra14freset(int))(Scsi*, int); . 352c } return addr - (char*)a; . 349,350c addr = a; while(n > 0){ len = scsirw(dev, 0, addr, n, sdrive[dev].offset); if(len <= 0) break; addr += len; n -= len; . 347a char *addr; . 315,338c x = scsibread(dev, b, n, d->bytes, block); if(x < offset) len = 0; else if(len > x - offset) len = x - offset; memmove(a, (char*)b->virt + offset, len); . 300c if(p == 0 || write) . 261c if(getcfields(line[i], field, 3, " ") != 3) . 257c n = getcfields(cp, line, Npart+1, "\n"); . 250a else strcpy(b->virt, p); . 246,249c sprint(buf, "sd%dpartition", dev); if((p = getconf(buf)) == 0){ if(scsibread(dev, b, 1, dp->bytes, dp->cap-1) <= 0){ scsifree(b); print("can't read partition block\n"); return; } . 243c * Check if the partitions are described in plan9.ini. * If not, read the disc. . 220,221c char *field[3], *line[Npart+1], *cp, buf[NAMELEN], *p; . 170,203d wq //GO.SYSIN DD VADIM scsi.c sum=`{sum < 874002976/scsi.c} if(~ dc2842b86608 $sum(1)^$sum(2)) echo if not{ echo 874002976/scsi.c checksum error creating updated file exit checksum } target=874002976/scsi14f.c echo -n '874002976/scsi14f.c: ' if(! test -f $srcdir/scsi14f.c || ! test -r $srcdir/scsi14f.c){ echo $srcdir/scsi14f.c unreadable exit unreadable } sum=`{sum < $srcdir/scsi14f.c} if(! ~ 3398ee3b9428 $sum(1)^$sum(2)){ echo $srcdir/scsi14f.c is not the original distribution file exit original } cp $srcdir/scsi14f.c 874002976/scsi14f.c ed 874002976/scsi14f.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM scsi14f.c' 295c if(port) ctlr->io = port; else ctlr->io = Port; . 283c ultra14freset(int port))(Scsi*, int) . wq //GO.SYSIN DD VADIM scsi14f.c sum=`{sum < 874002976/scsi14f.c} if(~ 1348d99e9468 $sum(1)^$sum(2)) echo if not{ echo 874002976/scsi14f.c checksum error creating updated file exit checksum } target=874002976/scsi1542.c echo -n '874002976/scsi1542.c: ' if(! test -f $srcdir/scsi1542.c || ! test -r $srcdir/scsi1542.c){ echo $srcdir/scsi1542.c unreadable exit unreadable } sum=`{sum < $srcdir/scsi1542.c} if(! ~ 5f471b0e14169 $sum(1)^$sum(2)){ echo $srcdir/scsi1542.c is not the original distribution file exit original } cp $srcdir/scsi1542.c 874002976/scsi1542.c ed 874002976/scsi1542.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM scsi1542.c' 499a /* * If the BIOS is enabled on the 1542C/CF and BIOS options for support of drives * > 1Gb, dynamic scanning of the SCSI bus or more than 2 drives under DOS 5.0 are * enabled, the BIOS disables accepting Cmbinit to protect against running with * drivers which don't support those options. In order to unlock the interface * it is necessary to read a lock-code using Cextbios and write it back using * Cmbienable; the lock-code is non-zero. */ ctlr->cmd[0] = Cinquiry; ctlr->cmdlen = 1; ctlr->datalen = 4; issuepollcmd(ctlr); if(ctlr->data[0] > 0x43){ ctlr->cmd[0] = Cextbios; ctlr->cmdlen = 1; ctlr->datalen = 2; issuepollcmd(ctlr); /* * Lock-code returned in data[1]. If it's non-zero write it back * along with bit 0 of byte 0 cleared to enable mailbox initialisation. */ if(ctlr->data[1]){ ctlr->cmd[0] = Cmbienable; ctlr->cmd[1] = 0; ctlr->cmd[2] = ctlr->data[1]; ctlr->cmdlen = 3; ctlr->datalen = 0; issuepollcmd(ctlr); } } . 486c if(port) ctlr->port = port; else ctlr->port = Port; . 476c aha1542reset(int port))(Scsi*, int) . 67a Cextbios = 0x28, /* return extended BIOS information */ Cmbienable = 0x29, /* set mailbox interface enable */ . wq //GO.SYSIN DD VADIM scsi1542.c sum=`{sum < 874002976/scsi1542.c} if(~ e99128df15318 $sum(1)^$sum(2)) echo if not{ echo 874002976/scsi1542.c checksum error creating updated file exit checksum } target=874002976/ether79c970.c echo -n '874002976/ether79c970.c (new): ' cat > 874002976/ether79c970.c >[2]/dev/null <<'//GO.SYSIN DD VADIM /sys/lib/pcdist/src/b' /* * AM79C970 * PCnet-PCI Single-Chip Ethernet Controller for PCI Local Bus * To do: * only issue transmit interrupt if necessary? * dynamically increase rings as necessary? * use Block's as receive buffers? */ #include "u.h" #include "lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" #include "ether.h" enum { Lognrdre = 4, Nrdre = (1<card.port; outl(port+Rdp, Iena|Strt); } static void transmit(Ctlr *ctlr) { int port, len; Amd *amdp; RingBuf *tb; Tdre *tdre; port = ctlr->card.port; amdp = &amd[ctlr->ctlrno]; tdre = &amdp->tdr[amdp->tdrx]; for(tb = &ctlr->tb[ctlr->ti]; tb->owner == Interface; tb = &ctlr->tb[ctlr->ti]){ if(tdre->tmd1 & Own) break; /* * Copy the packet to the transmit buffer. */ len = tb->len; memmove(KADDR(tdre->tbadr), tb->pkt, len); /* * Give ownership of the descriptor to the chip, increment the * software ring descriptor pointer and tell the chip to poll. * Free the software ring buffer back to the host. */ tdre->tmd2 = 0; tdre->tmd1 = Own|Stp|Enp|(-len & 0xFFFF); amdp->tdrx = NEXT(amdp->tdrx, Ntdre); outl(port+Rdp, Iena|Tdmd); tb->owner = Host; ctlr->ti = NEXT(ctlr->ti, ctlr->ntb); tdre = &amdp->tdr[amdp->tdrx]; } } static void interrupt(Ureg*, Ctlr *ctlr) { int len, port, csr0, status; Amd *amdp; Rdre *rdre; RingBuf *rb; Etherpkt *pkt; port = ctlr->card.port; amdp = &amd[ctlr->ctlrno]; /* * Acknowledge all interrupts and whine about those that shouldn't * happen. */ csr0 = inl(port+Rdp); outl(port+Rdp, Babl|Cerr|Miss|Merr|Rint|Tint|Iena); if(csr0 & (Babl|Miss|Merr)) print("AMD70C970#%d: csr0 = 0x%uX\n", ctlr->ctlrno, csr0); /* * Receiver interrupt: run round the descriptor ring logging * errors and passing valid receive data up to the higher levels * until we encounter a descriptor still owned by the chip. */ if(csr0 & Rint){ rdre = &amdp->rdr[amdp->rdrx]; while(((status = rdre->rmd1) & Own) == 0){ if(status & RxErr){ if(status & RxBuff) ctlr->buffs++; if(status & RxCrc) ctlr->crcs++; if(status & RxOflo) ctlr->overflows++; } else{ /* * We have a packet. Read it into the next * free ring buffer, if any. */ rb = &ctlr->rb[ctlr->ri]; if(rb->owner == Interface){ len = (rdre->rmd2 & 0x0FFF)-4; rb->len = len; memmove(rb->pkt, KADDR(rdre->rbadr), len); /* * Update the ring if it's really intended * for us. */ pkt = (Etherpkt*)rb->pkt; if(memcmp(pkt->d, ctlr->card.ea, Eaddrlen) == 0){ rb->owner = Host; ctlr->ri = NEXT(ctlr->ri, ctlr->nrb); } } } /* * Finished with this descriptor, reinitialise it, * give it back to the chip, then on to the next... */ rdre->rmd2 = 0; rdre->rmd1 = Own|(-Rbsize & 0xFFFF); amdp->rdrx = NEXT(amdp->rdrx, Nrdre); rdre = &amdp->rdr[amdp->rdrx]; } } /* * Transmitter interrupt: handle anything queued for a free descriptor. */ if(csr0 & Tint) transmit(ctlr); } static void ringinit(Amd* amdp) { int i, x; /* * Initialise the receive and transmit buffer rings. The ring * entries must be aligned on 16-byte boundaries. */ if(amdp->rdr == 0) amdp->rdr = ialloc(Nrdre*sizeof(Rdre), 0x10); if(amdp->rrb == 0) amdp->rrb = ialloc(Nrdre*Rbsize, 0); x = PADDR(amdp->rrb); for(i = 0; i < Nrdre; i++){ amdp->rdr[i].rbadr = x; x += Rbsize; amdp->rdr[i].rmd1 = Own|(-Rbsize & 0xFFFF); } amdp->rdrx = 0; if(amdp->tdr == 0) amdp->tdr = ialloc(Ntdre*sizeof(Tdre), 0x10); if(amdp->trb == 0) amdp->trb = ialloc(Ntdre*Rbsize, 0); x = PADDR(amdp->trb); for(i = 0; i < Ntdre; i++){ amdp->tdr[i].tbadr = x; x += Rbsize; } amdp->tdrx = 0; } typedef struct Adapter Adapter; struct Adapter { Adapter* next; int port; PCIcfg* pcicfg; }; static Adapter *adapter; static PCIcfg* amd79c90(ISAConf* isa) { PCIcfg pcicfg, *pcip; static int devno = 0; int port; Adapter *ap; for(;;){ pcicfg.vid = 0x1022; pcicfg.did = 0x2000; if((devno = pcimatch(0, devno, &pcicfg)) == -1) break; pcip = ialloc(sizeof(PCIcfg), 0); memmove(pcip, &pcicfg, sizeof(PCIcfg)); port = pcip->baseaddr[0] & ~0x01; if(isa->port == 0 || isa->port == port) return pcip; ap = ialloc(sizeof(Adapter), 0); ap->pcicfg = pcip; ap->port = port; ap->next = adapter; adapter = ap; } return 0; } int amd79c970reset(Ctlr* ctlr) { int port, x; PCIcfg *pcicfg; Adapter *ap, **app; uchar ea[Eaddrlen]; Amd *amdp; /* * Any adapter matches if no ctlr->port is supplied, otherwise the * ports must match. First see if we've already found an adapter that fits * the bill. If not then scan for another. */ port = 0; pcicfg = 0; for(app = &adapter, ap = *app; ap; app = &ap->next, ap = ap->next){ if(ctlr->card.port == 0 || ctlr->card.port == ap->port){ port = ap->port; pcicfg = ap->pcicfg; *app = ap->next; /*free(ap);lost*/ break; } } if(port == 0 && (pcicfg = amd79c90(&ctlr->card))){ port = pcicfg->baseaddr[0] & ~0x01; ctlr->card.irq = pcicfg->irq; } if(port == 0) return -1; if(pcicfg) /*free(pcicfg)lost*/; /* * How can we tell what mode we're in at this point - if we're in WORD * mode then the only 32-bit access we are allowed to make is a write to * the RDP, which forces the chip to DWORD mode; if we're in DWORD mode * then we're not allowed to make any non-DWORD accesses? * Assuming we do a DWORD write to the RDP, how can we tell what we're * about to overwrite as we can't reliably access the RAP? * * Force DWORD mode by writing to RDP, doing a reset then writing to RDP * again; at least we know what state we're in now. The value of RAP after * a reset is 0, so the second DWORD write will be to CSR0. * Set the software style in BCR20 to be PCnet-PCI to ensure 32-bit access. * Set the auto pad transmit in CSR4. */ outl(port+Rdp, 0x00); inl(port+Sreset); outl(port+Rdp, Stop); outl(port+Rap, 20); outl(port+Bdp, 0x0002); outl(port+Rap, 4); x = inl(port+Rdp) & 0xFFFF; outl(port+Rdp, ApadXmt|x); outl(port+Rap, 0); /* * Check if we are going to override the adapter's station address. * If not, read it from the I/O-space and set in ctlr->ea prior to loading the * station address in the initialisation block. */ memset(ea, 0, Eaddrlen); if(memcmp(ea, ctlr->card.ea, Eaddrlen) == 0){ x = inl(port+Aprom); ctlr->card.ea[0] = x & 0xFF; ctlr->card.ea[1] = (x>>8) & 0xFF; ctlr->card.ea[2] = (x>>16) & 0xFF; ctlr->card.ea[3] = (x>>24) & 0xFF; x = inl(port+Aprom+4); ctlr->card.ea[4] = x & 0xFF; ctlr->card.ea[5] = (x>>8) & 0xFF; } /* * Allocate a controller structure and start to fill in the * initialisation block (must be DWORD aligned). */ amdp = &amd[ctlr->ctlrno]; amdp->iblock.rlen = Lognrdre<<4; amdp->iblock.tlen = Logntdre<<4; memmove(amdp->iblock.padr, ctlr->card.ea, sizeof(amdp->iblock.padr)); ringinit(amdp); amdp->iblock.rdra = PADDR(amdp->rdr); amdp->iblock.tdra = PADDR(amdp->tdr); /* * Point the chip at the initialisation block and tell it to go. * Mask the Idon interrupt and poll for completion. Strt and interrupt * enables will be set later when we're ready to attach to the network. */ x = PADDR(&amdp->iblock); outl(port+Rap, 1); outl(port+Rdp, x & 0xFFFF); outl(port+Rap, 2); outl(port+Rdp, (x>>16) & 0xFFFF); outl(port+Rap, 3); outl(port+Rdp, Idonm); outl(port+Rap, 0); outl(port+Rdp, Init); while((inl(port+Rdp) & Idon) == 0) ; outl(port+Rdp, Idon|Stop); ctlr->card.reset = amd79c970reset; ctlr->card.port = port; ctlr->card.attach = attach; ctlr->card.transmit = transmit; ctlr->card.intr = interrupt; return 0; } //GO.SYSIN DD VADIM /sys/lib/pcdist/src/b sum=`{sum < 874002976/ether79c970.c} if(~ 6fed5e9711025 $sum(1)^$sum(2)) echo if not{ echo 874002976/ether79c970.c checksum error extracting new file exit checksum } target=874002976/pci.c echo -n '874002976/pci.c (new): ' cat > 874002976/pci.c >[2]/dev/null <<'//GO.SYSIN DD VADIM /sys/lib/pcdist/src/b' #include "u.h" #include "lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" static int pcicfgmode = -1; static void pcicfginit(int) { /* * Try to determine which PCI configuration mode is implemented. * Mode2 uses a byte at 0xCF8 and another at 0xCFA; Mode1 uses * a DWORD at 0xCF8 and another at 0xCFC and will pass through * any non-DWORD accesses as normal I/O cycles. There shouldn't be * a device behind theses addresses so if Mode2 accesses fail try * for Mode1 (which is preferred, Mode2 is deprecated). */ outb(PCIcse, 0); if(inb(PCIcse) == 0){ pcicfgmode = 2; return; } outl(PCIaddr, 0); if(inl(PCIaddr) == 0){ pcicfgmode = 1; return; } pcicfgmode = -1; } /* * Read a chunk of PCI configuration space. * Assumes arguments are within limits and regno and * nbytes are DWORD aligned. */ void pcicfgr(int busno, int devno, int funcno, int regno, void* data, int nbytes) { ulong addr, *p; int base, len; if(pcicfgmode == -1) pcicfginit(busno); switch(pcicfgmode){ case 1: addr = 0x80000000|((busno & 0xFF)<<16)|((devno & 0x1F)<<11)|((funcno & 0x03)<<8); p = data; for(len = nbytes/sizeof(ulong); len > 0; len--){ outl(PCIaddr, addr|(regno & 0xFF)); *p = inl(PCIdata); p++; regno += sizeof(ulong); } outl(PCIaddr, 0); break; case 2: if(devno >= 16) break; outb(PCIcse, 0x80|((funcno & 0x07)<<1)); outb(PCIforward, busno); base = (0xC000|(devno<<8)) + regno; p = data; for(len = nbytes/sizeof(ulong); len > 0; len--){ *p = inl(base); p++; base += sizeof(*p); } outb(PCIcse, 0); break; } } int pcimatch(int busno, int devno, PCIcfg* pcicfg) { ulong l; while(devno < MaxPCI){ if(pcicfgmode == 2 && devno >= 16) break; l = 0; pcicfgr(busno, devno, 0, 0, &l, sizeof(ulong)); devno++; if((l & 0xFFFF) != pcicfg->vid) continue; if(pcicfg->did && ((l>>16) & 0xFFFF) != pcicfg->did) continue; pcicfgr(busno, devno-1, 0, 0, pcicfg, sizeof(PCIcfg)); return devno; } return -1; } //GO.SYSIN DD VADIM /sys/lib/pcdist/src/b sum=`{sum < 874002976/pci.c} if(~ b89725d72038 $sum(1)^$sum(2)) echo if not{ echo 874002976/pci.c checksum error extracting new file exit checksum } echo obsolete files: /n/juke/plan_9/sys/src/boot/pc/install.c