summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2016-01-21 00:08:17 -0600
committerAaron Durbin <adurbin@chromium.org>2016-01-23 18:25:48 +0100
commiteb907b3c9047fc262893a57c42777928b50c17d9 (patch)
tree5e42d469d9594eccfac5fbd511a0abf86b191063
parent1b915b89044c06ae7957544b97d6c30d496366e0 (diff)
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>
-rw-r--r--src/arch/x86/Makefile.inc109
-rw-r--r--src/arch/x86/include/arch/header.ld4
-rw-r--r--src/arch/x86/memlayout.ld18
-rw-r--r--src/lib/Makefile.inc7
4 files changed, 90 insertions, 48 deletions
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 1d1dd26b15..bc4a7d4b51 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -56,18 +56,52 @@ endif
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
###############################################################################
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 += memcpy.c
bootblock-y += memset.c
@@ -79,6 +113,25 @@ bootblock-y += mmap_boot.c
bootblock-y += id.S
$(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 += walkcbfs.S
$(obj)/arch/x86/bootblock.bootblock.o: $(objgenerated)/bootblock.inc
@@ -114,44 +167,10 @@ $(objcbfs)/bootblock.debug: $$(bootblock-objs)
$(filter-out %.ld,$(bootblock-objs)) \
-T $(obj)/arch/x86/bootblock.bootblock.ld
+endif # C_ENVIRONMENT_BOOTBLOCK
-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
+endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64
###############################################################################
# verstage
@@ -171,6 +190,8 @@ verstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
verstage-libs += $(objgenerated)/libverstage.a
+$(eval $(call early_x86_assembly_entry_rule,verstage))
+
ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y)
$(eval $(call early_x86_stage,verstage,elf32-i386))
else
@@ -227,6 +248,8 @@ endif
romstage-libs ?=
+$(eval $(call early_x86_assembly_entry_rule,romstage))
+
ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
$(eval $(call early_x86_stage,romstage,elf32-i386))
else
diff --git a/src/arch/x86/include/arch/header.ld b/src/arch/x86/include/arch/header.ld
index 07aec76ea2..89cb6de467 100644
--- a/src/arch/x86/include/arch/header.ld
+++ b/src/arch/x86/include/arch/header.ld
@@ -40,3 +40,7 @@ PHDRS
ENTRY(protected_start)
#endif
#endif
+
+#if IS_ENABLED(CONFIG_C_ENVIRONMENT_BOOTBLOCK) && ENV_BOOTBLOCK
+ENTRY(reset_vector)
+#endif
diff --git a/src/arch/x86/memlayout.ld b/src/arch/x86/memlayout.ld
index d7ebf75a67..1ecae8c230 100644
--- a/src/arch/x86/memlayout.ld
+++ b/src/arch/x86/memlayout.ld
@@ -42,5 +42,23 @@ SECTIONS
/* Pull in the cache-as-ram rules. */
#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
}
+
+#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 */
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 30638bcf6d..5e788c0589 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -181,11 +181,8 @@ romstage-y += halt.c
ramstage-y += halt.c
smm-y += halt.c
-ifneq ($(CONFIG_ARCH_X86),y)
-# X86 bootblock uses custom ldscripts that are all glued together,
-# so we need to exclude it here or it would pick these up as well
-bootblock-y += program.ld
-endif
+# Use program.ld for all the platforms which use C fo the bootblock.
+bootblock-$(CONFIG_C_ENVIRONMENT_BOOTBLOCK) += program.ld
romstage-y += program.ld
ramstage-y += program.ld