Browse Source

Plan 9 from Bell Labs 2007-10-29

David du Colombier 16 years ago
parent
commit
e71a7ec9d1

+ 9 - 9
dist/replica/_plan9.db

@@ -1,8 +1,8 @@
 386 - 20000000775 sys sys 1010957353 0
-386/9load - 775 sys sys 1193358654 336916
-386/9loaddebug - 775 sys sys 1193358658 450489
-386/9loadlite - 775 sys sys 1193358657 160216
-386/9loadlitedebug - 775 sys sys 1193358659 236032
+386/9load - 775 sys sys 1193603518 337132
+386/9loaddebug - 775 sys sys 1193603527 450713
+386/9loadlite - 775 sys sys 1193603532 160432
+386/9loadlitedebug - 775 sys sys 1193603540 236256
 386/9pc - 775 sys sys 1192646200 2054406
 386/9pc.gz - 664 sys sys 1192646200 873537
 386/9pccpu - 775 sys sys 1191889923 1749481
@@ -11,7 +11,7 @@
 386/9pcdisk.gz - 664 sys sys 1192741561 973813
 386/9pcf - 775 sys sys 1191889940 2874011
 386/9pcf.gz - 664 sys sys 1191889940 1230163
-386/9pxeload - 775 sys sys 1193358656 336920
+386/9pxeload - 775 sys sys 1193603555 337136
 386/bin - 20000000775 sys sys 1018897690 0
 386/bin/8a - 775 sys sys 1168402260 116604
 386/bin/8c - 775 sys sys 1190520740 367214
@@ -9147,7 +9147,7 @@ sys/src/boot/pc/clock.c - 664 sys sys 1103641772 6425
 sys/src/boot/pc/conf.c - 664 sys sys 1094674484 10217
 sys/src/boot/pc/console.c - 664 sys sys 1094674483 3388
 sys/src/boot/pc/dat.h - 664 sys sys 1190921443 3637
-sys/src/boot/pc/devbios.c - 664 sys sys 1193353518 9297
+sys/src/boot/pc/devbios.c - 664 sys sys 1193607862 9299
 sys/src/boot/pc/devbios.h - 664 sys sys 1193167027 493
 sys/src/boot/pc/devfloppy.c - 664 sys sys 1032215913 15505
 sys/src/boot/pc/devfloppy.h - 664 sys sys 1032409559 4081
@@ -9195,7 +9195,7 @@ 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 1193167045 18213
 sys/src/boot/pc/lib.h - 664 sys sys 1190921452 2847
-sys/src/boot/pc/load.c - 664 sys sys 1193359334 9765
+sys/src/boot/pc/load.c - 664 sys sys 1193607906 9806
 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 1019533021 10272
@@ -9216,8 +9216,8 @@ 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 1193341405 11270
 sys/src/boot/pc/sdata.c - 664 sys sys 1175564193 38846
-sys/src/boot/pc/sdbios.c - 664 sys sys 1193359341 3001
-sys/src/boot/pc/sdiahci.c - 664 sys sys 1191886818 27133
+sys/src/boot/pc/sdbios.c - 664 sys sys 1193607899 3102
+sys/src/boot/pc/sdiahci.c - 664 sys sys 1193607891 27167
 sys/src/boot/pc/sdmylex.c - 664 sys sys 1171783051 28694
 sys/src/boot/pc/sdscsi.c - 664 sys sys 1144961224 7006
 sys/src/boot/pc/trap.c - 664 sys sys 1193167011 7497

+ 9 - 9
dist/replica/plan9.db

@@ -1,8 +1,8 @@
 386 - 20000000775 sys sys 1010957353 0
-386/9load - 775 sys sys 1193358654 336916
-386/9loaddebug - 775 sys sys 1193358658 450489
-386/9loadlite - 775 sys sys 1193358657 160216
-386/9loadlitedebug - 775 sys sys 1193358659 236032
+386/9load - 775 sys sys 1193603518 337132
+386/9loaddebug - 775 sys sys 1193603527 450713
+386/9loadlite - 775 sys sys 1193603532 160432
+386/9loadlitedebug - 775 sys sys 1193603540 236256
 386/9pc - 775 sys sys 1192646200 2054406
 386/9pc.gz - 664 sys sys 1192646200 873537
 386/9pccpu - 775 sys sys 1191889923 1749481
@@ -11,7 +11,7 @@
 386/9pcdisk.gz - 664 sys sys 1192741561 973813
 386/9pcf - 775 sys sys 1191889940 2874011
 386/9pcf.gz - 664 sys sys 1191889940 1230163
-386/9pxeload - 775 sys sys 1193358656 336920
+386/9pxeload - 775 sys sys 1193603555 337136
 386/bin - 20000000775 sys sys 1018897690 0
 386/bin/8a - 775 sys sys 1168402260 116604
 386/bin/8c - 775 sys sys 1190520740 367214
@@ -9147,7 +9147,7 @@ sys/src/boot/pc/clock.c - 664 sys sys 1103641772 6425
 sys/src/boot/pc/conf.c - 664 sys sys 1094674484 10217
 sys/src/boot/pc/console.c - 664 sys sys 1094674483 3388
 sys/src/boot/pc/dat.h - 664 sys sys 1190921443 3637
-sys/src/boot/pc/devbios.c - 664 sys sys 1193353518 9297
+sys/src/boot/pc/devbios.c - 664 sys sys 1193607862 9299
 sys/src/boot/pc/devbios.h - 664 sys sys 1193167027 493
 sys/src/boot/pc/devfloppy.c - 664 sys sys 1032215913 15505
 sys/src/boot/pc/devfloppy.h - 664 sys sys 1032409559 4081
@@ -9195,7 +9195,7 @@ 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 1193167045 18213
 sys/src/boot/pc/lib.h - 664 sys sys 1190921452 2847
-sys/src/boot/pc/load.c - 664 sys sys 1193359334 9765
+sys/src/boot/pc/load.c - 664 sys sys 1193607906 9806
 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 1019533021 10272
@@ -9216,8 +9216,8 @@ 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 1193341405 11270
 sys/src/boot/pc/sdata.c - 664 sys sys 1175564193 38846
-sys/src/boot/pc/sdbios.c - 664 sys sys 1193359341 3001
-sys/src/boot/pc/sdiahci.c - 664 sys sys 1191886818 27133
+sys/src/boot/pc/sdbios.c - 664 sys sys 1193607899 3102
+sys/src/boot/pc/sdiahci.c - 664 sys sys 1193607891 27167
 sys/src/boot/pc/sdmylex.c - 664 sys sys 1171783051 28694
 sys/src/boot/pc/sdscsi.c - 664 sys sys 1144961224 7006
 sys/src/boot/pc/trap.c - 664 sys sys 1193167011 7497

+ 14 - 0
dist/replica/plan9.log

@@ -53160,3 +53160,17 @@
 1193430604 0 c sys/src/ape/lib/ap/gen/mktime.c - 664 sys sys 1193430538 2373
 1193441403 0 d sys/src/cmd/grap/find - 775 sys sys 944960999 0
 1193455803 0 c 386/lib/ape/libap.a - 664 sys sys 1193455425 820230
+1193551205 0 c 386/9load - 775 sys sys 1193550843 336800
+1193551205 1 c 386/9loaddebug - 775 sys sys 1193550850 450363
+1193551205 2 c 386/9loadlite - 775 sys sys 1193550854 160104
+1193551205 3 c 386/9loadlitedebug - 775 sys sys 1193550858 235906
+1193551205 4 c 386/9pxeload - 775 sys sys 1193550864 336808
+1193605204 0 c 386/9load - 775 sys sys 1193603518 337132
+1193605204 1 c 386/9loaddebug - 775 sys sys 1193603527 450713
+1193605204 2 c 386/9loadlite - 775 sys sys 1193603532 160432
+1193605204 3 c 386/9loadlitedebug - 775 sys sys 1193603540 236256
+1193605204 4 c 386/9pxeload - 775 sys sys 1193603555 337136
+1193608804 0 c sys/src/boot/pc/load.c - 664 sys sys 1193607906 9806
+1193608804 1 c sys/src/boot/pc/devbios.c - 664 sys sys 1193607862 9299
+1193608804 2 c sys/src/boot/pc/sdbios.c - 664 sys sys 1193607899 3102
+1193608804 3 c sys/src/boot/pc/sdiahci.c - 664 sys sys 1193607891 27167

+ 79 - 85
sys/src/boot/pc/devbios.c

@@ -22,7 +22,6 @@ enum {
 	CF = 1,
 	Flopid = 0,			/* first floppy */
 	Baseid = 0x80,			/* first disk */
-	Sectsize = 512,
 
 	/* bios calls: int 13 disk services */
 	Biosinit	= 0,		/* initialise disk & floppy ctlrs */
@@ -48,10 +47,43 @@ struct Biosdrive {
 struct Biosdev {
 	Devbytes size;
 	Devbytes offset;
-	uchar	id;
+	uchar	id;			/* drive number; e.g., 0x80 */
 	char	type;
+	ushort	sectsz;
 };
 
+typedef struct Extread {
+	uchar	size;
+	uchar	unused1;
+	uchar	nsects;
+	uchar	unused2;
+	ulong	addr;		/* segment:offset */
+	uvlong	stsect;		/* starting sector */
+} Extread;
+typedef struct Edrvparam {
+	/* from edd 1.1 spec */
+	ushort	size;			/* max. buffer size */
+	ushort	flags;
+	ulong	physcyls;
+	ulong	physheads;
+	ulong	phystracksects;
+	uvlong	physsects;
+	ushort	sectsz;
+	void	*dpte;			/* ~0ull: invalid */
+
+	/* remainder from edd 3.0 spec */
+	ushort	key;			/* 0xbedd if present */
+	uchar	dpilen;
+	uchar	unused1;
+	ushort	unused2;
+	char	bustype[4];		/* "PCI" or "ISA" */
+	char	ifctype[8]; /* "ATA", "ATAPI", "SCSI", "USB", "1394", "FIBRE" */
+	uvlong	ifcpath;
+	uvlong	devpath;
+	uchar	unused3;
+	uchar	dpicksum;
+} Edrvparam;
+
 void	realmode(int intr, Ureg *ureg);		/* from trap.c */
 
 static Biosdev bdev[Maxdevs];
@@ -59,8 +91,8 @@ static Biosdrive bdrive;
 static Ureg regs;
 
 static int	dreset(uchar drive);
-static Devbytes	extgetsize(uchar drive);
-static Devbytes	getsize(uchar drive, char *type);
+static Devbytes	extgetsize(Biosdev *);
+static Devsects	getsize(uchar drive, char *type);
 static int	islba(uchar drive);
 
 static int
@@ -96,7 +128,7 @@ biosinit(void)
 	mask = lastbit = 0;
 
 	/* 9pxeload can't use bios int 13 calls; they wedge the machine */
-	if (pxe)
+	if (pxe || getconf("*nobiosload") != nil)
 		return mask;
 	for (devid = 0; devid < (1 << 8) && bdrive.ndevs < Maxdevs; devid++) {
 		lba = islba(devid);
@@ -109,15 +141,16 @@ biosinit(void)
 			devid--;
 			continue;
 		}
-		size = extgetsize(devid);
-		print("bios%d: drive 0x%ux: %llud bytes, type %d\n",
-			bdrive.ndevs, devid, size, type);
 		lastbit = 1 << bdrive.ndevs;
 		mask |= lastbit;
-		bdp = &bdev[bdrive.ndevs++];
+		bdp = &bdev[bdrive.ndevs];
 		bdp->id = devid;
 		bdp->type = type;
+		size = extgetsize(bdp);
 		bdp->size = size;
+		print("bios%d: drive 0x%ux: %llud bytes, type %d\n",
+			bdrive.ndevs, devid, size, type);
+		bdrive.ndevs++;
 	}
 	/*
 	 * bioses seem to only be able to read from drive number 0x80
@@ -171,34 +204,19 @@ biosboot(int dev, char *file, Boot *b)
 	return fsboot(fs, file, b);
 }
 
-// void
-// biosprintbootdevs(int dev)
-// {
-// 	print(" bios%d: %ux, %lld", dev, bdev[dev].id, bdev[dev].size);
-// }
-
-typedef struct Extread {
-	uchar	size;
-	uchar	unused1;
-	uchar	nsects;
-	uchar	unused2;
-	ulong	addr;		/* segment:offset */
-	uvlong	stsect;		/* starting sector */
-} Extread;
-
 /* read n bytes at sector offset into a from drive id */
 long
-sectread(void *a, long n, Devsects offset, uchar id)
+sectread(Biosdev *bdp, void *a, long n, Devsects offset)
 {
 	uchar *biosparam, *cp;
 	Extread *erp;
 
-	if(n < 0 || n > Sectsize)
+	if(n < 0 || n > bdp->sectsz)
 		return -1;
 	if(Debug)
-		memset((uchar *)BIOSXCHG, 'r', Sectsize); /* preclean the buffer. */
+		memset((uchar *)BIOSXCHG, 'r', bdp->sectsz); /* preclean the buffer. */
 
-	biosdiskcall(&regs, Biosdrvrdy, 0, id, 0);
+	biosdiskcall(&regs, Biosdrvrdy, 0, bdp->id, 0);
 
 	/* space for a BIG sector, just in case... */
 	biosparam = (uchar *)BIOSXCHG + 2*1024;
@@ -210,9 +228,9 @@ sectread(void *a, long n, Devsects offset, uchar id)
 	erp->nsects = 1;
 	erp->addr = PADDR(BIOSXCHG);
 	erp->stsect = offset;
-	if (biosdiskcall(&regs, Biosrdsect, 0, id, PADDR(erp)) < 0) {
-		print("sectread: bios failed to read %ld @ off %lld from %ux\n",
-			n, offset, id);
+	if (biosdiskcall(&regs, Biosrdsect, 0, bdp->id, PADDR(erp)) < 0) {
+		print("sectread: bios failed to read %ld @ sector %lld of 0x%ux\n",
+			n, offset, bdp->id);
 		return -1;
 	}
 
@@ -241,20 +259,19 @@ print("\n");
 static int
 islba(uchar drive)
 {
-	if (biosdiskcall(&regs, Biosckext, 0x55aa, drive, 0) < 0) {
-//		print("islba: failed\n");
+	if (biosdiskcall(&regs, Biosckext, 0x55aa, drive, 0) < 0)
 		return 0;
-	}
 	if(regs.bx != 0xaa55){
 		print("islba: buggy bios\n");
 		return 0;
 	}
 	if (Debug)
-		print("islba: drive %ux extensions version %d.%d cx 0x%lux\n",
+		print("islba: drive 0x%ux extensions version %d.%d cx 0x%lux\n",
 			drive, (uchar)(regs.ax >> 8),
 			(uchar)regs.ax, regs.cx); /* cx: 4=edd, 1=use dap */
 	if(!(regs.cx & 1)){
-		print("islba: drive %ux: no dap bit in extensions cx\n", drive);
+		print("islba: drive 0x%ux: no dap bit in extensions cx\n",
+			drive);
 		return 0;
 	}
 //	dreset(drive);		/* pbslba does this, but it wedges here */
@@ -265,56 +282,30 @@ islba(uchar drive)
  * works so so... some floppies are 0x80+x when they shouldn't be,
  * and report lba even if they cannot...
  */
-static Devbytes
-getsize(uchar drive, char *typep)
+static Devsects
+getsize(uchar id, char *typep)
 {
 	int dtype;
-	Devsects size;
 
-	if (biosdiskcall(&regs, Biosdrvtype, 0x55aa, drive, 0) < 0)
+	if (biosdiskcall(&regs, Biosdrvtype, 0x55aa, id, 0) < 0)
 		return 0;
 
 	dtype = (ushort)regs.ax >> 8;
-	size = (ushort)regs.cx | regs.dx << 16;
 	if(dtype == Typenone){
-		print("no such device %ux of type %ux\n", drive, dtype);
+		print("no such device 0x%ux of type %d\n", id, dtype);
 		return 0;
 	}
-	*typep = dtype;
 	if(dtype != Typedisk){
-		print("non-disk device %ux of type %ux\n", drive, dtype);
+		print("non-disk device 0x%ux of type %d\n", id, dtype);
 		return 0;
 	}
-	return (Devbytes)size * Sectsize; /* size is in sectors; return bytes */
+	*typep = dtype;
+	return (ushort)regs.cx | regs.dx << 16;
 }
 
-typedef struct Edrvparam {
-	/* from edd 1.1 spec */
-	ushort	size;			/* max. buffer size */
-	ushort	flags;
-	ulong	physcyls;
-	ulong	physheads;
-	ulong	phystracksects;
-	uvlong	physsects;
-	ushort	sectsz;
-	void	*dpte;			/* ~0ull: invalid */
-
-	/* remainder from edd 3.0 spec */
-	ushort	key;			/* 0xbedd if present */
-	uchar	dpilen;
-	uchar	unused1;
-	ushort	unused2;
-	char	bustype[4];		/* "PCI" or "ISA" */
-	char	ifctype[8]; /* "ATA", "ATAPI", "SCSI", "USB", "1394", "FIBRE" */
-	uvlong	ifcpath;
-	uvlong	devpath;
-	uchar	unused3;
-	uchar	dpicksum;
-} Edrvparam;
-
 /* extended get size */
 static Devbytes
-extgetsize(uchar drive)
+extgetsize(Biosdev *bdp)
 {
 	Edrvparam *edp;
 
@@ -322,17 +313,21 @@ extgetsize(uchar drive)
 	memset(edp, 0, sizeof *edp);
 	edp->size = sizeof *edp;
 	edp->dpilen = 36;
-	if (biosdiskcall(&regs, Biosedrvparam, 0, drive, PADDR(edp)) < 0) {
-//		print("extgetsize: Biosedrvparam failed\n");
+	if (biosdiskcall(&regs, Biosedrvparam, 0, bdp->id, PADDR(edp)) < 0)
 		return 0;
-	}
 	if(Debug) {
-		print("extgetsize: drive %ux info flags 0x%ux",
-			drive, edp->flags);
+		print("extgetsize: drive 0x%ux info flags 0x%ux",
+			bdp->id, edp->flags);
 		if (edp->key == 0xbedd)
 			print(" %s %s", edp->bustype, edp->ifctype);
 		print("\n");
 	}
+	if (edp->sectsz <= 0) {
+		print("extgetsize: drive 0x%ux: non-positive sector size\n",
+			bdp->id);
+		edp->sectsz = 1;		/* don't divide by zero */
+	}
+	bdp->sectsz = edp->sectsz;
 	return edp->physsects * edp->sectsz;
 }
 
@@ -342,7 +337,6 @@ biosread(Fs *fs, void *a, long n)
 	int want, got, part;
 	long totnr, stuck;
 	Devbytes offset;
-	uchar id;
 	Biosdev *bdp;
 
 	if(fs->dev > bdrive.ndevs)
@@ -350,17 +344,16 @@ biosread(Fs *fs, void *a, long n)
 	if (n <= 0)
 		return n;
 	bdp = &bdev[fs->dev];
-	id = bdp->id;
 	offset = bdp->offset;
 	stuck = 0;
 	for (totnr = 0; totnr < n && stuck < 4; totnr += got) {
-		want = Sectsize;
+		want = bdp->sectsz;
 		if (totnr + want > n)
 			want = n - totnr;
 		if(Debug)
-			print("bios%d, read: %ld @ off %lld, want: %d, id: %ux\n",
-				fs->dev, n, offset, want, id);
-		part = offset % Sectsize;
+			print("bios%d, read: %ld @ off %lld, want: %d, id: 0x%ux\n",
+				fs->dev, n, offset, want, bdp->id);
+		part = offset % bdp->sectsz;
 		if (part != 0) {	/* back up to start of sector */
 			offset -= part;
 			totnr  -= part;
@@ -373,15 +366,16 @@ biosread(Fs *fs, void *a, long n)
 			print("biosread: negative offset %lld\n", offset);
 			return -1;
 		}
-		got = sectread((char *)a + totnr, want, offset/Sectsize, id);
+		got = sectread(bdp, (char *)a + totnr, want, offset/bdp->sectsz);
 		if(got <= 0){
-			print("biosread: failed to read %ld @ off %lld of %ux, "
-				"want %d got %d\n", n, offset, id, want, got);
+//			print("biosread: failed to read %ld @ off %lld of 0x%ux, "
+//				"want %d got %d\n",
+//				n, offset, bdp->id, want, got);
 			return -1;
 		}
 		offset += got;
 		bdp->offset = offset;
-		if (got < Sectsize)
+		if (got < bdp->sectsz)
 			stuck++;	/* we'll have to re-read this sector */
 		else
 			stuck = 0;

+ 1 - 0
sys/src/boot/pc/load.c

@@ -205,6 +205,7 @@ boot(Medium *mp, char *file)
 	}
 
 	sprint(BOOTLINE, "%s!%s", mp->name, file);
+	print("booting %s!%s", mp->name, file);
 	return (*mp->type->boot)(mp->dev, file, &b);
 }
 

+ 2 - 1
sys/src/boot/pc/sdbios.c

@@ -130,7 +130,8 @@ biospnp(void)
 {
 	SDev *sdev;
 
-	if (pxe)
+	/* 9pxeload can't use bios int 13 calls; they wedge the machine */
+	if (pxe || getconf("*nobiosload") != nil)
 		return nil;
 	if((sdev = malloc(sizeof(SDev))) != nil) {
 		sdev->ifc = &sdbiosifc;

+ 1 - 1
sys/src/boot/pc/sdiahci.c

@@ -1512,7 +1512,7 @@ iapnp(void)
 	SDev *head, *tail, *s;
 	static int done;
 
-	if(done)
+	if (done || getconf("*noahciload") != nil)
 		return nil;
 	done = 1;
 	p = nil;