arch/x86: link bootblock like other stages for C_ENVIRONMENT_BOOTBLOCK

When C_ENVIRONMENT_BOOTBLOCK is selected link bootblock using the
memlayout.ld scripts and infrastructure. This allows bootblock on
x86 to utilize all the other coreboot infrastructure without
relying romcc.

Change-Id: Ie3e077d553360853bf33f30cf8a347ba1df1e389
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/13069
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Tested-by: build bot (Jenkins)
Tested-by: Raptor Engineering Automated Test Stand <noreply@raptorengineeringinc.com>
This commit is contained in:
Aaron Durbin 2016-01-21 00:08:17 -06:00
parent 1b915b8904
commit eb907b3c90
4 changed files with 90 additions and 48 deletions

View File

@ -55,19 +55,53 @@ endif
## Calculate the base address of CBFS for later comparisons ## Calculate the base address of CBFS for later comparisons
CBFS_BASE_ADDRESS=$(call int-add, $(call int-subtract, 0xffffffff $(CONFIG_CBFS_SIZE)) 1) CBFS_BASE_ADDRESS=$(call int-add, $(call int-subtract, 0xffffffff $(CONFIG_CBFS_SIZE)) 1)
###############################################################################
# common support for early assembly includes
###############################################################################
# Chipset specific assembly stubs in the romstage program flow. Certain
# boards have more than one assembly stub so collect those and put them
# into a single generated file.
crt0s = $(cpu_incs-y)
$(objgenerated)/assembly.inc: $$(crt0s)
@printf " GEN $(subst $(obj)/,,$(@))\n"
printf '$(foreach crt0,$(crt0s),#include "$(crt0)"\n)' > $@
define early_x86_assembly_entry_rule
# $1 stage name
# Add the assembly file that pulls in the rest of the dependencies in
# the right order. Make sure the auto generated assembly.inc is a proper
# dependency.
$(1)-y += assembly_entry.S
$$(obj)/arch/x86/assembly_entry.$(1).o: $(objgenerated)/assembly.inc
endef
define early_x86_stage
# $1 stage name
# $2 oformat
$(1)-y += memlayout.ld
# The '.' include path is needed for the generated assembly.inc file.
$(1)-S-ccopts += -I.
$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs)
@printf " LINK $$(subst $$(obj)/,,$$(@))\n"
$$(LD_$(1)) $$(LDFLAGS_$(1)) -o $$@ -L$$(obj) $$(COMPILER_RT_FLAGS_$(1)) --whole-archive --start-group $$(filter-out %.ld,$$($(1)-objs)) $$($(1)-libs) --no-whole-archive $$(COMPILER_RT_$(1)) --end-group -T $$(obj)/arch/x86/memlayout.$(1).ld --oformat $(2)
-LANG=C LC_ALL= $$(OBJCOPY_$(1)) --only-section .illegal_globals $$(@) $$(objcbfs)/$(1)_null.offenders >/dev/null 2>&1
if [ -z "$$$$($$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders 2>&1 | grep 'no symbols')" ];then \
echo "Forbidden global variables in $(1):"; \
$$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders; false; \
fi
endef
############################################################################### ###############################################################################
# bootblock # bootblock
############################################################################### ###############################################################################
ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y) ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y)
# x86-specific linker flags
ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
LDFLAGS_bootblock += -m elf_i386 --oformat elf32-i386
else
LDFLAGS_bootblock += -m elf_x86_64 --oformat elf64-x86-64
endif
bootblock-y += boot.c bootblock-y += boot.c
bootblock-y += memcpy.c bootblock-y += memcpy.c
bootblock-y += memset.c bootblock-y += memset.c
@ -79,6 +113,25 @@ bootblock-y += mmap_boot.c
bootblock-y += id.S bootblock-y += id.S
$(obj)/arch/x86/id.bootblock.o: $(obj)/build.h $(obj)/arch/x86/id.bootblock.o: $(obj)/build.h
ifeq ($(CONFIG_C_ENVIRONMENT_BOOTBLOCK),y)
bootblock-y += memlayout.ld
ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
$(eval $(call early_x86_stage,bootblock,elf32-i386))
else
$(eval $(call early_x86_stage,bootblock,elf64-x86-64))
endif
else # !C_ENVIRONMENT_BOOTBLOCK
# x86-specific linker flags
ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
LDFLAGS_bootblock += -m elf_i386 --oformat elf32-i386
else
LDFLAGS_bootblock += -m elf_x86_64 --oformat elf64-x86-64
endif
bootblock-y += bootblock.S bootblock-y += bootblock.S
bootblock-y += walkcbfs.S bootblock-y += walkcbfs.S
$(obj)/arch/x86/bootblock.bootblock.o: $(objgenerated)/bootblock.inc $(obj)/arch/x86/bootblock.bootblock.o: $(objgenerated)/bootblock.inc
@ -114,45 +167,11 @@ $(objcbfs)/bootblock.debug: $$(bootblock-objs)
$(filter-out %.ld,$(bootblock-objs)) \ $(filter-out %.ld,$(bootblock-objs)) \
-T $(obj)/arch/x86/bootblock.bootblock.ld -T $(obj)/arch/x86/bootblock.bootblock.ld
endif # C_ENVIRONMENT_BOOTBLOCK
endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64 endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64
###############################################################################
# common support for early assembly includes
###############################################################################
# Chipset specific assembly stubs in the romstage program flow. Certain
# boards have more than one assembly stub so collect those and put them
# into a single generated file.
crt0s = $(cpu_incs-y)
$(objgenerated)/assembly.inc: $$(crt0s)
@printf " GEN $(subst $(obj)/,,$(@))\n"
printf '$(foreach crt0,$(crt0s),#include "$(crt0)"\n)' > $@
define early_x86_stage
# $1 stage name
# $2 oformat
$(1)-y += memlayout.ld
# Add the assembly file that pulls in the rest of the dependencies in
# the right order. Make sure the auto generated assembly.inc is a proper
# dependency.
$(1)-y += assembly_entry.S
$$(obj)/arch/x86/assembly_entry.$(1).o: $(objgenerated)/assembly.inc
# The '.' include path is needed for the generated assembly.inc file.
$(1)-S-ccopts += -I.
$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs)
@printf " LINK $$(subst $$(obj)/,,$$(@))\n"
$$(LD_$(1)) $$(LDFLAGS_$(1)) -o $$@ -L$$(obj) $$(COMPILER_RT_FLAGS_$(1)) --whole-archive --start-group $$(filter-out %.ld,$$($(1)-objs)) $$($(1)-libs) --no-whole-archive $$(COMPILER_RT_$(1)) --end-group -T $$(obj)/arch/x86/memlayout.$(1).ld --oformat $(2)
-LANG=C LC_ALL= $$(OBJCOPY_$(1)) --only-section .illegal_globals $$(@) $$(objcbfs)/$(1)_null.offenders >/dev/null 2>&1
if [ -z "$$$$($$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders 2>&1 | grep 'no symbols')" ];then \
echo "Forbidden global variables in $(1):"; \
$$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders; false; \
fi
endef
############################################################################### ###############################################################################
# verstage # verstage
############################################################################### ###############################################################################
@ -171,6 +190,8 @@ verstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
verstage-libs += $(objgenerated)/libverstage.a verstage-libs += $(objgenerated)/libverstage.a
$(eval $(call early_x86_assembly_entry_rule,verstage))
ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y) ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y)
$(eval $(call early_x86_stage,verstage,elf32-i386)) $(eval $(call early_x86_stage,verstage,elf32-i386))
else else
@ -227,6 +248,8 @@ endif
romstage-libs ?= romstage-libs ?=
$(eval $(call early_x86_assembly_entry_rule,romstage))
ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
$(eval $(call early_x86_stage,romstage,elf32-i386)) $(eval $(call early_x86_stage,romstage,elf32-i386))
else else

View File

@ -40,3 +40,7 @@ PHDRS
ENTRY(protected_start) ENTRY(protected_start)
#endif #endif
#endif #endif
#if IS_ENABLED(CONFIG_C_ENVIRONMENT_BOOTBLOCK) && ENV_BOOTBLOCK
ENTRY(reset_vector)
#endif

View File

@ -42,5 +42,23 @@ SECTIONS
/* Pull in the cache-as-ram rules. */ /* Pull in the cache-as-ram rules. */
#include "car.ld" #include "car.ld"
#elif ENV_BOOTBLOCK
/* This is for C_ENVIRONMENT_BOOTBLOCK. arch/x86/bootblock.ld contains
* the logic for the romcc linking. */
BOOTBLOCK(0xffff0000, 64K)
/* Pull in the cache-as-ram rules. */
#include "car.ld"
#endif #endif
} }
#if ENV_BOOTBLOCK
/* Bootblock specific scripts which provide more SECTION directives. */
#include <cpu/x86/16bit/entry16.ld>
#include <cpu/x86/16bit/reset16.ld>
#include <arch/x86/id.ld>
#if IS_ENABLED(CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE)
#include <cpu/intel/fit/fit.ld>
#endif
#endif /* ENV_BOOTBLOCK */

View File

@ -181,11 +181,8 @@ romstage-y += halt.c
ramstage-y += halt.c ramstage-y += halt.c
smm-y += halt.c smm-y += halt.c
ifneq ($(CONFIG_ARCH_X86),y) # Use program.ld for all the platforms which use C fo the bootblock.
# X86 bootblock uses custom ldscripts that are all glued together, bootblock-$(CONFIG_C_ENVIRONMENT_BOOTBLOCK) += program.ld
# so we need to exclude it here or it would pick these up as well
bootblock-y += program.ld
endif
romstage-y += program.ld romstage-y += program.ld
ramstage-y += program.ld ramstage-y += program.ld