Skip to content

Commit

Permalink
[CMake]: add ta script
Browse files Browse the repository at this point in the history
[Desc]: as title

Signed-off-by: pengyinjie <[email protected]>
  • Loading branch information
XMPengYinjie committed Dec 26, 2024
1 parent c3cb025 commit d5c176f
Show file tree
Hide file tree
Showing 7 changed files with 593 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ta/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# ##############################################################################
# frameworks/security/ta/CMakeList.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################

nuttx_add_subdirectory()

nuttx_generate_kconfig(MENUDESC "Trusted applications")
95 changes: 95 additions & 0 deletions ta/alipay/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#
# 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_TA_ALIPAY)
set(WLDFLAGS
-Wl,--export=wasm_TA_CreateEntryPoint
-Wl,--export=wasm_TA_DestroyEntryPoint
-Wl,--export=wasm_TA_OpenSessionEntryPoint
-Wl,--export=wasm_TA_CloseSessionEntryPoint
-Wl,--export=wasm_TA_InvokeCommandEntryPoint)

list(APPEND CFLAGS -DCFG_NUM_THREADS=1 -DUSER_TA_WASM)

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()

list(
APPEND
INCDIR
${APPDIR}/frameworks/security/include
${APPDIR}/frameworks/security/optee_vela/include
${APPDIR}/interpreters/wamr/wamr/core/iwasm/include
${APPDIR}/external/optee/optee_os/optee_os/core/include
${APPDIR}/external/optee/optee_os/optee_os/lib/libutee/include
${APPDIR}/external/optee/optee_os/optee_os/lib/libutils/ext/include)

if(CONFIG_ARCH_SIM)
wasm_add_application(
NAME
ta_alipay
SRCS
alipay_ta.c
STACK_SIZE
4096
WINCLUDES
${INCDIR}
WAMR_MODE
WASM
WLDFLAGS
${WLDFLAGS}
WCFLAGS
${CFLAGS}
INSTALL_NAME
etc/ta/F1490647578C565BA2C321FD51DC6791)
else()
wasm_add_application(
NAME
ta_alipay
SRCS
alipay_ta.c
STACK_SIZE
4096
WINCLUDES
${INCDIR}
WAMR_MODE
XIP
WLDFLAGS
${WLDFLAGS}
WCFLAGS
${CFLAGS}
INSTALL_NAME
etc/ta/F1490647578C565BA2C321FD51DC6791)
endif()

wasm_add_library(
NAME
ta_frameworks
SRCS
${APPDIR}/frameworks/security/optee_vela/wasm/wasm_ta_framework.c
WINCLUDES
${INCDIR}
WCFLAGS
${CFLAGS})

endif()
95 changes: 95 additions & 0 deletions ta/comsst/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#
# 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_TA_COMSST)
set(WLDFLAGS
-Wl,--export=wasm_TA_CreateEntryPoint
-Wl,--export=wasm_TA_DestroyEntryPoint
-Wl,--export=wasm_TA_OpenSessionEntryPoint
-Wl,--export=wasm_TA_CloseSessionEntryPoint
-Wl,--export=wasm_TA_InvokeCommandEntryPoint)

list(APPEND CFLAGS -DCFG_NUM_THREADS=1 -DUSER_TA_WASM)

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()

list(
APPEND
INCDIR
${APPDIR}/frameworks/security/include
${APPDIR}/frameworks/security/optee_vela/include
${APPDIR}/interpreters/wamr/wamr/core/iwasm/include
${APPDIR}/external/optee/optee_os/optee_os/core/include
${APPDIR}/external/optee/optee_os/optee_os/lib/libutee/include
${APPDIR}/external/optee/optee_os/optee_os/lib/libutils/ext/include)

if(CONFIG_ARCH_SIM)
wasm_add_application(
NAME
ta_comsst
SRCS
comsst_ta.c
STACK_SIZE
4096
WINCLUDES
${INCDIR}
WAMR_MODE
WASM
WLDFLAGS
${WLDFLAGS}
WCFLAGS
${CFLAGS}
INSTALL_NAME
etc/ta/F617ACC99AE5405985D05056DF6BF28B)
else()
wasm_add_application(
NAME
ta_comsst
SRCS
comsst_ta.c
STACK_SIZE
4096
WINCLUDES
${INCDIR}
WAMR_MODE
XIP
WLDFLAGS
${WLDFLAGS}
WCFLAGS
${CFLAGS}
INSTALL_NAME
etc/ta/F617ACC99AE5405985D05056DF6BF28B)
endif()

wasm_add_library(
NAME
ta_frameworks
SRCS
${APPDIR}/frameworks/security/optee_vela/wasm/wasm_ta_framework.c
WINCLUDES
${INCDIR}
WCFLAGS
${CFLAGS})

endif()
95 changes: 95 additions & 0 deletions ta/hello_world/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#
# 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_TA_HELLO_WORLD)
set(WLDFLAGS
-Wl,--export=wasm_TA_CreateEntryPoint
-Wl,--export=wasm_TA_DestroyEntryPoint
-Wl,--export=wasm_TA_OpenSessionEntryPoint
-Wl,--export=wasm_TA_CloseSessionEntryPoint
-Wl,--export=wasm_TA_InvokeCommandEntryPoint)

list(APPEND CFLAGS -DCFG_NUM_THREADS=1 -DUSER_TA_WASM)

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()

list(
APPEND
INCDIR
${APPDIR}/frameworks/security/include
${APPDIR}/frameworks/security/optee_vela/include
${APPDIR}/interpreters/wamr/wamr/core/iwasm/include
${APPDIR}/external/optee/optee_os/optee_os/core/include
${APPDIR}/external/optee/optee_os/optee_os/lib/libutee/include
${APPDIR}/external/optee/optee_os/optee_os/lib/libutils/ext/include)

if(CONFIG_ARCH_SIM)
wasm_add_application(
NAME
ta_hello_world
SRCS
hello_world_ta.c
STACK_SIZE
4096
WINCLUDES
${INCDIR}
WAMR_MODE
WASM
WLDFLAGS
${WLDFLAGS}
WCFLAGS
${CFLAGS}
INSTALL_NAME
etc/ta/00F2AA8A5024E411ABE20002A5D5C51B)
else()
wasm_add_application(
NAME
ta_hello_world
SRCS
hello_world_ta.c
STACK_SIZE
4096
WINCLUDES
${INCDIR}
WAMR_MODE
XIP
WLDFLAGS
${WLDFLAGS}
WCFLAGS
${CFLAGS}
INSTALL_NAME
etc/ta/00F2AA8A5024E411ABE20002A5D5C51B)
endif()

wasm_add_library(
NAME
ta_frameworks
SRCS
${APPDIR}/frameworks/security/optee_vela/wasm/wasm_ta_framework.c
WINCLUDES
${INCDIR}
WCFLAGS
${CFLAGS})

endif()
Loading

0 comments on commit d5c176f

Please sign in to comment.