Attention is currently required from: Jason Glenesk, Martin L Roth, Matt DeVillier, Julius Werner, Fred Reitberger, Yu-Ping Wu, Felix Held.
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/69240 )
Change subject: HACK: Add ramstage sources to bootblock ......................................................................
HACK: Add ramstage sources to bootblock
Change-Id: I7ac96ada466d4410c80ea53f7d4ff05948e3c566 Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M Makefile.inc M src/arch/x86/c_start.S M src/cpu/x86/Makefile.inc M src/cpu/x86/smm/Makefile.inc M src/include/rules.h M src/lib/hardwaremain.c M src/lib/prog_loaders.c M src/lib/program.ld M src/lib/string.c M src/security/vboot/Makefile.inc M src/soc/amd/picasso/Kconfig M src/soc/amd/picasso/Makefile.inc 12 files changed, 51 insertions(+), 22 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/40/69240/1
diff --git a/Makefile.inc b/Makefile.inc index 14205698..d9a9fb2 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -1212,9 +1212,10 @@ endif else # CONFIG_SEPARATE_ROMSTAGE postinclude-hooks += $$(eval bootblock-srcs += $$(romstage-srcs)) +postinclude-hooks += $$(eval bootblock-srcs += $$(ramstage-srcs)) endif
-cbfs-files-$(CONFIG_HAVE_RAMSTAGE) += $(CONFIG_CBFS_PREFIX)/ramstage +cbfs-files-n += $(CONFIG_CBFS_PREFIX)/ramstage $(CONFIG_CBFS_PREFIX)/ramstage-file := $(RAMSTAGE) $(CONFIG_CBFS_PREFIX)/ramstage-type := stage $(CONFIG_CBFS_PREFIX)/ramstage-compression := $(CBFS_COMPRESS_FLAG) diff --git a/src/arch/x86/c_start.S b/src/arch/x86/c_start.S index 84fbed2..c3f158a 100644 --- a/src/arch/x86/c_start.S +++ b/src/arch/x86/c_start.S @@ -25,8 +25,10 @@ #else .code32 #endif - .globl _start -_start: +// .globl _start +//_start: +.globl ramstage +ramstage: cli #if ENV_X86_64 movabs $gdtaddr, %rax @@ -112,7 +114,7 @@ call gdb_hw_init call gdb_stub_breakpoint #endif - call main + call main_b /* NOTREACHED */ .Lhlt: post_code(POST_DEAD_CODE) /* post ee */ diff --git a/src/cpu/x86/Makefile.inc b/src/cpu/x86/Makefile.inc index dffc2b1..2d3215b 100644 --- a/src/cpu/x86/Makefile.inc +++ b/src/cpu/x86/Makefile.inc @@ -27,7 +27,7 @@ SIPI_DOTO=$(SIPI_ELF:.elf=.o)
ifeq ($(CONFIG_HAVE_RAMSTAGE),y) -TARGET_STAGE=ramstage +TARGET_STAGE=bootblock else ifeq ($(CONFIG_RAMPAYLOAD),y) TARGET_STAGE=postcar else diff --git a/src/cpu/x86/smm/Makefile.inc b/src/cpu/x86/smm/Makefile.inc index 5f69590..30db07d 100644 --- a/src/cpu/x86/smm/Makefile.inc +++ b/src/cpu/x86/smm/Makefile.inc @@ -23,8 +23,13 @@ @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" cd $(dir $<); $(OBJCOPY_smm) -I binary $(notdir $<) $(target-objcopy) $(abspath $@)
+$(call src-to-obj,bootblock,$(obj)/cpu/x86/smm/smm.manual): $(obj)/smm/smm + @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" + cd $(dir $<); $(OBJCOPY_smm) -I binary $(notdir $<) $(target-objcopy) $(abspath $@) + ifeq ($(CONFIG_HAVE_SMI_HANDLER),y) -ramstage-srcs += $(obj)/cpu/x86/smm/smm.manual +#ramstage-srcs += $(obj)/cpu/x86/smm/smm.manual +bootblock-srcs += $(obj)/cpu/x86/smm/smm.manual endif
smm-y += save_state.c @@ -64,6 +69,11 @@ @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" cd $(dir $<); $(OBJCOPY_smmstub) -I binary $(notdir $<) $(target-objcopy) $(abspath $@)
+$(call src-to-obj,bootblock,$(obj)/cpu/x86/smm/smmstub.manual): $(obj)/smmstub/smmstub + @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" + cd $(dir $<); $(OBJCOPY_smmstub) -I binary $(notdir $<) $(target-objcopy) $(abspath $@) + + # C-based SMM handler.
ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) diff --git a/src/include/rules.h b/src/include/rules.h index ae7bead..5637fe1 100644 --- a/src/include/rules.h +++ b/src/include/rules.h @@ -257,7 +257,7 @@ #else /* ENV_PAYLOAD_LOADER is set when you are in a stage that loads the payload. * For now, that is the ramstage. */ -#define ENV_PAYLOAD_LOADER ENV_RAMSTAGE +#define ENV_PAYLOAD_LOADER ENV_BOOTBLOCK #endif
#define ENV_ROMSTAGE_OR_BEFORE \ @@ -279,7 +279,7 @@ #define ENV_SEPARATE_BSS (ENV_CACHE_AS_RAM && (ENV_BOOTBLOCK || !CONFIG(NO_XIP_EARLY_STAGES)))
/* Currently rmodules, ramstage and smm have heap. */ -#define ENV_HAS_HEAP_SECTION (ENV_RMODULE || ENV_RAMSTAGE || ENV_SMM) +#define ENV_HAS_HEAP_SECTION (ENV_RMODULE || ENV_RAMSTAGE || ENV_SMM) || ENV_BOOTBLOCK
/* Set USER_SPACE in the makefile for the rare code that runs in userspace */ #if defined(__USER_SPACE__) @@ -329,7 +329,7 @@ * be built with simple device model. */
-#if !ENV_RAMSTAGE +#if !ENV_RAMSTAGE && !ENV_BOOTBLOCK #define __SIMPLE_DEVICE__ #endif
diff --git a/src/lib/hardwaremain.c b/src/lib/hardwaremain.c index 714452d..1673fe9 100644 --- a/src/lib/hardwaremain.c +++ b/src/lib/hardwaremain.c @@ -423,7 +423,8 @@ } }
-void main(void) +void main_a(void); +void main_a(void) { /* * We can generally jump between C and Ada code back and forth @@ -439,12 +440,12 @@
/* TODO: Understand why this is here and move to arch/platform code. */ /* For MMIO UART this needs to be called before any other printk. */ - if (ENV_X86) - init_timer(); + /* if (ENV_X86) */ + /* init_timer(); */
/* console_init() MUST PRECEDE ALL printk()! Additionally, ensure * it is the very first thing done in ramstage.*/ - console_init(); + /* console_init(); */ post_code(POST_CONSOLE_READY);
exception_init(); @@ -453,7 +454,7 @@ * CBMEM needs to be recovered because timestamps, ACPI, etc rely on * the cbmem infrastructure being around. Explicitly recover it. */ - cbmem_initialize(); + // cbmem_initialize();
timestamp_add_now(TS_RAMSTAGE_START); post_code(POST_ENTRY_HARDWAREMAIN); diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c index ee7f480..7c66e57 100644 --- a/src/lib/prog_loaders.c +++ b/src/lib/prog_loaders.c @@ -88,8 +88,12 @@
cbfs_preload(CONFIG_CBFS_PREFIX "/ramstage"); } + +void main_a(void); void __noreturn run_ramstage(void) { + main_a(); + struct prog ramstage = PROG_INIT(PROG_RAMSTAGE, CONFIG_CBFS_PREFIX "/ramstage");
diff --git a/src/lib/program.ld b/src/lib/program.ld index 67f685f..4dd91af 100644 --- a/src/lib/program.ld +++ b/src/lib/program.ld @@ -39,7 +39,7 @@ _ersbe_init_begin = .; RECORD_SIZE(rsbe_init_begin)
-#if ENV_RAMSTAGE +#if ENV_RAMSTAGE || ENV_BOOTBLOCK . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _pci_drivers = .; KEEP(*(.rodata.pci_driver)); @@ -100,7 +100,8 @@ PROVIDE(_preram_cbmem_console = .); PROVIDE(_epreram_cbmem_console = _preram_cbmem_console); PROVIDE(_preram_cbmem_console_size = ABSOLUTE(0)); -#elif ENV_RAMSTAGE +#endif +#if ENV_RAMSTAGE || ENV_BOOTBLOCK . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _bs_init_begin = .; KEEP(*(.bs_init)); diff --git a/src/lib/string.c b/src/lib/string.c index dd7d151..74b2841 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -8,7 +8,7 @@
char *strdup(const char *s) { - if (!ENV_RAMSTAGE) + if (!ENV_RAMSTAGE && !ENV_BOOTBLOCK) dead_code(); /* This can't be used without malloc(). */
size_t sz = strlen(s) + 1; diff --git a/src/security/vboot/Makefile.inc b/src/security/vboot/Makefile.inc index a708b3a..2f653ee 100644 --- a/src/security/vboot/Makefile.inc +++ b/src/security/vboot/Makefile.inc @@ -43,7 +43,7 @@ ifeq ($(CONFIG_SEPARATE_ROMSTAGE),y) $(eval $(call vboot-for-stage,romstage)) endif -$(eval $(call vboot-for-stage,ramstage)) +#$(eval $(call vboot-for-stage,ramstage)) $(eval $(call vboot-for-stage,postcar))
endif # CONFIG_VBOOT_LIB diff --git a/src/soc/amd/picasso/Kconfig b/src/soc/amd/picasso/Kconfig index e852826..64a6a57 100644 --- a/src/soc/amd/picasso/Kconfig +++ b/src/soc/amd/picasso/Kconfig @@ -179,13 +179,13 @@
config ROMSTAGE_SIZE hex - default 0x80000 + default 0x200000 help Sets the size of DRAM allocation for romstage in linker script.
config FSP_M_ADDR hex - default 0x20C0000 + default 0x21C0000 help Sets the address in DRAM where FSP-M should be loaded. cbfstool performs relocation of FSP-M to this address. diff --git a/src/soc/amd/picasso/Makefile.inc b/src/soc/amd/picasso/Makefile.inc index 397c54d..7c11ac9 100644 --- a/src/soc/amd/picasso/Makefile.inc +++ b/src/soc/amd/picasso/Makefile.inc @@ -206,10 +206,10 @@
OPT_PSP_SOFTFUSE=$(call add_opt_prefix, $(PSP_SOFTFUSE), --soft-fuse)
-ifeq ($(CONFIG_VBOOT),) +#ifeq ($(CONFIG_VBOOT),) OPT_APOB0_NV_SIZE=$(OPT_APOB_NV_SIZE) OPT_APOB0_NV_BASE=$(OPT_APOB_NV_BASE) -endif +#endif
OPT_WHITELIST_FILE=$(call add_opt_prefix, $(PSP_WHITELIST_FILE), --whitelist)