Build: Tweak conditional compilation

Use CONFIG_TFM_USE_TRUSTZONE and the flags for the two ns_agent partitions
where appropriate.

Change-Id: I216edbd09af483cca4e46b4124617f5a4affca96
Signed-off-by: Chris Brand <chris.brand@cypress.com>
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index cb917a4..dd5141b 100755
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -46,8 +46,7 @@
     INTERFACE
         ${INTERFACE_INC_DIR}
         ${CMAKE_BINARY_DIR}/generated/interface/include
-        $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:${INTERFACE_INC_DIR}/multi_core>
-        $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:${CMAKE_SOURCE_DIR}/platform/ext/cmsis>
+        $<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:${INTERFACE_INC_DIR}/multi_core>
 )
 
 # Include NS local interface headers
@@ -75,6 +74,7 @@
         $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC>
         $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID>
         $<$<BOOL:${TEST_NS_MANAGE_NSID}>:TEST_NS_MANAGE_NSID>
+        $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:CONFIG_TFM_USE_TRUSTZONE>
         $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:TFM_MULTI_CORE_TOPOLOGY>
         $<$<BOOL:${TFM_MULTI_CORE_NS_OS}>:TFM_MULTI_CORE_NS_OS>
         $<$<AND:$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>,$<BOOL:${TFM_MULTI_CORE_NS_OS}>>:TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD>
@@ -95,7 +95,7 @@
         $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${NSID_MGR_DIR}/tfm_nsid_manager.c>
 )
 
-if (${TFM_PSA_API})
+if (TFM_PSA_API)
     target_sources(tfm_api_ns PRIVATE
         $<$<OR:$<BOOL:${FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_PLATFORM}>>:${INTERFACE_SRC_DIR}/tfm_platform_ipc_api.c>
         $<$<OR:$<BOOL:${FORWARD_PROT_MSG}>,$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>>:${INTERFACE_SRC_DIR}/tfm_ps_ipc_api.c>
@@ -105,7 +105,7 @@
         $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${INTERFACE_SRC_DIR}/tfm_firmware_update_ipc_api.c>
         )
 
-    if (TFM_MULTI_CORE_TOPOLOGY)
+    if (TFM_PARTITION_NS_AGENT_MAILBOX)
         target_sources(tfm_api_ns PRIVATE
             ${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_ns_api.c
             ${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_psa_ns_api.c
@@ -118,15 +118,6 @@
             $<$<BOOL:${TFM_MULTI_CORE_NS_OS}>:${NS_INTERFACE_DIR}/multi_core/tfm_ns_mailbox_rtos_api.c>
             $<$<BOOL:${TEST_NS_MULTI_CORE}>:${NS_INTERFACE_DIR}/multi_core/tfm_ns_mailbox_test.c>
         )
-    else()
-        target_sources(tfm_api_ns PRIVATE
-           ${INTERFACE_SRC_DIR}/tfm_psa_ns_api.c
-        )
-
-        # NS specific implementation of NS interface dispacther
-        target_sources(tfm_api_ns PRIVATE
-           ${CMAKE_CURRENT_SOURCE_DIR}/tfm_ns_interface.c
-        )
     endif()
 else()
     target_sources(tfm_api_ns PRIVATE
@@ -138,18 +129,19 @@
         $<$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>:${INTERFACE_SRC_DIR}/tfm_initial_attestation_func_api.c>
         $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${INTERFACE_SRC_DIR}/tfm_firmware_update_func_api.c>
     )
-
-    # NS specific implementation of NS interface dispacther
-    target_sources(tfm_api_ns PRIVATE
-        ${CMAKE_CURRENT_SOURCE_DIR}/tfm_ns_interface.c
-    )
 endif()
 
+target_sources(tfm_api_ns PRIVATE
+    $<$<AND:$<BOOL:${TFM_PSA_API}>,$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>>:${INTERFACE_SRC_DIR}/tfm_psa_ns_api.c>
+    # NS specific implementation of NS interface dispacther
+    $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:${CMAKE_CURRENT_SOURCE_DIR}/tfm_ns_interface.c>
+)
+
 target_link_libraries(tfm_api_ns
     PUBLIC
         tfm_ns_interface
     PRIVATE
-        $<$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>:tfm_s_veneers>
+        $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:tfm_s_veneers>
         platform_ns
 )
 
diff --git a/app/main_ns.c b/app/main_ns.c
index 8189142..19224e5 100644
--- a/app/main_ns.c
+++ b/app/main_ns.c
@@ -1,5 +1,7 @@
 /*
  * Copyright (c) 2017-2022, Arm Limited. All rights reserved.
+ * Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
+ * or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -14,7 +16,7 @@
 #include "tfm_plat_ns.h"
 #include "driver/Driver_USART.h"
 #include "device_cfg.h"
-#ifdef TFM_MULTI_CORE_TOPOLOGY
+#ifdef TFM_PARTITION_NS_AGENT_MAILBOX
 #include "tfm_multi_core_api.h"
 #include "tfm_ns_mailbox.h"
 #endif
@@ -66,7 +68,7 @@
 };
 #endif
 
-#ifdef TFM_MULTI_CORE_TOPOLOGY
+#ifdef TFM_PARTITION_NS_AGENT_MAILBOX
 static struct ns_mailbox_queue_t ns_mailbox_queue;
 
 static void tfm_ns_multi_core_boot(void)
@@ -92,7 +94,9 @@
         }
     }
 }
-#else
+#endif /* TFM_PARTITION_NS_AGENT_MAILBOX */
+
+#ifdef CONFIG_TFM_USE_TRUSTZONE
 extern uint32_t tfm_ns_interface_init(void);
 #endif
 
@@ -155,9 +159,11 @@
 
     (void) osKernelInitialize();
 
-#ifdef TFM_MULTI_CORE_TOPOLOGY
+#ifdef TFM_PARTITION_NS_AGENT_MAILBOX
     tfm_ns_multi_core_boot();
-#else
+#endif
+
+#ifdef CONFIG_TFM_USE_TRUSTZONE
     /* Initialize the TFM NS interface */
     tfm_ns_interface_init();
 #endif