summaryrefslogtreecommitdiff
authorShuide Chen <shuide.chen@amlogic.com>2019-05-28 06:06:41 (GMT)
committer Shuide Chen <shuide.chen@amlogic.com>2019-07-15 03:24:31 (GMT)
commitcd5a1f60ecf6dc77051cc90d9391058a04d57817 (patch)
treea361e83fbdb0d691236c4c80322de3c5eff13e1f
parent6c054e1526f661f9d36232550809b5531473e943 (diff)
downloadtdk_linuxdriver-p-amlogic.zip
tdk_linuxdriver-p-amlogic.tar.gz
tdk_linuxdriver-p-amlogic.tar.bz2
tee: integrate tee module build to android build system [1/2]
PD#SWPL-9058 Problem: optee module build trigged at scanning Android.mk stage, it's too early and the module not depend to kernel, which may introduce very strange errors, and it customize toolchain and configures, which made the system very hard to maintain. Solution: Rewrite the makefile and structure for the above problem This CL also support build on Q Verify: locally Change-Id: I8d883735d926c54848a4135518e4be139594a147 Signed-off-by: Shuide Chen <shuide.chen@amlogic.com>
Diffstat
-rw-r--r--[-rwxr-xr-x]Android.mk87
-rw-r--r--[-rwxr-xr-x]Kconfig0
-rw-r--r--[-rwxr-xr-x]Makefile0
-rw-r--r--[-rwxr-xr-x]include/linux/arm-smccc.h0
-rw-r--r--[-rwxr-xr-x]include/linux/tee.h0
-rw-r--r--[-rwxr-xr-x]include/linux/tee_drv.h0
-rw-r--r--[-rwxr-xr-x]optee/Kconfig0
-rw-r--r--[-rwxr-xr-x]optee/optee_msg.h0
-rw-r--r--[-rwxr-xr-x]optee/optee_private.h0
-rw-r--r--[-rwxr-xr-x]optee/optee_smc.h0
-rw-r--r--[-rwxr-xr-x]optee/smccc-call.S0
-rw-r--r--[-rwxr-xr-x]optee/supp.c0
-rw-r--r--[-rwxr-xr-x]tee_core.c0
-rw-r--r--[-rwxr-xr-x]tee_private.h0
-rw-r--r--[-rwxr-xr-x]tee_shm.c0
15 files changed, 59 insertions, 28 deletions
diff --git a/Android.mk b/Android.mk
index de85d75..7757047 100755..100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,51 +1,82 @@
LOCAL_PATH := $(call my-dir)
-ifeq ($(BOARD_KERNEL_VERSION), 4.9)
-KERNEL_DIR := kernel/common_4.9
-else ifeq ($(BOARD_KERNEL_VERSION), 3.14)
-KERNEL_DIR := kernel/common_3.14
-else
-KERNEL_DIR := common
-endif
-KERNEL_OUT_DIR := $(PRODUCT_OUT)/obj/KERNEL_OBJ
-ifeq ($(KERNEL_A32_SUPPORT), true)
-KERNEL_ARCH := arm
-KERNEL_DRIVER_CROSS_COMPILE := /opt/gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
-KERNEL_CONFIG=meson64_a32_defconfig
-else
-KERNEL_ARCH := arm64
-KERNEL_DRIVER_CROSS_COMPILE := aarch64-linux-gnu-
-KERNEL_CONFIG=meson64_defconfig
-endif
-OPTEE_MODULES := $(shell pwd)/$(PRODUCT_OUT)/obj/optee_modules
-include $(CLEAR_VARS)
-$(info $(shell if [ ! -d $(KERNEL_OUT_DIR) ]; then mkdir -p $(KERNEL_OUT_DIR); fi))
+ifneq ($(TARGET_KERNEL_BUILT_FROM_SOURCE), false)
-$(info $(shell if [ ! -e $(KERNEL_OUT_DIR)/include/generated/autoconf.h ]; then $(MAKE) -C $(KERNEL_DIR) O=../$(KERNEL_OUT_DIR) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_DRIVER_CROSS_COMPILE) $(KERNEL_CONFIG); fi))
+OPTEE_MODULES := $(shell pwd)/$(PRODUCT_OUT)/obj/optee_modules/
+OPTEE_DRIVERS := $(shell pwd)/vendor/amlogic/common/tdk/linuxdriver/
+KERNEL_OUT_DIR := $(shell pwd)/$(PRODUCT_OUT)/obj/KERNEL_OBJ/
+##############################################################################
+###
+### Build tee modules for Android. Since is in Android.mk, not standalone
+### module build script, all kernel related configurations(e.g:CROSS_COMPILE),
+### PLEASE PLEASE extends from the build system, DO NOT customization here!
+##############################################################################
+ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29 && echo OK),OK)
+define build_optee_modules
+ echo "$(1) $(2) $(3)"
+ mkdir -p $(2)/
+ cp -rfa $(1)/* $(2)/
+ PATH=$$(cd ./$(TARGET_HOST_TOOL_PATH); pwd):$$PATH \
+ $(MAKE) -C $(KERNEL_OUT_DIR) M=$(strip $(2)) \
+ KERNEL_A32_SUPPORT=$(KERNEL_A32_SUPPORT) ARCH=$(KERNEL_ARCH) \
+ CROSS_COMPILE=$(PREFIX_CROSS_COMPILE)
+endef
+else
+define build_optee_modules
+ echo "$(1) $(2) $(3)"
+ mkdir -p $(2)/
+ cp -rfa $(1)/* $(2)/
+ $(MAKE) -C $(KERNEL_OUT_DIR) M=$(strip $(2)) \
+ KERNEL_A32_SUPPORT=$(KERNEL_A32_SUPPORT) ARCH=$(KERNEL_ARCH) \
+ CROSS_COMPILE=$(PREFIX_CROSS_COMPILE)
+endef
+endif
-$(info $(shell if [ ! -e $(KERNEL_OUT_DIR)/include/generated/autoconf.h ]; then $(MAKE) -C $(KERNEL_DIR) O=../$(KERNEL_OUT_DIR) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_DRIVER_CROSS_COMPILE) modules_prepare; fi))
+$(PRODUCT_OUT)/obj/optee_modules/optee.ko: $(INSTALLED_KERNEL_TARGET)
+ $(call build_optee_modules, $(OPTEE_DRIVERS), $(OPTEE_MODULES))
-$(info $(shell if [ ! -d $(OPTEE_MODULES) ]; then mkdir -p $(OPTEE_MODULES); fi))
-$(info $(shell cp $(LOCAL_PATH)/* $(OPTEE_MODULES) -rfa))
-$(info $(shell $(MAKE) -C $(shell pwd)/$(KERNEL_OUT_DIR) M=$(OPTEE_MODULES) KERNEL_A32_SUPPORT=$(KERNEL_A32_SUPPORT) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_DRIVER_CROSS_COMPILE) modules))
+endif
include $(CLEAR_VARS)
LOCAL_MODULE := optee_armtz
-LOCAL_PREBUILT_MODULE_FILE := $(OPTEE_MODULES)/optee/optee_armtz.ko
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+
+ifneq ($(TARGET_KERNEL_BUILT_FROM_SOURCE), false)
+GEN_OPTEE_ARMTZ := $(local-generated-sources-dir)/optee_armtz.ko
+$(GEN_OPTEE_ARMTZ): $(PRODUCT_OUT)/obj/optee_modules/optee.ko | $(ACP)
+ cp $(PRODUCT_OUT)/obj/optee_modules/optee/optee_armtz.ko $(GEN_OPTEE_ARMTZ)
+
+LOCAL_PREBUILT_MODULE_FILE := $(GEN_OPTEE_ARMTZ)
+else
+# TARGET_BOOTLOADER_BOARD_NAME currently defined the same as platform device name
+LOCAL_SRC_FILES := device/amlogic/$(TARGET_BOOTLOADER_BOARD_NAME)-kernel/optee_armtz.ko
+endif
+
LOCAL_MODULE_SUFFIX := .ko
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/lib
LOCAL_STRIP_MODULE := false
include $(BUILD_PREBUILT)
+
include $(CLEAR_VARS)
LOCAL_MODULE := optee
-LOCAL_PREBUILT_MODULE_FILE := $(OPTEE_MODULES)/optee.ko
-LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+
+ifneq ($(TARGET_KERNEL_BUILT_FROM_SOURCE), false)
+GEN_OPTEE := $(local-generated-sources-dir)/optee.ko
+$(GEN_OPTEE): $(PRODUCT_OUT)/obj/optee_modules/optee.ko | $(ACP)
+ cp $(PRODUCT_OUT)/obj/optee_modules/optee.ko $(GEN_OPTEE)
+
+LOCAL_PREBUILT_MODULE_FILE := $(GEN_OPTEE)
+else
+LOCAL_SRC_FILES := \
+ device/amlogic/$(TARGET_BOOTLOADER_BOARD_NAME)-kernel/optee.ko
+
+endif
+LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := .ko
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/lib
LOCAL_STRIP_MODULE := false
diff --git a/Kconfig b/Kconfig
index 2330a4e..2330a4e 100755..100644
--- a/Kconfig
+++ b/Kconfig
diff --git a/Makefile b/Makefile
index f94a071..f94a071 100755..100644
--- a/Makefile
+++ b/Makefile
diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
index 699c0d8..699c0d8 100755..100644
--- a/include/linux/arm-smccc.h
+++ b/include/linux/arm-smccc.h
diff --git a/include/linux/tee.h b/include/linux/tee.h
index 31f7127..31f7127 100755..100644
--- a/include/linux/tee.h
+++ b/include/linux/tee.h
diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h
index 401c014..401c014 100755..100644
--- a/include/linux/tee_drv.h
+++ b/include/linux/tee_drv.h
diff --git a/optee/Kconfig b/optee/Kconfig
index 0126de8..0126de8 100755..100644
--- a/optee/Kconfig
+++ b/optee/Kconfig
diff --git a/optee/optee_msg.h b/optee/optee_msg.h
index dd7a06e..dd7a06e 100755..100644
--- a/optee/optee_msg.h
+++ b/optee/optee_msg.h
diff --git a/optee/optee_private.h b/optee/optee_private.h
index cc5e0b5..cc5e0b5 100755..100644
--- a/optee/optee_private.h
+++ b/optee/optee_private.h
diff --git a/optee/optee_smc.h b/optee/optee_smc.h
index 13b7c98..13b7c98 100755..100644
--- a/optee/optee_smc.h
+++ b/optee/optee_smc.h
diff --git a/optee/smccc-call.S b/optee/smccc-call.S
index 81087ce..81087ce 100755..100644
--- a/optee/smccc-call.S
+++ b/optee/smccc-call.S
diff --git a/optee/supp.c b/optee/supp.c
index de1b5f9..de1b5f9 100755..100644
--- a/optee/supp.c
+++ b/optee/supp.c
diff --git a/tee_core.c b/tee_core.c
index 536654a..536654a 100755..100644
--- a/tee_core.c
+++ b/tee_core.c
diff --git a/tee_private.h b/tee_private.h
index 21cb6be..21cb6be 100755..100644
--- a/tee_private.h
+++ b/tee_private.h
diff --git a/tee_shm.c b/tee_shm.c
index 89b1c07..89b1c07 100755..100644
--- a/tee_shm.c
+++ b/tee_shm.c