coreboot classes: Add dynamic classes to coreboot
Provide functionality to create dynamic classes based on program name and architecture for which the program needs to be compiled/linked. define_class takes program_name and arch as its arguments and adds the program_name to classes-y to create dynamic class. Also, compiler toolset is created for the specified arch. All the files for this program can then be added to program_name-y += .. Ensure that define_class is called before any files are added to the class. Check subdirs-y for order of directory inclusion. One such example of dynamic class is rmodules. Multiple rmodules can be used which need to be compiled for different architectures. With dynamic classes, this is possible. Change-Id: Ie143ed6f79ced5f58c200394cff89b006bc9b342 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: http://review.coreboot.org/6426 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
This commit is contained in:
parent
9d2cb7c11e
commit
133096b6dc
|
@ -75,7 +75,11 @@ subdirs-y += site-local
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Add source classes and their build options
|
# 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
|
# Helper functions for ramstage postprocess
|
||||||
|
|
|
@ -308,10 +308,9 @@ endif
|
||||||
|
|
||||||
ramstage-libs ?=
|
ramstage-libs ?=
|
||||||
|
|
||||||
$(eval $(call create_class_compiler,rmodules,x86_32))
|
|
||||||
ifeq ($(CONFIG_RELOCATABLE_RAMSTAGE),y)
|
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.
|
# The rmodule_link defintion creates an elf file with .rmod extension.
|
||||||
$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
|
$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
|
||||||
|
|
|
@ -30,8 +30,8 @@ smm-y += memcpy.c
|
||||||
smm-y += memmove.c
|
smm-y += memmove.c
|
||||||
smm-y += rom_media.c
|
smm-y += rom_media.c
|
||||||
|
|
||||||
rmodules-y += memset.c
|
rmodules_x86_32-y += memset.c
|
||||||
rmodules-y += memcpy.c
|
rmodules_x86_32-y += memcpy.c
|
||||||
rmodules-y += memmove.c
|
rmodules_x86_32-y += memmove.c
|
||||||
|
|
||||||
endif # CONFIG_ARCH_RAMSTAGE_X86_32
|
endif # CONFIG_ARCH_RAMSTAGE_X86_32
|
|
@ -13,16 +13,16 @@ SIPI_DOTO=$(SIPI_ELF:.elf=.o)
|
||||||
ifeq ($(CONFIG_PARALLEL_MP),y)
|
ifeq ($(CONFIG_PARALLEL_MP),y)
|
||||||
ramstage-srcs += $(SIPI_BIN)
|
ramstage-srcs += $(SIPI_BIN)
|
||||||
endif
|
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
|
$(SIPI_DOTO): $(dir $(SIPI_ELF))sipi_vector.rmodules_$(ARCH-ramstage-y).o
|
||||||
$(CC_ramstage) $(CFLAGS_ramstage) -nostdlib -r -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)
|
$(SIPI_BIN): $(SIPI_RMOD)
|
||||||
$(OBJCOPY_ramstage) -O binary $< $@
|
$(OBJCOPY_ramstage) -O binary $< $@
|
||||||
|
|
||||||
$(SIPI_BIN).ramstage.o: $(SIPI_BIN)
|
$(SIPI_BIN).ramstage.o: $(SIPI_BIN)
|
||||||
@printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
|
@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 $@)
|
||||||
|
|
|
@ -39,7 +39,7 @@ $(obj)/cpu/x86/smm/smmstub.o: $$(smmstub-objs)
|
||||||
$(CC_smmstub) $(CFLAGS_smmstub) -nostdlib -r -o $@ $^
|
$(CC_smmstub) $(CFLAGS_smmstub) -nostdlib -r -o $@ $^
|
||||||
|
|
||||||
# Link the SMM stub module with a 0-byte heap.
|
# 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
|
$(obj)/cpu/x86/smm/smmstub: $(obj)/cpu/x86/smm/smmstub.elf.rmod
|
||||||
$(OBJCOPY_smmstub) -O binary $< $@
|
$(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
|
$(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
|
$(obj)/cpu/x86/smm/smm: $(obj)/cpu/x86/smm/smm.elf.rmod
|
||||||
$(OBJCOPY_smm) -O binary $< $@
|
$(OBJCOPY_smm) -O binary $< $@
|
||||||
|
|
|
@ -24,7 +24,9 @@ bootblock-y += memcmp.c
|
||||||
|
|
||||||
romstage-y += memchr.c
|
romstage-y += memchr.c
|
||||||
romstage-y += memcmp.c
|
romstage-y += memcmp.c
|
||||||
rmodules-y += memcmp.c
|
$(foreach arch,$(ARCH_SUPPORTED),\
|
||||||
|
$(eval rmodules_$(arch)-y += memcmp.c))
|
||||||
|
|
||||||
romstage-y += cbfs.c
|
romstage-y += cbfs.c
|
||||||
romstage-$(CONFIG_COMPRESS_RAMSTAGE) += lzma.c
|
romstage-$(CONFIG_COMPRESS_RAMSTAGE) += lzma.c
|
||||||
#romstage-y += lzmadecode.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
|
# (1) the object name to link
|
||||||
# (2) the dependencies
|
# (2) the dependencies
|
||||||
# (3) heap size of the relocatable module
|
# (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
|
# It will create the necessary Make rules to create a rmodule. The resulting
|
||||||
# rmdoule is named $(1).rmod
|
# rmdoule is named $(1).rmod
|
||||||
define rmodule_link
|
define rmodule_link
|
||||||
$(strip $(1)): $(strip $(2)) $$(RMODULE_LDSCRIPT) $$(obj)/ldoptions $$(RMODTOOL)
|
$(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
|
$$(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) -n $$@ > $$(basename $$@).map
|
$$(NM_rmodules_$(4)) -n $$@ > $$(basename $$@).map
|
||||||
|
|
||||||
$(strip $(1)).rmod: $(strip $(1))
|
$(strip $(1)).rmod: $(strip $(1))
|
||||||
$$(RMODTOOL) -i $$^ -o $$@
|
$$(RMODTOOL) -i $$^ -o $$@
|
||||||
|
|
|
@ -36,7 +36,7 @@ ifeq ($(CONFIG_VBOOT_VERIFY_FIRMWARE),y)
|
||||||
romstage-y += vboot_handoff.c
|
romstage-y += vboot_handoff.c
|
||||||
ramstage-y += vboot_handoff.c
|
ramstage-y += vboot_handoff.c
|
||||||
romstage-y += vboot_loader.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
|
VB_LIB = $(obj)/external/vboot_reference/vboot_fw.a
|
||||||
# Currently, vboot comes into picture only during the romstage, thus
|
# 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)
|
VBOOT_STUB_DOTO = $(VBOOT_STUB_ELF:.elf=.o)
|
||||||
|
|
||||||
# Dependency for the vboot rmodules. Ordering matters.
|
# Dependency for the vboot rmodules. Ordering matters.
|
||||||
VBOOT_STUB_DEPS += $(obj)/vendorcode/google/chromeos/vboot_wrapper.rmodules.o
|
VBOOT_STUB_DEPS += $(obj)/vendorcode/google/chromeos/vboot_wrapper.rmodules_$(ARCH-romstage-y).o
|
||||||
VBOOT_STUB_DEPS += $(obj)/lib/memcmp.rmodules.o
|
VBOOT_STUB_DEPS += $(obj)/lib/memcmp.rmodules_$(ARCH-romstage-y).o
|
||||||
VBOOT_STUB_DEPS += $(obj)/arch/x86/lib/memset.rmodules.o
|
VBOOT_STUB_DEPS += $(obj)/arch/x86/lib/memset.rmodules_$(ARCH-romstage-y).o
|
||||||
VBOOT_STUB_DEPS += $(obj)/arch/x86/lib/memcpy.rmodules.o
|
VBOOT_STUB_DEPS += $(obj)/arch/x86/lib/memcpy.rmodules_$(ARCH-romstage-y).o
|
||||||
VBOOT_STUB_DEPS += $(VB_LIB)
|
VBOOT_STUB_DEPS += $(VB_LIB)
|
||||||
# Remove the '-include' option since that will break vboot's build and ensure
|
# Remove the '-include' option since that will break vboot's build and ensure
|
||||||
# vboot_reference can get to coreboot's include files.
|
# 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_CFLAGS += -DVBOOT_DEBUG
|
||||||
|
|
||||||
$(VBOOT_STUB_DOTO): $(VBOOT_STUB_DEPS)
|
$(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.
|
# 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.
|
# Build vboot library without the default includes from coreboot proper.
|
||||||
$(VB_LIB):
|
$(VB_LIB):
|
||||||
|
|
|
@ -98,6 +98,18 @@ CPPFLAGS_$(1) += $$(CPPFLAGS_common) $$(CPPFLAGS_$(2))
|
||||||
LIBGCC_FILE_NAME_$(1) = $(wildcard $(shell $(CC_$(2)) $(CFLAGS_$(2)) -print-libgcc-file-name))
|
LIBGCC_FILE_NAME_$(1) = $(wildcard $(shell $(CC_$(2)) $(CFLAGS_$(2)) -print-libgcc-file-name))
|
||||||
endef
|
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
|
# initialize standard toolchain (CC,AS and others) for give stage
|
||||||
# @1 : stage for which the toolchain is to be initialized
|
# @1 : stage for which the toolchain is to be initialized
|
||||||
init_standard_toolchain = \
|
init_standard_toolchain = \
|
||||||
|
|
Loading…
Reference in New Issue