diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2015-11-11 14:08:26 +0100 |
---|---|---|
committer | Jens Wiklander <jens.wiklander@linaro.org> | 2015-12-03 09:29:52 +0100 |
commit | bc33bbd90ab37717cf6f15d67feed35bed654029 (patch) | |
tree | f3b5e8a16d52e49556d62d4b79aa2af2990251eb /ta | |
parent | 4175ef9a7b3d58706518cd5725736732675849fa (diff) |
Add support to generate multiple TA dev kits
Adds support to generate multiple TA dev kits, one for each word in the
variable "ta-targets". ta/ta.mk is included once for each word in
"ta-targets" with the word assigned to "ta-target". This word is the
assigned the variable "sm" to allow each "ta-target" to be built as a
separate sub-module.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'ta')
-rw-r--r-- | ta/arch/arm/arm.mk | 8 | ||||
-rw-r--r-- | ta/arch/arm/link.mk | 17 | ||||
-rw-r--r-- | ta/arch/arm/ta.ld.S (renamed from ta/arch/arm/user_ta_elf_arm.lds) | 6 | ||||
-rw-r--r-- | ta/mk/ta_dev_kit.mk | 12 | ||||
-rw-r--r-- | ta/ta.mk | 46 |
5 files changed, 60 insertions, 29 deletions
diff --git a/ta/arch/arm/arm.mk b/ta/arch/arm/arm.mk index 9e4d47d3..7202131d 100644 --- a/ta/arch/arm/arm.mk +++ b/ta/arch/arm/arm.mk @@ -1,6 +1,6 @@ -ifeq ($(CFG_ARM64_user_ta),y) -user_ta-platform-cppflags += -DARM64=1 -D__LP64__=1 +ifeq ($(CFG_ARM64_$(sm)),y) +$(sm)-platform-cppflags += -DARM64=1 -D__LP64__=1 endif -ifeq ($(CFG_ARM32_user_ta),y) -user_ta-platform-cppflags += -DARM32=1 -D__ILP32__=1 +ifeq ($(CFG_ARM32_$(sm)),y) +$(sm)-platform-cppflags += -DARM32=1 -D__ILP32__=1 endif diff --git a/ta/arch/arm/link.mk b/ta/arch/arm/link.mk index abc89c5a..6201bb30 100644 --- a/ta/arch/arm/link.mk +++ b/ta/arch/arm/link.mk @@ -1,7 +1,8 @@ link-out-dir = $(out-dir) -link-script = $(TA_DEV_KIT_DIR)/src/user_ta_elf_arm.lds +link-script = $(TA_DEV_KIT_DIR)/src/ta.ld.S link-script-pp = $(link-out-dir)/ta.lds +link-script-dep = $(link-out-dir)/.ta.ld.d SIGN = $(TA_DEV_KIT_DIR)/scripts/sign.py TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem @@ -27,10 +28,20 @@ link-ldadd += $(addprefix -L,$(libdirs)) link-ldadd += $(addprefix -l,$(call reverse,$(libnames))) ldargs-$(binary).elf := $(link-ldflags) $(objs) $(link-ldadd) + +link-script-cppflags-$(sm) := -DASM=1 \ + $(filter-out $(CPPFLAGS_REMOVE) $(cppflags-remove), \ + $(nostdinc$(sm)) $(CPPFLAGS) \ + $(addprefix -I,$(incdirs$(sm)) $(link-out-dir)) \ + $(cppflags$(sm))) + +-include $(link-script-dep) + $(link-script-pp): $(link-script) $(MAKEFILE_LIST) - @$(cmd-echo-silent) ' CP $@' + @$(cmd-echo-silent) ' CPP $@' $(q)mkdir -p $(dir $@) - $(q)cp $< $@ + $(q)$(CPP$(sm)) -Wp,-P,-MT,$@,-MD,$(link-script-dep) \ + $(link-script-cppflags-$(sm)) $< > $@ $(link-out-dir)/$(binary).elf: $(objs) $(libdeps) $(link-script-pp) @$(cmd-echo-silent) ' LD $@' diff --git a/ta/arch/arm/user_ta_elf_arm.lds b/ta/arch/arm/ta.ld.S index a7798231..67e7a821 100644 --- a/ta/arch/arm/user_ta_elf_arm.lds +++ b/ta/arch/arm/ta.ld.S @@ -1,5 +1,11 @@ +#ifdef ARM32 OUTPUT_FORMAT("elf32-littlearm") OUTPUT_ARCH(arm) +#endif +#ifdef ARM64 +OUTPUT_FORMAT("elf64-littleaarch64") +OUTPUT_ARCH(aarch64) +#endif PHDRS { rodata PT_LOAD; diff --git a/ta/mk/ta_dev_kit.mk b/ta/mk/ta_dev_kit.mk index efa9934c..8183292c 100644 --- a/ta/mk/ta_dev_kit.mk +++ b/ta/mk/ta_dev_kit.mk @@ -1,5 +1,3 @@ - - # Get the dir of the ta-dev-kit, requires make version 3.81 or later ta-dev-kit-dir := $(patsubst %/,%,$(abspath $(dir $(lastword $(MAKEFILE_LIST)))..)) @@ -7,8 +5,8 @@ ta-dev-kit-dir := $(patsubst %/,%,$(abspath $(dir $(lastword $(MAKEFILE_LIST))). .PHONY: all all: -sm := user_ta -sm-$(ta) := y +include $(ta-dev-kit-dir)/mk/conf.mk + binary := $(BINARY) CROSS_COMPILE_$(sm) ?= $(CROSS_COMPILE) @@ -43,9 +41,9 @@ endif include $(ta-dev-kit-dir)/mk/arch.mk -include $(ta-dev-kit-dir)/mk/platform_flags.mk -cppflags$(sm) += $(platform-cppflags) $(user_ta-platform-cppflags) -aflags$(sm) += $(platform-aflags) $(user_ta-platform-aflags) -cflags$(sm) += $(platform-cflags) $(user_ta-platform-cflags) +cppflags$(sm) := $(platform-cppflags) $($(sm)-platform-cppflags) +aflags$(sm) := $(platform-aflags) $($(sm)-platform-aflags) +cflags$(sm) := $(platform-cflags) $($(sm)-platform-cflags) CFG_TEE_TA_LOG_LEVEL ?= 2 cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL) @@ -1,7 +1,7 @@ include mk/cleanvars.mk # Set current submodule (used for module specific flags compile result etc) -sm := user_ta +sm := $(ta-target) sm-$(sm) := y # Setup compiler for this sub module @@ -11,16 +11,17 @@ include mk/$(COMPILER_$(sm)).mk include ta/arch/$(ARCH)/$(ARCH).mk -cppflags$(sm) += $(platform-cppflags) $(user_ta-platform-cppflags) -cflags$(sm) += $(platform-cflags) $(user_ta-platform-cflags) -aflags$(sm) += $(platform-aflags) $(user_ta-platform-aflags) +# Expand platform flags here as $(sm) will change if we have several TA +# targets. Platform flags should not change after inclusion of ta/ta.mk. +cppflags$(sm) := $(platform-cppflags) $($(sm)-platform-cppflags) +cflags$(sm) := $(platform-cflags) $($(sm)-platform-cflags) +aflags$(sm) := $(platform-aflags) $($(sm)-platform-aflags) # Config flags from mk/config.mk cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL) cppflags$(sm) += -DCFG_TEE_CORE_USER_MEM_DEBUG=$(CFG_TEE_CORE_USER_MEM_DEBUG) cppflags$(sm) += -DENABLE_MDBG=$(CFG_TEE_TA_MALLOC_DEBUG) - base-prefix := $(sm)- libname = utils @@ -62,7 +63,7 @@ endef # Copy the .a files $(foreach f, $(libfiles), \ - $(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/lib))) + $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/lib))) # Copy .mk files ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk \ @@ -71,10 +72,10 @@ ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk \ ta/mk/ta_dev_kit.mk $(foreach f, $(ta-mkfiles), \ - $(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/mk))) + $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/mk))) # Special treatment for ta/arch/$(ARCH)/$(ARCH).mk -arch-arch-mk := $(out-dir)/export-user_ta/mk/arch.mk +arch-arch-mk := $(out-dir)/export-$(sm)/mk/arch.mk $(arch-arch-mk): ta/arch/$(ARCH)/$(ARCH).mk @set -e; \ mkdir -p $(dir $@) ; \ @@ -91,26 +92,41 @@ $$(foreach h, $$(sf), $$(eval $$(call copy-file, $1/$$(h), \ $$(patsubst %/,%,$$(subst /./,/,$2/$$(dir $$(h))))))) endef $(foreach d, $(incdirs$(sm)), \ - $(eval $(call copy-incdir, $(d), $(out-dir)/export-user_ta/include))) + $(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/include))) # Copy the .h files needed by host $(foreach d, $(incdirs-host), \ - $(eval $(call copy-incdir, $(d), $(out-dir)/export-user_ta/host_include))) + $(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/host_include))) $(foreach f, $(incfiles-extra-host), \ - $(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/host_include))) + $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/host_include))) # Copy the src files ta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c \ - $(wildcard ta/arch/$(ARCH)/user_ta_elf_arm.lds) + $(wildcard ta/arch/$(ARCH)/ta.ld.S) $(foreach f, $(ta-srcfiles), \ - $(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/src))) + $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/src))) # Copy keys ta-keys = keys/default_ta.pem $(foreach f, $(ta-keys), \ - $(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/keys))) + $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/keys))) # Copy the scripts ta-scripts = $(wildcard scripts/sign.py) $(foreach f, $(ta-scripts), \ - $(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/scripts))) + $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/scripts))) + +# Create config file +conf-file := $(out-dir)/export-$(sm)/mk/conf.mk +sm-$(conf-file) := $(sm) +# The file is only created if it doesn't exist, this is currently OK as the +# content of the file is static for a given TA dev kit. +$(conf-file): + @$(cmd-echo-silent) ' GEN ' $@ + $(q)echo sm := $(sm-$(@)) > $@ + $(q)echo sm-$(sm-$(@)) := y >> $@ + $(q)echo CFG_ARM32_$(sm-$(@)) := $(CFG_ARM32_$(sm-$(@))) >> $@ + $(q)echo CFG_ARM64_$(sm-$(@)) := $(CFG_ARM64_$(sm-$(@))) >> $@ + +cleanfiles := $(cleanfiles) $(conf-file) +all: $(conf-file) |