Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/11858
-gerrit
commit f6fd880bfae7a31fd16f9c88cdaeb62ea3026255
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Sat Oct 10 16:35:58 2015 -0700
cpu/qemu-x86: Run a C environment in the bootblock
Make use of the ROMCC-less bootblock introduced earlier. The "qemu"
cpu is particularly easy because it does not require CAR setup.
Change-Id: Idf161d363d2daf3c55454d376ca42d492463971a
Signed-off-by: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
---
src/cpu/qemu-x86/Kconfig | 1 +
src/cpu/qemu-x86/Makefile.inc | 2 ++
src/cpu/qemu-x86/bootblock.c | 55 ++++++++++++++++++++++++++++++++++++++++
src/cpu/qemu-x86/bootblock_asm.S | 48 +++++++++++++++++++++++++++++++++++
4 files changed, 106 insertions(+)
diff --git a/src/cpu/qemu-x86/Kconfig b/src/cpu/qemu-x86/Kconfig
index ea2bc46..0ace941 100644
--- a/src/cpu/qemu-x86/Kconfig
+++ b/src/cpu/qemu-x86/Kconfig
@@ -19,4 +19,5 @@ config CPU_QEMU_X86
select ARCH_VERSTAGE_X86_32
select ARCH_ROMSTAGE_X86_32
select ARCH_RAMSTAGE_X86_32
+ select C_ENVIRONMENT_BOOTBLOCK
select SMP
diff --git a/src/cpu/qemu-x86/Makefile.inc b/src/cpu/qemu-x86/Makefile.inc
index b5f8369..0ed76f9 100644
--- a/src/cpu/qemu-x86/Makefile.inc
+++ b/src/cpu/qemu-x86/Makefile.inc
@@ -12,6 +12,8 @@
## GNU General Public License for more details.
##
+bootblock-y += bootblock_asm.S
+bootblock-y += bootblock.c
ramstage-y += qemu.c
subdirs-y += ../x86/mtrr
subdirs-y += ../x86/lapic
diff --git a/src/cpu/qemu-x86/bootblock.c b/src/cpu/qemu-x86/bootblock.c
new file mode 100644
index 0000000..92dd6f7
--- /dev/null
+++ b/src/cpu/qemu-x86/bootblock.c
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <arch/cpu.h>
+#include <cbfs.h>
+#include <halt.h>
+
+/* Called from assembly. Prototype not needed by external .c file */
+asmlinkage void bootblock_main(uint32_t bist, uint32_t tsc_lo, uint32_t tsc_hi);
+
+/*
+ * TODO: Implement a generic fallback/normal mechanism
+ */
+static const char *get_next_stage_name(void)
+{
+ if (IS_ENABLED(CONFIG_BOOTBLOCK_SIMPLE))
+ return CONFIG_CBFS_PREFIX "/romstage";
+
+ /* BOOTBLOCK_NORMAL not implemented */
+ return CONFIG_CBFS_PREFIX "/romstage";
+}
+
+static void enter_romstage(void *romstage_entry, uint32_t bist)
+{
+ asm volatile (
+ "jmp *%0\n\t"
+ : : "r" (romstage_entry), "a" (bist)
+ );
+}
+
+asmlinkage void bootblock_main(uint32_t bist, uint32_t tsc_lo, uint32_t tsc_hi)
+{
+ void *entry;
+ struct cbfs_stage *romstage;
+ const char* target1 = get_next_stage_name();
+
+ romstage = cbfs_boot_map_with_leak(target1, CBFS_TYPE_STAGE, NULL);
+
+ /*
+ * TODO: Do something constructive with tsc_lo and tsc_hi
+ */
+ if (romstage) {
+ entry = (void *)(uintptr_t)romstage->entry;
+ enter_romstage(entry, bist);
+ }
+ halt();
+}
diff --git a/src/cpu/qemu-x86/bootblock_asm.S b/src/cpu/qemu-x86/bootblock_asm.S
new file mode 100644
index 0000000..6e1cd2e
--- /dev/null
+++ b/src/cpu/qemu-x86/bootblock_asm.S
@@ -0,0 +1,48 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <console/post_codes.h>
+
+#define STACK_SIZE 0x10000
+#define STACK_BASE 0xd0000
+
+.intel_syntax noprefix
+
+#define post_code(code) \
+ mov eax, code; \
+ out 0x80, eax
+
+.global bootblock_pre_c_entry
+
+.section .text
+bootblock_pre_c_entry:
+
+ /* Set up a stack */
+ mov esp, (STACK_BASE + STACK_SIZE - 4)
+
+ /*
+ * We have the following values saved from earlier:
+ * mm0: BIST result
+ * mm1: TSC timestamp low 32 bits
+ * mm2: TSC timestamp high 32 bits
+ */
+ movd eax, mm2
+ push eax
+ movd eax, mm1
+ push eax
+ movd eax, mm0
+ push eax
+ call bootblock_main
+
+.halt_forever:
+ post_code(POST_DEAD_CODE)
+ hlt
+ jmp .halt_forever
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12874
-gerrit
commit e4bececdf745e04643bf902bff137d440f2b35f4
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Fri Jan 8 21:56:43 2016 -0800
drivers/uart/Makefile.inc: Compile uart8250io in bootblock
This is needed for the next patch, which enables bootblock console on
"qemu" CPUs, since that platform uses the 8250io driver.
Note that the include is guarded by CONFIG_DRIVERS_UART_8250IO, so
there is no risk of breaking builds on non-x86 architectures.
Change-Id: Iaeed7280aa97b58d46b003df66647dae4a4e0e29
Signed-off-by: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
---
src/drivers/uart/Makefile.inc | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/drivers/uart/Makefile.inc b/src/drivers/uart/Makefile.inc
index da8b5f7..4b2aa53 100644
--- a/src/drivers/uart/Makefile.inc
+++ b/src/drivers/uart/Makefile.inc
@@ -10,6 +10,7 @@ smm-$(CONFIG_DEBUG_SMI) += util.c
# be located in the soc/ or cpu/ directories instead of here.
ifeq ($(CONFIG_DRIVERS_UART_8250IO),y)
+bootblock-y += uart8250io.c
verstage-y += uart8250io.c
romstage-y += uart8250io.c
ramstage-y += uart8250io.c
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12875
-gerrit
commit aa95a775371fa2d832c845a8bd464d06076c8d86
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Fri Jan 8 22:00:21 2016 -0800
cpu/qemu-x86: Enable bootblock console
This brings the qemu C environment bootblock closer to the generic
bootblock in lib/. This is a step before the bootblocks can be
converged, but the code is not yet ready for unification.
When running qemu with the "-serial stdio" flag, the
"bootblock starting..." message now appears on the console.
Change-Id: I121bce620cf7f8a713e7dad1833cff1b0dc2116f
Signed-off-by: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
---
src/cpu/qemu-x86/bootblock.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/cpu/qemu-x86/bootblock.c b/src/cpu/qemu-x86/bootblock.c
index 92dd6f7..d62c47e 100644
--- a/src/cpu/qemu-x86/bootblock.c
+++ b/src/cpu/qemu-x86/bootblock.c
@@ -11,6 +11,7 @@
#include <arch/cpu.h>
#include <cbfs.h>
+#include <console/console.h>
#include <halt.h>
/* Called from assembly. Prototype not needed by external .c file */
@@ -42,6 +43,9 @@ asmlinkage void bootblock_main(uint32_t bist, uint32_t tsc_lo, uint32_t tsc_hi)
struct cbfs_stage *romstage;
const char* target1 = get_next_stage_name();
+ if (IS_ENABLED(CONFIG_BOOTBLOCK_CONSOLE))
+ console_init();
+
romstage = cbfs_boot_map_with_leak(target1, CBFS_TYPE_STAGE, NULL);
/*
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12870
-gerrit
commit ed2c73fc9480731d087ff185b53564c52b69bf44
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Tue Oct 6 16:35:39 2015 -0700
src/arch/x86: Link the compiler runtime library in the bootblock
At least on GCC __udivdi3 and __umoddi3 are needed by the console
code. They are provided by the compiler runtime library.
Change-Id: I78bbea425c33d7eebaf829d58d763b7a1c6e997c
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/arch/x86/Makefile.inc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index f372645..c940f44 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -112,8 +112,12 @@ endif
# $(obj)/arch/x86/bootblock.bootblock.ld is part of $(bootblock-objs)
$(objcbfs)/bootblock.debug: $$(bootblock-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \
- $(filter-out %.ld,$(bootblock-objs)) \
+ $(LD_bootblock) $(LDFLAGS_bootblock) -static \
+ -o $@ $(COMPILER_RT_FLAGS_bootblock) -L$(obj) \
+ -whole-archive --start-group \
+ $(filter %.o,$(bootblock-objs)) \
+ --no-whole-archive $(COMPILER_RT_bootblock) \
+ --end-group \
-T $(obj)/arch/x86/bootblock.bootblock.ld
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12871
-gerrit
commit 384f3a4f2d094617f2276163c0eb965d1dc8a9c2
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Fri Oct 2 18:01:18 2015 -0700
console: Allow selecting C environment bootblock console on x86
There's no reason to not have console in the bootblock, if the
bootblock is running a C environment.
Change-Id: Ia3e41796d9aea197cee0a073acce63761823c3aa
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/console/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/console/Kconfig b/src/console/Kconfig
index 73c6b28..57b828a 100644
--- a/src/console/Kconfig
+++ b/src/console/Kconfig
@@ -2,7 +2,7 @@ menu "Console"
config BOOTBLOCK_CONSOLE
bool "Enable early (bootblock) console output."
- depends on ARCH_ARM || ARCH_ARM64 || ARCH_RISCV || ARCH_MIPS
+ depends on ARCH_ARM || ARCH_ARM64 || ARCH_RISCV || ARCH_MIPS || C_ENVIRONMENT_BOOTBLOCK
default n
help
Use console during the bootblock if supported
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12881
-gerrit
commit 3e4ec37c1e2fc141afd82a5a3310d3a092ad392b
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Fri Jan 8 23:08:09 2016 -0800
cpu/qemu-x86: Use run_romstage instead of custom inline assembly
Now that passing the BIST result to romstage is no longer required,
we no longer need to use custom assembly to call into romstage.
Instead, a lot of the logic in the bootblock can now be replaced by
a single call to run_romstage(). This is another step in converging
the bootblock with the generic bootblock logic in lib/.
Change-Id: I66436c8fba5121a3758d02955f691ac9d273b049
Signed-off-by: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
---
src/cpu/qemu-x86/bootblock.c | 34 ++--------------------------------
1 file changed, 2 insertions(+), 32 deletions(-)
diff --git a/src/cpu/qemu-x86/bootblock.c b/src/cpu/qemu-x86/bootblock.c
index b4700a7..056bde4 100644
--- a/src/cpu/qemu-x86/bootblock.c
+++ b/src/cpu/qemu-x86/bootblock.c
@@ -18,32 +18,8 @@
/* Called from assembly. Prototype not needed by external .c file */
asmlinkage void bootblock_main(uint32_t bist, uint32_t tsc_lo, uint32_t tsc_hi);
-/*
- * TODO: Implement a generic fallback/normal mechanism
- */
-static const char *get_next_stage_name(void)
-{
- if (IS_ENABLED(CONFIG_BOOTBLOCK_SIMPLE))
- return CONFIG_CBFS_PREFIX "/romstage";
-
- /* BOOTBLOCK_NORMAL not implemented */
- return CONFIG_CBFS_PREFIX "/romstage";
-}
-
-static void enter_romstage(void *romstage_entry, uint32_t bist)
-{
- asm volatile (
- "jmp *%0\n\t"
- : : "r" (romstage_entry), "a" (bist)
- );
-}
-
asmlinkage void bootblock_main(uint32_t bist, uint32_t tsc_lo, uint32_t tsc_hi)
{
- void *entry;
- struct cbfs_stage *romstage;
- const char* target1 = get_next_stage_name();
-
if (IS_ENABLED(CONFIG_BOOTBLOCK_CONSOLE))
console_init();
@@ -53,14 +29,8 @@ asmlinkage void bootblock_main(uint32_t bist, uint32_t tsc_lo, uint32_t tsc_hi)
*/
report_bist_failure(bist);
- romstage = cbfs_boot_map_with_leak(target1, CBFS_TYPE_STAGE, NULL);
+ run_romstage();
- /*
- * TODO: Do something constructive with tsc_lo and tsc_hi
- */
- if (romstage) {
- entry = (void *)(uintptr_t)romstage->entry;
- enter_romstage(entry, bist);
- }
+ /* Should never be reached, but halt just in case. */
halt();
}
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12880
-gerrit
commit 9bef3cf2eb75e096cf9a2fcac8ba643c534bb2e0
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Fri Jan 8 23:05:00 2016 -0800
arch/x86: Include in the bootblock files needed by run_romstage
run_romstage(), the generic function for loading romstage from the
bootblock makes use of CBFS APIs which requires symbols that were not
previously available in the x86 bootblock. Compile the files which
provide these symbols in the bootblock.
Change-Id: I36558b672a926ab22bc9018cd51aee32213792c2
Signed-off-by: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
---
src/arch/x86/Makefile.inc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index c940f44..8249a77 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -68,7 +68,9 @@ else
LDFLAGS_bootblock += -m elf_x86_64 --oformat elf64-x86-64
endif
+bootblock-y += boot.c
bootblock-y += memcpy.c
+bootblock-y += memset.c
bootblock-y += mmap_boot.c
# Add the assembly file that pulls in the rest of the dependencies in
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12881
-gerrit
commit f6dd761b76b55c8b73e3267ba09b82a917a8e451
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Fri Jan 8 23:08:09 2016 -0800
cpu/qemu-x86: Use run_romstage instead of custom inline assembly
Now that passing the BIST result to romstage is no longer required,
we no longer need to use custom assembly to call into romstage.
Instead, a lot of the logic in the bootblock can now be replaced by
a single call to run_romstage(). This is another step in converging
the bootblock with the generic bootblock logic in lib/.
Change-Id: I66436c8fba5121a3758d02955f691ac9d273b049
Signed-off-by: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
---
src/cpu/qemu-x86/bootblock.c | 34 ++--------------------------------
1 file changed, 2 insertions(+), 32 deletions(-)
diff --git a/src/cpu/qemu-x86/bootblock.c b/src/cpu/qemu-x86/bootblock.c
index b4700a7..056bde4 100644
--- a/src/cpu/qemu-x86/bootblock.c
+++ b/src/cpu/qemu-x86/bootblock.c
@@ -18,32 +18,8 @@
/* Called from assembly. Prototype not needed by external .c file */
asmlinkage void bootblock_main(uint32_t bist, uint32_t tsc_lo, uint32_t tsc_hi);
-/*
- * TODO: Implement a generic fallback/normal mechanism
- */
-static const char *get_next_stage_name(void)
-{
- if (IS_ENABLED(CONFIG_BOOTBLOCK_SIMPLE))
- return CONFIG_CBFS_PREFIX "/romstage";
-
- /* BOOTBLOCK_NORMAL not implemented */
- return CONFIG_CBFS_PREFIX "/romstage";
-}
-
-static void enter_romstage(void *romstage_entry, uint32_t bist)
-{
- asm volatile (
- "jmp *%0\n\t"
- : : "r" (romstage_entry), "a" (bist)
- );
-}
-
asmlinkage void bootblock_main(uint32_t bist, uint32_t tsc_lo, uint32_t tsc_hi)
{
- void *entry;
- struct cbfs_stage *romstage;
- const char* target1 = get_next_stage_name();
-
if (IS_ENABLED(CONFIG_BOOTBLOCK_CONSOLE))
console_init();
@@ -53,14 +29,8 @@ asmlinkage void bootblock_main(uint32_t bist, uint32_t tsc_lo, uint32_t tsc_hi)
*/
report_bist_failure(bist);
- romstage = cbfs_boot_map_with_leak(target1, CBFS_TYPE_STAGE, NULL);
+ run_romstage();
- /*
- * TODO: Do something constructive with tsc_lo and tsc_hi
- */
- if (romstage) {
- entry = (void *)(uintptr_t)romstage->entry;
- enter_romstage(entry, bist);
- }
+ /* Should never be reached, but halt just in case. */
halt();
}