Refactor crypto deployment structure
Refactors the crypto service deployment build and directory structure
to allow for alternative build configurations.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I8e7422fef7afac080a3d59f18807755db0d65c3d
diff --git a/deployments/crypto/opteesp/CMakeLists.txt b/deployments/crypto/config/default-opteesp/CMakeLists.txt
similarity index 82%
rename from deployments/crypto/opteesp/CMakeLists.txt
rename to deployments/crypto/config/default-opteesp/CMakeLists.txt
index 6909fd5..6d92c79 100644
--- a/deployments/crypto/opteesp/CMakeLists.txt
+++ b/deployments/crypto/config/default-opteesp/CMakeLists.txt
@@ -15,7 +15,7 @@
set(CMAKE_BUILD_TYPE "MinSizWithDebInfo" CACHE STRING "Build type.")
endif()
-include(../../deployment.cmake REQUIRED)
+include(../../../deployment.cmake REQUIRED)
#-------------------------------------------------------------------------------
# The CMakeLists.txt for building the crypto deployment for opteesp
@@ -36,8 +36,12 @@
SP_NAME "crypto"
)
+target_include_directories(crypto PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}
+)
+
#-------------------------------------------------------------------------------
-# Components that are specific to deployment in the opteesp environment.
+# Deployment specific components
#
#-------------------------------------------------------------------------------
add_components(TARGET "crypto"
@@ -46,7 +50,9 @@
"environments/opteesp"
)
-include(../crypto.cmake REQUIRED)
+include(../../env/commonsp/crypto_sp.cmake REQUIRED)
+include(../../crypto.cmake REQUIRED)
+include(../../infra/baremetal-psa.cmake REQUIRED)
#-------------------------------------------------------------------------------
# Set target platform to provide drivers needed by the deployment
@@ -54,16 +60,13 @@
#-------------------------------------------------------------------------------
add_platform(TARGET "crypto")
-#################################################################
-
+#-------------------------------------------------------------------------------
+# Deployment specific build options
+#-------------------------------------------------------------------------------
target_compile_definitions(crypto PRIVATE
ARM64=1
)
-target_include_directories(crypto PRIVATE
- ${TS_ROOT}/deployments/crypto/opteesp
-)
-
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(crypto PRIVATE
-std=c99
@@ -73,7 +76,9 @@
compiler_generate_stripped_elf(TARGET crypto NAME "${SP_UUID_CANON}.stripped.elf" RES STRIPPED_ELF)
-######################################## install
+#-------------------------------------------------------------------------------
+# Deployment specific install options
+#-------------------------------------------------------------------------------
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
endif()
diff --git a/deployments/crypto/opteesp/default_crypto.dts.in b/deployments/crypto/config/default-opteesp/default_crypto.dts.in
similarity index 100%
rename from deployments/crypto/opteesp/default_crypto.dts.in
rename to deployments/crypto/config/default-opteesp/default_crypto.dts.in
diff --git a/deployments/crypto/opteesp/optee_sp_user_defines.h b/deployments/crypto/config/default-opteesp/optee_sp_user_defines.h
similarity index 100%
rename from deployments/crypto/opteesp/optee_sp_user_defines.h
rename to deployments/crypto/config/default-opteesp/optee_sp_user_defines.h
diff --git a/deployments/crypto/sp/CMakeLists.txt b/deployments/crypto/config/default-sp/CMakeLists.txt
similarity index 84%
rename from deployments/crypto/sp/CMakeLists.txt
rename to deployments/crypto/config/default-sp/CMakeLists.txt
index 943b9a6..964fd60 100644
--- a/deployments/crypto/sp/CMakeLists.txt
+++ b/deployments/crypto/config/default-sp/CMakeLists.txt
@@ -15,7 +15,7 @@
set(CMAKE_BUILD_TYPE "MinSizWithDebInfo" CACHE STRING "Build type.")
endif()
-include(../../deployment.cmake REQUIRED)
+include(../../../deployment.cmake REQUIRED)
#-------------------------------------------------------------------------------
# The CMakeLists.txt for building the crypto deployment for generic sp
@@ -46,7 +46,9 @@
environments/sp
)
-include(../crypto.cmake REQUIRED)
+include(../../env/commonsp/crypto_sp.cmake REQUIRED)
+include(../../crypto.cmake REQUIRED)
+include(../../infra/baremetal-psa.cmake REQUIRED)
#-------------------------------------------------------------------------------
# Set target platform to provide drivers needed by the deployment
@@ -54,8 +56,9 @@
#-------------------------------------------------------------------------------
add_platform(TARGET "crypto")
-#################################################################
-
+#-------------------------------------------------------------------------------
+# Deployment specific build options
+#-------------------------------------------------------------------------------
target_compile_definitions(crypto PRIVATE
ARM64=1
)
@@ -73,7 +76,9 @@
include(${TS_ROOT}/tools/cmake/common/ExportMemoryRegionsToManifest.cmake REQUIRED)
export_memory_regions_to_manifest(TARGET crypto NAME "${SP_UUID_CANON}_memory_regions.dtsi" RES EXPORT_MEMORY_REGIONS_DTSI)
-######################################## install
+#-------------------------------------------------------------------------------
+# Deployment specific install options
+#-------------------------------------------------------------------------------
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
endif()
diff --git a/deployments/crypto/sp/default_crypto.dts.in b/deployments/crypto/config/default-sp/default_crypto.dts.in
similarity index 100%
rename from deployments/crypto/sp/default_crypto.dts.in
rename to deployments/crypto/config/default-sp/default_crypto.dts.in
diff --git a/deployments/crypto/crypto.cmake b/deployments/crypto/crypto.cmake
index 3285ffd..9020cc0 100644
--- a/deployments/crypto/crypto.cmake
+++ b/deployments/crypto/crypto.cmake
@@ -8,19 +8,9 @@
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"
@@ -40,33 +30,22 @@
"components/service/crypto/provider/extension/aead/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
#
#-------------------------------------------------------------------------------
# Nanopb
-include(../../../external/nanopb/nanopb.cmake)
+include(${TS_ROOT}/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
-include(../../../external/MbedTLS/MbedTLS.cmake)
+include(${TS_ROOT}/external/MbedTLS/MbedTLS.cmake)
target_link_libraries(crypto PRIVATE mbedcrypto)
target_link_libraries(mbedcrypto INTERFACE stdlib::c)
diff --git a/deployments/crypto/common/crypto_sp.c b/deployments/crypto/env/commonsp/crypto_sp.c
similarity index 100%
rename from deployments/crypto/common/crypto_sp.c
rename to deployments/crypto/env/commonsp/crypto_sp.c
diff --git a/deployments/crypto/env/commonsp/crypto_sp.cmake b/deployments/crypto/env/commonsp/crypto_sp.cmake
new file mode 100644
index 0000000..10e7e3c
--- /dev/null
+++ b/deployments/crypto/env/commonsp/crypto_sp.cmake
@@ -0,0 +1,28 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Includes components needed for deploying the crypto service provider
+# within a secure partition.
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# Common components for crypto sp deployments
+#
+#-------------------------------------------------------------------------------
+add_components(TARGET "crypto"
+ BASE_DIR ${TS_ROOT}
+ COMPONENTS
+ "components/common/fdt"
+ "components/common/trace"
+ "components/common/utils"
+ "components/config/ramstore"
+ "components/config/loader/sp"
+ "components/messaging/ffa/libsp"
+ "components/rpc/ffarpc/endpoint"
+)
+
+target_sources(crypto PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/crypto_sp.c
+)
diff --git a/deployments/crypto/common/crypto_sp.h b/deployments/crypto/env/commonsp/crypto_sp.h
similarity index 100%
rename from deployments/crypto/common/crypto_sp.h
rename to deployments/crypto/env/commonsp/crypto_sp.h
diff --git a/deployments/crypto/infra/baremetal-psa.cmake b/deployments/crypto/infra/baremetal-psa.cmake
new file mode 100644
index 0000000..afd3bbe
--- /dev/null
+++ b/deployments/crypto/infra/baremetal-psa.cmake
@@ -0,0 +1,33 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Defines an infrastructure for the crypto service provider that uses a
+# baremetal platform TRNG driver and PSA storage for persistent key storage.
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# Infrastructure components
+#
+#-------------------------------------------------------------------------------
+add_components(TARGET "crypto"
+ BASE_DIR ${TS_ROOT}
+ COMPONENTS
+ "components/rpc/ffarpc/caller/sp"
+ "components/rpc/common/caller"
+ "components/service/common/client"
+ "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/service/secure_storage/packed-c"
+)
+
+#-------------------------------------------------------------------------------
+# This infrastructure depends on platform specific drivers
+#
+#-------------------------------------------------------------------------------
+add_platform(TARGET "crypto")
diff --git a/deployments/crypto/opteesp/.gitignore b/deployments/crypto/opteesp/.gitignore
deleted file mode 100644
index 378eac2..0000000
--- a/deployments/crypto/opteesp/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-build