Test: Gather test execution code in app_broker

This change consolidates all code for tests execution into a single
module named app_broker. The broker creates execution environment for
tests (regression and PSA aPI) requireing the tests implement only
entry functoin: void test_app(void *arg) defined in test_app.h

Signed-off-by: Anton Komlev <anton.komlev@arm.com>
Change-Id: I410f6dd0a635b4b543a25af528195d9365dcf320
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index ebac5f3..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2021-2023, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-
-cmake_minimum_required(VERSION 3.15)
-
-# This is a legacy root CMake script, kept for backward compatibility.
-# In a new, split build please go to a dedicated test's subdirectory.
-# For example: ./app_ns_test for building NS regression tests.
-
-add_subdirectory(log)
-
-add_subdirectory(lib/ext)
-
-if(NS)
-    add_subdirectory(app)
-endif()
-
-add_subdirectory(test)
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
deleted file mode 100755
index 18123fa..0000000
--- a/app/CMakeLists.txt
+++ /dev/null
@@ -1,356 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2020-2023, Arm Limited. All rights reserved.
-# Copyright (c) 2022-2023 Cypress Semiconductor Corporation (an Infineon company)
-# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-
-cmake_minimum_required(VERSION 3.13)
-project(tfm_ns LANGUAGES ASM C)
-
-# For multi-core projects, the NS app can be run on a different CPU to the
-# Secure code. To facilitate this, we once again reload the compiler to load the
-# setting for the NS CPU. Cmake settings are directory scoped so this affects
-# anything loaded from or declared in this dir.
-if (EXISTS ${TARGET_PLATFORM_PATH}/preload_ns.cmake)
-    include(${TARGET_PLATFORM_PATH}/preload_ns.cmake)
-    tfm_toolchain_reload_compiler()
-endif()
-
-if (TFM_MULTI_CORE_TOPOLOGY)
-    # Enable TFM_MULTI_CORE_NS_OS when building with tf-m-tests NS App.
-    set(TFM_MULTI_CORE_NS_OS ON CACHE BOOL "Enable NS RTOS support in NS mailbox")
-endif()
-
-# In actual NS integration, NS side build should include the source files
-# exported by TF-M build.
-# Directly include interface folder to simplify the NS build in this demo, since
-# install always occurs at the end of build.
-set(INTERFACE_SRC_DIR    ${CMAKE_SOURCE_DIR}/interface/src)
-set(INTERFACE_INC_DIR    ${CMAKE_SOURCE_DIR}/interface/include)
-
-# NS interface implemented by NSPE
-set(NS_INTERFACE_DIR     ${CMAKE_CURRENT_SOURCE_DIR}/../ns_interface)
-
-# nsid_manager
-set(NSID_MGR_DIR         ${NS_INTERFACE_DIR}/ns_client_ext)
-
-############################# TF-M NS interface #####################################
-add_library(tfm_api_ns STATIC)
-
-# Include interface headers exported by TF-M
-target_include_directories(tfm_api_ns
-    PUBLIC
-        ${INTERFACE_INC_DIR}
-        ${CMAKE_BINARY_DIR}/generated/interface/include
-        $<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:${INTERFACE_INC_DIR}/multi_core>
-)
-
-# Include NS local interface headers
-target_include_directories(tfm_api_ns
-    PUBLIC
-        ${NS_INTERFACE_DIR}
-        ${NSID_MGR_DIR}
-)
-
-# Include selection of Secure Partitions from TF-M build.
-# It can be replaced by NS side configurations later.
-target_link_libraries(tfm_api_ns
-    PUBLIC
-        tfm_config
-)
-
-target_compile_definitions(tfm_api_ns
-    PUBLIC
-        $<$<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_PARTITION_NS_AGENT_MAILBOX}>:TFM_PARTITION_NS_AGENT_MAILBOX>
-        $<$<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>
-)
-
-target_compile_options(tfm_api_ns
-    PUBLIC
-        ${COMPILER_CP_FLAG}
-)
-
-target_sources(tfm_api_ns
-    PRIVATE
-        $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${NSID_MGR_DIR}/tfm_nsid_manager.c>
-)
-
-target_sources(tfm_api_ns PRIVATE
-    $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${INTERFACE_SRC_DIR}/tfm_platform_api.c>
-    $<$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_ps_api.c>
-    $<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_its_api.c>
-    $<$<BOOL:${TFM_PARTITION_CRYPTO}>:${INTERFACE_SRC_DIR}/tfm_crypto_api.c>
-    $<$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>:${INTERFACE_SRC_DIR}/tfm_attest_api.c>
-    $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${INTERFACE_SRC_DIR}/tfm_fwu_api.c>
-    )
-
-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
-        $<$<NOT:$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>>:${INTERFACE_SRC_DIR}/multi_core/tfm_ns_mailbox.c>
-        $<$<AND:$<BOOL:${TFM_MULTI_CORE_NS_OS}>,$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>>:${INTERFACE_SRC_DIR}/multi_core/tfm_ns_mailbox_thread.c>
-    )
-
-    # NS RTOS specific implementation of NS mailbox
-    target_sources(tfm_api_ns PRIVATE
-        $<$<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>
-    )
-endif()
-
-target_sources(tfm_api_ns PRIVATE
-    $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:${INTERFACE_SRC_DIR}/tfm_psa_ns_api.c>
-    # NS specific implementation of NS interface dispatcher
-    $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:${INTERFACE_SRC_DIR}/os_wrapper/tfm_ns_interface_rtos.c>
-)
-
-target_link_libraries(tfm_api_ns
-    PRIVATE
-        $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:tfm_s_veneers>
-        platform_ns
-)
-
-############################# PSA test integration #############################
-
-if(TEST_PSA_API AND NOT PSA_ARCH_TESTS_BINARY_PATH)
-    if(NOT SUITE)
-        set(SUITE ${TEST_PSA_API})
-    endif()
-
-    if (NOT DEFINED PSA_API_TEST_TARGET OR PSA_API_TEST_TARGET STREQUAL "")
-        string(REGEX REPLACE ".*/" "" PSA_API_TEST_TARGET ${TFM_PLATFORM})
-    endif()
-
-    if(NOT TARGET)
-        if (NOT "${TEST_PSA_API}" STREQUAL "IPC")
-            set(TARGET tgt_dev_apis_tfm_${PSA_API_TEST_TARGET})
-        else()
-            set(TARGET tgt_ff_tfm_${PSA_API_TEST_TARGET})
-        endif()
-    endif()
-
-
-    if(NOT PSA_INCLUDE_PATHS)
-        set(PSA_INCLUDE_PATHS ${INTERFACE_INC_DIR}/
-                              ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/
-                              ${CMAKE_BINARY_DIR}/generated/interface/include
-        )
-    endif()
-
-    if(NOT SP_HEAP_MEM_SUPP)
-        set(SP_HEAP_MEM_SUPP 0)
-    endif()
-    if(NOT PLATFORM_PSA_ISOLATION_LEVEL)
-        set(PLATFORM_PSA_ISOLATION_LEVEL ${TFM_ISOLATION_LEVEL})
-    endif()
-
-    if (NOT TOOLCHAIN)
-        if (${CMAKE_C_COMPILER_ID} STREQUAL GNU)
-            set(TOOLCHAIN GNUARM)
-        elseif (${CMAKE_C_COMPILER_ID} STREQUAL ARMClang)
-            set(TOOLCHAIN ARMCLANG)
-        endif()
-    endif()
-
-    if (NOT CPU_ARCH)
-        if (${TFM_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.main)
-            set(CPU_ARCH armv8m_ml)
-        elseif (${TFM_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.base)
-            set(CPU_ARCH armv8m_bl)
-        elseif (${TFM_SYSTEM_ARCHITECTURE} STREQUAL armv8.1-m.main)
-            set(CPU_ARCH armv81m_ml)
-        elseif (${TFM_SYSTEM_ARCHITECTURE} STREQUAL armv7-m)
-            set(CPU_ARCH armv7m)
-        endif()
-    endif()
-
-    add_subdirectory(${PSA_ARCH_TESTS_PATH}/api-tests ${CMAKE_CURRENT_BINARY_DIR}/psa_api_tests)
-
-    if (TEST_PSA_API STREQUAL IPC)
-        target_include_directories(tfm_partitions
-            INTERFACE
-                ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests
-        )
-
-        target_sources(tfm_psa_rot_partition_driver_partition
-            PRIVATE
-                ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_driver_partition_psa.c
-        )
-        target_link_libraries(tfm_psa_rot_partition_driver_partition
-            PRIVATE
-                psa_interface
-                platform_s
-        )
-        target_compile_definitions(tfm_psa_rot_partition_driver_partition
-            PRIVATE
-                CONFIG_TFM_BUILDING_SPE=1
-                TFM_ISOLATION_LEVEL=${TFM_ISOLATION_LEVEL}
-        )
-
-        target_sources(tfm_app_rot_partition_client_partition
-            PRIVATE
-                ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_client_partition_psa.c
-        )
-        target_link_libraries(tfm_app_rot_partition_client_partition
-            PRIVATE
-                psa_interface
-                platform_s
-        )
-        target_compile_definitions(tfm_app_rot_partition_client_partition
-            PRIVATE
-                CONFIG_TFM_BUILDING_SPE=1
-                TFM_ISOLATION_LEVEL=${TFM_ISOLATION_LEVEL}
-        )
-
-        target_sources(tfm_app_rot_partition_server_partition
-            PRIVATE
-                ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_server_partition_psa.c
-        )
-        target_link_libraries(tfm_app_rot_partition_server_partition
-            PRIVATE
-                psa_interface
-                platform_s
-        )
-        target_compile_definitions(tfm_app_rot_partition_server_partition
-            PRIVATE
-                CONFIG_TFM_BUILDING_SPE=1
-                TFM_ISOLATION_LEVEL=${TFM_ISOLATION_LEVEL}
-        )
-
-        target_sources(tfm_partitions
-            INTERFACE
-                ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_driver_partition_psa.c
-                ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_client_partition_psa.c
-                ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_server_partition_psa.c
-        )
-
-        target_link_libraries(tfm_partitions
-            INTERFACE
-                tfm_psa_rot_partition_driver_partition
-                tfm_app_rot_partition_client_partition
-                tfm_app_rot_partition_server_partition
-        )
-    endif()
-endif()
-
-############################# Test integration #################################
-if(CONFIG_TFM_ERPC_TEST_FRAMEWORK)
-    add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../erpc/server/app ${CMAKE_CURRENT_BINARY_DIR}/erpc)
-endif()
-
-add_library(tfm_test_app STATIC EXCLUDE_FROM_ALL)
-
-target_sources(tfm_test_app
-    PUBLIC
-        $<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:${CMAKE_SOURCE_DIR}/platform/ext/common/syscalls_stub.c>
-    PRIVATE
-        $<$<NOT:$<BOOL:${CONFIG_TFM_ERPC_TEST_FRAMEWORK}>>:test_app.c>
-)
-
-target_include_directories(tfm_test_app
-    PUBLIC
-        .
-)
-
-target_link_libraries(tfm_test_app
-    PRIVATE
-        $<$<BOOL:${TFM_NS_REG_TEST}>:tfm_ns_tests>
-        $<$<BOOL:${TEST_PSA_API}>:val_nspe>
-        $<$<BOOL:${TEST_PSA_API}>:pal_nspe>
-        $<$<BOOL:${TEST_PSA_API}>:test_combine>
-        $<$<BOOL:${CONFIG_TFM_ERPC_TEST_FRAMEWORK}>:erpc_app>
-        tfm_api_ns
-        tfm_log
-)
-
-target_compile_definitions(tfm_test_app
-    PUBLIC
-        $<$<BOOL:${TFM_NS_REG_TEST}>:TFM_NS_REG_TEST>
-        $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_NS>
-)
-
-############################# Profiling integration ############################
-
-if(CONFIG_TFM_ENALBE_PROFILING)
-    add_subdirectory(${TFM_PROFILING_PATH}/profiling_cases/tfm_ns_profiling
-                     ${CMAKE_CURRENT_BINARY_DIR}/profiling_cases)
-endif()
-
-############################# TFM NS app #######################################
-
-add_executable(tfm_ns)
-
-target_sources(tfm_ns
-    PRIVATE
-        main_ns.c
-)
-
-target_link_libraries(tfm_ns
-    PRIVATE
-        CMSIS_5_tfm_ns
-        tfm_test_app
-        tfm_log
-        platform_ns
-        $<$<BOOL:${CONFIG_TFM_ENALBE_PROFILING}>:tfm_ns_profiling>
-)
-
-set_target_properties(tfm_ns PROPERTIES
-    SUFFIX ".axf"
-    RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
-)
-
-target_link_options(tfm_ns
-    PRIVATE
-        $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
-        $<$<C_COMPILER_ID:ARMClang>:--map>
-        $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
-)
-
-add_convert_to_bin_target(tfm_ns)
-
-############################# CMSIS ############################################
-
-include(FetchContent)
-
-set(FETCHCONTENT_QUIET FALSE)
-cmake_policy(SET CMP0079 NEW)
-
-add_library(CMSIS_5_tfm_ns INTERFACE)
-
-target_sources(CMSIS_5_tfm_ns
-    INTERFACE
-        ${NSID_MGR_DIR}/tz_shim_layer.c
-        ${CMSIS_5_PATH}/RTOS2/RTX/Config/RTX_Config.c
-        ${CMSIS_5_PATH}/RTOS2/RTX/Source/rtx_lib.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/os_wrapper_cmsis_rtos_v2.c
-        $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_SOURCE_DIR}/tfm_nsid_map_table.c>
-)
-
-target_include_directories(CMSIS_5_tfm_ns
-    INTERFACE
-        ${CMSIS_5_PATH}/Core/Include
-        ${CMSIS_5_PATH}/RTOS2/Include
-        ${CMSIS_5_PATH}/RTOS2/RTX/Include
-        ${CMSIS_5_PATH}/RTOS2/RTX/Config
-        $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_SOURCE_DIR}>
-)
-
-target_link_libraries(CMSIS_5_tfm_ns
-    INTERFACE
-        platform_ns
-)
-
-target_compile_definitions(CMSIS_5_tfm_ns
-    INTERFACE
-        $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID>
-)
diff --git a/app/test_app.c b/app/test_app.c
deleted file mode 100644
index 0e26e89..0000000
--- a/app/test_app.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2017-2022, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#include "test_app.h"
-#include "tfm_log.h"
-
-#ifdef TFM_NS_REG_TEST
-#include "test_framework_integ_test.h"
-#endif
-
-#if PSA_API_TEST_NS
-/**
- * \brief This symbol is the entry point provided by the PSA API compliance
- *        test libraries
- */
-extern void val_entry(void);
-#endif
-
-/**
- * \brief Services test thread
- *
- */
-__attribute__((noreturn))
-void test_app(void *argument)
-{
-    UNUSED_VARIABLE(argument);
-
-#ifdef TFM_NS_REG_TEST
-    tfm_non_secure_client_run_tests();
-#endif
-
-#ifdef PSA_API_TEST_NS
-    val_entry();
-#endif
-
-    /* Output EOT char for test environments like FVP. */
-    LOG_MSG("\x04");
-
-    /* End of test */
-    for (;;) {
-    }
-}
diff --git a/CMSIS/CMakeLists.txt b/app_broker/CMSIS/CMakeLists.txt
similarity index 99%
rename from CMSIS/CMakeLists.txt
rename to app_broker/CMSIS/CMakeLists.txt
index 0d603ed..3a20f9c 100644
--- a/CMSIS/CMakeLists.txt
+++ b/app_broker/CMSIS/CMakeLists.txt
@@ -59,6 +59,7 @@
     PRIVATE
         CMSIS_5_RTX_V8MMN
         tfm_test_broker
+    PUBLIC
         platform_ns         # for cmsis_compiler.h
         psa_interface       # for os_wrapper/common.h
 )
diff --git a/CMSIS/LICENSE.txt b/app_broker/CMSIS/LICENSE.txt
similarity index 100%
rename from CMSIS/LICENSE.txt
rename to app_broker/CMSIS/LICENSE.txt
diff --git a/CMSIS/README b/app_broker/CMSIS/README
similarity index 100%
rename from CMSIS/README
rename to app_broker/CMSIS/README
diff --git a/CMSIS/RTOS2/Include/cmsis_os2.h b/app_broker/CMSIS/RTOS2/Include/cmsis_os2.h
similarity index 100%
rename from CMSIS/RTOS2/Include/cmsis_os2.h
rename to app_broker/CMSIS/RTOS2/Include/cmsis_os2.h
diff --git a/CMSIS/RTOS2/RTX/Config/RTX_Config.c b/app_broker/CMSIS/RTOS2/RTX/Config/RTX_Config.c
similarity index 100%
rename from CMSIS/RTOS2/RTX/Config/RTX_Config.c
rename to app_broker/CMSIS/RTOS2/RTX/Config/RTX_Config.c
diff --git a/CMSIS/RTOS2/RTX/Config/RTX_Config.h b/app_broker/CMSIS/RTOS2/RTX/Config/RTX_Config.h
similarity index 100%
rename from CMSIS/RTOS2/RTX/Config/RTX_Config.h
rename to app_broker/CMSIS/RTOS2/RTX/Config/RTX_Config.h
diff --git a/CMSIS/RTOS2/RTX/Include/rtx_evr.h b/app_broker/CMSIS/RTOS2/RTX/Include/rtx_evr.h
similarity index 100%
rename from CMSIS/RTOS2/RTX/Include/rtx_evr.h
rename to app_broker/CMSIS/RTOS2/RTX/Include/rtx_evr.h
diff --git a/CMSIS/RTOS2/RTX/Include/rtx_os.h b/app_broker/CMSIS/RTOS2/RTX/Include/rtx_os.h
similarity index 100%
rename from CMSIS/RTOS2/RTX/Include/rtx_os.h
rename to app_broker/CMSIS/RTOS2/RTX/Include/rtx_os.h
diff --git a/CMSIS/RTOS2/RTX/Include/tz_context.h b/app_broker/CMSIS/RTOS2/RTX/Include/tz_context.h
similarity index 100%
rename from CMSIS/RTOS2/RTX/Include/tz_context.h
rename to app_broker/CMSIS/RTOS2/RTX/Include/tz_context.h
diff --git a/CMSIS/RTOS2/RTX/Library/ARM/RTX_CM0.lib b/app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_CM0.lib
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/ARM/RTX_CM0.lib
rename to app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_CM0.lib
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/ARM/RTX_CM3.lib b/app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_CM3.lib
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/ARM/RTX_CM3.lib
rename to app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_CM3.lib
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/ARM/RTX_CM4F.lib b/app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_CM4F.lib
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/ARM/RTX_CM4F.lib
rename to app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_CM4F.lib
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MB.lib b/app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MB.lib
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MB.lib
rename to app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MB.lib
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MBN.lib b/app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MBN.lib
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MBN.lib
rename to app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MBN.lib
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MM.lib b/app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MM.lib
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MM.lib
rename to app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MM.lib
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMF.lib b/app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMF.lib
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMF.lib
rename to app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMF.lib
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMFN.lib b/app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMFN.lib
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMFN.lib
rename to app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMFN.lib
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMN.lib b/app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMN.lib
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMN.lib
rename to app_broker/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMN.lib
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/GCC/libRTX_CM0.a b/app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_CM0.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/GCC/libRTX_CM0.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_CM0.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/GCC/libRTX_CM3.a b/app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_CM3.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/GCC/libRTX_CM3.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_CM3.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/GCC/libRTX_CM4F.a b/app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_CM4F.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/GCC/libRTX_CM4F.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_CM4F.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MB.a b/app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MB.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MB.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MB.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MBN.a b/app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MBN.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MBN.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MBN.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MM.a b/app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MM.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MM.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MM.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMF.a b/app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMF.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMF.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMF.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMFN.a b/app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMFN.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMFN.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMFN.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMN.a b/app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMN.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMN.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMN.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/IAR/RTX_CM0.a b/app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_CM0.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/IAR/RTX_CM0.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_CM0.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/IAR/RTX_CM3.a b/app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_CM3.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/IAR/RTX_CM3.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_CM3.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/IAR/RTX_CM4F.a b/app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_CM4F.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/IAR/RTX_CM4F.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_CM4F.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/IAR/RTX_V81MMN.a b/app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V81MMN.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/IAR/RTX_V81MMN.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V81MMN.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MB.a b/app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MB.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MB.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MB.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MBN.a b/app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MBN.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MBN.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MBN.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MM.a b/app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MM.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MM.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MM.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MMF.a b/app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MMF.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MMF.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MMF.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MMFN.a b/app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MMFN.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MMFN.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MMFN.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MMN.a b/app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MMN.a
similarity index 100%
rename from CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MMN.a
rename to app_broker/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MMN.a
Binary files differ
diff --git a/CMSIS/RTOS2/RTX/Source/rtx_lib.c b/app_broker/CMSIS/RTOS2/RTX/Source/rtx_lib.c
similarity index 100%
rename from CMSIS/RTOS2/RTX/Source/rtx_lib.c
rename to app_broker/CMSIS/RTOS2/RTX/Source/rtx_lib.c
diff --git a/app_broker/CMakeLists.txt b/app_broker/CMakeLists.txt
new file mode 100644
index 0000000..2a8a6eb
--- /dev/null
+++ b/app_broker/CMakeLists.txt
@@ -0,0 +1,46 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+#
+# This CMake script used in a split build only. In the legacy 'sinlge' build
+# this file is ignoed. Please don't be confused.
+#
+cmake_minimum_required(VERSION 3.15)
+
+# This is important to add this SPE subdirectory at first as it
+# brings configuration from TF-M build
+add_subdirectory(${CONFIG_SPE_PATH} ${CMAKE_BINARY_DIR}/spe)
+
+add_subdirectory(log)
+add_subdirectory(CMSIS)
+add_subdirectory(os_wrapper)
+
+add_library(tfm_test_broker STATIC
+    main_ns.c
+)
+
+target_include_directories(tfm_test_broker PUBLIC .)
+
+target_link_libraries(tfm_test_broker
+    PUBLIC
+        tfm_api_ns
+        tfm_log
+        os_wrapper
+)
+
+add_subdirectory(nsid_manager)
+target_link_libraries(tfm_test_broker PUBLIC tfm_nsid_manager)
+
+if (TFM_PARTITION_NS_AGENT_MAILBOX)
+    add_subdirectory(multi_core)
+    target_link_libraries(tfm_test_broker PUBLIC ns_multi_core)
+endif()
+
+# platform_region_defs needed by PS tests
+add_library(platform_region_defs INTERFACE)
+
+
+
diff --git a/log/CMakeLists.txt b/app_broker/log/CMakeLists.txt
similarity index 92%
rename from log/CMakeLists.txt
rename to app_broker/log/CMakeLists.txt
index 101c94d..3612435 100644
--- a/log/CMakeLists.txt
+++ b/app_broker/log/CMakeLists.txt
@@ -19,8 +19,6 @@
 )
 
 target_link_libraries(tfm_log
-    INTERFACE
-        platform_common_interface
     PUBLIC
         platform_ns
 )
diff --git a/log/tfm_log.h b/app_broker/log/tfm_log.h
similarity index 100%
rename from log/tfm_log.h
rename to app_broker/log/tfm_log.h
diff --git a/log/tfm_log_raw.c b/app_broker/log/tfm_log_raw.c
similarity index 100%
rename from log/tfm_log_raw.c
rename to app_broker/log/tfm_log_raw.c
diff --git a/log/tfm_log_raw.h b/app_broker/log/tfm_log_raw.h
similarity index 100%
rename from log/tfm_log_raw.h
rename to app_broker/log/tfm_log_raw.h
diff --git a/app/main_ns.c b/app_broker/main_ns.c
similarity index 98%
rename from app/main_ns.c
rename to app_broker/main_ns.c
index 8793148..c072896 100644
--- a/app/main_ns.c
+++ b/app_broker/main_ns.c
@@ -13,7 +13,7 @@
 #include "tfm_nsid_manager.h"
 #include "test_app.h"
 #include "tfm_plat_ns.h"
-#include "driver/Driver_USART.h"
+#include "Driver_USART.h"
 #include "device_cfg.h"
 #ifdef TFM_PARTITION_NS_AGENT_MAILBOX
 #include "tfm_multi_core_api.h"
diff --git a/ns_interface/multi_core/CMakeLists.txt b/app_broker/multi_core/CMakeLists.txt
similarity index 100%
rename from ns_interface/multi_core/CMakeLists.txt
rename to app_broker/multi_core/CMakeLists.txt
diff --git a/ns_interface/multi_core/tfm_ns_mailbox_rtos_api.c b/app_broker/multi_core/tfm_ns_mailbox_rtos_api.c
similarity index 100%
rename from ns_interface/multi_core/tfm_ns_mailbox_rtos_api.c
rename to app_broker/multi_core/tfm_ns_mailbox_rtos_api.c
diff --git a/ns_interface/multi_core/tfm_ns_mailbox_test.c b/app_broker/multi_core/tfm_ns_mailbox_test.c
similarity index 100%
rename from ns_interface/multi_core/tfm_ns_mailbox_test.c
rename to app_broker/multi_core/tfm_ns_mailbox_test.c
diff --git a/app_broker/nsid_manager/CMakeLists.txt b/app_broker/nsid_manager/CMakeLists.txt
new file mode 100644
index 0000000..24c5d9e
--- /dev/null
+++ b/app_broker/nsid_manager/CMakeLists.txt
@@ -0,0 +1,34 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 3.15)
+
+add_library(tfm_nsid_manager STATIC)
+
+target_include_directories(tfm_nsid_manager PUBLIC .)
+
+target_link_libraries(tfm_nsid_manager PRIVATE RTX_OS)
+
+if(TFM_NS_MANAGE_NSID)
+    target_sources(tfm_nsid_manager
+        PUBLIC
+            tfm_nsid_manager.c
+            tfm_nsid_map_table.c
+            tz_shim_layer.c
+    )
+
+    target_compile_definitions(tfm_nsid_manager
+        PUBLIC
+            TFM_NS_MANAGE_NSID
+            $<$<BOOL:${TEST_NS_MANAGE_NSID}>:TEST_NS_MANAGE_NSID>
+    )
+else()
+    target_sources(tfm_nsid_manager
+        PUBLIC
+            tz_stub.c
+    )
+endif()
diff --git a/ns_interface/ns_client_ext/tfm_nsid_manager.c b/app_broker/nsid_manager/tfm_nsid_manager.c
similarity index 100%
rename from ns_interface/ns_client_ext/tfm_nsid_manager.c
rename to app_broker/nsid_manager/tfm_nsid_manager.c
diff --git a/ns_interface/ns_client_ext/tfm_nsid_manager.h b/app_broker/nsid_manager/tfm_nsid_manager.h
similarity index 100%
rename from ns_interface/ns_client_ext/tfm_nsid_manager.h
rename to app_broker/nsid_manager/tfm_nsid_manager.h
diff --git a/app/tfm_nsid_map_table.c b/app_broker/nsid_manager/tfm_nsid_map_table.c
similarity index 100%
rename from app/tfm_nsid_map_table.c
rename to app_broker/nsid_manager/tfm_nsid_map_table.c
diff --git a/app/tfm_nsid_map_table.h b/app_broker/nsid_manager/tfm_nsid_map_table.h
similarity index 100%
rename from app/tfm_nsid_map_table.h
rename to app_broker/nsid_manager/tfm_nsid_map_table.h
diff --git a/ns_interface/ns_client_ext/tz_shim_layer.c b/app_broker/nsid_manager/tz_shim_layer.c
similarity index 100%
rename from ns_interface/ns_client_ext/tz_shim_layer.c
rename to app_broker/nsid_manager/tz_shim_layer.c
diff --git a/app_broker/nsid_manager/tz_stub.c b/app_broker/nsid_manager/tz_stub.c
new file mode 100644
index 0000000..306112d
--- /dev/null
+++ b/app_broker/nsid_manager/tz_stub.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*
+ * This is a stub functoins for TF-M shim layer of TZ APIs
+ *
+ */
+
+#include "tz_context.h"
+/*
+ * TF-M shim layer of the CMSIS TZ RTOS thread context management API
+ */
+
+/*
+ * Initialize token-nsid map table in tfm nsid manager
+ * Return execution status (1: success, 0: error)
+ */
+uint32_t TZ_InitContextSystem_S(void)
+{
+    return 1U;    /* Success */
+}
+
+/*
+ * Allocate context memory from Secure side
+ * Param: TZ_ModuleId_t (NSID if TFM_NS_MANAGE_NSID is enabled)
+ * Return token if TFM_NS_MANAGE_NSID is enabled
+ * Return 0 if no memory available or internal error
+ */
+TZ_MemoryId_t TZ_AllocModuleContext_S(TZ_ModuleId_t module)
+{
+    return 1U;    /* Success */
+}
+
+/*
+ * Free context memory that was previously allocated with TZ_AllocModuleContext_S
+ * Param: TZ_MemoryId_t (token if TFM_NS_MANAGE_NSID is enabled)
+ * Return execution status (1: success, 0: error)
+ */
+uint32_t TZ_FreeModuleContext_S(TZ_MemoryId_t id)
+{
+    return 1U;    /* Success */
+}
+
+/*
+ * Load secure context (called on RTOS thread context switch)
+ * Param: TZ_MemoryId_t (token if TFM_NS_MANAGE_NSID is enabled)
+ * Return execution status (1: success, 0: error)
+ */
+uint32_t TZ_LoadContext_S(TZ_MemoryId_t id)
+{
+    return 1U;    /* Success */
+}
+
+/*
+ * Store secure context (called on RTOS thread context switch)
+ * Param: TZ_MemoryId_t (token if TFM_NS_MANAGE_NSID is enabled)
+ * Return execution status (1: success, 0: error)
+ */
+uint32_t TZ_StoreContext_S(TZ_MemoryId_t id)
+{
+    return 1U;    /* Success */
+}
diff --git a/app_broker/os_wrapper/CMakeLists.txt b/app_broker/os_wrapper/CMakeLists.txt
new file mode 100644
index 0000000..d7f043e
--- /dev/null
+++ b/app_broker/os_wrapper/CMakeLists.txt
@@ -0,0 +1,25 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020-2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 3.13)
+
+add_library(os_wrapper STATIC)
+
+target_sources(os_wrapper
+    PUBLIC
+        os_wrapper_cmsis_rtos_v2.c
+)
+
+target_include_directories(os_wrapper PUBLIC .)
+
+target_link_libraries(os_wrapper
+    PRIVATE
+        psa_interface
+    PUBLIC
+        tfm_nsid_manager
+        RTX_OS
+)
diff --git a/ns_interface/os_wrapper/delay.h b/app_broker/os_wrapper/delay.h
similarity index 100%
rename from ns_interface/os_wrapper/delay.h
rename to app_broker/os_wrapper/delay.h
diff --git a/ns_interface/os_wrapper/msg_queue.h b/app_broker/os_wrapper/msg_queue.h
similarity index 100%
rename from ns_interface/os_wrapper/msg_queue.h
rename to app_broker/os_wrapper/msg_queue.h
diff --git a/app/os_wrapper_cmsis_rtos_v2.c b/app_broker/os_wrapper/os_wrapper_cmsis_rtos_v2.c
similarity index 98%
rename from app/os_wrapper_cmsis_rtos_v2.c
rename to app_broker/os_wrapper/os_wrapper_cmsis_rtos_v2.c
index f582b07..005554d 100755
--- a/app/os_wrapper_cmsis_rtos_v2.c
+++ b/app_broker/os_wrapper/os_wrapper_cmsis_rtos_v2.c
@@ -5,10 +5,10 @@
  *
  */
 
-#include "os_wrapper/thread.h"
+#include "thread.h"
 #include "os_wrapper/mutex.h"
-#include "os_wrapper/semaphore.h"
-#include "os_wrapper/delay.h"
+#include "semaphore.h"
+#include "delay.h"
 
 #include "cmsis_os2.h"
 
diff --git a/ns_interface/os_wrapper/semaphore.h b/app_broker/os_wrapper/semaphore.h
similarity index 100%
rename from ns_interface/os_wrapper/semaphore.h
rename to app_broker/os_wrapper/semaphore.h
diff --git a/ns_interface/os_wrapper/thread.h b/app_broker/os_wrapper/thread.h
similarity index 100%
rename from ns_interface/os_wrapper/thread.h
rename to app_broker/os_wrapper/thread.h
diff --git a/ns_interface/os_wrapper/tick.h b/app_broker/os_wrapper/tick.h
similarity index 100%
rename from ns_interface/os_wrapper/tick.h
rename to app_broker/os_wrapper/tick.h
diff --git a/app/test_app.h b/app_broker/test_app.h
similarity index 100%
rename from app/test_app.h
rename to app_broker/test_app.h
diff --git a/app_test_ns/CMakeLists.txt b/app_test_ns/CMakeLists.txt
index 7845d39..3e51212 100644
--- a/app_test_ns/CMakeLists.txt
+++ b/app_test_ns/CMakeLists.txt
@@ -44,8 +44,8 @@
 
 add_executable(tfm_ns)
 
-add_subdirectory(../ns_interface ${CMAKE_BINARY_DIR}/ns_interface)
-add_subdirectory(../test         ${CMAKE_BINARY_DIR}/tests)
+add_subdirectory(../app_broker ${CMAKE_BINARY_DIR}/app_broker)
+add_subdirectory(../test       ${CMAKE_BINARY_DIR}/test)
 
 ############################# TFM NS main app ##################################
 
diff --git a/app_test_s/config_test.cmake b/app_test_s/config_test.cmake
index b1b3512..33e5a47 100644
--- a/app_test_s/config_test.cmake
+++ b/app_test_s/config_test.cmake
@@ -29,6 +29,6 @@
 # Use local repositories and avoid fetching them on evey clean build.
 # A tempoarl settings to be remove later.
 #-------------------------------------------------------------------------------
-if(EXISTS ${CMAKE_SOURCE_DIR}/localrepos.cmake)
-    include(${CMAKE_SOURCE_DIR}/localrepos.cmake)
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/localrepos.cmake)
+    include(${CMAKE_CURRENT_SOURCE_DIR}/localrepos.cmake)
 endif()
diff --git a/app_test_s/localrepos.cmake b/app_test_s/localrepos.cmake
new file mode 100644
index 0000000..1d7393a
--- /dev/null
+++ b/app_test_s/localrepos.cmake
@@ -0,0 +1,12 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+message(WARNING "Local repositries are used for MBEDCRYPTO_PATH, MCUBOOT_PATH, QCBOR_PATH")
+
+set(MBEDCRYPTO_PATH    /home/antkom01/x-temp/repos/mbedcrypto-src CACHE PATH "" FORCE)
+set(MCUBOOT_PATH       /home/antkom01/x-temp/repos/mcuboot-src    CACHE PATH "" FORCE)
+set(QCBOR_PATH         /home/antkom01/x-temp/repos/qcbor-src      CACHE PATH "" FORCE)
diff --git a/ns_interface/CMakeLists.txt b/ns_interface/CMakeLists.txt
deleted file mode 100644
index 0c6990b..0000000
--- a/ns_interface/CMakeLists.txt
+++ /dev/null
@@ -1,77 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2023, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-#
-# This CMake script used in a split build only. In the legacy 'sinlge' build
-# this file is ignoed. Please don't be confused.
-#
-cmake_minimum_required(VERSION 3.15)
-
-# This is important to add this SPE subdirectory at first as it
-# brings configuration from TF-M build
-add_subdirectory(${CONFIG_SPE_PATH} ${CMAKE_BINARY_DIR}/spe)
-
-add_subdirectory(../log             ${CMAKE_BINARY_DIR}/log)
-add_subdirectory(../CMSIS           ${CMAKE_BINARY_DIR}/CMSIS)
-
-add_library(tfm_test_broker STATIC)
-
-target_sources(tfm_test_broker
-    PUBLIC
-        ../app/main_ns.c
-        ../app/os_wrapper_cmsis_rtos_v2.c
-        ns_client_ext/tz_shim_layer.c
-)
-
-target_include_directories(tfm_test_broker
-    PUBLIC
-        .
-        ../app
-)
-
-target_link_libraries(tfm_test_broker
-    PUBLIC
-        RTX_OS
-        tfm_api_ns
-        tfm_log
-)
-
-add_subdirectory(ns_client_ext)
-target_link_libraries(tfm_test_broker PUBLIC tfm_nsid_manager)
-
-if (TFM_PARTITION_NS_AGENT_MAILBOX)
-    add_subdirectory(multi_core)
-    target_link_libraries(tfm_test_broker PUBLIC ns_multi_core)
-endif()
-
-################################################################################
-########### Patches and stubs to the existing (single) build process to leave
-# legacy code untouched for backwrd compatibility.
-# TODO: Sort it out after single build deprecation and code restructuring
-
-# platform_common_interface target is linked to the log target only
-add_library(platform_common_interface INTERFACE)
-
-# platform_region_defs needed by PS tests
-add_library(platform_region_defs INTERFACE)
-
-# stub the tfm_partition target.
-add_library(tfm_partitions INTERFACE)
-
-target_link_libraries(platform_common_interface
-    INTERFACE
-        platform_ns
-)
-
-target_include_directories(tfm_test_broker
-    PUBLIC
-        ns_client_ext   # TODO: It shall be in tfm_nsid_manager. Need to sort out dependencies
-)
-
-target_include_directories(tfm_config
-    INTERFACE
-        ${CMAKE_CURRENT_SOURCE_DIR}
-)
diff --git a/ns_interface/ns_client_ext/CMakeLists.txt b/ns_interface/ns_client_ext/CMakeLists.txt
deleted file mode 100644
index 24a0971..0000000
--- a/ns_interface/ns_client_ext/CMakeLists.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2023, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-#
-# This CMake script used in a split build only. In the legacy 'sinlge' build
-# this file is ignoed. Please don't be confused.
-#
-cmake_minimum_required(VERSION 3.15)
-
-if (TFM_NS_MANAGE_NSID)
-    add_library(tfm_nsid_manager STATIC
-            tfm_nsid_manager.c
-            ../../app/tfm_nsid_map_table.c
-    )
-
-    target_compile_definitions(tfm_nsid_manager
-        PUBLIC
-            TFM_NS_MANAGE_NSID
-            $<$<BOOL:${TEST_NS_MANAGE_NSID}>:TEST_NS_MANAGE_NSID>
-    )
-else()
-    add_library(tfm_nsid_manager INTERFACE)
-endif()
diff --git a/test/secure_fw/suites/ps/CMakeLists.txt b/test/secure_fw/suites/ps/CMakeLists.txt
index 53eb697..2ca1e29 100644
--- a/test/secure_fw/suites/ps/CMakeLists.txt
+++ b/test/secure_fw/suites/ps/CMakeLists.txt
@@ -37,6 +37,7 @@
             tfm_test_framework_ns
             platform_region_defs
             tfm_test_suite_its_ns
+            os_wrapper
     )
 
     target_link_libraries(tfm_ns_tests
diff --git a/test/secure_fw/suites/ps/non_secure/ns_test_helpers.c b/test/secure_fw/suites/ps/non_secure/ns_test_helpers.c
index 98066c3..e3de61f 100644
--- a/test/secure_fw/suites/ps/non_secure/ns_test_helpers.c
+++ b/test/secure_fw/suites/ps/non_secure/ns_test_helpers.c
@@ -7,8 +7,8 @@
 
 #include "ns_test_helpers.h"
 
-#include "os_wrapper/thread.h"
-#include "os_wrapper/semaphore.h"
+#include "thread.h"
+#include "semaphore.h"
 
 #define PS_TEST_TASK_STACK_SIZE (768)