Separate the generic part of SP deployments
Move the non opteesp environment dependent code of SP deployments into
a separate directory and split CMake files into a generic and an
environment specific part.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I4f09d6d3adef07644e98f2a05d6cb077a92b385b
diff --git a/deployments/crypto/opteesp/crypto_sp.c b/deployments/crypto/common/crypto_sp.c
similarity index 100%
rename from deployments/crypto/opteesp/crypto_sp.c
rename to deployments/crypto/common/crypto_sp.c
diff --git a/deployments/crypto/common/crypto_sp.h b/deployments/crypto/common/crypto_sp.h
new file mode 100644
index 0000000..be1e097
--- /dev/null
+++ b/deployments/crypto/common/crypto_sp.h
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef CRYPTO_SP_H
+#define CRYPTO_SP_H
+
+#define CRYPTO_SP_UUID_BYTES \
+ {0xd9, 0xdf, 0x52, 0xd5, 0x16, 0xa2, 0x4b, 0xb2, \
+ 0x9a, 0xa4, 0xd2, 0x6d, 0x3b, 0x84, 0xe8, 0xc0}
+
+#endif /* CRYPTO_SP_H */
diff --git a/deployments/crypto/crypto.cmake b/deployments/crypto/crypto.cmake
new file mode 100644
index 0000000..c5f1e3a
--- /dev/null
+++ b/deployments/crypto/crypto.cmake
@@ -0,0 +1,81 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+add_components(TARGET "crypto"
+ BASE_DIR ${TS_ROOT}
+ COMPONENTS
+ "components/common/fdt"
+ "components/common/tlv"
+ "components/common/trace"
+ "components/common/utils"
+ "components/config/ramstore"
+ "components/config/loader/sp"
+ "components/messaging/ffa/libsp"
+ "components/rpc/ffarpc/endpoint"
+ "components/rpc/ffarpc/caller/sp"
+ "components/rpc/common/caller"
+ "components/rpc/common/interface"
+ "components/service/common/include"
+ "components/service/common/client"
+ "components/service/common/serializer/protobuf"
+ "components/service/common/provider"
+ "components/service/discovery/provider"
+ "components/service/discovery/provider/serializer/packed-c"
+ "components/service/crypto/provider"
+ "components/service/crypto/provider/serializer/protobuf"
+ "components/service/crypto/provider/serializer/packed-c"
+ "components/service/crypto/provider/extension/hash"
+ "components/service/crypto/provider/extension/hash/serializer/packed-c"
+ "components/service/crypto/provider/extension/cipher"
+ "components/service/crypto/provider/extension/cipher/serializer/packed-c"
+ "components/service/crypto/provider/extension/key_derivation"
+ "components/service/crypto/provider/extension/key_derivation/serializer/packed-c"
+ "components/service/crypto/provider/extension/mac"
+ "components/service/crypto/provider/extension/mac/serializer/packed-c"
+ "components/service/crypto/factory/full"
+ "components/service/crypto/backend/mbedcrypto"
+ "components/service/crypto/backend/mbedcrypto/trng_adapter/platform"
+ "components/service/secure_storage/include"
+ "components/service/secure_storage/frontend/psa/its"
+ "components/service/secure_storage/backend/secure_storage_client"
+ "components/service/secure_storage/backend/null_store"
+ "components/service/secure_storage/factory/sp/rot_store"
+ "protocols/rpc/common/packed-c"
+ "protocols/service/secure_storage/packed-c"
+ "protocols/service/crypto/protobuf"
+)
+
+target_sources(crypto PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/common/crypto_sp.c
+)
+
+#-------------------------------------------------------------------------------
+# Components used from external projects
+#
+#-------------------------------------------------------------------------------
+
+# Get libc include dir
+get_property(LIBC_INCLUDE_PATH TARGET stdlib::c PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+
+# Nanopb
+list(APPEND NANOPB_EXTERNAL_INCLUDE_PATHS ${LIBC_INCLUDE_PATH})
+include(../../../external/nanopb/nanopb.cmake)
+target_link_libraries(crypto PRIVATE nanopb::protobuf-nanopb-static)
+protobuf_generate_all(TGT "crypto" NAMESPACE "protobuf" BASE_DIR "${TS_ROOT}/protocols")
+
+# Mbed TLS provides libmbedcrypto
+list(APPEND MBEDTLS_EXTRA_INCLUDES ${LIBC_INCLUDE_PATH})
+include(../../../external/MbedTLS/MbedTLS.cmake)
+target_link_libraries(crypto PRIVATE mbedcrypto)
+target_link_libraries(mbedcrypto INTERFACE stdlib::c)
+
+#################################################################
+
+target_include_directories(crypto PRIVATE
+ ${TS_ROOT}
+ ${TS_ROOT}/components
+)
diff --git a/deployments/crypto/opteesp/CMakeLists.txt b/deployments/crypto/opteesp/CMakeLists.txt
index 92bd249..a3307bc 100644
--- a/deployments/crypto/opteesp/CMakeLists.txt
+++ b/deployments/crypto/opteesp/CMakeLists.txt
@@ -18,8 +18,8 @@
#-------------------------------------------------------------------------------
include(${TS_ROOT}/environments/opteesp/env.cmake)
project(trusted-services LANGUAGES C ASM)
-add_executable(crypto-sp)
-target_include_directories(crypto-sp PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+add_executable(crypto)
+target_include_directories(crypto PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
set(SP_UUID "d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0")
set(SP_HEAP_SIZE "490 * 1024" CACHE STRING "SP heap size in bytes")
set(TRACE_PREFIX "CRYPTO" CACHE STRING "Trace prefix")
@@ -28,96 +28,32 @@
# Components that are specific to deployment in the opteesp environment.
#
#-------------------------------------------------------------------------------
-add_components(TARGET "crypto-sp"
+add_components(TARGET "crypto"
BASE_DIR ${TS_ROOT}
COMPONENTS
- "components/common/fdt"
- "components/common/tlv"
- "components/common/trace"
- "components/common/utils"
- "components/config/ramstore"
- "components/config/loader/sp"
- "components/messaging/ffa/libsp"
- "components/rpc/ffarpc/endpoint"
- "components/rpc/ffarpc/caller/sp"
- "components/rpc/common/caller"
- "components/rpc/common/interface"
- "components/service/common/include"
- "components/service/common/client"
- "components/service/common/serializer/protobuf"
- "components/service/common/provider"
- "components/service/discovery/provider"
- "components/service/discovery/provider/serializer/packed-c"
- "components/service/crypto/provider"
- "components/service/crypto/provider/serializer/protobuf"
- "components/service/crypto/provider/serializer/packed-c"
- "components/service/crypto/provider/extension/hash"
- "components/service/crypto/provider/extension/hash/serializer/packed-c"
- "components/service/crypto/provider/extension/cipher"
- "components/service/crypto/provider/extension/cipher/serializer/packed-c"
- "components/service/crypto/provider/extension/key_derivation"
- "components/service/crypto/provider/extension/key_derivation/serializer/packed-c"
- "components/service/crypto/provider/extension/mac"
- "components/service/crypto/provider/extension/mac/serializer/packed-c"
- "components/service/crypto/factory/full"
- "components/service/crypto/backend/mbedcrypto"
- "components/service/crypto/backend/mbedcrypto/trng_adapter/platform"
- "components/service/secure_storage/include"
- "components/service/secure_storage/frontend/psa/its"
- "components/service/secure_storage/backend/secure_storage_client"
- "components/service/secure_storage/backend/null_store"
- "components/service/secure_storage/factory/sp/rot_store"
- "protocols/rpc/common/packed-c"
- "protocols/service/secure_storage/packed-c"
- "protocols/service/crypto/protobuf"
"environments/opteesp"
)
-target_sources(crypto-sp PRIVATE
- crypto_sp.c
-)
+include(../crypto.cmake REQUIRED)
#-------------------------------------------------------------------------------
# Set target platform to provide drivers needed by the deployment
#
#-------------------------------------------------------------------------------
-add_platform(TARGET "crypto-sp")
-
-#-------------------------------------------------------------------------------
-# Components used from external projects
-#
-#-------------------------------------------------------------------------------
-
-# Get libc include dir
-get_property(LIBC_INCLUDE_PATH TARGET stdlib::c PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
-
-# Nanopb
-list(APPEND NANOPB_EXTERNAL_INCLUDE_PATHS ${LIBC_INCLUDE_PATH})
-include(../../../external/nanopb/nanopb.cmake)
-target_link_libraries(crypto-sp PRIVATE nanopb::protobuf-nanopb-static)
-protobuf_generate_all(TGT "crypto-sp" NAMESPACE "protobuf" BASE_DIR "${TS_ROOT}/protocols")
-
-# Mbed TLS provides libmbedcrypto
-list(APPEND MBEDTLS_EXTRA_INCLUDES ${LIBC_INCLUDE_PATH})
-include(../../../external/MbedTLS/MbedTLS.cmake)
-target_link_libraries(crypto-sp PRIVATE mbedcrypto)
-target_link_libraries(mbedcrypto INTERFACE stdlib::c)
-
+add_platform(TARGET "crypto")
#################################################################
-target_compile_definitions(crypto-sp PRIVATE
+target_compile_definitions(crypto PRIVATE
ARM64=1
)
-target_include_directories(crypto-sp PRIVATE
- ${TS_ROOT}
- ${TS_ROOT}/components
+target_include_directories(crypto PRIVATE
${TS_ROOT}/deployments/crypto/opteesp
)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_compile_options(crypto-sp PRIVATE
+ target_compile_options(crypto PRIVATE
-fdiagnostics-show-option
-gdwarf-2
-mstrict-align
@@ -126,18 +62,18 @@
)
# Options for GCC that control linking
- target_link_options(crypto-sp PRIVATE
+ target_link_options(crypto PRIVATE
-zmax-page-size=4096
)
# Options directly for LD, these are not understood by GCC
- target_link_options(crypto-sp PRIVATE
+ target_link_options(crypto PRIVATE
-Wl,--as-needed
-Wl,--sort-section=alignment
# -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list
)
endif()
-compiler_generate_stripped_elf(TARGET crypto-sp NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF)
+compiler_generate_stripped_elf(TARGET crypto NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF)
######################################## install
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
@@ -145,13 +81,13 @@
endif()
#TODO: api headers
-install(TARGETS crypto-sp
+install(TARGETS crypto
PUBLIC_HEADER DESTINATION ${TS_ENV}/include
RUNTIME DESTINATION ${TS_ENV}/bin
)
install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin)
-get_property(_PROTO_FILES TARGET crypto-sp PROPERTY PROTOBUF_FILES)
+get_property(_PROTO_FILES TARGET crypto PROPERTY PROTOBUF_FILES)
install(FILES ${_PROTO_FILES} DESTINATION ${TS_ENV}/lib/protobuf)
include(${TS_ROOT}/tools/cmake/common/ExportSp.cmake)
diff --git a/deployments/crypto/opteesp/crypto_sp.h b/deployments/crypto/opteesp/crypto_sp.h
deleted file mode 100644
index 73aae18..0000000
--- a/deployments/crypto/opteesp/crypto_sp.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef CRYPTO_SP_H
-#define CRYPTO_SP_H
-
-#define CRYPTO_SP_UUID \
- {0xd9df52d5, 0x16a2, 0x4bb2, \
- {0x9a, 0xa4, 0xd2, 0x6d, 0x3b, 0x84, 0xe8, 0xc0}}
-
-#define CRYPTO_SP_UUID_BYTES \
- {0xd9, 0xdf, 0x52, 0xd5, 0x16, 0xa2, 0x4b, 0xb2, \
- 0x9a, 0xa4, 0xd2, 0x6d, 0x3b, 0x84, 0xe8, 0xc0}
-
-#endif /* CRYPTO_SP_H */
diff --git a/deployments/crypto/opteesp/optee_sp_user_defines.h b/deployments/crypto/opteesp/optee_sp_user_defines.h
index dc40c5e..29b2749 100644
--- a/deployments/crypto/opteesp/optee_sp_user_defines.h
+++ b/deployments/crypto/opteesp/optee_sp_user_defines.h
@@ -3,13 +3,13 @@
* Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
*/
-#ifndef SP_HEADER_DEFINES_H
-#define SP_HEADER_DEFINES_H
+#ifndef OPTEE_SP_USER_DEFINES_H
+#define OPTEE_SP_USER_DEFINES_H
-/* To get UUID definition */
-#include "crypto_sp.h"
+#define OPTEE_SP_UUID \
+ {0xd9df52d5, 0x16a2, 0x4bb2, \
+ {0x9a, 0xa4, 0xd2, 0x6d, 0x3b, 0x84, 0xe8, 0xc0}}
-#define OPTEE_SP_UUID CRYPTO_SP_UUID
#define OPTEE_SP_FLAGS 0
/* Provisioned stack size */