This is a set of proposed changes for doing initram which are
backward-compatible (and tested) on qemu. The change is to exploit the
elf-parsing abilities of lar to better set up the initram files in
LAR, and get away from worrying about potential gld bugs, now and in
the future.

The change is to use the elf-parsing capabilities of LAR to parse the
initram.o file, and create a valid LAR header with an entry value.
This will fix the problems I am having on the ALIX 1C and probably
allow it to boot. It also sets the text base of the  .o to 0, instead
of whatever wacky value gld is choosing, so all platforms will have
the same value.

I would appreciate comments on this, and I wonder if we shouldn't just
drop the "binary blob" initram immediately. I don't see a need for it
at this point.

That said, this is backwards-compatible for now.

Note that we can next apply this to stage 2, and completely remove the
dreaded "binary blobs" from the LAR, and also remove our use of
objcopy for this use.

ron

thanks

ron
Index: lib/lar.c
===================================================================
--- lib/lar.c	(revision 521)
+++ lib/lar.c	(working copy)
@@ -263,9 +263,9 @@
 			       filename);
 			return 1;
 		}
-		where = result.start;
+		where = result.start + (u32)result.entry;
 	}
-	printk(BIOS_SPEW, "where is %p\n", where);
+	printk(BIOS_SPEW, "Entry point is %p\n", where);
 	ret = run_address(where);
 	printk(BIOS_SPEW, "run_file returns with %d\n", ret);
 	return ret;
Index: arch/x86/stage1.c
===================================================================
--- arch/x86/stage1.c	(revision 521)
+++ arch/x86/stage1.c	(working copy)
@@ -138,17 +138,23 @@
 	// find first initram
 	if (check_normal_boot_flag()) {
 		printk(BIOS_DEBUG, "Choosing normal boot.\n");
-		ret = execute_in_place(&archive, "normal/initram");
+		ret = execute_in_place(&archive, "normal/initram.o/segment0");
+		if (ret) /* choose the old style */
+			ret = execute_in_place(&archive, "normal/initram");
 	} else {
 		printk(BIOS_DEBUG, "Choosing fallback boot.\n");
-		ret = execute_in_place(&archive, "fallback/initram");
+		ret = execute_in_place(&archive, "fallback/initram.o/segment0");
+		if (ret) /* choose the old style */
+			ret = execute_in_place(&archive, "fallback/initram");
 		/* Try a normal boot if fallback doesn't exist in the lar.
 		 * TODO: There are other ways to do this.
 		 * It could be ifdef or the boot flag could be forced.
 		 */
 		if (ret) {
 			printk(BIOS_DEBUG, "Fallback failed. Try normal boot\n");
-			ret = execute_in_place(&archive, "normal/initram");
+			ret = execute_in_place(&archive, "normal/initram.o/segment0");
+			if (ret) /* choose the old style */
+				ret = execute_in_place(&archive, "normal/initram");
 		}
 	}
 
Index: arch/x86/Makefile
===================================================================
--- arch/x86/Makefile	(revision 521)
+++ arch/x86/Makefile	(working copy)
@@ -36,7 +36,7 @@
 
 ROM_SIZE := $(shell expr $(CONFIG_LINUXBIOS_ROMSIZE_KB) \* 1024)
 
-LARFILES := nocompress:normal/initram normal/stage2 nocompress:normal/option_table
+LARFILES := nocompress:normal/initram.o normal/stage2 nocompress:normal/option_table
 ifneq ($(CONFIG_PAYLOAD_NONE),y)
 LARFILES += normal/payload
 endif
@@ -57,11 +57,11 @@
 COMPRESSFLAG := -C nrv2b
 endif
 
-$(obj)/linuxbios.rom $(obj)/linuxbios.map: $(obj)/linuxbios.bootblock $(obj)/util/lar/lar lzma nrv2b $(obj)/linuxbios.initram $(obj)/linuxbios.stage2 $(obj)/option_table
+$(obj)/linuxbios.rom $(obj)/linuxbios.map: $(obj)/linuxbios.bootblock $(obj)/util/lar/lar lzma nrv2b $(obj)/linuxbios.initram.o $(obj)/linuxbios.stage2 $(obj)/option_table
 	$(Q)rm -rf $(obj)/lar.tmp
 	$(Q)mkdir $(obj)/lar.tmp
 	$(Q)mkdir $(obj)/lar.tmp/normal
-	$(Q)cp $(obj)/linuxbios.initram $(obj)/lar.tmp/normal/initram
+	$(Q)cp $(obj)/linuxbios.initram.o $(obj)/lar.tmp/normal/initram.o
 	$(Q)cp $(obj)/linuxbios.stage2 $(obj)/lar.tmp/normal/stage2
 	$(Q)cp $(obj)/option_table $(obj)/lar.tmp/normal/option_table
 ifeq ($(CONFIG_PAYLOAD_NONE),y)
-- 
linuxbios mailing list
linuxbios@linuxbios.org
http://www.linuxbios.org/mailman/listinfo/linuxbios

Reply via email to