1#-------------------------------------------------------------------------------
2# Copyright (c) 2020, Arm Limited. All rights reserved.
3# Copyright (c) 2021 STMicroelectronics. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7#-------------------------------------------------------------------------------
8# Allow linking to things 'upwards' in the directory tree (in this case bl2 / tfm_partition_crypto)
9cmake_policy(SET CMP0079 NEW)
10# Allow relative paths
11cmake_policy(SET CMP0076 NEW)
12
13if(NOT DEFINED PLATFORM_DIR)
14    set(PLATFORM_DIR ../../.. CACHE PATH "Path to plaform dir")
15endif()
16target_compile_definitions(platform_bl2
17    PRIVATE
18        CRYPTO_HW_ACCELERATOR
19)
20
21if (PLATFORM_DEFAULT_PROVISIONING)
22    # mbedtls_accelerator_config.h is included from the profile config files and must
23    # be visible in the platform_s always, due to the compilation of provisioning.c
24    target_include_directories(platform_s
25        PUBLIC
26            ${PLATFORM_DIR}/ext/target/${TFM_PLATFORM}/accelerator/
27            ${PLATFORM_DIR}/ext/target/${CRYPTO_HW_ACCELERATOR_TYPE}/common/hal/accelerator/
28    )
29
30    # Same for platform_bl2
31    target_include_directories(platform_bl2
32        PUBLIC
33            ${PLATFORM_DIR}/ext/target/${TFM_PLATFORM}/accelerator/
34            ${PLATFORM_DIR}/ext/target/${CRYPTO_HW_ACCELERATOR_TYPE}/common/hal/accelerator/
35    )
36
37endif()
38
39################################ BL2 ###########################################
40if(BL2)
41
42    set(STM_LIB_TARGET bl2_crypto_hw)
43
44    target_compile_definitions(bl2_mbedcrypto
45        PUBLIC
46            CRYPTO_HW_ACCELERATOR
47    )
48
49    target_compile_options(bl2_mbedcrypto
50        PRIVATE
51            $<$<C_COMPILER_ID:GNU>:-Wno-unused-parameter>
52            $<$<C_COMPILER_ID:ARMClang>:-Wno-unused-parameter>
53    )
54endif()
55include(${PLATFORM_DIR}/ext/target/${TFM_PLATFORM}/accelerator/CMakeLists.txt)
56
57if (TFM_PARTITION_CRYPTO)
58    set(STM_LIB_TARGET crypto_service_crypto_hw)
59
60    target_link_libraries(crypto_service_mbedcrypto
61        PUBLIC
62            crypto_service_crypto_hw
63    )
64
65    target_compile_definitions(crypto_service_mbedcrypto
66        PUBLIC
67            CRYPTO_HW_ACCELERATOR
68            LEGACY_DRIVER_API_ENABLED
69    )
70
71    target_compile_options(crypto_service_mbedcrypto
72        PRIVATE
73            $<$<C_COMPILER_ID:GNU>:-Wno-unused-parameter>
74            $<$<C_COMPILER_ID:ARMClang>:-Wno-unused-parameter>
75    )
76endif()
77