From c9fa96d04c85430c7397473b2995f8f4913beb9c Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Wed, 24 Feb 2010 13:58:23 +0000 Subject: Enable user selectable bootblocks, and provide a bootblock that selects between "fallback" and "normal", in addition to the already present "fallback"-only bootblock. Signed-off-by: Patrick Georgi Acked-by: Stefan Reinauer git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5157 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- src/arch/i386/Kconfig | 18 ++++++ src/arch/i386/Makefile.bootblock.inc | 104 +++++++++++++++++++++++++++++++ src/arch/i386/Makefile.inc | 2 +- src/arch/i386/Makefile.tinybootblock.inc | 104 ------------------------------- src/arch/i386/include/bootblock_common.h | 33 ++++++++++ src/arch/i386/init/bootblock.c | 47 -------------- src/arch/i386/init/bootblock_normal.c | 29 +++++++++ src/arch/i386/init/bootblock_simple.c | 15 +++++ 8 files changed, 200 insertions(+), 152 deletions(-) create mode 100644 src/arch/i386/Makefile.bootblock.inc delete mode 100644 src/arch/i386/Makefile.tinybootblock.inc create mode 100644 src/arch/i386/include/bootblock_common.h delete mode 100644 src/arch/i386/init/bootblock.c create mode 100644 src/arch/i386/init/bootblock_normal.c create mode 100644 src/arch/i386/init/bootblock_simple.c (limited to 'src/arch/i386') diff --git a/src/arch/i386/Kconfig b/src/arch/i386/Kconfig index bf60039f8f..50a8057371 100644 --- a/src/arch/i386/Kconfig +++ b/src/arch/i386/Kconfig @@ -49,6 +49,24 @@ config BIG_BOOTBLOCK default n if TINY_BOOTBLOCK default y +choice + prompt "Bootblock behaviour" + default BOOTBLOCK_SIMPLE + depends on TINY_BOOTBLOCK + +config BOOTBLOCK_SIMPLE + bool "Always load fallback" + +config BOOTBLOCK_NORMAL + bool "Switch to normal if CMOS says so" + +endchoice + +config BOOTBLOCK_SOURCE + string + default "bootblock_simple.c" if BOOTBLOCK_SIMPLE + default "bootblock_normal.c" if BOOTBLOCK_NORMAL + config UPDATE_IMAGE bool "Update existing coreboot.rom image" default n diff --git a/src/arch/i386/Makefile.bootblock.inc b/src/arch/i386/Makefile.bootblock.inc new file mode 100644 index 0000000000..a7cbc6c9cf --- /dev/null +++ b/src/arch/i386/Makefile.bootblock.inc @@ -0,0 +1,104 @@ +ifdef POST_EVALUATION + +####################################################################### +# Build the final rom image + +ifneq ($(CONFIG_UPDATE_IMAGE),y) +$(obj)/coreboot.pre1: $(obj)/coreboot.bootblock $(CBFSTOOL) + rm -f $@ + $(CBFSTOOL) $@ create $(CONFIG_COREBOOT_ROMSIZE_KB)K $(obj)/coreboot.bootblock +else +$(obj)/coreboot.pre1: $(CBFSTOOL) + mv $(obj)/coreboot.rom $@ +endif + +$(obj)/coreboot.pre: $(obj)/coreboot.romstage $(obj)/coreboot.pre1 $(CBFSTOOL) + rm -f $@ + cp $(obj)/coreboot.pre1 $@ + $(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 + +####################################################################### +# Build the bootblock + +$(obj)/coreboot.bootblock: $(obj)/bootblock.elf + @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" + $(OBJCOPY) -O binary $< $@ + +bootblock_lds := $(src)/arch/i386/init/ldscript_failover.lb +bootblock_lds += $(src)/cpu/x86/16bit/entry16.lds +bootblock_lds += $(src)/cpu/x86/16bit/reset16.lds +bootblock_lds += $(src)/arch/i386/lib/id.lds +bootblock_lds += $(chipset_bootblock_lds) + +bootblock_inc := $(src)/arch/i386/init/bootblock_prologue.c +bootblock_inc += $(src)/cpu/x86/16bit/entry16.inc +bootblock_inc += $(src)/cpu/x86/16bit/reset16.inc +bootblock_inc += $(src)/cpu/x86/32bit/entry32.inc +bootblock_inc += $(src)/arch/i386/lib/id.inc +bootblock_inc += $(chipset_bootblock_inc) + +ifeq ($(CONFIG_SSE),y) +bootblock_inc += $(src)/cpu/x86/sse_enable.inc +endif +bootblock_inc += $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc +bootblock_inc += $(src)/arch/i386/lib/walkcbfs.S + +bootblock_romccflags := -mcpu=i386 +ifeq ($(CONFIG_SSE),y) +bootblock_romccflags := -mcpu=k7 -msse +endif + +$(obj)/bootblock/ldscript.ld: $(bootblock_ldscripts) $(obj)/ldoptions + mkdir -p $(obj)/bootblock + printf '$(foreach ldscript,ldoptions $(bootblock_lds),INCLUDE "$(ldscript)"\n)' > $@ + +$(obj)/bootblock/bootblock.c: $(bootblock_inc) + mkdir -p $(obj)/bootblock + printf '$(foreach crt0,config.h $(bootblock_inc),#include "$(crt0)"\n)' > $@ + +$(obj)/mainboard/$(MAINBOARDDIR)/bootblock.o: $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.s + $(CC) -I$(obj) -Wa,-acdlns -c -o $@ $< > $(dir $@)/crt0.disasm + +$(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: $(src)/arch/i386/init/$(subst ",,$(CONFIG_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" + $(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(obj)/bootblock/ldscript.ld $< + $(NM) -n $(obj)/bootblock.elf | sort > $(obj)/bootblock.map + +####################################################################### +# Build the romstage +$(obj)/coreboot.romstage: $(obj)/coreboot.pre1 $(initobjs) $(obj)/romstage/ldscript.ld + @printf " LINK $(subst $(obj)/,,$(@))\n" + printf "CONFIG_ROMBASE = 0x0;\nAUTO_XIP_ROM_BASE = 0x0;\n" > $(obj)/location.ld + $(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 $(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) + $(NM) -n $(obj)/romstage.elf | sort > $(obj)/romstage.map + $(OBJCOPY) -O binary $(obj)/romstage.elf $@ + +$(obj)/romstage/ldscript.ld: $(ldscripts) $(obj)/ldoptions + mkdir -p $(obj)/romstage + printf '$(foreach ldscript,ldoptions location.ld $(ldscripts),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' > $@ + +$(obj)/romstage/crt0_includes.h: $(crt0s) + @printf " GEN $(subst $(obj)/,,$(@))\n" + mkdir -p $(obj)/romstage + printf '$(foreach crt0,config.h $(crt0s),#include "$(crt0:$(obj)/%=%)"\n)' > $@ + +$(obj)/mainboard/$(MAINBOARDDIR)/crt0.initobj.o: $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s + $(CC) -I$(obj) -Wa,-acdlns -c -o $@ $< > $(dir $@)/crt0.disasm + +$(obj)/mainboard/$(MAINBOARDDIR)/crt0.s: $(src)/arch/i386/init/crt0.S.lb $(obj)/romstage/crt0_includes.h + $(CC) -x assembler-with-cpp -DASSEMBLY -E -I$(src)/include -I$(src)/arch/i386/include -I$(obj) -I$(obj)/romstage -include $(obj)/config.h -I. -I$(src) $< > $@.new && mv $@.new $@ + +endif diff --git a/src/arch/i386/Makefile.inc b/src/arch/i386/Makefile.inc index 831c8cf90a..950381aedf 100644 --- a/src/arch/i386/Makefile.inc +++ b/src/arch/i386/Makefile.inc @@ -95,7 +95,7 @@ endif endif ifeq ($(CONFIG_TINY_BOOTBLOCK),y) -include $(src)/arch/i386/Makefile.tinybootblock.inc +include $(src)/arch/i386/Makefile.bootblock.inc else include $(src)/arch/i386/Makefile.bigbootblock.inc endif diff --git a/src/arch/i386/Makefile.tinybootblock.inc b/src/arch/i386/Makefile.tinybootblock.inc deleted file mode 100644 index 8911844d9e..0000000000 --- a/src/arch/i386/Makefile.tinybootblock.inc +++ /dev/null @@ -1,104 +0,0 @@ -ifdef POST_EVALUATION - -####################################################################### -# Build the final rom image - -ifneq ($(CONFIG_UPDATE_IMAGE),y) -$(obj)/coreboot.pre1: $(obj)/coreboot.bootblock $(CBFSTOOL) - rm -f $@ - $(CBFSTOOL) $@ create $(CONFIG_COREBOOT_ROMSIZE_KB)K $(obj)/coreboot.bootblock -else -$(obj)/coreboot.pre1: $(CBFSTOOL) - mv $(obj)/coreboot.rom $@ -endif - -$(obj)/coreboot.pre: $(obj)/coreboot.romstage $(obj)/coreboot.pre1 $(CBFSTOOL) - rm -f $@ - cp $(obj)/coreboot.pre1 $@ - $(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 - -####################################################################### -# Build the bootblock - -$(obj)/coreboot.bootblock: $(obj)/bootblock.elf - @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" - $(OBJCOPY) -O binary $< $@ - -bootblock_lds := $(src)/arch/i386/init/ldscript_failover.lb -bootblock_lds += $(src)/cpu/x86/16bit/entry16.lds -bootblock_lds += $(src)/cpu/x86/16bit/reset16.lds -bootblock_lds += $(src)/arch/i386/lib/id.lds -bootblock_lds += $(chipset_bootblock_lds) - -bootblock_inc := $(src)/arch/i386/init/bootblock_prologue.c -bootblock_inc += $(src)/cpu/x86/16bit/entry16.inc -bootblock_inc += $(src)/cpu/x86/16bit/reset16.inc -bootblock_inc += $(src)/cpu/x86/32bit/entry32.inc -bootblock_inc += $(src)/arch/i386/lib/id.inc -bootblock_inc += $(chipset_bootblock_inc) - -ifeq ($(CONFIG_SSE),y) -bootblock_inc += $(src)/cpu/x86/sse_enable.inc -endif -bootblock_inc += $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc -bootblock_inc += $(src)/arch/i386/lib/walkcbfs.S - -bootblock_romccflags := -mcpu=i386 -ifeq ($(CONFIG_SSE),y) -bootblock_romccflags := -mcpu=k7 -msse -endif - -$(obj)/bootblock/ldscript.ld: $(bootblock_ldscripts) $(obj)/ldoptions - mkdir -p $(obj)/bootblock - printf '$(foreach ldscript,ldoptions $(bootblock_lds),INCLUDE "$(ldscript)"\n)' > $@ - -$(obj)/bootblock/bootblock.c: $(bootblock_inc) - mkdir -p $(obj)/bootblock - printf '$(foreach crt0,config.h $(bootblock_inc),#include "$(crt0)"\n)' > $@ - -$(obj)/mainboard/$(MAINBOARDDIR)/bootblock.o: $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.s - $(CC) -I$(obj) -Wa,-acdlns -c -o $@ $< > $(dir $@)/crt0.disasm - -$(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: $(src)/arch/i386/init/bootblock.c $(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" - $(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(obj)/bootblock/ldscript.ld $< - $(NM) -n $(obj)/bootblock.elf | sort > $(obj)/bootblock.map - -####################################################################### -# Build the romstage -$(obj)/coreboot.romstage: $(obj)/coreboot.pre1 $(initobjs) $(obj)/romstage/ldscript.ld - @printf " LINK $(subst $(obj)/,,$(@))\n" - printf "CONFIG_ROMBASE = 0x0;\nAUTO_XIP_ROM_BASE = 0x0;\n" > $(obj)/location.ld - $(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 $(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) - $(NM) -n $(obj)/romstage.elf | sort > $(obj)/romstage.map - $(OBJCOPY) -O binary $(obj)/romstage.elf $@ - -$(obj)/romstage/ldscript.ld: $(ldscripts) $(obj)/ldoptions - mkdir -p $(obj)/romstage - printf '$(foreach ldscript,ldoptions location.ld $(ldscripts),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' > $@ - -$(obj)/romstage/crt0_includes.h: $(crt0s) - @printf " GEN $(subst $(obj)/,,$(@))\n" - mkdir -p $(obj)/romstage - printf '$(foreach crt0,config.h $(crt0s),#include "$(crt0:$(obj)/%=%)"\n)' > $@ - -$(obj)/mainboard/$(MAINBOARDDIR)/crt0.initobj.o: $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s - $(CC) -I$(obj) -Wa,-acdlns -c -o $@ $< > $(dir $@)/crt0.disasm - -$(obj)/mainboard/$(MAINBOARDDIR)/crt0.s: $(src)/arch/i386/init/crt0.S.lb $(obj)/romstage/crt0_includes.h - $(CC) -x assembler-with-cpp -DASSEMBLY -E -I$(src)/include -I$(src)/arch/i386/include -I$(obj) -I$(obj)/romstage -include $(obj)/config.h -I. -I$(src) $< > $@.new && mv $@.new $@ - -endif diff --git a/src/arch/i386/include/bootblock_common.h b/src/arch/i386/include/bootblock_common.h new file mode 100644 index 0000000000..895a185c6f --- /dev/null +++ b/src/arch/i386/include/bootblock_common.h @@ -0,0 +1,33 @@ +#define __PRE_RAM__ +#if CONFIG_LOGICAL_CPUS && \ + (defined(CONFIG_BOOTBLOCK_NORTHBRIDGE_INIT) || defined(CONFIG_BOOTBLOCK_SOUTHBRIDGE_INIT)) +#include +#else +#define boot_cpu(x) 1 +#endif + +#ifdef CONFIG_BOOTBLOCK_NORTHBRIDGE_INIT +#include CONFIG_BOOTBLOCK_NORTHBRIDGE_INIT +#else +static void bootblock_northbridge_init(void) { } +#endif +#ifdef CONFIG_BOOTBLOCK_SOUTHBRIDGE_INIT +#include CONFIG_BOOTBLOCK_SOUTHBRIDGE_INIT +#else +static void bootblock_southbridge_init(void) { } +#endif + +static unsigned long findstage(char* target) +{ + unsigned long entry; + asm volatile ( + "mov $1f, %%esp\n\t" + "jmp walkcbfs\n\t" + "1:\n\t" : "=a" (entry) : "S" (target) : "ebx", "ecx", "edi", "esp"); + return entry; +} + +static void call(unsigned long addr, unsigned long bist) +{ + asm volatile ("jmp *%0\n\t" : : "r" (addr), "a" (bist)); +} diff --git a/src/arch/i386/init/bootblock.c b/src/arch/i386/init/bootblock.c deleted file mode 100644 index 86a5c5b136..0000000000 --- a/src/arch/i386/init/bootblock.c +++ /dev/null @@ -1,47 +0,0 @@ -#define __PRE_RAM__ -#if CONFIG_LOGICAL_CPUS && \ - (defined(CONFIG_BOOTBLOCK_NORTHBRIDGE_INIT) || defined(CONFIG_BOOTBLOCK_SOUTHBRIDGE_INIT)) -#include -#else -#define boot_cpu(x) 1 -#endif - -#ifdef CONFIG_BOOTBLOCK_NORTHBRIDGE_INIT -#include CONFIG_BOOTBLOCK_NORTHBRIDGE_INIT -#else -static void bootblock_northbridge_init(void) { } -#endif -#ifdef CONFIG_BOOTBLOCK_SOUTHBRIDGE_INIT -#include CONFIG_BOOTBLOCK_SOUTHBRIDGE_INIT -#else -static void bootblock_southbridge_init(void) { } -#endif - -static unsigned long findstage(char* target) -{ - unsigned long entry; - asm volatile ( - "mov $1f, %%esp\n\t" - "jmp walkcbfs\n\t" - "1:\n\t" : "=a" (entry) : "S" (target) : "ebx", "ecx", "edi", "esp"); - return entry; -} - -static void call(unsigned long addr, unsigned long bist) -{ - asm volatile ("jmp *%0\n\t" : : "r" (addr), "a" (bist)); -} - -static void main(unsigned long bist) -{ - if (boot_cpu()) { - bootblock_northbridge_init(); - bootblock_southbridge_init(); - } - const char* target1 = "fallback/romstage"; - unsigned long entry; - entry = findstage(target1); - if (entry) call(entry, bist); - asm volatile ("1:\n\thlt\n\tjmp 1b\n\t"); -} - diff --git a/src/arch/i386/init/bootblock_normal.c b/src/arch/i386/init/bootblock_normal.c new file mode 100644 index 0000000000..0e5bd25556 --- /dev/null +++ b/src/arch/i386/init/bootblock_normal.c @@ -0,0 +1,29 @@ +#include + +#include +#include "arch/romcc_io.h" +#include "pc80/mc146818rtc_early.c" + +static void main(unsigned long bist) +{ + if (boot_cpu()) { + bootblock_northbridge_init(); + bootblock_southbridge_init(); + } + + unsigned long entry; + if (do_normal_boot()) + entry = findstage("normal/romstage"); + else + entry = findstage("fallback/romstage"); + + if (entry) call(entry, bist); + + /* run fallback if normal can't be found */ + entry = findstage("fallback/romstage"); + if (entry) call(entry, bist); + + /* duh. we're stuck */ + asm volatile ("1:\n\thlt\n\tjmp 1b\n\t"); +} + diff --git a/src/arch/i386/init/bootblock_simple.c b/src/arch/i386/init/bootblock_simple.c new file mode 100644 index 0000000000..e8994ee092 --- /dev/null +++ b/src/arch/i386/init/bootblock_simple.c @@ -0,0 +1,15 @@ +#include + +static void main(unsigned long bist) +{ + if (boot_cpu()) { + bootblock_northbridge_init(); + bootblock_southbridge_init(); + } + const char* target1 = "fallback/romstage"; + unsigned long entry; + entry = findstage(target1); + if (entry) call(entry, bist); + asm volatile ("1:\n\thlt\n\tjmp 1b\n\t"); +} + -- cgit v1.2.3