diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 9c970ae6d6..6b4dcd1d2d 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -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 @@ else 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 @@ else 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)) \ diff --git a/arch/x86/stage1.c b/arch/x86/stage1.c index 6ad199e15c..f3ac5c8f5b 100644 --- a/arch/x86/stage1.c +++ b/arch/x86/stage1.c @@ -22,12 +22,16 @@ #include #include #include +#include #include #include #include #include -#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 @@ static void enable_rom(void) 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 @@ void __attribute__((stdcall)) stage1_main(u32 bist) 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,19 +168,31 @@ void __attribute__((stdcall)) stage1_main(u32 bist) 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"); - } - 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"); - } + if (! ret) + legacy(&archive, "normal/payload", (void *)UNCOMPRESS_AREA, mem); - ret = elfboot_mem(mem, (void *)UNCOMPRESS_AREA, result.reallen); - printk(BIOS_ERR, "elfboot_mem returns %d\n", ret); + /* 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; + } + printk(BIOS_SPEW, "all loaded, entry %p\n", entry); + run_address(entry); + + die("FATAL: No usable payload found.\n"); die ("FATAL: Last stage returned to LinuxBIOS.\n"); }