Browse Source

Plan 9 from Bell Labs 2008-10-09

David du Colombier 12 years ago
parent
commit
c79c03984b

+ 4 - 4
dist/replica/_plan9.db

@@ -9195,7 +9195,7 @@ sys/src/boot/pc/devfloppy.c - 664 sys sys 1212010456 15657
 sys/src/boot/pc/devfloppy.h - 664 sys sys 1032409559 4081
 sys/src/boot/pc/devi82365.c - 664 sys sys 1144961189 15051
 sys/src/boot/pc/devpccard.c - 664 sys sys 1153333456 33897
-sys/src/boot/pc/devsd.c - 664 sys sys 1212259573 11548
+sys/src/boot/pc/devsd.c - 664 sys sys 1223515526 11557
 sys/src/boot/pc/dma.c - 664 sys sys 1015007949 4972
 sys/src/boot/pc/dosboot.c - 664 sys sys 1212010488 11337
 sys/src/boot/pc/dosfs.h - 664 sys sys 1032215924 1467
@@ -9237,13 +9237,13 @@ sys/src/boot/pc/kfs.h - 664 sys sys 1032215924 861
 sys/src/boot/pc/kfsboot.c - 664 sys sys 1032215914 4788
 sys/src/boot/pc/l.s - 664 sys sys 1216786858 18260
 sys/src/boot/pc/lib.h - 664 sys sys 1212090562 3280
-sys/src/boot/pc/load.c - 664 sys sys 1218660619 11499
+sys/src/boot/pc/load.c - 664 sys sys 1223515569 11433
 sys/src/boot/pc/mbr.s - 664 sys sys 1015007953 6234
 sys/src/boot/pc/mem.h - 664 sys sys 1190921475 3437
 sys/src/boot/pc/memory.c - 664 sys sys 1212010326 10266
 sys/src/boot/pc/mkfile - 664 sys sys 1216788017 3614
 sys/src/boot/pc/noether.c - 664 sys sys 1193336537 416
-sys/src/boot/pc/part.c - 664 sys sys 1200690166 7158
+sys/src/boot/pc/part.c - 664 sys sys 1223515556 7355
 sys/src/boot/pc/pbs.s - 664 sys sys 1143465387 8291
 sys/src/boot/pc/pbsdebug.s - 664 sys sys 1205786244 6371
 sys/src/boot/pc/pbslba.s - 664 sys sys 1186031549 8180
@@ -9254,7 +9254,7 @@ sys/src/boot/pc/queue.c - 664 sys sys 1015007954 566
 sys/src/boot/pc/sd.h - 664 sys sys 1200690169 2249
 sys/src/boot/pc/sd53c8xx.c - 664 sys sys 1186031515 52082
 sys/src/boot/pc/sd53c8xx.i - 664 sys sys 1015007955 27245
-sys/src/boot/pc/sdaoe.c - 664 sys sys 1204324647 11381
+sys/src/boot/pc/sdaoe.c - 664 sys sys 1223515593 11739
 sys/src/boot/pc/sdata.c - 664 sys sys 1213134120 39148
 sys/src/boot/pc/sdbios.c - 664 sys sys 1212010334 3280
 sys/src/boot/pc/sdiahci.c - 664 sys sys 1213134135 28620

+ 4 - 4
dist/replica/plan9.db

@@ -9195,7 +9195,7 @@ sys/src/boot/pc/devfloppy.c - 664 sys sys 1212010456 15657
 sys/src/boot/pc/devfloppy.h - 664 sys sys 1032409559 4081
 sys/src/boot/pc/devi82365.c - 664 sys sys 1144961189 15051
 sys/src/boot/pc/devpccard.c - 664 sys sys 1153333456 33897
-sys/src/boot/pc/devsd.c - 664 sys sys 1212259573 11548
+sys/src/boot/pc/devsd.c - 664 sys sys 1223515526 11557
 sys/src/boot/pc/dma.c - 664 sys sys 1015007949 4972
 sys/src/boot/pc/dosboot.c - 664 sys sys 1212010488 11337
 sys/src/boot/pc/dosfs.h - 664 sys sys 1032215924 1467
@@ -9237,13 +9237,13 @@ sys/src/boot/pc/kfs.h - 664 sys sys 1032215924 861
 sys/src/boot/pc/kfsboot.c - 664 sys sys 1032215914 4788
 sys/src/boot/pc/l.s - 664 sys sys 1216786858 18260
 sys/src/boot/pc/lib.h - 664 sys sys 1212090562 3280
-sys/src/boot/pc/load.c - 664 sys sys 1218660619 11499
+sys/src/boot/pc/load.c - 664 sys sys 1223515569 11433
 sys/src/boot/pc/mbr.s - 664 sys sys 1015007953 6234
 sys/src/boot/pc/mem.h - 664 sys sys 1190921475 3437
 sys/src/boot/pc/memory.c - 664 sys sys 1212010326 10266
 sys/src/boot/pc/mkfile - 664 sys sys 1216788017 3614
 sys/src/boot/pc/noether.c - 664 sys sys 1193336537 416
-sys/src/boot/pc/part.c - 664 sys sys 1200690166 7158
+sys/src/boot/pc/part.c - 664 sys sys 1223515556 7355
 sys/src/boot/pc/pbs.s - 664 sys sys 1143465387 8291
 sys/src/boot/pc/pbsdebug.s - 664 sys sys 1205786244 6371
 sys/src/boot/pc/pbslba.s - 664 sys sys 1186031549 8180
@@ -9254,7 +9254,7 @@ sys/src/boot/pc/queue.c - 664 sys sys 1015007954 566
 sys/src/boot/pc/sd.h - 664 sys sys 1200690169 2249
 sys/src/boot/pc/sd53c8xx.c - 664 sys sys 1186031515 52082
 sys/src/boot/pc/sd53c8xx.i - 664 sys sys 1015007955 27245
-sys/src/boot/pc/sdaoe.c - 664 sys sys 1204324647 11381
+sys/src/boot/pc/sdaoe.c - 664 sys sys 1223515593 11739
 sys/src/boot/pc/sdata.c - 664 sys sys 1213134120 39148
 sys/src/boot/pc/sdbios.c - 664 sys sys 1212010334 3280
 sys/src/boot/pc/sdiahci.c - 664 sys sys 1213134135 28620

+ 4 - 0
dist/replica/plan9.log

@@ -36157,3 +36157,7 @@
 1223323204 1 c sys/src/cmd/upas/smtp/smtpd.c - 664 sys sys 1223322786 33455
 1223350205 0 c 386/bin/dossrv - 775 sys sys 1223348950 136682
 1223350205 1 c 386/bin/upas/smtpd - 775 sys sys 1223348950 336055
+1223515804 0 c sys/src/boot/pc/devsd.c - 664 sys sys 1223515526 11557
+1223515804 1 c sys/src/boot/pc/load.c - 664 sys sys 1223515569 11433
+1223515804 2 c sys/src/boot/pc/part.c - 664 sys sys 1223515556 7355
+1223515804 3 c sys/src/boot/pc/sdaoe.c - 664 sys sys 1223515593 11739

+ 4 - 4
sys/src/boot/pc/devsd.c

@@ -15,7 +15,6 @@
 
 #define parttrace 0
 
-
 extern SDifc* sdifc[];
 
 static SDev* sdlist;
@@ -490,10 +489,11 @@ long
 sdbio(SDunit *unit, SDpart *pp, void* va, long len, vlong off)
 {
 	long l;
-	ulong bno, max, nb, offset;
-	static uchar *b;
+	ulong offset;
+	uvlong bno, max, nb;
 	char *a;
 	static ulong bsz;
+	static uchar *b;
 
 	a = va;
 memset(a, 0xDA, len);
@@ -538,7 +538,7 @@ memset(a, 0xDA, len);
 //	if(b == nil)
 //		return 0;
 
-	offset = off%unit->secsize;
+	offset = off % unit->secsize;
 	if((l = unit->dev->ifc->bio(unit, 0, 0, b, nb, bno)) < 0) {
 //		sdfree(b);
 		return 0;

+ 4 - 14
sys/src/boot/pc/load.c

@@ -95,33 +95,23 @@ extern SDifc sdiahciifc;
 extern SDifc sdaoeifc;
 extern SDifc sdbiosifc;
 
-#ifdef NOSCSI
-
-SDifc* sdifc[] = {
-	&sdataifc,
-	&sdiahciifc,
-	&sdbiosifc,
-	&sdaoeifc,
-	nil,
-};
-
-#else
-
+#ifndef NOSCSI
 extern SDifc sdmylexifc;
 extern SDifc sd53c8xxifc;
+#endif NOSCSI
 
 SDifc* sdifc[] = {
 	&sdataifc,
 	&sdiahciifc,
+#ifndef NOSCSI
 	&sdmylexifc,
 	&sd53c8xxifc,
+#endif
 	&sdbiosifc,
 	&sdaoeifc,
 	nil,
 };
 
-#endif NOSCSI
-
 typedef struct Mode Mode;
 
 enum {

+ 17 - 7
sys/src/boot/pc/part.c

@@ -13,6 +13,7 @@ enum {
 
 uchar *mbrbuf, *partbuf;
 int nbuf;
+
 #define trace 0
 
 int
@@ -105,7 +106,7 @@ p9part(SDunit *unit, char *name)
 	char *field[4], *line[Npart+1];
 	uvlong start, end;
 	int i, n;
-	
+
 	p = sdfindpart(unit, name);
 	if(p == nil)
 		return;
@@ -126,7 +127,7 @@ p9part(SDunit *unit, char *name)
 		if(getfields(line[i], field, 4, ' ') != 4)
 			break;
 		start = strtoull(field[2], 0, 0);
-		end = strtoull(field[3], 0, 0);
+		end   = strtoull(field[3], 0, 0);
 		if(start >= end || end > unit->sectors)
 			break;
 		sdaddpart(unit, field[1], p->start+start, p->start+end);
@@ -160,16 +161,18 @@ mbrpart(SDunit *unit)
 
 	taboffset = 0;
 	dp = (Dospart*)&mbrbuf[0x1BE];
-	if(1) {
+	{
 		/* get the MBR (allowing for DMDDO) */
-		if(tsdbio(unit, &unit->part[0], mbrbuf, (vlong)taboffset*unit->secsize, 1) < 0)
+		if(tsdbio(unit, &unit->part[0], mbrbuf,
+		    (vlong)taboffset * unit->secsize, 1) < 0)
 			return -1;
 		for(i=0; i<4; i++)
 			if(dp[i].type == DMDDO) {
 				if(trace)
 					print("DMDDO partition found\n");
 				taboffset = 63;
-				if(tsdbio(unit, &unit->part[0], mbrbuf, (vlong)taboffset*unit->secsize, 1) < 0)
+				if(tsdbio(unit, &unit->part[0], mbrbuf,
+				    (vlong)taboffset * unit->secsize, 1) < 0)
 					return -1;
 				i = -1;	/* start over */
 			}
@@ -183,7 +186,8 @@ mbrpart(SDunit *unit)
 	havedos = 0;
 	firstxpart = 0;
 	for(;;) {
-		if(tsdbio(unit, &unit->part[0], mbrbuf, (vlong)taboffset*unit->secsize, 1) < 0)
+		if(tsdbio(unit, &unit->part[0], mbrbuf,
+		    (vlong)taboffset * unit->secsize, 1) < 0)
 			return -1;
 		if(trace) {
 			if(firstxpart)
@@ -336,9 +340,15 @@ partition(SDunit *unit)
 		nbuf = unit->secsize;
 	}
 
+	/*
+	 * there might be no mbr (e.g. on a very large device), so look for
+	 * a bare plan 9 partition table if mbrpart fails.
+	 */
 	if((type & NEW) && mbrpart(unit) >= 0){
-		/* nothing to do */;
+		/* nothing to do */
 	}
+	else if (type & NEW)
+		p9part(unit, "data");
 	else if(type & OLD)
 		oldp9part(unit);
 }

+ 46 - 34
sys/src/boot/pc/sdaoe.c

@@ -1,5 +1,5 @@
 /*
- * aoe sd bootstrap driver, copyright © 2007 coraid
+ * aoe (ata over ethernet) sd bootstrap driver, copyright © 2007 coraid
  */
 
 #include "u.h"
@@ -11,10 +11,9 @@
 #include "sd.h"
 #include "aoe.h"
 
-#define uprint(...)	snprint(up->genbuf, sizeof up->genbuf, __VA_ARGS__);
-
 enum {
-	Nctlr	= 4,
+	NCtlr	= 4,
+	Ctlrlet = 'e',		/* first sd controller letter */
 };
 
 enum {
@@ -59,6 +58,9 @@ struct Ctlr{
 
 static	Ctlr	*head;
 static	Ctlr	*tail;
+// static Ctlr	aoectlr[NCtlr];
+// static SDev	sdevs[NCtlr];
+// static int	naoectlr;
 
 static	int	aoeether[10];
 
@@ -195,7 +197,8 @@ ataidentify(Ctlr *c, ushort *id)
 	idmove(c->firmware, id+23, 8);
 	idmove(c->model, id+27, 40);
 
-print("aoe discovers %d.%d: %s %s\n", c->major, c->minor, c->model, c->serial);
+	print("aoe: discovered %d.%d: %s %s\n",
+		c->major, c->minor, c->model, c->serial);
 
 	c->sectors = s;
 	c->mediachange = 1;
@@ -396,19 +399,6 @@ again:
 static char 	*probef[32];
 static int 	nprobe;
 
-int
-pnpprobeid(char *s)
-{
-	int id;
-
-	if(strlen(s) < 2)
-		return 0;
-	id = 'e';
-	if(s[1] == '!')
-		id = s[0];
-	return id;
-}
-
 int
 tokenize(char *s, char **args, int maxargs)
 {
@@ -428,7 +418,7 @@ tokenize(char *s, char **args, int maxargs)
 	return nargs;
 }
 
-int
+static int
 aoepnp0(void)
 {
 	int i;
@@ -436,7 +426,7 @@ aoepnp0(void)
 
 	if((p = getconf("aoeif")) == nil)
 		return 0;
-print("aoeif = %s\n", p);
+//	print("aoepnp0: aoeif=%s\n", p);
 	nprobe = tokenize(p, probef, nelem(probef));
 	for(i = 0; i < nprobe; i++){
 		if(strncmp(probef[i], "ether", 5) != 0)
@@ -449,10 +439,11 @@ print("aoeif = %s\n", p);
 
 	if((p = getconf("aoedev")) == nil)
 		return 0;
-	return nprobe = tokenize(p, probef, nelem(probef));
+	nprobe = tokenize(p, probef, nelem(probef));
+	return nprobe;
 }
 
-int
+static int
 probeshelf(char *s, int *shelf, int *slot)
 {
 	int a, b;
@@ -470,11 +461,11 @@ probeshelf(char *s, int *shelf, int *slot)
 
 	*shelf = a;
 	*slot = b;
-print("  shelf=%d.%d\n", a, b);
+//	print("aoe: found shelf=%d.%d\n", a, b);
 	return 0;
 }
 
-Ctlr*
+static Ctlr*
 pnpprobe(SDev *sd)
 {
 	int shelf, slot;
@@ -501,24 +492,25 @@ pnpprobe(SDev *sd)
  * we may need to pretend we found something
  */
 
-SDev*
+static SDev*
 aoepnp(void)
 {
 	int n, i, id;
-	char *p;
+//	char *p;
 	SDev *h, *t, *s;
 
-	p = getconf("aoeif");
-	if (p)
-		print("aoepnp: aoeif=%s\n", p);
+//	p = getconf("aoeif");
+//	if (p)
+//		print("aoepnp: aoeif=%s\n", p);
 
 	if((n = aoepnp0()) == 0)
 		n = 2;
-	t = h = 0;
+	t = h = nil;
 	for(i = 0; i < n; i++){
-		id = 'e';
+		id = Ctlrlet + i;
+//		print("aoepnp: id sd%C\n", id);
 		s = malloc(sizeof *s);
-		if(s == 0)
+		if(s == nil)
 			break;
 		s->ctlr = 0;
 		s->idno = id;
@@ -631,7 +623,7 @@ putlba(Aoeata *a, vlong lba)
 
 /*
  * you'll need to loop if you want to read more than 2 sectors.  for now
- * i'm cheeting and not bothering with a loop.
+ * i'm cheating and not bothering with a loop.
  */
 static uchar pktbuf[1024 + sizeof(Aoeata)];
 
@@ -719,12 +711,32 @@ aoerio(SDreq *r)
 	return SDok;
 }
 
+static SDev*
+aoeid(SDev* sdev)
+{
+	int i;
+	Ctlr *c, *aec;
+
+	for(; sdev; sdev = sdev->next){
+		if(sdev->ifc != &sdaoeifc)
+			continue;
+		c = sdev->ctlr;
+		i = 0;
+		for(aec = head; aec; aec = aec->next) {
+			if(c == aec)
+				sdev->idno = Ctlrlet + i;
+			i++;
+		}
+	}
+	return nil;
+}
+
 SDifc sdaoeifc = {
 	"aoe",
 
 	aoepnp,
 	nil,		/* legacy */
-	nil,		/* id */
+	aoeid,		/* id */
 	nil,		/* enable */
 	nil,		/* disable */