[coreboot-gerrit] Patch set updated for coreboot: WIP: arch/x86: Allow boot flow which runs CAR setup in bootblock

Alexandru Gagniuc (mr.nuke.me@gmail.com) gerrit at coreboot.org
Sun Oct 11 01:36:50 CEST 2015


Alexandru Gagniuc (mr.nuke.me at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11784

-gerrit

commit e9665bc8eaa2d13e99f137779e98e288936d01e6
Author: Alexandru Gagniuc <mr.nuke.me at gmail.com>
Date:   Fri Oct 2 12:42:26 2015 -0700

    WIP: arch/x86: Allow boot flow which runs CAR setup in bootblock
    
    On systems with non-memory-mapped boot media we simply do not have
    enough space for romstage. This means that CAR setup and early boot
    media (e.g. SPI) drivers need to be implemented with minimal overhead.
    The bootblock is the best place to do this.
    
    Note that this patch does introduce a somewhat awkward boot flow:
    reset(gas) -> bootblock main (romcc) -> car setup (gas) -> car (gcc)
    However, we've chosen this path as it is least intrusive on the
    existing infrastructure. In the future, we will investigate the
    possiblity of eliminating the romcc step.
    
    Change-Id: Icbf5804b66b9517f9ceb352bed86978dcf92228f
    Signed-off-by: Alexandru Gagniuc <mr.nuke.me at gmail.com>
---
 src/arch/x86/Kconfig             |  7 +++++++
 src/arch/x86/Makefile.inc        |  8 +++++++-
 src/arch/x86/bootblock.S         |  6 ++++++
 src/arch/x86/bootblock_simple.c  | 28 ++++++++++++++++++++++------
 src/arch/x86/include/arch/cbfs.h |  6 +++---
 5 files changed, 45 insertions(+), 10 deletions(-)

diff --git a/src/arch/x86/Kconfig b/src/arch/x86/Kconfig
index 88b2592..412e504 100644
--- a/src/arch/x86/Kconfig
+++ b/src/arch/x86/Kconfig
@@ -56,6 +56,13 @@ config ARCH_RAMSTAGE_X86_64
 	bool
 	default n
 
+# This is a new bootflow, in which a C environment is available in the
+# bootblock. That can be achieved either by performing CAR setup is in the
+# bootblock, or using memory available at boot-time (e.g. SRAM)
+config C_ENVIRONMENT_BOOTBLOCK
+	bool
+	default n
+
 # This is an SMP option. It relates to starting up APs.
 # It is usually set in mainboard/*/Kconfig.
 # TODO: Improve description.
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 56b176d..a9a1666 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -87,7 +87,6 @@ endif
 bootblock-y += id.S
 bootblock-y += bootblock.S
 bootblock-y += walkcbfs.S
-$(obj)/arch/x86/bootblock.bootblock.o: $(objgenerated)/bootblock.inc
 
 bootblock-y += bootblock.ld
 $(obj)/arch/x86/bootblock.bootblock.ld: $(objgenerated)/bootblock.ld
@@ -106,11 +105,18 @@ $(objgenerated)/bootblock.ld: $$(filter-out $(obj)/arch/x86/bootblock.bootblock.
 	cat $^ >> $@.tmp
 	mv $@.tmp $@
 
+ifeq ($(CONFIG_C_ENVIRONMENT_BOOTBLOCK),y)
+bootblock-$(CONFIG_BOOTBLOCK_SIMPLE) += bootblock_simple.c
+bootblock-$(CONFIG_BOOTBLOCK_NORMAL) += bootblock_normal.c
+else
+$(obj)/arch/x86/bootblock.bootblock.o: $(objgenerated)/bootblock.inc
+
 $(objgenerated)/bootblock.inc: $(src)/arch/x86/$(subst ",,$(CONFIG_BOOTBLOCK_SOURCE)) $(objutil)/romcc/romcc $(OPTION_TABLE_H) $(KCONFIG_AUTOHEADER)
 	@printf "    ROMCC      $(subst $(obj)/,,$(@))\n"
 	$(CC_bootblock) $(CPPFLAGS_bootblock) -MM -MT$(objgenerated)/bootblock.inc \
 		$< > $(objgenerated)/bootblock.inc.d
 	$(ROMCC) -c -S $(bootblock_romccflags) -I. $(CPPFLAGS_bootblock) $< -o $@
+endif
 
 # $(obj)/arch/x86/bootblock.bootblock.ld is part of $(bootblock-objs)
 $(objcbfs)/bootblock.debug: $$(bootblock-objs)
diff --git a/src/arch/x86/bootblock.S b/src/arch/x86/bootblock.S
index 645e491..afc7a68 100644
--- a/src/arch/x86/bootblock.S
+++ b/src/arch/x86/bootblock.S
@@ -34,6 +34,11 @@
 #include <cpu/x86/sse_enable.inc>
 #endif
 
+#if IS_ENABLED(CONFIG_C_ENVIRONMENT_BOOTBLOCK)
+
+	jmp	bootblock_pre_c_entry
+
+#else /* !IS_ENABLED(CONFIG_C_ENVIRONMENT_BOOTBLOCK) */
 /*
  * This bootblock.inc file is generated by ROMCC. The above program flow
  * falls through to this point. ROMCC assumes the last function it parsed
@@ -42,3 +47,4 @@
  * needs to come after bootblock.inc.
  */
 #include <generated/bootblock.inc>
+#endif /* !IS_ENABLED(CONFIG_C_ENVIRONMENT_BOOTBLOCK) */
diff --git a/src/arch/x86/bootblock_simple.c b/src/arch/x86/bootblock_simple.c
index adeecf7..160ff41 100644
--- a/src/arch/x86/bootblock_simple.c
+++ b/src/arch/x86/bootblock_simple.c
@@ -2,7 +2,24 @@
 #include <bootblock_common.h>
 #include <halt.h>
 
-static void main(unsigned long bist)
+static void advance_to_romstage(unsigned long bist)
+{
+	const char* target1 = "fallback/romstage";
+	unsigned long entry;
+	entry = findstage(target1);
+	if (entry) call(entry, bist);
+	halt();
+
+}
+
+static void advance_to_car_setup(unsigned long bist)
+{
+	__asm__ volatile(
+		"jmp bootblock_pre_car_entry"
+		:: "a" (bist)
+	);
+}
+void main(unsigned long bist)
 {
 	if (boot_cpu()) {
 		bootblock_mainboard_init();
@@ -15,9 +32,8 @@ static void main(unsigned long bist)
 #endif
 	}
 
-	const char* target1 = "fallback/romstage";
-	unsigned long entry;
-	entry = findstage(target1);
-	if (entry) call(entry, bist);
-	halt();
+	if (IS_ENABLED(CONFIG_CAR_BOOTBLOCK))
+		advance_to_car_setup(bist);
+	else
+		advance_to_romstage(bist);
 }
diff --git a/src/arch/x86/include/arch/cbfs.h b/src/arch/x86/include/arch/cbfs.h
index 195c06f..349f671 100644
--- a/src/arch/x86/include/arch/cbfs.h
+++ b/src/arch/x86/include/arch/cbfs.h
@@ -25,7 +25,7 @@
 
 #define CBFS_SUBHEADER(_p) ( (void *) ((((uint8_t *) (_p)) + ntohl((_p)->offset))) )
 
-static struct cbfs_file *walkcbfs_head(char *target)
+static struct cbfs_file *walkcbfs_head(const char *target)
 {
 	void *entry;
 	asm volatile (
@@ -35,7 +35,7 @@ static struct cbfs_file *walkcbfs_head(char *target)
 	return entry;
 }
 
-static void *walkcbfs(char *target)
+static void *walkcbfs(const char *target)
 {
 	struct cbfs_file *head = walkcbfs_head(target);
 	if ((u32)head != 0)
@@ -51,7 +51,7 @@ struct cbfs_stage_restricted {
 	unsigned long entry; // this is really 64bit, but properly endianized
 };
 
-static inline unsigned long findstage(char* target)
+static inline unsigned long findstage(const char* target)
 {
 	struct cbfs_stage_restricted *stage = walkcbfs(target);
 	if ((u32)stage != 0)



More information about the coreboot-gerrit mailing list