#!/bin/rc # # command: /bin/boddle /n/juke/plan_9/sys/src/boot/pc /sys/src/boot/pc # srcdir: /n/juke/plan_9/sys/src/boot/pc # version: 810864149 # date: Mon Sep 11 20:02:29 EDT 1995 # myname=$0 doextract=no fn usage{ echo $myname: usage: $myname '[-X] [src-directory]' >[1=2] exit usage } fn sigint{ rm -rf 810864149 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 810864149 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 810864149 mkdir 810864149 target=810864149/bb.s echo -n '810864149/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 810864149/bb.s ed 810864149/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 < 810864149/bb.s} if(~ fa2e3ee410651 $sum(1)^$sum(2)) echo if not{ echo 810864149/bb.s checksum error creating updated file exit checksum } target=810864149/bootp.c echo -n '810864149/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 810864149/bootp.c ed 810864149/bootp.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM bootp.c' 412c memmove(server.ea, broadcast, sizeof(server.ea)); . 230c continue; . 227,228c timo = TK2MS(m->ticks)+Timeout; while(timo > TK2MS(m->ticks)){ n = etherrxpkt(ctlrno, &pkt, timo-TK2MS(m->ticks)); . 224c ulong addr, timo; . 9a uchar broadcast[Eaddrlen] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }; . wq //GO.SYSIN DD VADIM bootp.c sum=`{sum < 810864149/bootp.c} if(~ 74d8dd109271 $sum(1)^$sum(2)) echo if not{ echo 810864149/bootp.c checksum error creating updated file exit checksum } target=810864149/clock.c echo -n '810864149/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 810864149/clock.c ed 810864149/clock.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM clock.c' 43a void microdelay(int l) { l *= loopconst; l /= 1000; if(l <= 0) l = 1; aamloop(l); } . wq //GO.SYSIN DD VADIM clock.c sum=`{sum < 810864149/clock.c} if(~ 477ee67d2216 $sum(1)^$sum(2)) echo if not{ echo 810864149/clock.c checksum error creating updated file exit checksum } target=810864149/console.c echo -n '810864149/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 810864149/console.c ed 810864149/console.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM console.c' 110c len = getline(buf, size, isdefault); . 99c getstr(char *prompt, char *buf, int size, char *def) . wq //GO.SYSIN DD VADIM console.c sum=`{sum < 810864149/console.c} if(~ a3a1c31f2682 $sum(1)^$sum(2)) echo if not{ echo 810864149/console.c checksum error creating updated file exit checksum } target=810864149/dat.h echo -n '810864149/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 810864149/dat.h ed 810864149/dat.h >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM dat.h' 161a typedef struct PCIcfg PCIcfg; . 40a extern uchar broadcast[Eaddrlen]; . wq //GO.SYSIN DD VADIM dat.h sum=`{sum < 810864149/dat.h} if(~ f0f0ca963019 $sum(1)^$sum(2)) echo if not{ echo 810864149/dat.h checksum error creating updated file exit checksum } target=810864149/donprint.c echo -n '810864149/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 810864149/donprint.c ed 810864149/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 < 810864149/donprint.c} if(~ 7238b0e24095 $sum(1)^$sum(2)) echo if not{ echo 810864149/donprint.c checksum error creating updated file exit checksum } target=810864149/dosboot.c echo -n '810864149/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 810864149/dosboot.c ed 810864149/dosboot.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM dosboot.c' 18,19c #define chatty 0 #define chat if(chatty)print . wq //GO.SYSIN DD VADIM dosboot.c sum=`{sum < 810864149/dosboot.c} if(~ 82c1343511250 $sum(1)^$sum(2)) echo if not{ echo 810864149/dosboot.c checksum error creating updated file exit checksum } target=810864149/ether.c echo -n '810864149/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 810864149/ether.c ed 810864149/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; } . 149a int s; . 146c ethertxpkt(int ctlrno, Etherpkt *pkt, int len, int) . 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 < 810864149/ether.c} if(~ a37d21663253 $sum(1)^$sum(2)) echo if not{ echo 810864149/ether.c checksum error creating updated file exit checksum } target=810864149/ether.h echo -n '810864149/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 810864149/ether.h ed 810864149/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 */ . wq //GO.SYSIN DD VADIM ether.h sum=`{sum < 810864149/ether.h} if(~ 81ae12b93220 $sum(1)^$sum(2)) echo if not{ echo 810864149/ether.h checksum error creating updated file exit checksum } target=810864149/ether509.c echo -n '810864149/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 810864149/ether509.c ed 810864149/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); . 578c if(pcicfg == 0) acr = ins(port+AddressConfig); else{ ctlr->card.irq = pcicfg->irq; acr = Xcvr10BaseT; COMMAND(port, SelectWindow, 3); l = inl(port+InternalCgf); l &= ~0x700000; outl(port+InternalCgf, l); /*free(pcicfg);lost*/ } . 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 uchar devno = 0; ulong port; Adapter *ap; while(devno < MaxPCI){ pcicfg.vid = 0x10B7; pcicfg.did = 0; if(pcimatch(0, devno++, &pcicfg) == 0) continue; 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) . 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. Should deal with UP (Update Statistics) * for happier coexistence with Windows drivers. . 271,280c status &= ~(TxAvailable|TxComplete); } . 268,269c 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); COMMAND(port, TxEnable, 0); ctlr->oerrs++; } if(status & (TxAvailable|TxComplete)){ /* * Reset the Tx FIFO threshold. */ if(status & TxAvailable) COMMAND(port, AckIntr, TxAvailable); . 263,266c if(status & RxComplete){ receive(ctlr); status &= ~RxComplete; . 256,261c 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; . 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 . 121,122c COMMAND(port, SetReadZeroMask, (AllIntr|Latch) & ~Update); COMMAND(port, SetIntrMask, (AllIntr|Latch) & ~Update); . 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 < 810864149/ether509.c} if(~ f36a29c616014 $sum(1)^$sum(2)) echo if not{ echo 810864149/ether509.c checksum error creating updated file exit checksum } target=810864149/ether8003.c echo -n '810864149/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 810864149/ether8003.c ed 810864149/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 < 810864149/ether8003.c} if(~ 1d9f71ac7015 $sum(1)^$sum(2)) echo if not{ echo 810864149/ether8003.c checksum error creating updated file exit checksum } target=810864149/ether8390.c echo -n '810864149/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 810864149/ether8390.c ed 810864149/ether8390.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM ether8390.c' 581c while(isr = (dp8390inb(dp8390+Isr) & (Cnte|Ovwe|Txee|Rxee|Ptxe|Prxe))){ . wq //GO.SYSIN DD VADIM ether8390.c sum=`{sum < 810864149/ether8390.c} if(~ 368625ff16009 $sum(1)^$sum(2)) echo if not{ echo 810864149/ether8390.c checksum error creating updated file exit checksum } target=810864149/floppy.c echo -n '810864149/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 810864149/floppy.c ed 810864149/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; } . 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 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, . wq //GO.SYSIN DD VADIM floppy.c sum=`{sum < 810864149/floppy.c} if(~ 825da65c12917 $sum(1)^$sum(2)) echo if not{ echo 810864149/floppy.c checksum error creating updated file exit checksum } target=810864149/fns.h echo -n '810864149/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 810864149/fns.h ed 810864149/fns.h >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM fns.h' 55a void pcicfgr(int, int, int, int, void*, int); int pcimatch(int, int, PCIcfg*); int plan9boot(int, long (*)(int, long), long (*)(int, void*, int)); . 54d 45a void microdelay(int); . 26c int getstr(char*, char*, int, char*); . wq //GO.SYSIN DD VADIM fns.h sum=`{sum < 810864149/fns.h} if(~ d3d796b92265 $sum(1)^$sum(2)) echo if not{ echo 810864149/fns.h checksum error creating updated file exit checksum } target=810864149/hard.c echo -n '810864149/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 810864149/hard.c ed 810864149/hard.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM hard.c' 531c for(i = 0; i < 64; i++) . 527c dp->lba = 0; for(i = 0; i < 16; i++) . 189,190c if(dp->lba) print("hd%d: %d sectors %d bytes\n", dp->drive, dp->sectors, dp->cap); else print("hd%d: %d cylinders %d heads %d sectors/track %d bytes\n", dp->drive, dp->cyl, dp->heads, dp->sectors, dp->cap); . wq //GO.SYSIN DD VADIM hard.c sum=`{sum < 810864149/hard.c} if(~ 323f1cf014744 $sum(1)^$sum(2)) echo if not{ echo 810864149/hard.c checksum error creating updated file exit checksum } target=810864149/io.h echo -n '810864149/io.h: ' if(! test -f $srcdir/io.h || ! test -r $srcdir/io.h){ echo $srcdir/io.h unreadable exit unreadable } sum=`{sum < $srcdir/io.h} if(! ~ beb2e1241102 $sum(1)^$sum(2)){ echo $srcdir/io.h is not the original distribution file exit original } cp $srcdir/io.h 810864149/io.h ed 810864149/io.h >/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; . wq //GO.SYSIN DD VADIM io.h sum=`{sum < 810864149/io.h} if(~ 104c6d792260 $sum(1)^$sum(2)) echo if not{ echo 810864149/io.h checksum error creating updated file exit checksum } target=810864149/l.s echo -n '810864149/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 810864149/l.s ed 810864149/l.s >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM l.s' 135c * to real mode before trying any privileged operations . 88a #endif /* notdef */ . 82a * Well, no. Windows95 won't co-operate here so we have * to explcitly set mode 3. . 79a #ifdef notdef . wq //GO.SYSIN DD VADIM l.s sum=`{sum < 810864149/l.s} if(~ b603357a11862 $sum(1)^$sum(2)) echo if not{ echo 810864149/l.s checksum error creating updated file exit checksum } target=810864149/main.c echo -n '810864149/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 810864149/main.c ed 810864149/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; . 398c if(getstr("boot from", line, sizeof(line), def) >= 0){ . wq //GO.SYSIN DD VADIM main.c sum=`{sum < 810864149/main.c} if(~ 8cc079d27715 $sum(1)^$sum(2)) echo if not{ echo 810864149/main.c checksum error creating updated file exit checksum } target=810864149/mkfile echo -n '810864149/mkfile: ' if(! test -f $srcdir/mkfile || ! test -r $srcdir/mkfile){ echo $srcdir/mkfile unreadable exit unreadable } sum=`{sum < $srcdir/mkfile} if(! ~ 4e185c511160 $sum(1)^$sum(2)){ echo $srcdir/mkfile is not the original distribution file exit original } cp $srcdir/mkfile 810864149/mkfile ed 810864149/mkfile >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM mkfile' 25a pci.$O\ . 19a ether79c970.$O\ . wq //GO.SYSIN DD VADIM mkfile sum=`{sum < 810864149/mkfile} if(~ 22ca83f71186 $sum(1)^$sum(2)) echo if not{ echo 810864149/mkfile checksum error creating updated file exit checksum } target=810864149/scsi1542.c echo -n '810864149/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 810864149/scsi1542.c ed 810864149/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); } } . 67a Cextbios = 0x28, /* return extended BIOS information */ Cmbienable = 0x29, /* set mailbox interface enable */ . wq //GO.SYSIN DD VADIM scsi1542.c sum=`{sum < 810864149/scsi1542.c} if(~ ddcedf7415276 $sum(1)^$sum(2)) echo if not{ echo 810864149/scsi1542.c checksum error creating updated file exit checksum } target=810864149/ether79c970.c echo -n '810864149/ether79c970.c (new): ' cat > 810864149/ether79c970.c >[2]/dev/null <<'//GO.SYSIN DD VADIM /sys/src/boot/pc' /* * 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 uchar devno = 0; int port; Adapter *ap; while(devno < MaxPCI){ pcicfg.vid = 0x1022; pcicfg.did = 0x2000; if(pcimatch(0, devno++, &pcicfg) == 0) continue; 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/src/boot/pc sum=`{sum < 810864149/ether79c970.c} if(~ 5f598f3611035 $sum(1)^$sum(2)) echo if not{ echo 810864149/ether79c970.c checksum error extracting new file exit checksum } target=810864149/pci.c echo -n '810864149/pci.c (new): ' cat > 810864149/pci.c >[2]/dev/null <<'//GO.SYSIN DD VADIM /sys/src/boot/pc' #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(ulong); } outb(PCIcse, 0); } } int pcimatch(int busno, int devno, PCIcfg* pcicfg) { ulong l; l = 0; pcicfgr(busno, devno, 0, 0, &l, sizeof(ulong)); if((l & 0xFFFF) != pcicfg->vid) return 0; if(pcicfg->did && ((l>>16) & 0xFFFF) != pcicfg->did) return 0; pcicfgr(busno, devno, 0, 0, pcicfg, sizeof(PCIcfg)); return 1; } //GO.SYSIN DD VADIM /sys/src/boot/pc sum=`{sum < 810864149/pci.c} if(~ e41c3fe31922 $sum(1)^$sum(2)) echo if not{ echo 810864149/pci.c checksum error extracting new file exit checksum }