DragonFly BSD
DragonFly bugs List (threaded) for 2004-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re2: Manual installation on 3ware 9500 sata controller wont boot


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 24 Jul 2004 13:11:24 -0700 (PDT)

    Oops, I forgot to zero out %eax in the last patch.  Here's a new one.
    Told ya it's experiemental! :-)

    DR is testing.

						-Matt
Index: bootasm.h
===================================================================
RCS file: /cvs/src/sys/boot/i386/bootasm.h,v
retrieving revision 1.3
diff -u -r1.3 bootasm.h
--- bootasm.h	19 Jul 2004 23:30:29 -0000	1.3
+++ bootasm.h	24 Jul 2004 18:56:57 -0000
@@ -70,6 +70,12 @@
 #define MEM_BIOS_LADDR	0x7c00		/* Load address (static/BIOS) */
 
 /*
+ * This is the origin of boot2.bin relative to the BTX user address space
+ * (e.g. physical address would be MEM_BTX_USR+BOOT2_VORIGIN).
+ */
+#define BOOT2_VORIGIN	0x2000
+
+/*
  * NOTE: BOOT0_ORIGIN is extracted from this file and used in boot0/Makefile
  * 	 BOOT1_ORIGIN is extracted from this file and used in boot2/Makefile
  *
Index: bootasmdef.c
===================================================================
RCS file: /cvs/src/sys/boot/i386/bootasmdef.c,v
retrieving revision 1.1
diff -u -r1.1 bootasmdef.c
--- bootasmdef.c	19 Jul 2004 23:30:29 -0000	1.1
+++ bootasmdef.c	24 Jul 2004 18:52:38 -0000
@@ -44,7 +44,7 @@
 void
 usage(const char *arg0, int code)
 {
-    fprintf(stderr, "%s {BOOT0_ORIGIN,BOOT1_ORIGIN,MEM_BIOS_LADDR}\n", arg0);
+    fprintf(stderr, "%s {BOOT0_ORIGIN,BOOT1_ORIGIN,MEM_BIOS_LADDR,BOOT2_VORIGIN}\n", arg0);
     exit(code);
 }
 
@@ -72,6 +72,8 @@
 	printf(fmt, BOOT1_ORIGIN);
     } else if (strcmp(var, "MEM_BIOS_LADDR") == 0) {
 	printf(fmt, MEM_BIOS_LADDR);
+    } else if (strcmp(var, "BOOT2_VORIGIN") == 0) {
+	printf(fmt, BOOT2_VORIGIN);
     } else {
 	usage(av[0], 1);
     }
Index: boot2/Makefile
===================================================================
RCS file: /cvs/src/sys/boot/i386/boot2/Makefile,v
retrieving revision 1.9
diff -u -r1.9 Makefile
--- boot2/Makefile	19 Jul 2004 23:30:32 -0000	1.9
+++ boot2/Makefile	24 Jul 2004 18:52:08 -0000
@@ -40,7 +40,7 @@
 # the start of the BTX *USER* address space, not the start of physical 
 # memory.
 #
-ORG2=	0x2000
+ORG2=	`${.OBJDIR}/bootasmdef.nx BOOT2_VORIGIN`
 
 # Decide Level of UFS support.  UFS1_AND_UFS2 doesn't fit.
 
Index: boot2/boot1.S
===================================================================
RCS file: /cvs/src/sys/boot/i386/boot2/boot1.S,v
retrieving revision 1.7
diff -u -r1.7 boot1.S
--- boot2/boot1.S	19 Jul 2004 23:30:32 -0000	1.7
+++ boot2/boot1.S	24 Jul 2004 19:22:04 -0000
@@ -216,19 +216,33 @@
 main.5: 	pushw %dx			// Save args
 		movb $NSECT,%dh			// Sector count
 		callw nread			// Read disk
-		mov $MEM_BTX_ORG,%bx		// BTX
-		mov 0xa(%bx),%si		// Get BTX length and set
-		add %bx,%si			//  %si to start of boot2.bin
-		mov $MEM_BTX_USR+SIZ_PAG*2,%di	// Client page 2
-		mov $MEM_BTX_ORG+(NSECT-1)*SIZ_SEC,%cx // Size of client data
-		sub %si,%cx			//  count
-		rep				// Relocate
-		movsb				//  client
+		mov $MEM_BTX_ORG,%bx		// Base of BTX header
+		mov 0xa(%bx),%si		// Get BTX text length (btx.S)
+		add %bx,%si			// %si = start of boot2.bin
+						// %di = relocation target
+		mov $MEM_BTX_USR+BOOT2_VORIGIN,%di 
+		mov $MEM_BTX_ORG+(NSECT-1)*SIZ_SEC,%cx
+		sub %si,%cx			// %cx = Size of boot2 client
+		rep				// Relocate boot2
+		movsb
 		popw MEM_BTX_USR_ARG		// save (disk,slice) for boot2
-		sub %di,%cx			// count = 0x[1]0000 - DSTPTR
-		xorb %al,%al			// Zero assumed bss from
-		rep				//  the end of boot2.bin
-		stosb				//  up to 0x10000
+
+#if 0
+		// XXX DISABLED.  This makes incorrect assumptions about
+		// where BSS begins, potentially leaving garbage in the BSS
+		// space.  The BSS zeroing code has been moved to
+		// btx/lib/btxcsu.S (BTX client startup code) where we have
+		// more definitive knowledge about where BSS resides.
+		//
+		// %cx now contains 0.  Calculate 0x[1]0000 - %di to get a
+		// count of assumed BSS bytes from the end of boot2.bin up
+		// to 0x10000, then zero it out.
+		//
+		sub %di,%cx
+		xorb %al,%al
+		rep
+		stosb
+#endif
 		callw seta20			// Enable A20
 
 		// YYY
Index: boot2/boot2.c
===================================================================
RCS file: /cvs/src/sys/boot/i386/boot2/boot2.c,v
retrieving revision 1.12
diff -u -r1.12 boot2.c
--- boot2/boot2.c	19 Jul 2004 23:30:32 -0000	1.12
+++ boot2/boot2.c	24 Jul 2004 20:09:40 -0000
@@ -110,6 +110,8 @@
 
 #define NOPT		12
 
+#define INVALID_S	"Bad %s\n"
+
 extern uint32_t _end;
 
 static const char optstr[NOPT] = { "VhaCgmnPprsv" };
@@ -191,7 +193,7 @@
 xfsread(ino_t inode, void *buf, size_t nbyte)
 {
     if ((size_t)fsread(inode, buf, nbyte) != nbyte) {
-	printf("Invalid %s\n", "format");
+	printf(INVALID_S, "format");
 	return -1;
     }
     return 0;
@@ -355,7 +357,7 @@
     else if (IS_ELF(hdr.eh))
 	fmt = 1;
     else {
-	printf("Invalid %s\n", "format");
+	printf(INVALID_S, "format");
 	return;
     }
     if (fmt == 0) {
@@ -541,7 +543,7 @@
 	    if (sl != COMPATIBILITY_SLICE)
 		dp += sl - BASE_SLICE;
 	    if (dp->dp_typ != DOSPTYP_386BSD) {
-		printf("Invalid %s\n", "slice");
+		printf(INVALID_S, "slice");
 		return -1;
 	    }
 	    dsk.start = dp->dp_start;
@@ -551,7 +553,7 @@
 	d = (void *)(sec + LABELOFFSET);
 	if (d->d_magic != DISKMAGIC || d->d_magic2 != DISKMAGIC) {
 	    if (dsk.part != RAW_PART) {
-		printf("Invalid %s\n", "label");
+		printf(INVALID_S, "label");
 		return -1;
 	    }
 	} else {
@@ -562,7 +564,7 @@
 	    }
 	    if (dsk.part >= d->d_npartitions ||
 		!d->d_partitions[dsk.part].p_size) {
-		printf("Invalid %s\n", "partition");
+		printf(INVALID_S, "partition");
 		return -1;
 	    }
 	    dsk.start += d->d_partitions[dsk.part].p_offset;
Index: btx/lib/btxcsu.S
===================================================================
RCS file: /cvs/src/sys/boot/i386/btx/lib/btxcsu.S,v
retrieving revision 1.5
diff -u -r1.5 btxcsu.S
--- btx/lib/btxcsu.S	19 Jul 2004 23:30:35 -0000	1.5
+++ btx/lib/btxcsu.S	24 Jul 2004 20:07:49 -0000
@@ -26,12 +26,20 @@
 		 * Globals.
 		 */
 		.global _start
+		.extern _edata, _end
 
 		/*
 		 * Client entry point.
 		 */
-_start: 	movl %eax,__base		# Set base address
-						# for Virt->Phys conversions
+_start: 
+		pushl %eax			# Save base address
+		movl $_edata,%edi		# Clear BSS
+		movl $_end,%ecx
+		subl %edi,%ecx
+		subl %eax,%eax
+		rep
+		stosb
+		popl __base			# Set base address
 		movl %esp,%eax			# Get base of arguments
 		addl $USR_ARGSPACE-USR_ARGOFFSET,%eax
 		movl %eax,__args



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]