Browse Source

Plan 9 from Bell Labs 2006-07-17

David du Colombier 18 years ago
parent
commit
bef264deec
7 changed files with 135 additions and 199 deletions
  1. 6 6
      dist/replica/_plan9.db
  2. 6 6
      dist/replica/plan9.db
  3. 6 0
      dist/replica/plan9.log
  4. 103 172
      sys/src/9/pc/devpccard.c
  5. 1 0
      sys/src/9/pc/ether82557.c
  6. 3 2
      sys/src/9/pc/fns.h
  7. 10 13
      sys/src/9/pc/pci.c

+ 6 - 6
dist/replica/_plan9.db

@@ -290,7 +290,7 @@
 386/bin/ip/gping - 775 sys sys 1150062738 183566
 386/bin/ip/hogports - 775 sys sys 1148500655 42914
 386/bin/ip/httpd - 20000000775 sys sys 1016920846 0
-386/bin/ip/httpd/httpd - 775 sys sys 1148500656 294993
+386/bin/ip/httpd/httpd - 775 sys sys 1153069070 294993
 386/bin/ip/httpd/imagemap - 775 sys sys 1148500656 117121
 386/bin/ip/httpd/man2html - 775 sys sys 1148500657 125679
 386/bin/ip/httpd/netlib_find - 775 sys sys 1148500657 117974
@@ -555,7 +555,7 @@
 386/lib/libframe.a - 664 sys sys 1147712341 66398
 386/lib/libgeometry.a - 664 sys sys 1143777862 50470
 386/lib/libhtml.a - 664 sys sys 1143777863 229354
-386/lib/libhttpd.a - 664 sys sys 1143777863 99458
+386/lib/libhttpd.a - 664 sys sys 1153069071 99458
 386/lib/libip.a - 664 sys sys 1143777863 35576
 386/lib/libl.a - 664 sys sys 1143777863 5372
 386/lib/libmach.a - 664 sys sys 1148180229 785314
@@ -7951,7 +7951,7 @@ sys/src/9/pc/devlm78.c - 664 sys sys 1128255048 6291
 sys/src/9/pc/devlml.c - 664 sys sys 1132448361 7502
 sys/src/9/pc/devlml.h - 664 sys sys 1026847636 2948
 sys/src/9/pc/devlpt.c - 664 sys sys 1015014514 4420
-sys/src/9/pc/devpccard.c - 664 sys sys 1146318335 40443
+sys/src/9/pc/devpccard.c - 664 sys sys 1153082883 39122
 sys/src/9/pc/devrtc.c - 664 sys sys 1015014515 7167
 sys/src/9/pc/devtv.c - 664 sys sys 1131290299 45676
 sys/src/9/pc/devusb.c - 664 sys sys 1105193103 18364
@@ -7965,7 +7965,7 @@ sys/src/9/pc/ether8003.c - 664 sys sys 1015014516 6665
 sys/src/9/pc/ether8139.c - 664 sys sys 1131290376 18400
 sys/src/9/pc/ether8169.c - 664 sys sys 1131290377 22723
 sys/src/9/pc/ether82543gc.c - 664 sys sys 1131290377 32294
-sys/src/9/pc/ether82557.c - 664 sys sys 1140802391 30152
+sys/src/9/pc/ether82557.c - 664 sys sys 1153082663 30197
 sys/src/9/pc/ether83815.c - 664 sys sys 1140271743 26125
 sys/src/9/pc/ether8390.c - 664 sys sys 1131290377 17702
 sys/src/9/pc/ether8390.h - 664 sys sys 1015014517 1511
@@ -7985,7 +7985,7 @@ sys/src/9/pc/ethervgbe.c - 664 sys sys 1138114457 26558
 sys/src/9/pc/ethervt6102.c - 664 sys sys 1131907459 22286
 sys/src/9/pc/etherwavelan.c - 664 sys sys 1131290380 3747
 sys/src/9/pc/floppy.h - 664 sys sys 1055700609 3835
-sys/src/9/pc/fns.h - 664 sys sys 1143129956 4531
+sys/src/9/pc/fns.h - 664 sys sys 1153082883 4564
 sys/src/9/pc/hcwAMC.h - 664 sys sys 1026860163 166004
 sys/src/9/pc/i8253.c - 664 sys sys 1139681387 6236
 sys/src/9/pc/i8259.c - 664 sys sys 1131290399 4586
@@ -8012,7 +8012,7 @@ sys/src/9/pc/pcdisk - 664 sys sys 1138115243 1471
 sys/src/9/pc/pcf - 664 sys sys 1138115243 1529
 sys/src/9/pc/pcfl - 664 sys sys 1042004821 1563
 sys/src/9/pc/pcflop - 664 sys sys 1138115244 1498
-sys/src/9/pc/pci.c - 664 sys sys 1150036688 26932
+sys/src/9/pc/pci.c - 664 sys sys 1153082883 26859
 sys/src/9/pc/pcmciamodem.c - 664 sys sys 1099761153 1586
 sys/src/9/pc/pcmkfile - 664 sys sys 1109303822 101
 sys/src/9/pc/piix4smbus.c - 664 sys sys 1091129037 5230

+ 6 - 6
dist/replica/plan9.db

@@ -290,7 +290,7 @@
 386/bin/ip/gping - 775 sys sys 1150062738 183566
 386/bin/ip/hogports - 775 sys sys 1148500655 42914
 386/bin/ip/httpd - 20000000775 sys sys 1016920846 0
-386/bin/ip/httpd/httpd - 775 sys sys 1148500656 294993
+386/bin/ip/httpd/httpd - 775 sys sys 1153069070 294993
 386/bin/ip/httpd/imagemap - 775 sys sys 1148500656 117121
 386/bin/ip/httpd/man2html - 775 sys sys 1148500657 125679
 386/bin/ip/httpd/netlib_find - 775 sys sys 1148500657 117974
@@ -555,7 +555,7 @@
 386/lib/libframe.a - 664 sys sys 1147712341 66398
 386/lib/libgeometry.a - 664 sys sys 1143777862 50470
 386/lib/libhtml.a - 664 sys sys 1143777863 229354
-386/lib/libhttpd.a - 664 sys sys 1143777863 99458
+386/lib/libhttpd.a - 664 sys sys 1153069071 99458
 386/lib/libip.a - 664 sys sys 1143777863 35576
 386/lib/libl.a - 664 sys sys 1143777863 5372
 386/lib/libmach.a - 664 sys sys 1148180229 785314
@@ -7951,7 +7951,7 @@ sys/src/9/pc/devlm78.c - 664 sys sys 1128255048 6291
 sys/src/9/pc/devlml.c - 664 sys sys 1132448361 7502
 sys/src/9/pc/devlml.h - 664 sys sys 1026847636 2948
 sys/src/9/pc/devlpt.c - 664 sys sys 1015014514 4420
-sys/src/9/pc/devpccard.c - 664 sys sys 1146318335 40443
+sys/src/9/pc/devpccard.c - 664 sys sys 1153082883 39122
 sys/src/9/pc/devrtc.c - 664 sys sys 1015014515 7167
 sys/src/9/pc/devtv.c - 664 sys sys 1131290299 45676
 sys/src/9/pc/devusb.c - 664 sys sys 1105193103 18364
@@ -7965,7 +7965,7 @@ sys/src/9/pc/ether8003.c - 664 sys sys 1015014516 6665
 sys/src/9/pc/ether8139.c - 664 sys sys 1131290376 18400
 sys/src/9/pc/ether8169.c - 664 sys sys 1131290377 22723
 sys/src/9/pc/ether82543gc.c - 664 sys sys 1131290377 32294
-sys/src/9/pc/ether82557.c - 664 sys sys 1140802391 30152
+sys/src/9/pc/ether82557.c - 664 sys sys 1153082663 30197
 sys/src/9/pc/ether83815.c - 664 sys sys 1140271743 26125
 sys/src/9/pc/ether8390.c - 664 sys sys 1131290377 17702
 sys/src/9/pc/ether8390.h - 664 sys sys 1015014517 1511
@@ -7985,7 +7985,7 @@ sys/src/9/pc/ethervgbe.c - 664 sys sys 1138114457 26558
 sys/src/9/pc/ethervt6102.c - 664 sys sys 1131907459 22286
 sys/src/9/pc/etherwavelan.c - 664 sys sys 1131290380 3747
 sys/src/9/pc/floppy.h - 664 sys sys 1055700609 3835
-sys/src/9/pc/fns.h - 664 sys sys 1143129956 4531
+sys/src/9/pc/fns.h - 664 sys sys 1153082883 4564
 sys/src/9/pc/hcwAMC.h - 664 sys sys 1026860163 166004
 sys/src/9/pc/i8253.c - 664 sys sys 1139681387 6236
 sys/src/9/pc/i8259.c - 664 sys sys 1131290399 4586
@@ -8012,7 +8012,7 @@ sys/src/9/pc/pcdisk - 664 sys sys 1138115243 1471
 sys/src/9/pc/pcf - 664 sys sys 1138115243 1529
 sys/src/9/pc/pcfl - 664 sys sys 1042004821 1563
 sys/src/9/pc/pcflop - 664 sys sys 1138115244 1498
-sys/src/9/pc/pci.c - 664 sys sys 1150036688 26932
+sys/src/9/pc/pci.c - 664 sys sys 1153082883 26859
 sys/src/9/pc/pcmciamodem.c - 664 sys sys 1099761153 1586
 sys/src/9/pc/pcmkfile - 664 sys sys 1109303822 101
 sys/src/9/pc/piix4smbus.c - 664 sys sys 1091129037 5230

+ 6 - 0
dist/replica/plan9.log

@@ -30199,3 +30199,9 @@
 1152730805 0 c sys/man/8/prep - 664 sys sys 1152729153 14013
 1152730805 1 c sys/src/9/pc/usbuhci.c - 664 sys sys 1152730364 30793
 1152982805 0 c sys/src/libhttpd/parsereq.c - 664 sys sys 1152982850 5041
+1153069205 0 c 386/bin/ip/httpd/httpd - 775 sys sys 1153069070 294993
+1153069205 1 c 386/lib/libhttpd.a - 664 sys sys 1153069071 99458
+1153083605 0 c sys/src/9/pc/devpccard.c - 664 sys sys 1153082883 39122
+1153083605 1 c sys/src/9/pc/ether82557.c - 664 sys sys 1153082663 30197
+1153083605 2 c sys/src/9/pc/fns.h - 664 sys sys 1153082883 4564
+1153083605 3 c sys/src/9/pc/pci.c - 664 sys sys 1153082883 26859

+ 103 - 172
sys/src/9/pc/devpccard.c

@@ -1,4 +1,4 @@
-/* 
+/*
      cardbus and pcmcia (grmph) support.
 */
 #include "u.h"
@@ -11,6 +11,8 @@
 
 #define DEBUG	0
 
+#pragma	varargck	type	"T"	int
+
 #define MAP(x,o)	(Rmap + (x)*0x8 + o)
 
 enum {
@@ -39,7 +41,7 @@ enum {
 
 	TI1131xSC = 0x80,		// system control
 		TI122X_SC_INTRTIE	= 1 << 29,
-	TI12xxIM = 0x8c,		// 
+	TI12xxIM = 0x8c,		//
 	TI1131xCC = 0x91,		// card control
 		TI113X_CC_RIENB = 1 << 7,
 		TI113X_CC_ZVENABLE = 1 << 6,
@@ -130,8 +132,8 @@ enum
 	 Fcardena=	 (1<<4),	/*  PC card enable */
 	Rigc= 		0x3,		/* interrupt and general control */
 	 Fiocard=	 (1<<5),	/*  I/O card (vs memory) */
-	 Fnotreset=	 (1<<6),	/*  reset if not set */	
-	 FSMIena=	 (1<<4),	/*  enable change interrupt on SMI */ 
+	 Fnotreset=	 (1<<6),	/*  reset if not set */
+	 FSMIena=	 (1<<4),	/*  enable change interrupt on SMI */
 	Rcsc= 		0x4,		/* card status change */
 	Rcscic= 	0x5,		/* card status change interrupt config */
 	 Fchangeena=	 (1<<3),	/*  card changed */
@@ -252,16 +254,16 @@ enum {
 static Cardbus cbslots[Nslots];
 static int nslots;
 
-static ulong exponent[8] = { 
-	1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 
+static ulong exponent[8] = {
+	1, 10, 100, 1000, 10000, 100000, 1000000, 10000000,
 };
 
 static ulong vmant[16] = {
 	10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80, 90,
 };
 
-static ulong mantissa[16] = { 
-	0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80, 
+static ulong mantissa[16] = {
+	0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80,
 };
 
 static char Enocard[] = "No card in slot";
@@ -278,13 +280,8 @@ static Cmdtab pccardctlmsg[] =
 	CMpower,	"power",	1,
 };
 
-static void cbint(Ureg *, void *);
 static int powerup(Cardbus *);
 static void configure(Cardbus *);
-static void managecard(Cardbus *);
-static void cardmanager(void *);
-static void eject(Cardbus *);
-static void interrupt(Ureg *, void *);
 static void powerdown(Cardbus *cb);
 static void unconfigure(Cardbus *cb);
 
@@ -491,7 +488,7 @@ cbinterrupt(Ureg *, void *)
 		rdreg(cb, Rcsc);	/* Ack the interrupt */
 
 		if(DEBUG)
-			print("#Y%ld: interrupt: event %.8lX, state %.8lX, (%s)\n", 
+			print("#Y%ld: interrupt: event %.8lX, state %.8lX, (%s)\n",
 				cb - cbslots, event, state, states[cb->state]);
 
 		if (event & SE_CCD) {
@@ -523,7 +520,7 @@ devpccardlink(void)
 	char *p;
 	void *baddrva;
 
-	if (initialized) 
+	if (initialized)
 		return;
 	initialized = 1;
 
@@ -560,7 +557,7 @@ devpccardlink(void)
 
 		cb->pci = pci;
 		cb->variant = &variant[i];
-		
+
 		if (pci->vid != TI_vid) {
 			// Gross hack, needs a fix.  Inherit the mappings from 9load
 			// for the TIs (pb)
@@ -584,7 +581,7 @@ devpccardlink(void)
 		}
 
 		// Patch up intl if needed.
-		if ((pin = pcicfgr8(pci, PciINTP)) != 0 && 
+		if ((pin = pcicfgr8(pci, PciINTP)) != 0 &&
 		    (pci->intl == 0xff || pci->intl == 0)) {
 			pci->intl = pciipin(nil, pin);
 			pcicfgw8(pci, PciINTL, pci->intl);
@@ -600,16 +597,16 @@ devpccardlink(void)
 
 				cc = pcicfgr8(pci, TI1131xCC);
 				cc &= ~(TI113X_CC_PCI_IRQ_ENA |
-						TI113X_CC_PCI_IREQ | 
+						TI113X_CC_PCI_IREQ |
 						TI113X_CC_PCI_CSC |
 						TI113X_CC_ZVENABLE);
-				cc |= TI113X_CC_PCI_IRQ_ENA | 
-						TI113X_CC_PCI_IREQ | 
+				cc |= TI113X_CC_PCI_IRQ_ENA |
+						TI113X_CC_PCI_IREQ |
 						TI113X_CC_SPKROUTEN;
 				pcicfgw8(pci, TI1131xCC, cc);
 
 				// PCI interrupts only
-				pcicfgw8(pci, TI1131xDC, 
+				pcicfgw8(pci, TI1131xDC,
 						pcicfgr8(pci, TI1131xDC) & ~6);
 
 				// CSC ints to PCI bus.
@@ -620,10 +617,10 @@ devpccardlink(void)
 			}
 			else if (pci->did == TI_1420_did) {
 				// Disable Vcc protection
-				pcicfgw32(cb->pci, 0x80, 
+				pcicfgw32(cb->pci, 0x80,
 					pcicfgr32(cb->pci, 0x80) | (1 << 21));
 			}
-			
+
 			pcicfgw16(cb->pci, PciPMC, pcicfgr16(cb->pci, PciPMC) & ~3);
 		}
 		if (pci->vid == O2_vid) {
@@ -652,7 +649,7 @@ devpccardlink(void)
 		/* Don't really know what to do with this... */
 		i82365probe(cb, LegacyAddr, LegacyAddr + 1);
 
-		print("#Y%ld: %s, %.8ulX intl %d\n", cb - cbslots, 
+		print("#Y%ld: %s, %.8ulX intl %d\n", cb - cbslots,
 			 variant[i].name, baddr, pci->intl);
 	}
 
@@ -681,7 +678,7 @@ devpccardlink(void)
 
 		/* Ack and enable interrupts on all events */
 		//cb->regs[SocketEvent] = cb->regs[SocketEvent];
-		cb->regs[SocketMask] |= 0xF;	
+		cb->regs[SocketMask] |= 0xF;
 		wrreg(cb, Rcscic, 0xC);
 	}
 }
@@ -720,15 +717,15 @@ powerup(Cardbus *cb)
 	}
 
 	if ((state & SS_3V) == 0 && (state & SS_5V) == 0) {
-		print("#Y%ld: Unsupported voltage, powering down card!\n", 
+		print("#Y%ld: Unsupported voltage, powering down card!\n",
 			cb - cbslots);
 		cb->regs[SocketControl] = 0;
 		return 0;
 	}
 
 	if(DEBUG)
-		print("#Y%ld: card %spowered at %d volt\n", cb - cbslots, 
-			(state & SS_POWER)? "": "not ", 
+		print("#Y%ld: card %spowered at %d volt\n", cb - cbslots,
+			(state & SS_POWER)? "": "not ",
 			(state & SS_3V)? 3: (state & SS_5V)? 5: -1);
 
 	/* Power up the card
@@ -770,13 +767,13 @@ powerdown(Cardbus *cb)
 static void
 configure(Cardbus *cb)
 {
-	Pcidev *pci;
+	int i, r;
 	ulong size, bar;
-	int i, ioindex, memindex, r;
+	Pcidev *pci;
+	ulong membase, iobase, memlen, iolen, rombase, romlen;
 
 	if(DEBUG)
-		print("configuring slot %ld (%s)\n",
-			cb - cbslots, states[cb->state]);
+		print("configuring slot %ld (%s)\n", cb - cbslots, states[cb->state]);
 	if (cb->state == SlotConfigured)
 		return;
 	engine(cb, CardConfigured);
@@ -790,8 +787,45 @@ configure(Cardbus *cb)
 
 	/* Scan the CardBus for new PCI devices */
 	pciscan(pcicfgr8(cb->pci, PciSBN), &cb->pci->bridge);
-	pci = cb->pci->bridge;
-	while (pci) {
+
+	/*
+	 * size the devices on the bus, reserve a minimum for devices arriving later,
+	 * allow for ROM space, allocate space, and set the cardbus mapping registers
+	 */
+	pcibussize(cb->pci->bridge, &memlen, &iolen);	/* TO DO: need initial alignments */
+
+	romlen = 0;
+	for(pci = cb->pci->bridge; pci != nil; pci = pci->list){
+		size = pcibarsize(pci, PciEBAR0);
+		if(size > 0){
+			pci->rom.bar = -1;
+			pci->rom.size = size;
+			romlen += size;
+		}
+	}
+
+	if(iolen < 512)
+		iolen = 512;
+	iobase = ioreserve(~0, iolen, 0, "cardbus");
+	pcicfgw32(cb->pci, PciCBIBR0, iobase);
+	pcicfgw32(cb->pci, PciCBILR0, iobase + iolen-1);
+	pcicfgw32(cb->pci, PciCBIBR1, 0);
+	pcicfgw32(cb->pci, PciCBILR1, 0);
+
+	rombase = memlen;
+	memlen += romlen;
+	if(memlen < 1*1024*1024)
+		memlen = 1*1024*1024;
+	membase = upaalloc(memlen, 4*1024*1024);	/* TO DO: better alignment */
+	pcicfgw32(cb->pci, PciCBMBR0, membase);
+	pcicfgw32(cb->pci, PciCBMLR0, membase + memlen-1);
+	pcicfgw32(cb->pci, PciCBMBR1, 0);
+	pcicfgw32(cb->pci, PciCBMLR1, 0);
+
+//	pcibussize(cb->pci->bridge, &membase, &iobase);	/* now assign them */
+	rombase += membase;
+
+	for(pci = cb->pci->bridge; pci != nil; pci = pci->list){
 		r = pcicfgr16(pci, PciPCR);
 		r &= ~(PciPCR_IO|PciPCR_MEM);
 		pcicfgw16(pci, PciPCR, r);
@@ -802,74 +836,28 @@ configure(Cardbus *cb)
 		 * CardBus cards.
 		 * XXX, need to support multifunction cards
 		 */
-		memindex = ioindex = 0;
-		for (i = 0; i != Nbars; i++) {
-
-			if (pci->mem[i].size == 0)
+		for(i = 0; i < Nbars; i++) {
+			if(pci->mem[i].size == 0)
 				continue;
-			if (pci->mem[i].bar & 1) {
-
-				// Allocate I/O space
-				if (ioindex > 1) {
-					print("#Y%ld: WARNING: Can only configure 2 I/O slots\n", cb - cbslots);
-					continue;
+			bar = pci->mem[i].bar;
+			if(bar & 1)
+				bar += iobase;
+			else
+				bar += membase;
+			pci->mem[i].bar = bar;
+			pcicfgw32(pci, PciBAR0 + 4*i, bar);
+			if((bar & 1) == 0){
+				print("%T mem[%d] %8.8lux %d\n", pci->tbdf, i, bar, pci->mem[i].size);
+				if(bar & 0x80){	/* TO DO: enable prefetch */
+					;
 				}
-				bar = ioreserve(-1, pci->mem[i].size, 0, "cardbus");
-
-				pci->mem[i].bar = bar | 1;
-				pcicfgw32(pci, PciBAR0 + i * sizeof(ulong), 
-					          pci->mem[i].bar);
-				pcicfgw16(cb->pci, PciCBIBR0 + ioindex * 8, bar);
-				pcicfgw16(cb->pci, PciCBILR0 + ioindex * 8, 
-						 bar + pci->mem[i].size - 1);
-				if(DEBUG)
-					print("ioindex[%d] %.8luX (%d)\n", 
-						ioindex, bar, pci->mem[i].size);
-				ioindex++;
-				continue;
 			}
-
-			// Allocating memory space
-			if (memindex > 1) {
-				print("#Y%ld: WARNING: Can only configure 2 memory slots\n", cb - cbslots);
-				continue;
-			}
-
-			bar = upaalloc(pci->mem[i].size, BY2PG);
-			pci->mem[i].bar = bar | (pci->mem[i].bar & 0x80);
-			pcicfgw32(pci, PciBAR0 + i * sizeof(ulong), pci->mem[i].bar);
-			pcicfgw32(cb->pci, PciCBMBR0 + memindex * 8, bar);
-			pcicfgw32(cb->pci, PciCBMLR0 + memindex * 8, 
-					  bar + pci->mem[i].size - 1);
-
-			if (pci->mem[i].bar & 0x80) {
-				/* Enable prefetch */
-				r = pcicfgr16(cb->pci, PciBCR);
-				r |= 1 << (8 + memindex);
-				pcicfgw16(cb->pci, PciBCR, r);
-			}
-
-			if(DEBUG)
-				print("memindex[%d] %.8luX (%d)\n", 
-					  memindex, bar, pci->mem[i].size);
-			memindex++;
 		}
-
-		if ((size = pcibarsize(pci, PciEBAR0)) > 0) {
-
-			if (memindex > 1)
-				print("#Y%ld: WARNING: Too many memory spaces, not mapping ROM space\n",
-					cb - cbslots);
-			else {
-				pci->rom.bar = upaalloc(size, BY2PG);
-				pci->rom.size = size;
-
-				pcicfgw32(pci, PciEBAR0, pci->rom.bar);
-				pcicfgw32(cb->pci, PciCBMBR0 + memindex * 8,
-						 pci->rom.bar);
-				pcicfgw32(cb->pci, PciCBMLR0 + memindex * 8, 
-						 pci->rom.bar + pci->rom.size - 1);
-			}
+		if((size = pcibarsize(pci, PciEBAR0)) > 0) {	/* TO DO: can this be done by pci.c? */
+			pci->rom.bar = rombase;
+			pci->rom.size = size;
+			rombase += size;
+			pcicfgw32(pci, PciEBAR0, pci->rom.bar);
 		}
 
 		/* Set the basic PCI registers for the device */
@@ -886,11 +874,9 @@ configure(Cardbus *cb)
 			pcicfgw8(pci, PciINTL, pci->intl);
 
 			/* Route interrupts to INTA#/B# */
-			pcicfgw16(cb->pci, PciBCR, 
+			pcicfgw16(cb->pci, PciBCR,
 					  pcicfgr16(cb->pci, PciBCR) & ~(1 << 7));
 		}
-			
-		pci = pci->list;
 	}
 }
 
@@ -909,9 +895,9 @@ unconfigure(Cardbus *cb)
 	}
 
 	pci = cb->pci->bridge;
-	if (pci == nil) 
+	if (pci == nil)
 		return;		/* Not configured */
-	cb->pci->bridge = nil;		
+	cb->pci->bridge = nil;
 
 	memindex = ioindex = 0;
 	while (pci) {
@@ -922,7 +908,7 @@ unconfigure(Cardbus *cb)
 				continue;
 			if (pci->mem[i].bar & 1) {
 				iofree(pci->mem[i].bar & ~1);
-				pcicfgw16(cb->pci, PciCBIBR0 + ioindex * 8, 
+				pcicfgw16(cb->pci, PciCBIBR0 + ioindex * 8,
 						 (ushort)-1);
 				pcicfgw16(cb->pci, PciCBILR0 + ioindex * 8, 0);
 				ioindex++;
@@ -1020,9 +1006,9 @@ pccard_pcmspecial(char *idstr, ISAConf *isa)
 
 		lock(cb);
 		if (cb->state == SlotConfigured &&
-		    cb->type == PC16 && 
+		    cb->type == PC16 &&
 		    !cb->special &&
-		    strstr(cb->linfo.verstr, idstr)) 
+		    strstr(cb->linfo.verstr, idstr))
 			break;
 		unlock(cb);
 	}
@@ -1054,7 +1040,7 @@ pccard_pcmspecial(char *idstr, ISAConf *isa)
 		index = strtol(&isa->opt[i][6], &cp, 0);
 		if(cp == &isa->opt[i][6] || index >= pi->nctab) {
 			unlock(cb);
-			print("#Y%d: Cannot find index %d in conf table\n", 
+			print("#Y%d: Cannot find index %d in conf table\n",
 				 (int)(cb - cbslots), index);
 			return -1;
 		}
@@ -1069,7 +1055,7 @@ pccard_pcmspecial(char *idstr, ISAConf *isa)
 			ct = pi->defctab;
 		else
 			ct = pi->ctab;
-	
+
 		/* try for best match */
 		if(ct->nio == 0
 		|| ct->io[0].start != isa->port || ((1<<irq) & ct->irqs) == 0){
@@ -1185,61 +1171,6 @@ pccard_pcmspecialclose(int slotno)
 	cb->special = 0;
 }
 
-static int
-xcistuple(int slotno, int tuple, int subtuple, void *v, int nv, int attr)
-{
-	PCMmap *m;
-	Cisdat cis;
-	int i, l;
-	uchar *p;
-	uchar type, link, n, c;
-	int this, subtype;
-	Cardbus *cb = &cbslots[slotno];
-
-	m = isamap(cb, 0, 0, attr);
-	if(m == 0)
-		return -1;
-
-	cis.cisbase = KADDR(m->isa);
-	cis.cispos = 0;
-	cis.cisskip = attr ? 2 : 1;
-	cis.cislen = m->len;
-
-	/* loop through all the tuples */
-	for(i = 0; i < 1000; i++){
-		this = cis.cispos;
-		if(readc(&cis, &type) != 1)
-			break;
-		if(type == 0xFF)
-			break;
-		if(readc(&cis, &link) != 1)
-			break;
-		if(link == 0xFF)
-			break;
-
-		n = link;
-		if (link > 1 && subtuple != -1) {
-			if (readc(&cis, &c) != 1)
-				break;
-			subtype = c;
-			n--;
-		} else
-			subtype = -1;
-
-		if(type == tuple && subtype == subtuple) {
-			p = v;
-			for(l=0; l<nv && l<n; l++)
-				if(readc(&cis, p++) != 1)
-					break;
-			isaunmap(m);
-			return nv;
-		}
-		cis.cispos = this + (2+link);
-	}
-	isaunmap(m);
-	return -1;
-}
-
 static Chan*
 pccardattach(char *spec)
 {
@@ -1285,10 +1216,10 @@ pccardgen(Chan *c, char*, Dirtab *, int , int i, Dir *dp)
 		snprint(up->genbuf, sizeof up->genbuf, "cb%dctl", slotno);
 	}
 	else {
-		/* Entries for memory regions.  I'll implement them when 
+		/* Entries for memory regions.  I'll implement them when
 		     needed. (pb) */
 	}
-	qid.vers = 0;	
+	qid.vers = 0;
 	qid.type = QTFILE;
 	devdir(c, qid, up->genbuf, len, eve, 0660, dp);
 	return 1;
@@ -1359,7 +1290,7 @@ pccardread(Chan *c, void *a, long n, vlong offset)
 		buf = p = malloc(READSTR);
 		buf[0] = 0;
 		e = p + READSTR;
-	
+
 		cb = &cbslots[SLOTNO(c)];
 		lock(cb);
 		p = seprint(p, e, "slot %ld: %s; ", cb - cbslots, states[cb->state]);
@@ -1375,13 +1306,13 @@ pccardread(Chan *c, void *a, long n, vlong offset)
 				int i;
 
 				while (pci) {
-					p = seprint(p, e, "%.4uX %.4uX; irq %d\n", 
+					p = seprint(p, e, "%.4uX %.4uX; irq %d\n",
 							  pci->vid, pci->did, pci->intl);
 					for (i = 0; i != Nbars; i++)
 						if (pci->mem[i].size)
-							p = seprint(p, e, 
+							p = seprint(p, e,
 									  "\tmem[%d] %.8ulX (%.8uX)\n",
-									  i, pci->mem[i].bar, 
+									  i, pci->mem[i].bar,
 									  pci->mem[i].size);
 					if (pci->rom.size)
 						p = seprint(p, e, "\tROM %.8ulX (%.8uX)\n",
@@ -1403,7 +1334,7 @@ pccardread(Chan *c, void *a, long n, vlong offset)
 					int j;
 
 					ct = &pi->ctab[i];
-					p = seprint(p, e, 
+					p = seprint(p, e,
 						"\tconfiguration[%d] irqs %.4uX; vpp %d, %d; %s\n",
 							  i, ct->irqs, ct->vpp1, ct->vpp2,
 							  (ct == pi->defctab)? "(default);": "");
@@ -1416,7 +1347,7 @@ pccardread(Chan *c, void *a, long n, vlong offset)
 			break;
 		}
 		unlock(cb);
-			
+
 		n = readstr(offset, a, n, buf);
 		free(buf);
 		return n;
@@ -1470,7 +1401,7 @@ Dev pccarddevtab = {
 	"cardbus",
 
 	devreset,
-	devinit,	
+	devinit,
 	devshutdown,
 	pccardattach,
 	pccardwalk,

+ 1 - 0
sys/src/9/pc/ether82557.c

@@ -928,6 +928,7 @@ i82557pci(void)
 		case 0x1050:		/* Intel 82562EZ */
 		case 0x1039:		/* Intel 82801BD PRO/100 VE */
 		case 0x103A:		/* Intel 82562 PRO/100 VE */
+		case 0x103D:		/* Intel 82562 PRO/100 VE */
 		case 0x1064:		/* Intel 82562 PRO/100 VE */
 		case 0x2449:		/* Intel 82562ET */
 			nop = 1;

+ 3 - 2
sys/src/9/pc/fns.h

@@ -77,8 +77,6 @@ void*	kaddr(ulong);
 void	kbdenable(void);
 void	kbdinit(void);
 #define	kmapinval()
-void	lapicclock(Ureg*, void*);
-void	lapictimerset(uvlong);
 void	lgdt(ushort[3]);
 void	lidt(ushort[3]);
 void	links(void);
@@ -103,6 +101,7 @@ void	outsl(int, void*, int);
 ulong	paddr(void*);
 int	pciscan(int, Pcidev**);
 ulong	pcibarsize(Pcidev*, int);
+void	pcibussize(Pcidev*, ulong*, ulong*);
 int	pcicfgr8(Pcidev*, int);
 int	pcicfgr16(Pcidev*, int);
 int	pcicfgr32(Pcidev*, int);
@@ -111,6 +110,7 @@ void	pcicfgw16(Pcidev*, int, int);
 void	pcicfgw32(Pcidev*, int, int);
 void	pciclrbme(Pcidev*);
 void	pciclrioe(Pcidev*);
+void	pciclrmwi(Pcidev*);
 int	pcigetpms(Pcidev*);
 void	pcihinv(Pcidev*);
 uchar	pciipin(Pcidev*, uchar);
@@ -119,6 +119,7 @@ Pcidev* pcimatchtbdf(int);
 void	pcireset(void);
 void	pcisetbme(Pcidev*);
 void	pcisetioe(Pcidev*);
+void	pcisetmwi(Pcidev*);
 int	pcisetpms(Pcidev*, int);
 void	pcmcisread(PCMslot*);
 int	pcmcistuple(int, int, int, void*, int);

+ 10 - 13
sys/src/9/pc/pci.c

@@ -176,10 +176,6 @@ pcibusmap(Pcidev *root, ulong *pmema, ulong *pioa, int wrreg)
 	int ntb, i, size, rno, hole;
 	ulong v, mema, ioa, sioa, smema, base, limit;
 	Pcisiz *table, *tptr, *mtb, *itb;
-	extern void qsort(void*, long, long, int (*)(void*, void*));
-
-	if(!nobios)
-		return;
 
 	ioa = *pioa;
 	mema = *pmema;
@@ -763,6 +759,14 @@ pcirouting(void)
 
 static void pcireservemem(void);
 
+void
+pcibussize(Pcidev *root, ulong *msize, ulong *iosize)
+{
+	*msize = 0;
+	*iosize = 0;
+	pcibusmap(root, msize, iosize, 0);
+}
+
 static void
 pcicfginit(void)
 {
@@ -854,8 +858,7 @@ pcicfginit(void)
 			  * If we have found a PCI-to-Cardbus bridge, make sure
 			  * it has no valid mappings anymore.  
 			  */
-			pci = pciroot;
-			while (pci) {
+			for(pci = pciroot; pci != nil; pci = pci->link){
 				if (pci->ccrb == 6 && pci->ccru == 7) {
 					ushort bcr;
 
@@ -864,7 +867,6 @@ pcicfginit(void)
 					pcicfgw16(pci, PciBCR, 0x40 | bcr);
 					delay(50);
 				}
-				pci = pci->link;
 			}
 		}
 	}
@@ -876,12 +878,7 @@ pcicfginit(void)
 		/*
 		 * Work out how big the top bus is
 		 */
-		mema = 0;
-		ioa = 0;
-		pcibusmap(pciroot, &mema, &ioa, 0);
-
-		DBG("Sizes: mem=%8.8lux size=%8.8lux io=%8.8lux\n",
-			mema, pcimask(mema), ioa);
+		pcibussize(pciroot, &mema, &ioa);
 	
 		/*
 		 * Align the windows and map it