Patchwork Flexible filename prefix

login
register
about
Submitter Patrick Georgi
Date 2010-02-09 18:01:47
Message ID <4B71A30B.5060409@georgi-clan.de>
Download mbox | patch
Permalink /patch/892/
State Accepted
Headers show

Comments

Patrick Georgi - 2010-02-09 18:01:47
Hi,

attached file is the first part of my quest for a fallback/normal switch
in the Kconfig regime.
It allows building images with different prefixes (ie. normal/romstage,
helloWorld/romstage, ...).
It defaults to fallback/, so there's no user visible change now.

It's intended to ultimately support switching between images in the
Tinybootblock build model, by running the build several times, adding to
the same image: First fallback, then normal, ...

Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Peter Stuge - 2010-02-09 19:08:30
Patrick Georgi wrote:
> Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>

Acked-by: Peter Stuge <peter@stuge.se>

Patch

Index: src/Kconfig
===================================================================
--- src/Kconfig	(revision 5100)
+++ src/Kconfig	(working copy)
@@ -39,6 +39,13 @@ 
 	  the coreboot version number, so that you can easily distinguish
 	  boot logs of different boards from each other.
 
+config CBFS_PREFIX
+	string "CBFS prefix to use"
+	default "fallback"
+	help
+	  Select the prefix to all files put into the image. It's "fallback"
+	  by default, "normal" is a common alternative.
+
 endmenu
 
 source src/mainboard/Kconfig
Index: src/cpu/amd/model_lx/cache_as_ram.inc
===================================================================
--- src/cpu/amd/model_lx/cache_as_ram.inc	(revision 5100)
+++ src/cpu/amd/model_lx/cache_as_ram.inc	(working copy)
@@ -278,8 +278,5 @@ 
 .previous
 
 #endif /* ASM_CONSOLE_LOGLEVEL > BIOS_DEBUG */
-#if CONFIG_USE_FALLBACK_IMAGE == 1
-str_coreboot_ram_name:	.string "fallback/coreboot_ram"
-#else
-str_coreboot_ram_name:	.string "normal/coreboot_ram"
-#endif
+str_coreboot_ram_name:	.ascii CONFIG_CBFS_PREFIX
+			.string "/coreboot_ram"
Index: src/cpu/amd/car/copy_and_run.c
===================================================================
--- src/cpu/amd/car/copy_and_run.c	(revision 5100)
+++ src/cpu/amd/car/copy_and_run.c	(working copy)
@@ -7,21 +7,13 @@ 
 
 static void copy_and_run(void)
 {
-#if CONFIG_USE_FALLBACK_IMAGE == 1
-	cbfs_and_run_core("fallback/coreboot_ram", 0);
-#else
-      	cbfs_and_run_core("normal/coreboot_ram", 0);
-#endif
+	cbfs_and_run_core(CONFIG_CBFS_PREFIX "/coreboot_ram", 0);
 }
 
 #if CONFIG_AP_CODE_IN_CAR == 1
 
 static void copy_and_run_ap_code_in_car(unsigned ret_addr)
 {
-# if CONFIG_USE_FALLBACK_IMAGE == 1
-	cbfs_and_run_core("fallback/coreboot_apc", ret_addr);
-# else
-      	cbfs_and_run_core("normal/coreboot_apc", ret_addr);
-# endif
+	cbfs_and_run_core(CONFIG_CBFS_PREFIX "/coreboot_apc", ret_addr);
 }
 #endif
Index: src/boot/hardwaremain.c
===================================================================
--- src/boot/hardwaremain.c	(revision 5100)
+++ src/boot/hardwaremain.c	(working copy)
@@ -103,11 +103,7 @@ 
 	 * write our configuration tables.
 	 */
 	lb_mem = write_tables();
-#if CONFIG_USE_FALLBACK_IMAGE == 1
-	cbfs_load_payload(lb_mem, "fallback/payload");
-#else
-	cbfs_load_payload(lb_mem, "normal/payload");
-#endif
+	cbfs_load_payload(lb_mem, CONFIG_CBFS_PREFIX "/payload");
 	printk(BIOS_ERR, "Boot failed.\n");
 }
 
Index: src/arch/i386/init/crt0.S.lb
===================================================================
--- src/arch/i386/init/crt0.S.lb	(revision 5100)
+++ src/arch/i386/init/crt0.S.lb	(working copy)
@@ -137,10 +137,7 @@ 
 
 #endif /* ASM_CONSOLE_LOGLEVEL > BIOS_DEBUG */
 
-#if CONFIG_USE_FALLBACK_IMAGE == 1
-str_coreboot_ram_name:	.string "fallback/coreboot_ram"
-#else
-str_coreboot_ram_name:	.string "normal/coreboot_ram"
-#endif
+str_coreboot_ram_name:	.ascii CONFIG_CBFS_PREFIX
+			.string "/coreboot_ram"
 
 #endif /* CONFIG_USE_DCACHE_RAM */
Index: src/arch/i386/Makefile.inc
===================================================================
--- src/arch/i386/Makefile.inc	(revision 5100)
+++ src/arch/i386/Makefile.inc	(working copy)
@@ -15,14 +15,14 @@ 
 	cp $(obj)/coreboot.pre $@
 	if [ -f fallback/coreboot_apc ]; \
 	then \
-		$(CBFSTOOL) $@ add-stage fallback/coreboot_apc fallback/coreboot_apc $(CBFS_COMPRESS_FLAG); \
+		$(CBFSTOOL) $@ add-stage fallback/coreboot_apc $(CONFIG_CBFS_PREFIX)/coreboot_apc $(CBFS_COMPRESS_FLAG); \
 	fi
-	$(CBFSTOOL) $@ add-stage $(obj)/coreboot_ram fallback/coreboot_ram $(CBFS_COMPRESS_FLAG)
+	$(CBFSTOOL) $@ add-stage $(obj)/coreboot_ram $(CONFIG_CBFS_PREFIX)/coreboot_ram $(CBFS_COMPRESS_FLAG)
 ifeq ($(CONFIG_PAYLOAD_NONE),y)
 	@printf "    PAYLOAD    none (as specified by user)\n"
 else
 	@printf "    PAYLOAD    $(CONFIG_FALLBACK_PAYLOAD_FILE) $(CBFS_PAYLOAD_COMPRESS_FLAG)\n"
-	$(CBFSTOOL) $(obj)/coreboot.rom add-payload $(CONFIG_FALLBACK_PAYLOAD_FILE) fallback/payload $(CBFS_PAYLOAD_COMPRESS_FLAG)
+	$(CBFSTOOL) $(obj)/coreboot.rom add-payload $(CONFIG_FALLBACK_PAYLOAD_FILE) $(CONFIG_CBFS_PREFIX)/payload $(CBFS_PAYLOAD_COMPRESS_FLAG)
 endif
 ifeq ($(CONFIG_VGA_BIOS),y)
 	@printf "    VGABIOS    $(CONFIG_FALLBACK_VGA_BIOS_FILE) $(CONFIG_FALLBACK_VGA_BIOS_ID)\n"
Index: src/arch/i386/Makefile.tinybootblock.inc
===================================================================
--- src/arch/i386/Makefile.tinybootblock.inc	(revision 5100)
+++ src/arch/i386/Makefile.tinybootblock.inc	(working copy)
@@ -3,14 +3,14 @@ 
 #######################################################################
 # Build the final rom image
 
 $(obj)/coreboot.pre1: $(obj)/coreboot.bootblock $(CBFSTOOL)
 	rm -f $@
 	$(CBFSTOOL) $@ create $(CONFIG_COREBOOT_ROMSIZE_KB)K $(obj)/coreboot.bootblock
 
 $(obj)/coreboot.pre: $(obj)/coreboot.romstage $(obj)/coreboot.pre1 $(CBFSTOOL)
 	rm -f $@
 	cp $(obj)/coreboot.pre1 $@
-	$(CBFSTOOL) $@ add-stage $(obj)/romstage.elf fallback/romstage x 0x$(shell cat $(obj)/location.txt)
+	$(CBFSTOOL) $@ add-stage $(obj)/romstage.elf $(CONFIG_CBFS_PREFIX)/romstage x 0x$(shell cat $(obj)/location.txt)
 #FIXME: location.txt might require an offset of header size
 
 #######################################################################
@@ -58,8 +58,8 @@ 
 $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.s: $(obj)/bootblock/bootblock.c
 	$(CC) -x assembler-with-cpp -DASSEMBLY -E -I$(src)/include -I$(src)/arch/i386/include -I$(obj) -I$(obj)/bootblock -include $(obj)/config.h -I. -I$(src) $< > $@.new && mv $@.new $@
 
-$(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc: $(obj)/romcc $(src)/arch/i386/init/bootblock.c
-	$(obj)/romcc $(bootblock_romccflags) -O2 $(ROMCCFLAGS) $(INCLUDES) $(src)/arch/i386/init/bootblock.c -o $@
+$(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc: $(src)/arch/i386/init/$(subst ",,$(CONFIG_TINY_BOOTBLOCK_SOURCE)) $(obj)/romcc
+	$(obj)/romcc $(bootblock_romccflags) -O2 $(ROMCCFLAGS) $(INCLUDES) $< -o $@
 
 $(obj)/bootblock.elf: $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.o $(obj)/bootblock/ldscript.ld
 	@printf "    LINK       $(subst $(obj)/,,$(@))\n"
@@ -74,7 +74,7 @@ 
 	$(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/ldscript.ld $(initobjs)
 	$(OBJCOPY) -O binary $(obj)/romstage.elf $(obj)/romstage.bin
 	printf "CONFIG_ROMBASE = 0x" > $(obj)/location.ld
-	$(CBFSTOOL) $(obj)/coreboot.pre1 locate $(obj)/romstage.bin fallback/romstage $(CONFIG_XIP_ROM_SIZE) > $(obj)/location.txt
+	$(CBFSTOOL) $(obj)/coreboot.pre1 locate $(obj)/romstage.bin $(CONFIG_CBFS_PREFIX)/romstage $(CONFIG_XIP_ROM_SIZE) > $(obj)/location.txt
 	cat $(obj)/location.txt >> $(obj)/location.ld
 	printf ';\nAUTO_XIP_ROM_BASE = CONFIG_ROMBASE & ~(CONFIG_XIP_ROM_SIZE - 1);\n' >> $(obj)/location.ld
 	$(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/ldscript.ld $(initobjs)