From a4273bfdceba18b5d188470f1a09df1302dc7617 Mon Sep 17 00:00:00 2001 From: Myles Watson Date: Thu, 13 Mar 2008 13:22:44 +0000 Subject: [PATCH] This patch is a hopefully less controversial version of a previous patch which removed the ELF loader from coreboot v3. This adds a Kconfig option PAYLOAD_ELF_LOADER which builds the loader into v3. In order to make it a little safer, I changed PAYLOAD_PREPARSE_ELF to PAYLOAD_NO_PREPARSE_ELF and made that option depend on PAYLOAD_ELF_LOADER so that no one adds an unparsed ELF without the loader. One part that was strange to me was that I first tried adding elfboot.o and archelfboot.o to the beginning of the list of object files. I added them to the end of the list instead. Myles Signed-off-by: Myles Watson Acked-by: Carl-Daniel Hailfinger git-svn-id: svn://coreboot.org/repository/coreboot-v3@640 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- Kconfig | 16 +++++++++++----- arch/x86/Makefile | 16 +++++++++++----- arch/x86/stage1.c | 9 +++++++++ 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Kconfig b/Kconfig index c889de8670..3fb13ecb4d 100644 --- a/Kconfig +++ b/Kconfig @@ -92,6 +92,12 @@ source northbridge/intel/i440bxemulation/Kconfig menu "Payload" +config PAYLOAD_ELF_LOADER + bool "Include ELF payload loader" + default n + help + This option allows an unparsed ELF paylaod to be added and loaded. + choice prompt "Payload type" default PAYLOAD_NONE @@ -125,10 +131,10 @@ config PAYLOAD_FILE help The path and filename of the ELF executable file to use as payload. -config PAYLOAD_PREPARSE_ELF - bool "Pre-parse ELF file and convert ELF segments to LAR entries" - depends PAYLOAD_ELF - default y +config PAYLOAD_NO_PREPARSE_ELF + bool "Add ELF without parsing and converting to LAR entries" + depends PAYLOAD_ELF && PAYLOAD_ELF_LOADER + default n help Until now, coreboot has used ELF for the payload. There are many problems with this, not least being the inefficiency -- the ELF has @@ -142,7 +148,7 @@ config PAYLOAD_PREPARSE_ELF flashed the FLASH and rebooted the machine. Boot time is really not the time you want to find out your ELF payload is broken. - With this option, coreboot will direct lar to break each ELF + Without this option, coreboot will direct lar to break each ELF segment into a LAR entry. ELF will not be used at all. Note that (for now) coreboot is not backward compatible -- if you put an ELF payload in, coreboot can not parse it. We hope to remove ELF diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 1064bffb2d..346aa7b640 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -105,11 +105,17 @@ $(obj)/coreboot.bootblock: $(obj)/coreboot.vpd $(obj)/stage0.init # initram module and the various stages and payload files. # -STAGE0_LIB_OBJ = uart8250.o mem.o elfboot.o lar.o delay.o vtxprintf.o \ + +STAGE0_LIB_OBJ = uart8250.o mem.o lar.o delay.o vtxprintf.o \ vsprintf.o console.o string.o $(DECOMPRESSORS) -STAGE0_ARCH_X86_OBJ = stage1.o serial.o archelfboot.o speaker.o \ +STAGE0_ARCH_X86_OBJ = stage1.o serial.o speaker.o \ udelay_io.o mc146818rtc.o post_code.o +ifeq ($(CONFIG_PAYLOAD_ELF_LOADER),y) +STAGE0_LIB_OBJ += elfboot.o +STAGE0_ARCH_X86_OBJ += archelfboot.o +endif + ifeq ($(CONFIG_CPU_I586),y) STAGE0_CAR_OBJ = stage0_i586.o else @@ -122,10 +128,10 @@ else endif endif -ifeq ($(CONFIG_PAYLOAD_PREPARSE_ELF), y) - PARSEELF = -e -else +ifeq ($(CONFIG_PAYLOAD_NO_PREPARSE_ELF), y) PARSEELF = +else + PARSEELF = -e endif STAGE0_OBJ := $(patsubst %,$(obj)/lib/%,$(STAGE0_LIB_OBJ)) \ diff --git a/arch/x86/stage1.c b/arch/x86/stage1.c index 62b3affd21..f8b3a01852 100644 --- a/arch/x86/stage1.c +++ b/arch/x86/stage1.c @@ -28,10 +28,12 @@ #include #include +#ifdef CONFIG_PAYLOAD_ELF_LOADER /* ah, well, what a mess! This is a hard code. FIX ME but how? * By getting rid of ELF ... */ #define UNCOMPRESS_AREA (0x400000) +#endif /* CONFIG_PAYLOAD_ELF_LOADER */ /* these prototypes should go into headers */ void uart_init(void); @@ -86,6 +88,8 @@ void dump_mem_range(int msg_level, unsigned char *buf, int size) return; } + +#ifdef CONFIG_PAYLOAD_ELF_LOADER /* until we get rid of elf */ int legacy(struct mem_file *archive, char *name, void *where, struct lb_memory *mem) { @@ -101,6 +105,7 @@ int legacy(struct mem_file *archive, char *name, void *where, struct lb_memory * printk(BIOS_ERR, "elfboot_mem returns %d\n", ret); return -1; } +#endif /* CONFIG_PAYLOAD_ELF_LOADER */ /* * This function is called from assembler code with its argument on the @@ -110,7 +115,9 @@ void __attribute__((stdcall)) stage1_main(u32 bist) { int ret; struct mem_file archive, result; +#ifdef CONFIG_PAYLOAD_ELF_LOADER int elfboot_mem(struct lb_memory *mem, void *where, int size); +#endif /* CONFIG_PAYLOAD_ELF_LOADER */ void *entry; /* we can't statically init this hack. */ @@ -202,9 +209,11 @@ void __attribute__((stdcall)) stage1_main(u32 bist) printk(BIOS_DEBUG, "Stage2 code done.\n"); +#ifdef CONFIG_PAYLOAD_ELF_LOADER ret = find_file(&archive, "normal/payload", &result); if (! ret) legacy(&archive, "normal/payload", (void *)UNCOMPRESS_AREA, mem); +#endif /* CONFIG_PAYLOAD_ELF_LOADER */ entry = load_file_segments(&archive, "normal/payload"); if (entry != (void*)-1) {