forked from open-vela/frameworks_security_optee_vela
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
164 lines (142 loc) · 4.74 KB
/
CMakeLists.txt
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
#
# Copyright (C) 2023 Xiaomi Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
if(CONFIG_OPTEE_OS)
# ############################################################################
# Flags
# ############################################################################
set(CFLAGS
-DCFG_CORE_DYN_SHM
-DCFG_NUM_THREADS=1
-DCFG_OTP_SUPPORT
-DCFG_OTP_SUPPORT_NO_PROVISION_TMP
-DCFG_WITH_USER_TA
-DHOST_FS_PARENT_PATH=\"${CONFIG_OPTEE_HOST_FS_PARENT_PATH}\")
if(CONFIG_TEE_CORE_DEBUG)
list(APPEND CFLAGS -DCFG_TEE_CORE_DEBUG)
endif()
if(CONFIG_DEBUG_INFO)
list(APPEND CFLAGS -DTRACE_LEVEL=3)
elseif(CONFIG_DEBUG_WARN)
list(APPEND CFLAGS -DTRACE_LEVEL=2)
elseif(CONFIG_DEBUG_ERROR)
list(APPEND CFLAGS -DTRACE_LEVEL=1)
else()
list(APPEND CFLAGS -DTRACE_LEVEL=1)
endif()
if(CONFIG_ARCH_ARM64)
list(APPEND CFLAGS -DARM64)
elseif(CONFIG_ARCH_ARM)
list(APPEND CFLAGS -DARM32)
elseif(CONFIG_ARCH_SIM)
list(APPEND CFLAGS -DARM32)
endif()
# ############################################################################
# Sources
# ############################################################################
set(CSRCS
compat/abort.c
compat/atomic.c
compat/core_mmu.c
compat/hmac_memory.c
compat/host_fs.c
compat/ldelf_loader.c
compat/malloc.c
compat/mempool.c
compat/mobj.c
compat/mobj_dyn_shm.c
compat/msg_param.c
compat/notif.c
compat/otp_stubs.c
compat/panic.c
compat/random.c
compat/scall.c
compat/spinlock.c
compat/tee_time_system.c
compat/thread.c
compat/thread_optee_compat.c
compat/trace_ext.c
compat/ts_manager.c
compat/user_access.c
compat/user_mode_ctx.c
compat/user_ta_entry_dummy.c
compat/vm.c)
if(CONFIG_TEE_CORE_DEBUG)
list(APPEND CSRCS compat/spin_lock_debug.c)
endif()
if(CONFIG_OPTEE_RPMB_FS)
list(APPEND CSRCS compat/rpmb_fs.c)
endif()
if(CONFIG_OPTEE_COMPAT_MITEE_FS)
list(
APPEND
CSRCS
compat/mitee_compat/huk_subkey.c
compat/mitee_compat/mitee_crypt.c
compat/mitee_compat/tee_fs_rpc.c
compat/mitee_compat/tee_fs_key_manager_compat.c
compat/mitee_compat/tee_obj.c
compat/mitee_compat/tee_ree_fs.c
compat/mitee_compat/tee_svc_compat.c
compat/mitee_compat/tee_svc_storage.c)
list(APPEND CFLAGS -DFS_STORAGE_DIR_PRIVATE=\"/sst/\")
endif()
if(CONFIG_USER_TA_WASM)
list(APPEND CSRCS wasm/user_ta_wasm.c wasm/libtee_builtin_wrapper.c)
list(APPEND CFLAGS -DUSER_TA_WASM)
endif()
# ############################################################################
# Include Directory
# ############################################################################
set(INCDIR ${CMAKE_CURRENT_LIST_DIR}/include)
if(CONFIG_OPTEE_COMPAT_MITEE_FS)
list(APPEND INCDIR ${CMAKE_CURRENT_LIST_DIR}/include/mitee_compat)
endif()
list(
APPEND
INCDIR
${NUTTX_APPS_DIR}/external/optee/optee_os/optee_os/core/include
${NUTTX_APPS_DIR}/external/optee/optee_os/optee_os/ldelf/include
${NUTTX_APPS_DIR}/external/optee/optee_os/optee_os/lib/libutils/ext/include
${NUTTX_APPS_DIR}/external/optee/optee_os/optee_os/lib/libutee/include
${NUTTX_APPS_DIR}/crypto/mbedtls/mbedtls/library)
# ############################################################################
# Library Configuration
# ############################################################################
nuttx_add_library(optee_nuttx STATIC)
target_sources(optee_nuttx PRIVATE ${CSRCS})
target_include_directories(optee_nuttx PRIVATE ${INCDIR})
target_compile_options(optee_nuttx PRIVATE ${CFLAGS})
# ############################################################################
# Applications Configuration
# ############################################################################
if(NOT CONFIG_OPTEE_SERVER_NONE)
nuttx_add_application(
NAME
${CONFIG_OPTEE_SERVER_PROGNAME}
STACKSIZE
${CONFIG_OPTEE_SERVER_STACKSIZE}
PRIORITY
${CONFIG_OPTEE_SERVER_PRIORITY}
SRCS
server/opteed.c
INCLUDE_DIRECTORIES
${INCDIR}
COMPILE_FLAGS
${CFLAGS}
DEPENDS
optee_nuttx)
endif()
endif()