SPM: Merge 'ffm' and 'cmsis_psa' sources

The library model referenced CMSIS sources hence its adaptation
layer name was 'cmsis_func' - and then this style was applied to
the IPC model and brought in an IPC adaptation layer with the name
'cmsis_psa'. And folder 'ffm' contains the common logic.

Now the library model is deprecated so 'cmsis_psa' is the only
adaptation layer left. As far of now, there are no obvious
requirements about referencing the common logic or the adaptation
layer individually, so let's merge common logic and the adaptation
sources into one folder 'core', and keep the folders containing
extended functionalities (Non-secure clients identification e.g.)
at the same level as 'core' with a suffix 'ext' in the folder name.

Signed-off-by: Ken Liu <Ken.Liu@arm.com>
Change-Id: Ibfd753879c60aff9adbf400b9f35c9c66de86eb9
Co-authored-by: Xinyu Zhang <xinyu.zhang@arm.com>
diff --git a/docs/contributing/code_review_guide.rst b/docs/contributing/code_review_guide.rst
index 622bf75..0677b29 100644
--- a/docs/contributing/code_review_guide.rst
+++ b/docs/contributing/code_review_guide.rst
@@ -78,18 +78,14 @@
 
 .. code-block:: c
 
-  /* R3.1 FILE: s/spm/ffm/psa_client.c */
+  /* R3.1 FILE: s/spm/core/psa_client.c */
 
-  /* R3.2 FILE: s/spm/cmsis_psa/tfm_secure_context.c */
+  /* R3.2 FILE: s/spm/core/tfm_secure_context.c */
 
-  /* R3.3 FILE: s/spm/cmsis_psa/main.c */
-
-  /* R3.4 FILE: s/spm/cmsis_psa/main.c, 'main' is a good entry name. */
-  void main(void);
-  /* R3.4 FILE: s/spm/ffm/spm.c, 'spm\_' as the namespace */
+  /* R3.4 FILE: s/spm/core/spm.c, 'spm\_' as the namespace */
   void spm_init(void);
 
-  /* R3.5 FILE: s/spm/ffm/main.c */
+  /* R3.5 FILE: s/spm/core/main.c */
   static void init_functions(void);
 
   /* R3.6 Not permitted: */
@@ -105,7 +101,7 @@
     external MACRO wrapped assembler code is allowed. Here is one example of the
     logic folder:
 
-    - 'secure_fw/spm/ffm'.
+    - 'secure_fw/spm'.
 
 Examples:
 
@@ -113,7 +109,7 @@
 
   /*
    * R4.1 The following MACRO is allowed to be referenced under
-   * 'secure_fw/spm/ffm'
+   * 'secure_fw/spm'
    */
   #define SVC(code) __asm volatile("svc  %0", ::"I"(code))
 
diff --git a/docs/integration_guide/source_structure/source_structure.rst b/docs/integration_guide/source_structure/source_structure.rst
index 126bd9c..d7882f4 100644
--- a/docs/integration_guide/source_structure/source_structure.rst
+++ b/docs/integration_guide/source_structure/source_structure.rst
@@ -117,8 +117,8 @@
 Folder name                    Description
 ============================== =============================================
 include                        SPM public headers.
-ffm                            SPM logic complies with PSA FF-M specification
-cmsis_psa                      CMSIS implementation for PSA FF-M SPM
+core                           SPM base functionalities
+\*ext                          Extended SPM functionalities
 ============================== =============================================
 
 --------------
diff --git a/platform/ext/common/tfm_interrupts.c b/platform/ext/common/tfm_interrupts.c
index 640696c..02238a3 100644
--- a/platform/ext/common/tfm_interrupts.c
+++ b/platform/ext/common/tfm_interrupts.c
@@ -14,7 +14,7 @@
 #include "spm.h"
 #include "tfm_hal_interrupt.h"
 #include "tfm_peripherals_def.h"
-#include "ffm/interrupt.h"
+#include "interrupt.h"
 #include "load/interrupt_defs.h"
 
 static struct irq_t timer0_irq = {0};
diff --git a/platform/ext/target/arm/mps2/an519/tfm_interrupts.c b/platform/ext/target/arm/mps2/an519/tfm_interrupts.c
index f285049..21f4b0b 100644
--- a/platform/ext/target/arm/mps2/an519/tfm_interrupts.c
+++ b/platform/ext/target/arm/mps2/an519/tfm_interrupts.c
@@ -14,7 +14,7 @@
 #include "spm.h"
 #include "tfm_hal_interrupt.h"
 #include "tfm_peripherals_def.h"
-#include "ffm/interrupt.h"
+#include "interrupt.h"
 #include "load/interrupt_defs.h"
 
 static const struct irq_load_info_t *p_tfm_timer0_irq_ldinf = NULL;
diff --git a/platform/ext/target/arm/mps2/an521/tfm_interrupts.c b/platform/ext/target/arm/mps2/an521/tfm_interrupts.c
index 640696c..02238a3 100644
--- a/platform/ext/target/arm/mps2/an521/tfm_interrupts.c
+++ b/platform/ext/target/arm/mps2/an521/tfm_interrupts.c
@@ -14,7 +14,7 @@
 #include "spm.h"
 #include "tfm_hal_interrupt.h"
 #include "tfm_peripherals_def.h"
-#include "ffm/interrupt.h"
+#include "interrupt.h"
 #include "load/interrupt_defs.h"
 
 static struct irq_t timer0_irq = {0};
diff --git a/platform/ext/target/arm/mps3/corstone310/fvp/tfm_interrupts.c b/platform/ext/target/arm/mps3/corstone310/fvp/tfm_interrupts.c
index 4b1985b..b88d8cd 100644
--- a/platform/ext/target/arm/mps3/corstone310/fvp/tfm_interrupts.c
+++ b/platform/ext/target/arm/mps3/corstone310/fvp/tfm_interrupts.c
@@ -14,7 +14,7 @@
 #include "spm.h"
 #include "tfm_hal_interrupt.h"
 #include "tfm_peripherals_def.h"
-#include "ffm/interrupt.h"
+#include "interrupt.h"
 #include "load/interrupt_defs.h"
 
 static struct irq_t dma0_ch0_irq = {0};
diff --git a/platform/ext/target/arm/musca_b1/tfm_interrupts.c b/platform/ext/target/arm/musca_b1/tfm_interrupts.c
index 640696c..02238a3 100644
--- a/platform/ext/target/arm/musca_b1/tfm_interrupts.c
+++ b/platform/ext/target/arm/musca_b1/tfm_interrupts.c
@@ -14,7 +14,7 @@
 #include "spm.h"
 #include "tfm_hal_interrupt.h"
 #include "tfm_peripherals_def.h"
-#include "ffm/interrupt.h"
+#include "interrupt.h"
 #include "load/interrupt_defs.h"
 
 static struct irq_t timer0_irq = {0};
diff --git a/platform/ext/target/arm/musca_s1/tfm_interrupts.c b/platform/ext/target/arm/musca_s1/tfm_interrupts.c
index 640696c..02238a3 100644
--- a/platform/ext/target/arm/musca_s1/tfm_interrupts.c
+++ b/platform/ext/target/arm/musca_s1/tfm_interrupts.c
@@ -14,7 +14,7 @@
 #include "spm.h"
 #include "tfm_hal_interrupt.h"
 #include "tfm_peripherals_def.h"
-#include "ffm/interrupt.h"
+#include "interrupt.h"
 #include "load/interrupt_defs.h"
 
 static struct irq_t timer0_irq = {0};
diff --git a/platform/ext/target/arm/rss/common/tfm_interrupts.c b/platform/ext/target/arm/rss/common/tfm_interrupts.c
index 3a1d71b..26cadfb 100644
--- a/platform/ext/target/arm/rss/common/tfm_interrupts.c
+++ b/platform/ext/target/arm/rss/common/tfm_interrupts.c
@@ -13,7 +13,7 @@
 #include "spm.h"
 #include "tfm_hal_interrupt.h"
 #include "tfm_peripherals_def.h"
-#include "ffm/interrupt.h"
+#include "interrupt.h"
 #include "load/interrupt_defs.h"
 #include "platform_irq.h"
 #ifdef TFM_MULTI_CORE_TOPOLOGY
diff --git a/platform/ext/target/cypress/psoc64/tfm_interrupts.c b/platform/ext/target/cypress/psoc64/tfm_interrupts.c
index 1fa9550..8568e10 100644
--- a/platform/ext/target/cypress/psoc64/tfm_interrupts.c
+++ b/platform/ext/target/cypress/psoc64/tfm_interrupts.c
@@ -16,7 +16,7 @@
 #include "spm.h"
 #include "tfm_hal_interrupt.h"
 #include "tfm_peripherals_def.h"
-#include "ffm/interrupt.h"
+#include "interrupt.h"
 #include "load/interrupt_defs.h"
 #include "mailbox/platform_multicore.h"
 
diff --git a/platform/ext/target/nordic_nrf/common/nrf5340/tfm_interrupts.c b/platform/ext/target/nordic_nrf/common/nrf5340/tfm_interrupts.c
index e3ec868..ccdf0d4 100644
--- a/platform/ext/target/nordic_nrf/common/nrf5340/tfm_interrupts.c
+++ b/platform/ext/target/nordic_nrf/common/nrf5340/tfm_interrupts.c
@@ -16,7 +16,7 @@
 #include "tfm_peripherals_def.h"
 #include "tfm_peripherals_config.h"
 #include "load/interrupt_defs.h"
-#include "ffm/interrupt.h"
+#include "interrupt.h"
 
 static enum tfm_hal_status_t irq_init(struct irq_t *irq, IRQn_Type irqn,
                                       void * p_pt,
diff --git a/platform/ext/target/nordic_nrf/common/nrf9160/tfm_interrupts.c b/platform/ext/target/nordic_nrf/common/nrf9160/tfm_interrupts.c
index 60e6d3a..df35a20 100644
--- a/platform/ext/target/nordic_nrf/common/nrf9160/tfm_interrupts.c
+++ b/platform/ext/target/nordic_nrf/common/nrf9160/tfm_interrupts.c
@@ -16,7 +16,7 @@
 #include "tfm_peripherals_def.h"
 #include "tfm_peripherals_config.h"
 #include "load/interrupt_defs.h"
-#include "ffm/interrupt.h"
+#include "interrupt.h"
 
 static enum tfm_hal_status_t irq_init(struct irq_t *irq, IRQn_Type irqn,
                                       void * p_pt,
diff --git a/secure_fw/CMakeLists.txt b/secure_fw/CMakeLists.txt
index 768b8d9..cee6808 100644
--- a/secure_fw/CMakeLists.txt
+++ b/secure_fw/CMakeLists.txt
@@ -82,9 +82,9 @@
 ############################ Secure API ########################################
 
 set_source_files_properties(
-    ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_svc.c
-    ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_cross.c
-    ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_sfn.c
+    ${CMAKE_SOURCE_DIR}/secure_fw/spm/core/psa_interface_svc.c
+    ${CMAKE_SOURCE_DIR}/secure_fw/spm/core/psa_interface_cross.c
+    ${CMAKE_SOURCE_DIR}/secure_fw/spm/core/psa_interface_sfn.c
     PROPERTIES
     COMPILE_FLAGS $<$<C_COMPILER_ID:GNU>:-Wno-unused-parameter>
     COMPILE_FLAGS $<$<C_COMPILER_ID:ARMClang>:-Wno-unused-parameter>
@@ -92,9 +92,9 @@
 
 target_sources(tfm_sprt
     PRIVATE
-        $<$<BOOL:${CONFIG_TFM_PSA_API_SUPERVISOR_CALL}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_svc.c>
-        $<$<BOOL:${CONFIG_TFM_PSA_API_CROSS_CALL}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_cross.c>
-        $<$<BOOL:${CONFIG_TFM_PSA_API_SFN_CALL}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_sfn.c>
+        $<$<BOOL:${CONFIG_TFM_PSA_API_SUPERVISOR_CALL}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/core/psa_interface_svc.c>
+        $<$<BOOL:${CONFIG_TFM_PSA_API_CROSS_CALL}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/core/psa_interface_cross.c>
+        $<$<BOOL:${CONFIG_TFM_PSA_API_SFN_CALL}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/core/psa_interface_sfn.c>
 )
 
 ############################# Secure veneers ###################################
diff --git a/secure_fw/partitions/ns_agent_mailbox/CMakeLists.txt b/secure_fw/partitions/ns_agent_mailbox/CMakeLists.txt
index 6e54c9b..1a67d42 100644
--- a/secure_fw/partitions/ns_agent_mailbox/CMakeLists.txt
+++ b/secure_fw/partitions/ns_agent_mailbox/CMakeLists.txt
@@ -18,8 +18,8 @@
 
 target_sources(tfm_psa_rot_partition_ns_agent_mailbox
     PRIVATE
-        ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/tfm_rpc.c
-        $<$<NOT:$<BOOL:${TFM_PLAT_SPECIFIC_MULTI_CORE_COMM}>>:${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/tfm_spe_mailbox.c>
+        ${CMAKE_SOURCE_DIR}/secure_fw/spm/core/tfm_rpc.c
+        $<$<NOT:$<BOOL:${TFM_PLAT_SPECIFIC_MULTI_CORE_COMM}>>:${CMAKE_SOURCE_DIR}/secure_fw/spm/core/tfm_spe_mailbox.c>
         ns_agent_mailbox.c
         tfm_multi_core_mem_check.c
 )
diff --git a/secure_fw/spm/CMakeLists.txt b/secure_fw/spm/CMakeLists.txt
index dda5398..1474add 100755
--- a/secure_fw/spm/CMakeLists.txt
+++ b/secure_fw/spm/CMakeLists.txt
@@ -23,58 +23,57 @@
     PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}
         ${CMAKE_CURRENT_SOURCE_DIR}/include
-        ${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa
-        ${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/include
+        ${CMAKE_CURRENT_SOURCE_DIR}/core
     PRIVATE
         ${CMAKE_SOURCE_DIR}
         ${CMAKE_SOURCE_DIR}/secure_fw/include
         ${CMAKE_BINARY_DIR}/generated
         ${CMAKE_BINARY_DIR}/generated/secure_fw/spm/include
-        ${CMAKE_BINARY_DIR}/generated/secure_fw/spm/cmsis_psa
+        ${CMAKE_BINARY_DIR}/generated/secure_fw/spm/core
 )
 
 target_sources(tfm_spm
     PRIVATE
-        ffm/tfm_boot_data.c
-        ffm/utilities.c
-        $<$<NOT:$<STREQUAL:${TFM_SPM_LOG_LEVEL},TFM_SPM_LOG_LEVEL_SILENCE>>:ffm/spm_log.c>
-        cmsis_psa/arch/tfm_arch.c
-        cmsis_psa/main.c
-        cmsis_psa/spm_ipc.c
-        $<$<BOOL:${CONFIG_TFM_PSA_API_CROSS_CALL}>:cmsis_psa/spm_cross_call.c>
-        cmsis_psa/rom_loader.c
-        ffm/psa_api.c
-        ffm/psa_call_api.c
-        ffm/psa_version_api.c
-        ffm/psa_read_write_skip_api.c
-        $<$<BOOL:${PSA_FRAMEWORK_HAS_MM_IOVEC}>:ffm/psa_mmiovec_api.c>
-        $<$<BOOL:${CONFIG_TFM_CONNECTION_BASED_SERVICE_API}>:ffm/psa_connection_api.c>
-        $<$<OR:$<BOOL:${CONFIG_TFM_FLIH_API}>,$<BOOL:${CONFIG_TFM_SLIH_API}>>:ffm/psa_irq_api.c>
-        $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_IPC}>:ffm/backend_ipc.c>
-        $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_SFN}>:ffm/backend_sfn.c>
-        $<$<OR:$<BOOL:${CONFIG_TFM_FLIH_API}>,$<BOOL:${CONFIG_TFM_SLIH_API}>>:ffm/interrupt.c>
-        $<$<BOOL:${CONFIG_TFM_STACK_WATERMARKS}>:ffm/stack_watermark.c>
-        cmsis_psa/tfm_core_svcalls_ipc.c
-        cmsis_psa/tfm_pools.c
-        $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_IPC}>:cmsis_psa/thread.c>
+        core/tfm_boot_data.c
+        core/utilities.c
+        $<$<NOT:$<STREQUAL:${TFM_SPM_LOG_LEVEL},TFM_SPM_LOG_LEVEL_SILENCE>>:core/spm_log.c>
+        core/arch/tfm_arch.c
+        core/main.c
+        core/spm_ipc.c
+        $<$<BOOL:${CONFIG_TFM_PSA_API_CROSS_CALL}>:core/spm_cross_call.c>
+        core/rom_loader.c
+        core/psa_api.c
+        core/psa_call_api.c
+        core/psa_version_api.c
+        core/psa_read_write_skip_api.c
+        $<$<BOOL:${PSA_FRAMEWORK_HAS_MM_IOVEC}>:core/psa_mmiovec_api.c>
+        $<$<BOOL:${CONFIG_TFM_CONNECTION_BASED_SERVICE_API}>:core/psa_connection_api.c>
+        $<$<OR:$<BOOL:${CONFIG_TFM_FLIH_API}>,$<BOOL:${CONFIG_TFM_SLIH_API}>>:core/psa_irq_api.c>
+        $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_IPC}>:core/backend_ipc.c>
+        $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_SFN}>:core/backend_sfn.c>
+        $<$<OR:$<BOOL:${CONFIG_TFM_FLIH_API}>,$<BOOL:${CONFIG_TFM_SLIH_API}>>:core/interrupt.c>
+        $<$<BOOL:${CONFIG_TFM_STACK_WATERMARKS}>:core/stack_watermark.c>
+        core/tfm_core_svcalls_ipc.c
+        core/tfm_pools.c
+        $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_IPC}>:core/thread.c>
         $<$<BOOL:${TFM_NS_MANAGE_NSID}>:ns_client_ext/tfm_ns_ctx.c>
         ns_client_ext/tfm_spm_ns_ctx.c
         #TODO add other arches
-        $<$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8.1-m.main>:cmsis_psa/arch/tfm_arch_v8m_main.c>
-        $<$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8-m.base>:cmsis_psa/arch/tfm_arch_v8m_base.c>
-        $<$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8-m.main>:cmsis_psa/arch/tfm_arch_v8m_main.c>
-        $<$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv6-m>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
-        $<$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv7-m>:cmsis_psa/arch/tfm_arch_v6m_v7m.c>
+        $<$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8.1-m.main>:core/arch/tfm_arch_v8m_main.c>
+        $<$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8-m.base>:core/arch/tfm_arch_v8m_base.c>
+        $<$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv8-m.main>:core/arch/tfm_arch_v8m_main.c>
+        $<$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv6-m>:core/arch/tfm_arch_v6m_v7m.c>
+        $<$<STREQUAL:${TFM_SYSTEM_ARCHITECTURE},armv7-m>:core/arch/tfm_arch_v6m_v7m.c>
         ${CMAKE_SOURCE_DIR}/platform/ext/common/tfm_hal_nvic.c
 )
 
 target_include_directories(tfm_spm_defs
     INTERFACE
-        ${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa
+        ${CMAKE_CURRENT_SOURCE_DIR}/core
         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/boot>
         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/interface>
-        ${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/arch
+        ${CMAKE_CURRENT_SOURCE_DIR}/core/arch
 )
 
 target_link_libraries(tfm_spm
@@ -122,7 +121,7 @@
 
 target_include_directories(tfm_arch
     INTERFACE
-        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cmsis_psa/arch>
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/core/arch>
 )
 
 ############################ Boot Status #######################################
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch.c b/secure_fw/spm/core/arch/tfm_arch.c
similarity index 100%
rename from secure_fw/spm/cmsis_psa/arch/tfm_arch.c
rename to secure_fw/spm/core/arch/tfm_arch.c
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.c b/secure_fw/spm/core/arch/tfm_arch_v6m_v7m.c
similarity index 100%
rename from secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.c
rename to secure_fw/spm/core/arch/tfm_arch_v6m_v7m.c
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.h b/secure_fw/spm/core/arch/tfm_arch_v6m_v7m.h
similarity index 100%
rename from secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.h
rename to secure_fw/spm/core/arch/tfm_arch_v6m_v7m.h
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c b/secure_fw/spm/core/arch/tfm_arch_v8m_base.c
similarity index 100%
rename from secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c
rename to secure_fw/spm/core/arch/tfm_arch_v8m_base.c
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c b/secure_fw/spm/core/arch/tfm_arch_v8m_main.c
similarity index 100%
rename from secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c
rename to secure_fw/spm/core/arch/tfm_arch_v8m_main.c
diff --git a/secure_fw/spm/ffm/backend_ipc.c b/secure_fw/spm/core/backend_ipc.c
similarity index 99%
rename from secure_fw/spm/ffm/backend_ipc.c
rename to secure_fw/spm/core/backend_ipc.c
index b77a7d9..019da0a 100644
--- a/secure_fw/spm/ffm/backend_ipc.c
+++ b/secure_fw/spm/core/backend_ipc.c
@@ -14,14 +14,14 @@
 #include "compiler_ext_defs.h"
 #include "config_spm.h"
 #include "runtime_defs.h"
-#include "ffm/stack_watermark.h"
+#include "stack_watermark.h"
 #include "spm.h"
 #include "tfm_hal_isolation.h"
 #include "tfm_hal_platform.h"
 #include "tfm_rpc.h"
 #include "ffm/backend.h"
 #include "utilities.h"
-#include "cmsis_psa/memory_symbols.h"
+#include "memory_symbols.h"
 #include "load/partition_defs.h"
 #include "load/service_defs.h"
 #include "load/spm_load_api.h"
diff --git a/secure_fw/spm/ffm/backend_sfn.c b/secure_fw/spm/core/backend_sfn.c
similarity index 99%
rename from secure_fw/spm/ffm/backend_sfn.c
rename to secure_fw/spm/core/backend_sfn.c
index d5f8b23..357b798 100644
--- a/secure_fw/spm/ffm/backend_sfn.c
+++ b/secure_fw/spm/core/backend_sfn.c
@@ -14,7 +14,7 @@
 #include "runtime_defs.h"
 #include "tfm_hal_platform.h"
 #include "ffm/backend.h"
-#include "ffm/stack_watermark.h"
+#include "stack_watermark.h"
 #include "load/partition_defs.h"
 #include "load/service_defs.h"
 #include "load/spm_load_api.h"
diff --git a/secure_fw/spm/cmsis_psa/internal_status_code.h b/secure_fw/spm/core/internal_status_code.h
similarity index 100%
rename from secure_fw/spm/cmsis_psa/internal_status_code.h
rename to secure_fw/spm/core/internal_status_code.h
diff --git a/secure_fw/spm/ffm/interrupt.c b/secure_fw/spm/core/interrupt.c
similarity index 100%
rename from secure_fw/spm/ffm/interrupt.c
rename to secure_fw/spm/core/interrupt.c
diff --git a/secure_fw/spm/ffm/interrupt.h b/secure_fw/spm/core/interrupt.h
similarity index 100%
rename from secure_fw/spm/ffm/interrupt.h
rename to secure_fw/spm/core/interrupt.h
diff --git a/secure_fw/spm/cmsis_psa/main.c b/secure_fw/spm/core/main.c
similarity index 98%
rename from secure_fw/spm/cmsis_psa/main.c
rename to secure_fw/spm/core/main.c
index fc06de0..17a0cde 100644
--- a/secure_fw/spm/cmsis_psa/main.c
+++ b/secure_fw/spm/core/main.c
@@ -7,7 +7,7 @@
 
 #include "build_config_check.h"
 #include "fih.h"
-#include "ffm/tfm_boot_data.h"
+#include "tfm_boot_data.h"
 #include "memory_symbols.h"
 #include "spm.h"
 #include "tfm_hal_isolation.h"
diff --git a/secure_fw/spm/cmsis_psa/memory_symbols.h b/secure_fw/spm/core/memory_symbols.h
similarity index 100%
rename from secure_fw/spm/cmsis_psa/memory_symbols.h
rename to secure_fw/spm/core/memory_symbols.h
diff --git a/secure_fw/spm/ffm/psa_api.c b/secure_fw/spm/core/psa_api.c
similarity index 100%
rename from secure_fw/spm/ffm/psa_api.c
rename to secure_fw/spm/core/psa_api.c
diff --git a/secure_fw/spm/ffm/psa_call_api.c b/secure_fw/spm/core/psa_call_api.c
similarity index 100%
rename from secure_fw/spm/ffm/psa_call_api.c
rename to secure_fw/spm/core/psa_call_api.c
diff --git a/secure_fw/spm/ffm/psa_connection_api.c b/secure_fw/spm/core/psa_connection_api.c
similarity index 100%
rename from secure_fw/spm/ffm/psa_connection_api.c
rename to secure_fw/spm/core/psa_connection_api.c
diff --git a/secure_fw/spm/cmsis_psa/psa_interface_cross.c b/secure_fw/spm/core/psa_interface_cross.c
similarity index 100%
rename from secure_fw/spm/cmsis_psa/psa_interface_cross.c
rename to secure_fw/spm/core/psa_interface_cross.c
diff --git a/secure_fw/spm/cmsis_psa/psa_interface_sfn.c b/secure_fw/spm/core/psa_interface_sfn.c
similarity index 100%
rename from secure_fw/spm/cmsis_psa/psa_interface_sfn.c
rename to secure_fw/spm/core/psa_interface_sfn.c
diff --git a/secure_fw/spm/cmsis_psa/psa_interface_svc.c b/secure_fw/spm/core/psa_interface_svc.c
similarity index 100%
rename from secure_fw/spm/cmsis_psa/psa_interface_svc.c
rename to secure_fw/spm/core/psa_interface_svc.c
diff --git a/secure_fw/spm/ffm/psa_irq_api.c b/secure_fw/spm/core/psa_irq_api.c
similarity index 100%
rename from secure_fw/spm/ffm/psa_irq_api.c
rename to secure_fw/spm/core/psa_irq_api.c
diff --git a/secure_fw/spm/ffm/psa_mmiovec_api.c b/secure_fw/spm/core/psa_mmiovec_api.c
similarity index 100%
rename from secure_fw/spm/ffm/psa_mmiovec_api.c
rename to secure_fw/spm/core/psa_mmiovec_api.c
diff --git a/secure_fw/spm/ffm/psa_read_write_skip_api.c b/secure_fw/spm/core/psa_read_write_skip_api.c
similarity index 100%
rename from secure_fw/spm/ffm/psa_read_write_skip_api.c
rename to secure_fw/spm/core/psa_read_write_skip_api.c
diff --git a/secure_fw/spm/ffm/psa_version_api.c b/secure_fw/spm/core/psa_version_api.c
similarity index 100%
rename from secure_fw/spm/ffm/psa_version_api.c
rename to secure_fw/spm/core/psa_version_api.c
diff --git a/secure_fw/spm/cmsis_psa/rom_loader.c b/secure_fw/spm/core/rom_loader.c
similarity index 100%
rename from secure_fw/spm/cmsis_psa/rom_loader.c
rename to secure_fw/spm/core/rom_loader.c
diff --git a/secure_fw/spm/cmsis_psa/spm.h b/secure_fw/spm/core/spm.h
similarity index 100%
rename from secure_fw/spm/cmsis_psa/spm.h
rename to secure_fw/spm/core/spm.h
diff --git a/secure_fw/spm/cmsis_psa/spm_cross_call.c b/secure_fw/spm/core/spm_cross_call.c
similarity index 100%
rename from secure_fw/spm/cmsis_psa/spm_cross_call.c
rename to secure_fw/spm/core/spm_cross_call.c
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/core/spm_ipc.c
old mode 100755
new mode 100644
similarity index 100%
rename from secure_fw/spm/cmsis_psa/spm_ipc.c
rename to secure_fw/spm/core/spm_ipc.c
diff --git a/secure_fw/spm/ffm/spm_log.c b/secure_fw/spm/core/spm_log.c
similarity index 100%
rename from secure_fw/spm/ffm/spm_log.c
rename to secure_fw/spm/core/spm_log.c
diff --git a/secure_fw/spm/ffm/stack_watermark.c b/secure_fw/spm/core/stack_watermark.c
similarity index 97%
rename from secure_fw/spm/ffm/stack_watermark.c
rename to secure_fw/spm/core/stack_watermark.c
index 75acfa1..ebce1bc 100644
--- a/secure_fw/spm/ffm/stack_watermark.c
+++ b/secure_fw/spm/core/stack_watermark.c
@@ -7,7 +7,7 @@
 
 #include <stdint.h>
 #include "ffm/backend.h"
-#include "ffm/stack_watermark.h"
+#include "stack_watermark.h"
 #include "lists.h"
 #include "load/spm_load_api.h"
 #include "spm.h"
diff --git a/secure_fw/spm/ffm/stack_watermark.h b/secure_fw/spm/core/stack_watermark.h
similarity index 100%
rename from secure_fw/spm/ffm/stack_watermark.h
rename to secure_fw/spm/core/stack_watermark.h
diff --git a/secure_fw/spm/ffm/tfm_boot_data.c b/secure_fw/spm/core/tfm_boot_data.c
similarity index 100%
rename from secure_fw/spm/ffm/tfm_boot_data.c
rename to secure_fw/spm/core/tfm_boot_data.c
diff --git a/secure_fw/spm/ffm/tfm_boot_data.h b/secure_fw/spm/core/tfm_boot_data.h
similarity index 100%
rename from secure_fw/spm/ffm/tfm_boot_data.h
rename to secure_fw/spm/core/tfm_boot_data.h
diff --git a/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c b/secure_fw/spm/core/tfm_core_svcalls_ipc.c
similarity index 98%
rename from secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c
rename to secure_fw/spm/core/tfm_core_svcalls_ipc.c
index 9c672bc..c82ee68 100644
--- a/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c
+++ b/secure_fw/spm/core/tfm_core_svcalls_ipc.c
@@ -16,8 +16,8 @@
 #include "tfm_svcalls.h"
 #include "utilities.h"
 #include "load/spm_load_api.h"
-#include "ffm/interrupt.h"
-#include "ffm/tfm_boot_data.h"
+#include "interrupt.h"
+#include "tfm_boot_data.h"
 #include "ffm/psa_api.h"
 #include "tfm_hal_isolation.h"
 #include "tfm_hal_spm_logdev.h"
diff --git a/secure_fw/spm/cmsis_psa/tfm_multi_core.h b/secure_fw/spm/core/tfm_multi_core.h
similarity index 100%
rename from secure_fw/spm/cmsis_psa/tfm_multi_core.h
rename to secure_fw/spm/core/tfm_multi_core.h
diff --git a/secure_fw/spm/cmsis_psa/tfm_pools.c b/secure_fw/spm/core/tfm_pools.c
similarity index 100%
rename from secure_fw/spm/cmsis_psa/tfm_pools.c
rename to secure_fw/spm/core/tfm_pools.c
diff --git a/secure_fw/spm/cmsis_psa/tfm_pools.h b/secure_fw/spm/core/tfm_pools.h
similarity index 100%
rename from secure_fw/spm/cmsis_psa/tfm_pools.h
rename to secure_fw/spm/core/tfm_pools.h
diff --git a/secure_fw/spm/cmsis_psa/tfm_rpc.c b/secure_fw/spm/core/tfm_rpc.c
similarity index 100%
rename from secure_fw/spm/cmsis_psa/tfm_rpc.c
rename to secure_fw/spm/core/tfm_rpc.c
diff --git a/secure_fw/spm/cmsis_psa/tfm_rpc.h b/secure_fw/spm/core/tfm_rpc.h
similarity index 100%
rename from secure_fw/spm/cmsis_psa/tfm_rpc.h
rename to secure_fw/spm/core/tfm_rpc.h
diff --git a/secure_fw/spm/cmsis_psa/tfm_spe_mailbox.c b/secure_fw/spm/core/tfm_spe_mailbox.c
similarity index 100%
rename from secure_fw/spm/cmsis_psa/tfm_spe_mailbox.c
rename to secure_fw/spm/core/tfm_spe_mailbox.c
diff --git a/secure_fw/spm/cmsis_psa/tfm_spe_mailbox.h b/secure_fw/spm/core/tfm_spe_mailbox.h
similarity index 100%
rename from secure_fw/spm/cmsis_psa/tfm_spe_mailbox.h
rename to secure_fw/spm/core/tfm_spe_mailbox.h
diff --git a/secure_fw/spm/cmsis_psa/tfm_svcalls.h b/secure_fw/spm/core/tfm_svcalls.h
similarity index 100%
rename from secure_fw/spm/cmsis_psa/tfm_svcalls.h
rename to secure_fw/spm/core/tfm_svcalls.h
diff --git a/secure_fw/spm/cmsis_psa/thread.c b/secure_fw/spm/core/thread.c
similarity index 100%
rename from secure_fw/spm/cmsis_psa/thread.c
rename to secure_fw/spm/core/thread.c
diff --git a/secure_fw/spm/cmsis_psa/thread.h b/secure_fw/spm/core/thread.h
similarity index 100%
rename from secure_fw/spm/cmsis_psa/thread.h
rename to secure_fw/spm/core/thread.h
diff --git a/secure_fw/spm/ffm/utilities.c b/secure_fw/spm/core/utilities.c
similarity index 100%
rename from secure_fw/spm/ffm/utilities.c
rename to secure_fw/spm/core/utilities.c