summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.inc6
-rw-r--r--src/arch/x86/Makefile.inc3
-rw-r--r--src/arch/x86/lib/Makefile.inc6
-rw-r--r--src/cpu/x86/Makefile.inc10
-rw-r--r--src/cpu/x86/smm/Makefile.inc4
-rw-r--r--src/lib/Makefile.inc9
-rw-r--r--src/vendorcode/google/chromeos/Makefile.inc14
-rw-r--r--toolchain.inc12
8 files changed, 41 insertions, 23 deletions
diff --git a/Makefile.inc b/Makefile.inc
index 0a6b7bbe91..d757c89a07 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -75,7 +75,11 @@ subdirs-y += site-local
#######################################################################
# Add source classes and their build options
-classes-y := ramstage romstage bootblock smm smmstub cpu_microcode rmodules
+classes-y := ramstage romstage bootblock smm smmstub cpu_microcode
+
+# Add dynamic classes for rmodules
+$(foreach supported_arch,$(ARCH_SUPPORTED), \
+ $(eval $(call define_class,rmodules_$(supported_arch),$(supported_arch))))
#######################################################################
# Helper functions for ramstage postprocess
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 90a697cdeb..036dc1a7a0 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -308,10 +308,9 @@ endif
ramstage-libs ?=
-$(eval $(call create_class_compiler,rmodules,x86_32))
ifeq ($(CONFIG_RELOCATABLE_RAMSTAGE),y)
-$(eval $(call rmodule_link,$(objcbfs)/ramstage.debug, $(objgenerated)/ramstage.o, $(CONFIG_HEAP_SIZE)))
+$(eval $(call rmodule_link,$(objcbfs)/ramstage.debug, $(objgenerated)/ramstage.o, $(CONFIG_HEAP_SIZE),x86_32))
# The rmodule_link defintion creates an elf file with .rmod extension.
$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
diff --git a/src/arch/x86/lib/Makefile.inc b/src/arch/x86/lib/Makefile.inc
index 0a3a5757c9..22306f1874 100644
--- a/src/arch/x86/lib/Makefile.inc
+++ b/src/arch/x86/lib/Makefile.inc
@@ -30,8 +30,8 @@ smm-y += memcpy.c
smm-y += memmove.c
smm-y += rom_media.c
-rmodules-y += memset.c
-rmodules-y += memcpy.c
-rmodules-y += memmove.c
+rmodules_x86_32-y += memset.c
+rmodules_x86_32-y += memcpy.c
+rmodules_x86_32-y += memmove.c
endif # CONFIG_ARCH_RAMSTAGE_X86_32 \ No newline at end of file
diff --git a/src/cpu/x86/Makefile.inc b/src/cpu/x86/Makefile.inc
index b27fac09b5..a05c72327f 100644
--- a/src/cpu/x86/Makefile.inc
+++ b/src/cpu/x86/Makefile.inc
@@ -13,16 +13,16 @@ SIPI_DOTO=$(SIPI_ELF:.elf=.o)
ifeq ($(CONFIG_PARALLEL_MP),y)
ramstage-srcs += $(SIPI_BIN)
endif
-rmodules-$(CONFIG_PARALLEL_MP) += sipi_vector.S
+rmodules_$(ARCH-ramstage-y)-$(CONFIG_PARALLEL_MP) += sipi_vector.S
-$(SIPI_DOTO): $(dir $(SIPI_ELF))sipi_vector.rmodules.o
- $(CC_ramstage) $(CFLAGS_ramstage) -nostdlib -r -o $@ $^
+$(SIPI_DOTO): $(dir $(SIPI_ELF))sipi_vector.rmodules_$(ARCH-ramstage-y).o
+ $(CC_rmodules_$(ARCH-ramstage-y)) $(CFLAGS_rmodules_$(ARCH-ramstage-y)) -nostdlib -r -o $@ $^
-$(eval $(call rmodule_link,$(SIPI_ELF), $(SIPI_ELF:.elf=.o), 0))
+$(eval $(call rmodule_link,$(SIPI_ELF), $(SIPI_ELF:.elf=.o), 0,x86_32))
$(SIPI_BIN): $(SIPI_RMOD)
$(OBJCOPY_ramstage) -O binary $< $@
$(SIPI_BIN).ramstage.o: $(SIPI_BIN)
@printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
- cd $(dir $@); $(OBJCOPY_ramstage) -I binary $(notdir $<) -O elf32-i386 -B i386 $(notdir $@)
+ cd $(dir $@); $(OBJCOPY_rmodules_$(ARCH-ramstage-y)) -I binary $(notdir $<) -O elf32-i386 -B i386 $(notdir $@)
diff --git a/src/cpu/x86/smm/Makefile.inc b/src/cpu/x86/smm/Makefile.inc
index ff4023b1f3..b179d7e397 100644
--- a/src/cpu/x86/smm/Makefile.inc
+++ b/src/cpu/x86/smm/Makefile.inc
@@ -39,7 +39,7 @@ $(obj)/cpu/x86/smm/smmstub.o: $$(smmstub-objs)
$(CC_smmstub) $(CFLAGS_smmstub) -nostdlib -r -o $@ $^
# Link the SMM stub module with a 0-byte heap.
-$(eval $(call rmodule_link,$(obj)/cpu/x86/smm/smmstub.elf, $(obj)/cpu/x86/smm/smmstub.o, 0))
+$(eval $(call rmodule_link,$(obj)/cpu/x86/smm/smmstub.elf, $(obj)/cpu/x86/smm/smmstub.o, 0,x86_32))
$(obj)/cpu/x86/smm/smmstub: $(obj)/cpu/x86/smm/smmstub.elf.rmod
$(OBJCOPY_smmstub) -O binary $< $@
@@ -54,7 +54,7 @@ $(obj)/cpu/x86/smm/smm.o: $$(smm-objs) $(LIBGCC_FILE_NAME_smm)
$(CC_smm) $(CFLAGS_smm) -nostdlib -r -o $@ -Wl,--wrap,__divdi3 -Wl,--wrap,__udivdi3 -Wl,--wrap,__moddi3 -Wl,--wrap,__umoddi3 -Wl,--start-group $(smm-objs) $(LIBGCC_FILE_NAME_smm) -Wl,--end-group
-$(eval $(call rmodule_link,$(obj)/cpu/x86/smm/smm.elf, $(obj)/cpu/x86/smm/smm.o, $(CONFIG_SMM_MODULE_HEAP_SIZE)))
+$(eval $(call rmodule_link,$(obj)/cpu/x86/smm/smm.elf, $(obj)/cpu/x86/smm/smm.o, $(CONFIG_SMM_MODULE_HEAP_SIZE),x86_32))
$(obj)/cpu/x86/smm/smm: $(obj)/cpu/x86/smm/smm.elf.rmod
$(OBJCOPY_smm) -O binary $< $@
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 5298bbec80..76ab3dd853 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -24,7 +24,9 @@ bootblock-y += memcmp.c
romstage-y += memchr.c
romstage-y += memcmp.c
-rmodules-y += memcmp.c
+$(foreach arch,$(ARCH_SUPPORTED),\
+ $(eval rmodules_$(arch)-y += memcmp.c))
+
romstage-y += cbfs.c
romstage-$(CONFIG_COMPRESS_RAMSTAGE) += lzma.c
#romstage-y += lzmadecode.c
@@ -106,12 +108,13 @@ RMODULE_LDFLAGS := -nostartfiles -Wl,--emit-relocs -Wl,-z,defs -Wl,-Bsymbolic -
# (1) the object name to link
# (2) the dependencies
# (3) heap size of the relocatable module
+# (4) arch for which the rmodules are to be linked
# It will create the necessary Make rules to create a rmodule. The resulting
# rmdoule is named $(1).rmod
define rmodule_link
$(strip $(1)): $(strip $(2)) $$(RMODULE_LDSCRIPT) $$(obj)/ldoptions $$(RMODTOOL)
- $$(CC_rmodules) $$(CFLAGS_rmodules) $$(RMODULE_LDFLAGS) -Wl,--defsym=__heap_size=$(strip $(3)) -o $$@ -Wl,--start-group $(strip $(2)) $$(LIBGCC_FILE_NAME_rmodules) -Wl,--end-group
- $$(NM_rmodules) -n $$@ > $$(basename $$@).map
+ $$(CC_rmodules_$(4)) $$(CFLAGS_rmodules_$(4)) $$(RMODULE_LDFLAGS) -Wl,--defsym=__heap_size=$(strip $(3)) -o $$@ -Wl,--start-group $(strip $(2)) $$(LIBGCC_FILE_NAME_rmodules_$(4)) -Wl,--end-group
+ $$(NM_rmodules_$(4)) -n $$@ > $$(basename $$@).map
$(strip $(1)).rmod: $(strip $(1))
$$(RMODTOOL) -i $$^ -o $$@
diff --git a/src/vendorcode/google/chromeos/Makefile.inc b/src/vendorcode/google/chromeos/Makefile.inc
index 9bd5091e76..ccde71a102 100644
--- a/src/vendorcode/google/chromeos/Makefile.inc
+++ b/src/vendorcode/google/chromeos/Makefile.inc
@@ -36,7 +36,7 @@ ifeq ($(CONFIG_VBOOT_VERIFY_FIRMWARE),y)
romstage-y += vboot_handoff.c
ramstage-y += vboot_handoff.c
romstage-y += vboot_loader.c
-rmodules-y += vboot_wrapper.c
+rmodules_$(ARCH-romstage-y)-y += vboot_wrapper.c
VB_LIB = $(obj)/external/vboot_reference/vboot_fw.a
# Currently, vboot comes into picture only during the romstage, thus
@@ -55,10 +55,10 @@ VBOOT_STUB = $(VBOOT_STUB_ELF).rmod
VBOOT_STUB_DOTO = $(VBOOT_STUB_ELF:.elf=.o)
# Dependency for the vboot rmodules. Ordering matters.
-VBOOT_STUB_DEPS += $(obj)/vendorcode/google/chromeos/vboot_wrapper.rmodules.o
-VBOOT_STUB_DEPS += $(obj)/lib/memcmp.rmodules.o
-VBOOT_STUB_DEPS += $(obj)/arch/x86/lib/memset.rmodules.o
-VBOOT_STUB_DEPS += $(obj)/arch/x86/lib/memcpy.rmodules.o
+VBOOT_STUB_DEPS += $(obj)/vendorcode/google/chromeos/vboot_wrapper.rmodules_$(ARCH-romstage-y).o
+VBOOT_STUB_DEPS += $(obj)/lib/memcmp.rmodules_$(ARCH-romstage-y).o
+VBOOT_STUB_DEPS += $(obj)/arch/x86/lib/memset.rmodules_$(ARCH-romstage-y).o
+VBOOT_STUB_DEPS += $(obj)/arch/x86/lib/memcpy.rmodules_$(ARCH-romstage-y).o
VBOOT_STUB_DEPS += $(VB_LIB)
# Remove the '-include' option since that will break vboot's build and ensure
# vboot_reference can get to coreboot's include files.
@@ -66,10 +66,10 @@ VBOOT_CFLAGS += $(patsubst -I%,-I../%,$(filter-out -include $(src)/include/kconf
VBOOT_CFLAGS += -DVBOOT_DEBUG
$(VBOOT_STUB_DOTO): $(VBOOT_STUB_DEPS)
- $(CC_romstage) $(CFLAGS_romstage) -nostdlib -r -o $@ $^
+ $(CC_rmodules_$(ARCH-romstage-y)) $(CFLAGS_rmodules_$(ARCH-romstage-y)) -nostdlib -r -o $@ $^
# Link the vbootstub module with a 64KiB-byte heap.
-$(eval $(call rmodule_link,$(VBOOT_STUB_ELF), $(VBOOT_STUB_DOTO), 0x10000))
+$(eval $(call rmodule_link,$(VBOOT_STUB_ELF), $(VBOOT_STUB_DOTO), 0x10000,$(ARCH-romstage-y)))
# Build vboot library without the default includes from coreboot proper.
$(VB_LIB):
diff --git a/toolchain.inc b/toolchain.inc
index 842473b648..3b9c5d297b 100644
--- a/toolchain.inc
+++ b/toolchain.inc
@@ -98,6 +98,18 @@ CPPFLAGS_$(1) += $$(CPPFLAGS_common) $$(CPPFLAGS_$(2))
LIBGCC_FILE_NAME_$(1) = $(wildcard $(shell $(CC_$(2)) $(CFLAGS_$(2)) -print-libgcc-file-name))
endef
+# define_class: Allows defining any program as dynamic class and compiler tool
+# set for the same based on the architecture for which the program is to be
+# compiled
+# @1: program (class name)
+# @2: architecture for which the program needs to be compiled
+# IMP: Ensure that define_class is called before any .c or .S files are added to
+# the class of the program. Check subdirs-y for order of subdirectory inclusions
+define define_class
+classes-y += $(1)
+$(eval $(call create_class_compiler,$(1),$(2)))
+endef
+
# initialize standard toolchain (CC,AS and others) for give stage
# @1 : stage for which the toolchain is to be initialized
init_standard_toolchain = \