hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
ifneq ($(filter rk312% rk322% rk3288 rk3328 rk3368 rk3399 rk3399pro px3 px5, $(TARGET_BOARD_PLATFORM)), )
$(info 'building rk_tee_user v1')
else
$(info 'building rk_tee_user v2')
 
LOCAL_PATH := $(call my-dir)
OPTEE_TEST_PATH := $(shell pwd)/$(LOCAL_PATH)
 
## include variants like TA_DEV_KIT_DIR
## and target of BUILD_OPTEE_OS
INCLUDE_FOR_BUILD_TA := false
include $(BUILD_OPTEE_MK)
INCLUDE_FOR_BUILD_TA :=
 
VERSION = $(shell git describe --always --dirty=-dev 2>/dev/null || echo Unknown)
 
# TA_DEV_KIT_DIR must be set to non-empty value to
# avoid the Android build scripts complaining about
# includes pointing outside the Android source tree.
# This var is expected to be set when OPTEE OS built.
# We set the default value to an invalid path.
TA_DEV_KIT_DIR ?= $(OPTEE_TEST_PATH)/export-ta_arm32
 
OPTEE_CLIENT_PATH ?= $(LOCAL_PATH)/client_export
 
include $(TA_DEV_KIT_DIR)/host_include/conf.mk
 
ifeq (1,$(strip $(shell expr $(PLATFORM_VERSION) \>= 11)))
ifeq ($(strip $(TARGET_ARCH)), arm64)
   CLIENT_LIB_PATH ?= $(shell pwd)/hardware/rockchip/optee/v2/arm64
else
   CLIENT_LIB_PATH ?= $(shell pwd)/hardware/rockchip/optee/v2/arm
endif
else
ifeq ($(strip $(TARGET_ARCH)), arm64)
   CLIENT_LIB_PATH ?= $(shell pwd)/vendor/rockchip/common/security/optee/v2/lib/arm64
else
   CLIENT_LIB_PATH ?= $(shell pwd)/vendor/rockchip/common/security/optee/v2/lib/arm
endif
endif
 
################################################################################
# Build xtest                                                                  #
################################################################################
include $(CLEAR_VARS)
LOCAL_MODULE := xtest
LOCAL_VENDOR_MODULE := true
LOCAL_SHARED_LIBRARIES := libteec
 
TA_DIR ?= /vendor/lib/optee_armtz
 
srcs := regression_1000.c
 
ifeq ($(CFG_GP_SOCKETS),y)
srcs += regression_2000.c \
   sock_server.c \
   rand_stream.c
endif
 
srcs +=    adbg/src/adbg_case.c \
   adbg/src/adbg_enum.c \
   adbg/src/adbg_expect.c \
   adbg/src/adbg_log.c \
   adbg/src/adbg_run.c \
   adbg/src/security_utils_hex.c \
   aes_perf.c \
   benchmark_1000.c \
   benchmark_2000.c \
   regression_4000.c \
   regression_4100.c \
   regression_5000.c \
   regression_6000.c \
   regression_8000.c \
   regression_8100.c \
   sha_perf.c \
   stats.c \
   xtest_helpers.c \
   xtest_main.c \
   xtest_test.c \
   xtest_uuid_helpers.c
 
ifeq ($(CFG_SECSTOR_TA_MGMT_PTA),y)
srcs += install_ta.c
endif
 
ifeq ($(CFG_SECURE_DATA_PATH),y)
srcs += sdp_basic.c
endif
 
ifeq ($(CFG_PKCS11_TA),y)
srcs += pkcs11_1000.c
LOCAL_CFLAGS += -DCFG_PKCS11_TA
LOCAL_SHARED_LIBRARIES += libckteec
endif
 
define my-embed-file
$(TARGET_OUT_HEADERS)/$(1).h: $(LOCAL_PATH)/$(2)
   @echo '  GEN     $$@'
   @$(LOCAL_PATH)/scripts/file_to_c.py --inf $$< --out $$@ --name $(1)
 
LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_HEADERS)/$(1).h
 
endef
 
$(eval $(call my-embed-file,regression_8100_ca_crt,cert/ca.crt))
$(eval $(call my-embed-file,regression_8100_mid_crt,cert/mid.crt))
$(eval $(call my-embed-file,regression_8100_my_crt,cert/my.crt))
$(eval $(call my-embed-file,regression_8100_my_csr,cert/my.csr))
 
LOCAL_SRC_FILES := $(patsubst %,host/xtest/%,$(srcs))
 
LOCAL_C_INCLUDES += $(LOCAL_PATH)/host/xtest \
       $(LOCAL_PATH)/host/xtest/adbg/include\
       $(LOCAL_PATH)/host/supp_plugin/include \
       $(LOCAL_PATH)/ta/include \
       $(LOCAL_PATH)/ta/create_fail_test/include \
       $(LOCAL_PATH)/ta/crypt/include \
       $(LOCAL_PATH)/ta/enc_fs/include \
       $(LOCAL_PATH)/ta/os_test/include \
       $(LOCAL_PATH)/ta/rpc_test/include \
       $(LOCAL_PATH)/ta/sims/include \
       $(LOCAL_PATH)/ta/miss/include \
       $(LOCAL_PATH)/ta/sims_keepalive/include \
       $(LOCAL_PATH)/ta/storage_benchmark/include \
       $(LOCAL_PATH)/ta/concurrent/include \
       $(LOCAL_PATH)/ta/concurrent_large/include \
       $(LOCAL_PATH)/ta/sha_perf/include \
       $(LOCAL_PATH)/ta/aes_perf/include \
       $(LOCAL_PATH)/ta/socket/include \
       $(LOCAL_PATH)/ta/sdp_basic/include \
       $(LOCAL_PATH)/ta/tpm_log_test/include \
       $(LOCAL_PATH)/ta/supp_plugin/include \
       $(OPTEE_CLIENT_PATH)/public
 
# Include configuration file generated by OP-TEE OS (CFG_* macros)
LOCAL_CFLAGS += -I $(TA_DEV_KIT_DIR)/host_include -include conf.h
LOCAL_CFLAGS += -pthread
LOCAL_CFLAGS += -g3
LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-format-zero-length
 
ifneq ($(TA_DIR),)
LOCAL_CFLAGS += -DTA_DIR=\"$(TA_DIR)\"
endif
 
## $(OPTEE_BIN) is the path of tee.bin like
## out/target/product/hikey/optee/arm-plat-hikey/core/tee.bin
## it will be generated after build the optee_os with target BUILD_OPTEE_OS
## which is defined in the common ta build mk file included before,
LOCAL_ADDITIONAL_DEPENDENCIES += $(OPTEE_BIN)
 
include $(BUILD_EXECUTABLE)
################################################################################
# Build rktest                                                                 #
################################################################################
include $(CLEAR_VARS)
LOCAL_CFLAGS += -DANDROID_BUILD -DUSER_SPACE
LOCAL_CFLAGS += -Wall -Wno-error
LOCAL_LDFLAGS += $(CLIENT_LIB_PATH)/libteec.so
LOCAL_LDFLAGS += -llog
 
SRC_FILES_DIR := $(wildcard $(LOCAL_PATH)/host/rk_test/*.c)
LOCAL_SRC_FILES += $(SRC_FILES_DIR:$(LOCAL_PATH)/%=%)
 
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ta/rk_test/include \
       $(LOCAL_PATH)/host/rk_test/include \
       $(LOCAL_PATH)/export-ta_arm32/host_include \
       $(OPTEE_CLIENT_PATH)/public
 
LOCAL_MODULE := rktest
LOCAL_MODULE_TAGS := optional
ifeq (1,$(strip $(shell expr $(PLATFORM_VERSION) \>= 8)))
   LOCAL_PROPRIETARY_MODULE := true
endif
include $(BUILD_EXECUTABLE)
 
include $(LOCAL_PATH)/ta/Android.mk
endif