[LinuxBIOS] r482 - LinuxBIOSv3/arch/x86

svn at openbios.org svn at openbios.org
Wed Aug 29 17:05:01 CEST 2007


Author: rminnich
Date: 2007-08-29 17:05:01 +0200 (Wed, 29 Aug 2007)
New Revision: 482

Modified:
   LinuxBIOSv3/arch/x86/Makefile
   LinuxBIOSv3/arch/x86/stage1.c
Log:

This patch is revised based on comments. This is the "remove elf and
replace with LAR" series; this set is for arch/x86.


note that the payload is now payload/segment0, payload/segment1, etc. I've extended
linuxbios to look for these. Note that you can now see all the things
that get loaded ;they're no longer hidden in an ELF header somewhere.
Elf failures are gone!

Note that I've left legacy elf support in, for now, but recommend we
get rid of it as soon as possible.

patch attached. This is a first pass. lar.c needs some refactoring but
I want to get the cmdline going. You can now have a linux payload and
it will uncompress with no problems.

This has been tested with filo and BOCHS.

Signed-off-by: Ronald G. Minnich <rminnich at gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>


Modified: LinuxBIOSv3/arch/x86/Makefile
===================================================================
--- LinuxBIOSv3/arch/x86/Makefile	2007-08-29 14:59:25 UTC (rev 481)
+++ LinuxBIOSv3/arch/x86/Makefile	2007-08-29 15:05:01 UTC (rev 482)
@@ -22,7 +22,7 @@
 ifeq ($(CONFIG_ARCH_X86),y)
 
 INITCFLAGS := $(CFLAGS) -I$(src)/include/arch/x86 -I$(src)/include \
-		-I$(obj) -fno-builtin
+		-I$(obj) -fno-builtin  
 
 SILENT := >/dev/null 2>&1
 
@@ -78,7 +78,7 @@
 endif
 	$(Q)printf "  LAR     $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)rm -f $(obj)/linuxbios.rom
-	$(Q)cd $(obj)/lar.tmp && ../util/lar/lar $(COMPRESSFLAG) -c \
+	$(Q)cd $(obj)/lar.tmp && ../util/lar/lar $(PARSEELF) $(COMPRESSFLAG) -c \
 		../linuxbios.rom \
 		$(LARFILES) \
 		-s $(ROM_SIZE) -b $(obj)/linuxbios.bootblock
@@ -122,6 +122,11 @@
 endif
 endif
 
+ifeq ($(CONFIG_NOELF), y)
+	PARSEELF = -e
+else
+	PARSEELF = 
+endif
 
 STAGE0_OBJ := $(patsubst %,$(obj)/lib/%,$(STAGE0_LIB_OBJ)) \
 	      $(patsubst %,$(obj)/arch/x86/%,$(STAGE0_ARCH_X86_OBJ)) \

Modified: LinuxBIOSv3/arch/x86/stage1.c
===================================================================
--- LinuxBIOSv3/arch/x86/stage1.c	2007-08-29 14:59:25 UTC (rev 481)
+++ LinuxBIOSv3/arch/x86/stage1.c	2007-08-29 15:05:01 UTC (rev 482)
@@ -22,12 +22,16 @@
 #include <io.h>
 #include <console.h>
 #include <lar.h>
+#include <string.h>
 #include <tables.h>
 #include <lib.h>
 #include <mc146818rtc.h>
 #include <post_code.h>
 
-#define UNCOMPRESS_AREA 0x60000
+/* ah, well, what a mess! This is a hard code. FIX ME but how? 
+ * By getting rid of ELF ...
+ */
+#define UNCOMPRESS_AREA (0x400000)
 
 /* these prototypes should go into headers */
 void uart_init(void);
@@ -48,6 +52,24 @@
 	post_code(0xf2);
 }
 
+
+/* until we get rid of elf */
+int legacy(struct mem_file *archive, char *name, void *where, struct lb_memory *mem)
+{
+	int ret;
+	struct mem_file result;
+	int elfboot_mem(struct lb_memory *mem, void *where, int size);
+	ret = copy_file(archive, name, where);
+	if (ret) {
+		printk(BIOS_ERR, "'%s' found, but could not load it.\n", name);
+	}
+
+	ret =  elfboot_mem(mem, where, result.reallen);
+
+	printk(BIOS_ERR, "elfboot_mem returns %d\n", ret);
+	return -1;
+}
+
 /*
  * This function is called from assembler code whith its argument on the
  * stack. Force the compiler to generate always correct code for this case.
@@ -57,6 +79,8 @@
 	int ret;
 	struct mem_file archive, result;
 	int elfboot_mem(struct lb_memory *mem, void *where, int size);
+	void *entry;
+	int i;
 
 	/* we can't statically init this hack. */
 	unsigned char faker[64];
@@ -144,20 +168,32 @@
 	printk(BIOS_DEBUG, "Stage2 code done.\n");
 
 	ret = find_file(&archive, "normal/payload", &result);
-	if (ret) {
-		printk(BIOS_ERR, "No such file '%s'.\n", "normal/payload");
-		die("FATAL: No payload found.\n");
+	if (! ret)
+		legacy(&archive, "normal/payload", (void *)UNCOMPRESS_AREA, mem);
+
+
+	/* new style lar boot. Install all the files in memory. 
+	  * By convention we take the entry point from the first 
+	  * one. Look for a cmdline as well. 
+	  */
+	for(i = 0, entry = (void *)0; ;i++) {
+		char filename[64];
+		void *newentry;
+		sprintf(filename, "normal/payload/segment%d", i);
+		archive.len = *(u32 *)0xfffffff4;
+		archive.start =(void *)(0UL-archive.len);
+		newentry = load_file(&archive, filename);
+		printk("newentry is %p\n", newentry);
+		if (newentry == (void *)-1)
+			break;
+		if (! entry)
+			entry = newentry;
 	}
-	ret = copy_file(&archive, "normal/payload", (void *)UNCOMPRESS_AREA);
-	if (ret) {
-		printk(BIOS_ERR, "'%s' found, but could not load it.\n", "normal/payload");
-		die("FATAL: No usable payload found.\n");
-	}
+	printk(BIOS_SPEW, "all loaded, entry %p\n", entry);
+	run_address(entry);
 
-	ret =  elfboot_mem(mem, (void *)UNCOMPRESS_AREA, result.reallen);
+	die("FATAL: No usable payload found.\n");
 
-	printk(BIOS_ERR, "elfboot_mem returns %d\n", ret);
-
 	die ("FATAL: Last stage returned to LinuxBIOS.\n");
 }
 





More information about the coreboot mailing list