From d5c176fedc80d80cd8cc3bfa8573479229cc2434 Mon Sep 17 00:00:00 2001 From: pengyinjie Date: Tue, 10 Dec 2024 16:30:54 +0800 Subject: [PATCH] [CMake]: add ta script [Desc]: as title Signed-off-by: pengyinjie --- ta/CMakeLists.txt | 23 +++++++++ ta/alipay/CMakeLists.txt | 95 +++++++++++++++++++++++++++++++++++ ta/comsst/CMakeLists.txt | 95 +++++++++++++++++++++++++++++++++++ ta/hello_world/CMakeLists.txt | 95 +++++++++++++++++++++++++++++++++++ ta/pin/CMakeLists.txt | 95 +++++++++++++++++++++++++++++++++++ ta/triad/CMakeLists.txt | 95 +++++++++++++++++++++++++++++++++++ ta/wxcodepay/CMakeLists.txt | 95 +++++++++++++++++++++++++++++++++++ 7 files changed, 593 insertions(+) create mode 100644 ta/CMakeLists.txt create mode 100644 ta/alipay/CMakeLists.txt create mode 100644 ta/comsst/CMakeLists.txt create mode 100644 ta/hello_world/CMakeLists.txt create mode 100644 ta/pin/CMakeLists.txt create mode 100644 ta/triad/CMakeLists.txt create mode 100644 ta/wxcodepay/CMakeLists.txt diff --git a/ta/CMakeLists.txt b/ta/CMakeLists.txt new file mode 100644 index 0000000..cb3d903 --- /dev/null +++ b/ta/CMakeLists.txt @@ -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") diff --git a/ta/alipay/CMakeLists.txt b/ta/alipay/CMakeLists.txt new file mode 100644 index 0000000..f2993ed --- /dev/null +++ b/ta/alipay/CMakeLists.txt @@ -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() diff --git a/ta/comsst/CMakeLists.txt b/ta/comsst/CMakeLists.txt new file mode 100644 index 0000000..f5f2724 --- /dev/null +++ b/ta/comsst/CMakeLists.txt @@ -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() diff --git a/ta/hello_world/CMakeLists.txt b/ta/hello_world/CMakeLists.txt new file mode 100644 index 0000000..880f729 --- /dev/null +++ b/ta/hello_world/CMakeLists.txt @@ -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() diff --git a/ta/pin/CMakeLists.txt b/ta/pin/CMakeLists.txt new file mode 100644 index 0000000..2fd2ef7 --- /dev/null +++ b/ta/pin/CMakeLists.txt @@ -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_PIN) + 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_pin + SRCS + pin_ta.c + STACK_SIZE + 4096 + WINCLUDES + ${INCDIR} + WAMR_MODE + WASM + WLDFLAGS + ${WLDFLAGS} + WCFLAGS + ${CFLAGS} + INSTALL_NAME + etc/ta/EE571882BE621355ADAB1B7F23DEFAA6) + else() + wasm_add_application( + NAME + ta_pin + SRCS + pin_ta.c + STACK_SIZE + 4096 + WINCLUDES + ${INCDIR} + WAMR_MODE + XIP + WLDFLAGS + ${WLDFLAGS} + WCFLAGS + ${CFLAGS} + INSTALL_NAME + etc/ta/EE571882BE621355ADAB1B7F23DEFAA6) + endif() + + wasm_add_library( + NAME + ta_frameworks + SRCS + ${APPDIR}/frameworks/security/optee_vela/wasm/wasm_ta_framework.c + WINCLUDES + ${INCDIR} + WCFLAGS + ${CFLAGS}) + +endif() diff --git a/ta/triad/CMakeLists.txt b/ta/triad/CMakeLists.txt new file mode 100644 index 0000000..837a854 --- /dev/null +++ b/ta/triad/CMakeLists.txt @@ -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_TRIAD) + 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_triad + SRCS + triad_ta.c + STACK_SIZE + 4096 + WINCLUDES + ${INCDIR} + WAMR_MODE + WASM + WLDFLAGS + ${WLDFLAGS} + WCFLAGS + ${CFLAGS} + INSTALL_NAME + etc/ta/1C6455C967DD255194BE7F9DCD557595) + else() + wasm_add_application( + NAME + ta_triad + SRCS + triad_ta.c + STACK_SIZE + 4096 + WINCLUDES + ${INCDIR} + WAMR_MODE + XIP + WLDFLAGS + ${WLDFLAGS} + WCFLAGS + ${CFLAGS} + INSTALL_NAME + etc/ta/1C6455C967DD255194BE7F9DCD557595) + endif() + + wasm_add_library( + NAME + ta_frameworks + SRCS + ${APPDIR}/frameworks/security/optee_vela/wasm/wasm_ta_framework.c + WINCLUDES + ${INCDIR} + WCFLAGS + ${CFLAGS}) + +endif() diff --git a/ta/wxcodepay/CMakeLists.txt b/ta/wxcodepay/CMakeLists.txt new file mode 100644 index 0000000..9ec68e4 --- /dev/null +++ b/ta/wxcodepay/CMakeLists.txt @@ -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_WXCODEPAY) + 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_wxcodepay + SRCS + wxcodepay_ta.c + STACK_SIZE + 4096 + WINCLUDES + ${INCDIR} + WAMR_MODE + WASM + WLDFLAGS + ${WLDFLAGS} + WCFLAGS + ${CFLAGS} + INSTALL_NAME + etc/ta/4EBA9EA8ACF42751AD93A5A4F03E1A67) + else() + wasm_add_application( + NAME + ta_wxcodepay + SRCS + wxcodepay_ta.c + STACK_SIZE + 4096 + WINCLUDES + ${INCDIR} + WAMR_MODE + XIP + WLDFLAGS + ${WLDFLAGS} + WCFLAGS + ${CFLAGS} + INSTALL_NAME + etc/ta/4EBA9EA8ACF42751AD93A5A4F03E1A67) + endif() + + wasm_add_library( + NAME + ta_frameworks + SRCS + ${APPDIR}/frameworks/security/optee_vela/wasm/wasm_ta_framework.c + WINCLUDES + ${INCDIR} + WCFLAGS + ${CFLAGS}) + +endif()