SPM: Sort up inline assembly
Purposes:
- Fix IAR toolchain build errors.
- Convert 'extend asm' into 'basic asm' for naked functions.
- Group 'thread call' interface in a section for easy the near jump.
Change-Id: I2eafceddd6d2be1e759163e50b3b6dc007257618
Signed-off-by: Ken Liu <Ken.Liu@arm.com>
diff --git a/secure_fw/include/compiler_ext_defs.h b/secure_fw/include/compiler_ext_defs.h
index fd84de7..9b336a8 100644
--- a/secure_fw/include/compiler_ext_defs.h
+++ b/secure_fw/include/compiler_ext_defs.h
@@ -22,6 +22,10 @@
#define __aligned(x) __attribute__((aligned(x)))
#endif
+#ifndef __used
+#define __used __attribute__((used))
+#endif
+
#endif /* __ARMCC_VERSION __GNUC__ __ICCARM__*/
#endif /* __COMPILER_EXT_DEFS_H__ */
diff --git a/secure_fw/spm/cmsis_func/arch.c b/secure_fw/spm/cmsis_func/arch.c
index 39446c0..0f6ac97 100644
--- a/secure_fw/spm/cmsis_func/arch.c
+++ b/secure_fw/spm/cmsis_func/arch.c
@@ -9,9 +9,9 @@
#include "compiler_ext_defs.h"
#include "exception_info.h"
#include "tfm_secure_api.h"
+#include "tfm_svcalls.h"
#if defined(__ICCARM__)
-uint32_t tfm_core_svc_handler(uint32_t *msp, uint32_t *psp, uint32_t exc_return);
#pragma required = tfm_core_svc_handler
#endif
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch.c
index ed0c74c..8f47f76 100644
--- a/secure_fw/spm/cmsis_psa/arch/tfm_arch.c
+++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch.c
@@ -16,7 +16,7 @@
".syntax unified \n"
#endif
"MOV lr, r0 \n"
- "LDR r0, ="M2S(VTOR_BASE)" \n" /* VTOR */
+ "LDR r0, ="M2S(VTOR_ADDR)" \n" /* VTOR */
"LDR r0, [r0] \n" /* MSP address */
"LDR r0, [r0] \n" /* MSP */
"SUBS r0, #8 \n" /* Exclude stack seal */
@@ -38,11 +38,10 @@
#ifndef __ICCARM__
".syntax unified \n"
#endif
- "ldr r0, =%a0 \n"
+ "ldr r0, ="M2S(ICSR_ADDR)" \n"
"ldr r1, ="M2S(SCB_ICSR_PENDSVSET_Msk)" \n"
"str r1, [r0, #0] \n"
"bx lr \n"
- :: "i" (&(SCB->ICSR))
);
}
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.c
index 6d5a3b6..88c2459 100644
--- a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.c
+++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.c
@@ -7,10 +7,11 @@
#include <inttypes.h>
#include "compiler_ext_defs.h"
+#include "spm_ipc.h"
+#include "tfm_arch.h"
#include "tfm_core_utils.h"
#include "tfm_hal_device_header.h"
-#include "tfm_arch.h"
-#include "spm_ipc.h"
+#include "tfm_svcalls.h"
#include "svc_num.h"
#include "exception_info.h"
@@ -19,10 +20,23 @@
#error "Unsupported ARM Architecture."
#endif
-extern uint32_t SVCHandler_main(uint32_t *svc_args, uint32_t lr);
-
/* Delcaraction flag to control the scheduling logic in PendSV. */
-static uint32_t pendsv_idling = 0;
+__used static uint32_t pendsv_idling = 0;
+
+/* IAR Specific */
+#if defined(__ICCARM__)
+
+#pragma required = do_schedule
+#pragma required = pendsv_idling
+#pragma required = tfm_core_svc_handler
+
+#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
+
+#pragma required = spcall_execute_c
+
+#endif /* CONFIG_TFM_PSA_API_THREAD_CALL */
+
+#endif
#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
@@ -41,46 +55,40 @@
" mov sp, r2 \n"
" mov r2, r4 \n"
"v6v7_lock_sched: \n"/* lock pendsv */
- " ldr r3, =%a1 \n"/* R2 = caller SP */
+ " ldr r3, =pendsv_idling \n"/* R2 = caller SP */
" movs r4, #0x1 \n"/* Do not touch */
" str r4, [r3, #0] \n"
" cpsie i \n"
" push {r2, r3} \n"
- " bl %a0 \n"
+ " bl spcall_execute_c \n"
" pop {r2, r3} \n"
" cpsid i \n"
" cmp r2, #0 \n"
" beq v6v7_release_sched \n"
" mov sp, r2 \n"/* switch stack */
"v6v7_release_sched: \n"
- " ldr r2, =%a1 \n"/* release pendsv */
+ " ldr r2, =pendsv_idling \n"/* release pendsv */
" movs r3, #0 \n"
" str r3, [r2, #0] \n"
" cpsie i \n"
" pop {r4, pc} \n"
- : : "i" (spcall_execute_c),
- "i" (&pendsv_idling)
);
}
#endif /* CONFIG_TFM_PSA_API_THREAD_CALL */
-#if defined(__ICCARM__)
-#pragma required = do_schedule
-#endif
-
__attribute__((naked)) void PendSV_Handler(void)
{
__ASM volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
- " ldr r0, =%a1 \n"
+ " ldr r0, =pendsv_idling \n"
" ldr r0, [r0] \n"
" cmp r0, #0 \n"
" bne v6v7_pendsv_exit \n"
" push {r0, lr} \n"
- " bl %a0 \n"
+ " bl do_schedule \n"
" pop {r2, r3} \n"
" mov lr, r3 \n"
" cmp r0, r1 \n" /* ctx of curr and next thrd */
@@ -110,17 +118,9 @@
" msr psp, r2 \n"
"v6v7_pendsv_exit: \n"
" bx lr \n"
- :: "i" (do_schedule),
- "i" (&pendsv_idling)
);
}
-#if defined(__ICCARM__)
-uint32_t tfm_core_svc_handler(uint32_t *msp, uint32_t exc_return,
- uint32_t *psp);
-#pragma required = tfm_core_svc_handler
-#endif
-
__attribute__((naked)) void SVC_Handler(void)
{
__ASM volatile(
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.h b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.h
index daae0a7..2266d68 100644
--- a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.h
+++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.h
@@ -35,7 +35,8 @@
#define EXC_NUM_SVCALL (11)
#define EXC_NUM_PENDSV (14)
-#define VTOR_BASE (0xE000ED08)
+#define ICSR_ADDR (0xE000ED04)
+#define VTOR_ADDR (0xE000ED08)
/**
* \brief Check whether Secure or Non-secure stack is used to restore stack
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c
index 32fe226..982a353 100644
--- a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c
+++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c
@@ -7,14 +7,14 @@
#include <inttypes.h>
#include "compiler_ext_defs.h"
+#include "exception_info.h"
#include "spm_ipc.h"
+#include "svc_num.h"
#include "tfm_hal_device_header.h"
#include "tfm_arch.h"
#include "tfm_core_utils.h"
-#include "exception_info.h"
#include "tfm_secure_api.h"
-#include "spm_ipc.h"
-#include "svc_num.h"
+#include "tfm_svcalls.h"
#include "utilities.h"
#if !defined(__ARM_ARCH_8M_BASE__)
@@ -22,7 +22,22 @@
#endif
/* Delcaraction flag to control the scheduling logic in PendSV. */
-static uint32_t pendsv_idling = EXC_RETURN_SECURE_STACK;
+__used static uint32_t pendsv_idling = EXC_RETURN_SECURE_STACK;
+
+/* IAR Specific */
+#if defined(__ICCARM__)
+
+#pragma required = do_schedule
+#pragma required = pendsv_idling
+#pragma required = tfm_core_svc_handler
+
+#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
+
+#pragma required = spcall_execute_c
+
+#endif /* CONFIG_TFM_PSA_API_THREAD_CALL */
+
+#endif
#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
@@ -45,11 +60,11 @@
" mov sp, r2 \n"
" msr psplim, r3 \n"
"v8b_lock_sched: \n"/*To lock sched */
- " ldr r2, =%a1 \n"
+ " ldr r2, =pendsv_idling \n"
" movs r3, #0x0 \n"
" str r3, [r2, #0] \n"
" cpsie i \n"
- " bl %a0 \n"
+ " bl spcall_execute_c \n"
" cpsid i \n"
" cmp r4, #0 \n"
" beq v8b_release_sched \n"
@@ -58,36 +73,29 @@
" mov sp, r4 \n"
" msr psplim, r5 \n"
"v8b_release_sched: \n"
- " ldr r2, =%a1 \n"/*To unlock sched*/
- " movs r3, %2 \n"
+ " ldr r2, =pendsv_idling \n"/*To unlock sched*/
+ " movs r3, #"M2S(EXC_RETURN_SECURE_STACK)" \n"
" str r3, [r2, #0] \n"
" cpsie i \n"
" pop {r4-r6, pc} \n"
- : : "i" (spcall_execute_c),
- "i" (&pendsv_idling),
- "I" (EXC_RETURN_SECURE_STACK)
);
}
#endif /* CONFIG_TFM_PSA_API_THREAD_CALL */
-#if defined(__ICCARM__)
-#pragma required = do_schedule
-#endif
-
__attribute__((naked)) void PendSV_Handler(void)
{
__ASM volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
- " ldr r0, =%a1 \n"
+ " ldr r0, =pendsv_idling \n"
" ldr r0, [r0] \n"
" mov r1, lr \n"
" tst r0, r1 \n" /* Was NS interrupted by S? */
" beq v8b_pendsv_exit \n" /* Yes, do not schedule */
" push {r0, lr} \n" /* Save dummy R0, LR */
- " bl %a0 \n"
+ " bl do_schedule \n"
" pop {r2, r3} \n"
" mov lr, r3 \n"
" cmp r0, r1 \n" /* ctx of curr and next thrd */
@@ -119,8 +127,6 @@
" msr psplim, r3 \n"
"v8b_pendsv_exit: \n"
" bx lr \n"
- : : "i" (do_schedule),
- "i" (&pendsv_idling)
);
}
@@ -147,12 +153,6 @@
__ASM volatile("b .");
}
-#if defined(__ICCARM__)
-uint32_t tfm_core_svc_handler(uint32_t *msp, uint32_t exc_return,
- uint32_t *psp);
-#pragma required = tfm_core_svc_handler
-#endif
-
__attribute__((naked)) void SVC_Handler(void)
{
__ASM volatile(
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c
index 57bb130..444801f 100644
--- a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c
+++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c
@@ -7,15 +7,16 @@
#include <inttypes.h>
#include "compiler_ext_defs.h"
-#include "tfm_hal_device_header.h"
-#include "region_defs.h"
-#include "tfm_arch.h"
-#include "tfm_memory_utils.h"
-#include "tfm_core_utils.h"
#include "exception_info.h"
-#include "tfm_secure_api.h"
+#include "region_defs.h"
#include "spm_ipc.h"
#include "svc_num.h"
+#include "tfm_arch.h"
+#include "tfm_core_utils.h"
+#include "tfm_hal_device_header.h"
+#include "tfm_memory_utils.h"
+#include "tfm_secure_api.h"
+#include "tfm_svcalls.h"
#include "utilities.h"
#if !defined(__ARM_ARCH_8M_MAIN__) && !defined(__ARM_ARCH_8_1M_MAIN__)
@@ -23,7 +24,22 @@
#endif
/* Delcaraction flag to control the scheduling logic in PendSV. */
-static uint32_t pendsv_idling = EXC_RETURN_SECURE_STACK;
+__used static uint32_t pendsv_idling = EXC_RETURN_SECURE_STACK;
+
+/* IAR Specific */
+#if defined(__ICCARM__)
+
+#pragma required = do_schedule
+#pragma required = pendsv_idling
+#pragma required = tfm_core_svc_handler
+
+#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
+
+#pragma required = spcall_execute_c
+
+#endif /* CONFIG_TFM_PSA_API_THREAD_CALL */
+
+#endif
#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
@@ -45,11 +61,11 @@
" movne r4, sp \n"
" movne sp, r2 \n"
" msrne psplim, r3 \n"
- " ldr r2, =%a1 \n"/*To lock sched */
+ " ldr r2, =pendsv_idling \n"/*To lock sched */
" movs r3, #0x0 \n"
" str r3, [r2, #0] \n"
" cpsie i \n"
- " bl %a0 \n"
+ " bl spcall_execute_c \n"
" cpsid i \n"
" movs r12, #0 \n"
" cmp r4, #0 \n"
@@ -57,35 +73,28 @@
" msrne psplim, r12 \n"
" movne sp, r4 \n"
" msrne psplim, r5 \n"
- " ldr r4, =%a1 \n"/*To unlock sched*/
- " movs r5, %2 \n"
+ " ldr r4, =pendsv_idling \n"/*To unlock sched*/
+ " movs r5, #"M2S(EXC_RETURN_SECURE_STACK)" \n"
" str r5, [r4, #0] \n"
" cpsie i \n"
" pop {r4-r6, pc} \n"
- : : "i" (spcall_execute_c),
- "i" (&pendsv_idling),
- "I" (EXC_RETURN_SECURE_STACK)
);
}
#endif /* CONFIG_TFM_PSA_API_THREAD_CALL */
-#if defined(__ICCARM__)
-#pragma required = do_schedule
-#endif
-
__attribute__((naked)) void PendSV_Handler(void)
{
__ASM volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
- " ldr r0, =%a1 \n"
+ " ldr r0, =pendsv_idling \n"
" ldr r0, [r0] \n"
" ands r0, lr \n"
" beq v8m_pendsv_exit \n" /* Yes, do not schedule */
" push {r0, lr} \n" /* Save dummy R0, LR */
- " bl %a0 \n"
+ " bl do_schedule \n"
" pop {r2, lr} \n"
" cmp r0, r1 \n" /* ctx of curr and next thrd */
" beq v8m_pendsv_exit \n" /* No schedule if curr = next */
@@ -99,8 +108,6 @@
" msr psplim, r3 \n"
"v8m_pendsv_exit: \n"
" bx lr \n"
- :: "i" (do_schedule),
- "i" (&pendsv_idling)
);
}
diff --git a/secure_fw/spm/cmsis_psa/psa_interface_svc.c b/secure_fw/spm/cmsis_psa/psa_interface_svc.c
index 0a1f146..3781332 100644
--- a/secure_fw/spm/cmsis_psa/psa_interface_svc.c
+++ b/secure_fw/spm/cmsis_psa/psa_interface_svc.c
@@ -9,6 +9,7 @@
#include "compiler_ext_defs.h"
#include "svc_num.h"
#include "tfm_psa_call_pack.h"
+#include "utilities.h"
#include "psa/client.h"
#include "psa/lifecycle.h"
#include "psa/service.h"
@@ -17,23 +18,20 @@
__naked uint32_t psa_framework_version_svc(void)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_FRAMEWORK_VERSION));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_FRAMEWORK_VERSION)"\n"
+ "bx lr \n");
}
__naked uint32_t psa_version_svc(uint32_t sid)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_VERSION));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_VERSION)" \n"
+ "bx lr \n");
}
__naked psa_handle_t psa_connect_svc(uint32_t sid, uint32_t version)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_CONNECT));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_CONNECT)" \n"
+ "bx lr \n");
}
__naked psa_status_t tfm_psa_call_pack_svc(psa_handle_t handle,
@@ -41,124 +39,107 @@
const psa_invec *in_vec,
psa_outvec *out_vec)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_CALL));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_CALL)" \n"
+ "bx lr \n");
}
__naked void psa_close_svc(psa_handle_t handle)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_CLOSE));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_CLOSE)" \n"
+ "bx lr \n");
}
__naked psa_signal_t psa_wait_svc(psa_signal_t signal_mask, uint32_t timeout)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_WAIT));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_WAIT)" \n"
+ "bx lr \n");
}
__naked psa_status_t psa_get_svc(psa_signal_t signal, psa_msg_t *msg)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_GET));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_GET)" \n"
+ "bx lr \n");
}
__naked void psa_set_rhandle_svc(psa_handle_t msg_handle, void *rhandle)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_SET_RHANDLE));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_SET_RHANDLE)" \n"
+ "bx lr \n");
}
__naked size_t psa_read_svc(psa_handle_t msg_handle, uint32_t invec_idx,
void *buffer, size_t num_bytes)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_READ));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_READ)" \n"
+ "bx lr \n");
}
__naked size_t psa_skip_svc(psa_handle_t msg_handle,
uint32_t invec_idx, size_t num_bytes)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_SKIP));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_SKIP)" \n"
+ "bx lr \n");
}
__naked void psa_write_svc(psa_handle_t msg_handle, uint32_t outvec_idx,
const void *buffer, size_t num_bytes)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_WRITE));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_WRITE)" \n"
+ "bx lr \n");
}
__naked void psa_reply_svc(psa_handle_t msg_handle, psa_status_t retval)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_REPLY));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_REPLY)" \n"
+ "bx lr \n");
}
__naked void psa_notify_svc(int32_t partition_id)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_NOTIFY));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_NOTIFY)" \n"
+ "bx lr \n");
}
__naked void psa_clear_svc(void)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_CLEAR));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_CLEAR)" \n"
+ "bx lr \n");
}
__naked void psa_eoi_svc(psa_signal_t irq_signal)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_EOI));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_EOI)" \n"
+ "bx lr \n");
}
__naked void psa_panic_svc(void)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_PANIC));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_PANIC)" \n"
+ "bx lr \n");
}
__naked void psa_irq_enable_svc(psa_signal_t irq_signal)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_IRQ_ENABLE));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_IRQ_ENABLE)" \n"
+ "bx lr \n");
}
__naked psa_irq_status_t psa_irq_disable_svc(psa_signal_t irq_signal)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_IRQ_DISABLE));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_IRQ_DISABLE)" \n"
+ "bx lr \n");
}
__naked void psa_reset_signal_svc(psa_signal_t irq_signal)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_RESET_SIGNAL));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_RESET_SIGNAL)" \n"
+ "bx lr \n");
}
__naked uint32_t psa_rot_lifecycle_state_svc(void)
{
- __asm volatile("svc %0 \n"
- "bx lr \n"
- : : "I" (TFM_SVC_PSA_LIFECYCLE));
+ __asm volatile("svc "M2S(TFM_SVC_PSA_LIFECYCLE)" \n"
+ "bx lr \n");
}
#endif /* CONFIG_TFM_PSA_API_SUPERVISOR_CALL */
diff --git a/secure_fw/spm/cmsis_psa/psa_interface_thread.c b/secure_fw/spm/cmsis_psa/psa_interface_thread.c
index 81f2d2c..f427c2a 100644
--- a/secure_fw/spm/cmsis_psa/psa_interface_thread.c
+++ b/secure_fw/spm/cmsis_psa/psa_interface_thread.c
@@ -17,70 +17,76 @@
#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
+#if defined(__ICCARM__)
+
+#pragma required = spm_interface_thread_dispatcher
+
+#endif
+
+/* Grab all functions here in one section to avoid fail in long jump */
+__used
+__naked
__section(".psa_interface_thread_call")
-__naked static uint32_t psa_interface_unified_abi(uint32_t r0)
+static uint32_t psa_interface_unified_abi(uint32_t r0)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"movs r2, #1 \n"
- "bl %a0 \n"
+ "bl spm_interface_thread_dispatcher \n"
"pop {r0-r4, pc} \n"
- :: "i" (spm_interface_thread_dispatcher)
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked uint32_t psa_framework_version_thread(void)
+uint32_t psa_framework_version_thread(void)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_client_psa_framework_version \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_client_psa_framework_version),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked uint32_t psa_version_thread(uint32_t sid)
+uint32_t psa_version_thread(uint32_t sid)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_client_psa_version \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_client_psa_version),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked psa_handle_t psa_connect_thread(uint32_t sid, uint32_t version)
+psa_handle_t psa_connect_thread(uint32_t sid, uint32_t version)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_client_psa_connect \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_client_psa_connect),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked psa_status_t tfm_psa_call_pack_thread(psa_handle_t handle,
+psa_status_t tfm_psa_call_pack_thread(psa_handle_t handle,
uint32_t ctrl_param,
const psa_invec *in_vec,
psa_outvec *out_vec)
@@ -90,32 +96,30 @@
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_client_psa_call \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_client_psa_call),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked void psa_close_thread(psa_handle_t handle)
+void psa_close_thread(psa_handle_t handle)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_client_psa_close \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_client_psa_close),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked psa_signal_t psa_wait_thread(psa_signal_t signal_mask,
+psa_signal_t psa_wait_thread(psa_signal_t signal_mask,
uint32_t timeout)
{
__asm volatile(
@@ -123,47 +127,45 @@
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_partition_psa_wait \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_psa_wait),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked psa_status_t psa_get_thread(psa_signal_t signal, psa_msg_t *msg)
+psa_status_t psa_get_thread(psa_signal_t signal, psa_msg_t *msg)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_partition_psa_get \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_psa_get),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked void psa_set_rhandle_thread(psa_handle_t msg_handle, void *rhandle)
+void psa_set_rhandle_thread(psa_handle_t msg_handle, void *rhandle)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_psa_set_rhandle),
- "i" (psa_interface_unified_abi)
+ "ldr r0, =tfm_spm_partition_psa_set_rhandle \n"
+ "mov r1, sp \n"
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked size_t psa_read_thread(psa_handle_t msg_handle, uint32_t invec_idx,
+size_t psa_read_thread(psa_handle_t msg_handle, uint32_t invec_idx,
void *buffer, size_t num_bytes)
{
__asm volatile(
@@ -171,16 +173,15 @@
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_partition_psa_read \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_psa_read),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked size_t psa_skip_thread(psa_handle_t msg_handle,
+size_t psa_skip_thread(psa_handle_t msg_handle,
uint32_t invec_idx, size_t num_bytes)
{
__asm volatile(
@@ -188,16 +189,15 @@
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_partition_psa_skip \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_psa_skip),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked void psa_write_thread(psa_handle_t msg_handle, uint32_t outvec_idx,
+void psa_write_thread(psa_handle_t msg_handle, uint32_t outvec_idx,
const void *buffer, size_t num_bytes)
{
__asm volatile(
@@ -205,155 +205,144 @@
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_partition_psa_write \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_psa_write),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked void psa_reply_thread(psa_handle_t msg_handle, psa_status_t status)
+void psa_reply_thread(psa_handle_t msg_handle, psa_status_t status)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_partition_psa_reply \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_psa_reply),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked void psa_notify_thread(int32_t partition_id)
+void psa_notify_thread(int32_t partition_id)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_partition_psa_notify \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_psa_notify),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked void psa_clear_thread(void)
+void psa_clear_thread(void)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_partition_psa_clear \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_psa_clear),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked void psa_eoi_thread(psa_signal_t irq_signal)
+void psa_eoi_thread(psa_signal_t irq_signal)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_partition_psa_eoi \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_psa_eoi),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked void psa_panic_thread(void)
+void psa_panic_thread(void)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_partition_psa_panic \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_psa_panic),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked psa_irq_status_t psa_irq_disable_thread(psa_signal_t irq_signal)
+psa_irq_status_t psa_irq_disable_thread(psa_signal_t irq_signal)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_partition_irq_disable \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_irq_disable),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked void psa_irq_enable_thread(psa_signal_t irq_signal)
+void psa_irq_enable_thread(psa_signal_t irq_signal)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_partition_irq_enable \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_irq_enable),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked void psa_reset_signal_thread(psa_signal_t irq_signal)
+void psa_reset_signal_thread(psa_signal_t irq_signal)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_partition_psa_reset_signal \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_partition_psa_reset_signal),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
+__naked
__section(".psa_interface_thread_call")
-__naked uint32_t psa_rot_lifecycle_state_thread(void)
+uint32_t psa_rot_lifecycle_state_thread(void)
{
__asm volatile(
#if !defined(__ICCARM__)
".syntax unified \n"
#endif
"push {r0-r4, lr} \n"
- "ldr r0, =%a0 \n"
+ "ldr r0, =tfm_spm_get_lifecycle_state \n"
"mov r1, sp \n"
- "b %a1 \n"
- :: "i" (tfm_spm_get_lifecycle_state),
- "i" (psa_interface_unified_abi)
+ "b psa_interface_unified_abi \n"
);
}
diff --git a/secure_fw/spm/cmsis_psa/spm_thread_call.c b/secure_fw/spm/cmsis_psa/spm_thread_call.c
index cdd7b95..76bf0e6 100644
--- a/secure_fw/spm/cmsis_psa/spm_thread_call.c
+++ b/secure_fw/spm/cmsis_psa/spm_thread_call.c
@@ -31,6 +31,7 @@
typedef uint32_t (*target_fn_t)(uint32_t a0, uint32_t a1,
uint32_t a2, uint32_t a3);
+__used
void spcall_execute_c(uintptr_t fn_addr, uintptr_t frame_addr)
{
struct spcall_abi_frame_t *p_frame =
@@ -40,6 +41,7 @@
p_frame->a2, p_frame->a3);
}
+__used
void spm_interface_thread_dispatcher(uintptr_t fn_addr,
uintptr_t frame_addr,
uint32_t switch_stack)
diff --git a/secure_fw/spm/cmsis_psa/tfm_psa_api_veneers.c b/secure_fw/spm/cmsis_psa/tfm_psa_api_veneers.c
index a3af13b..311b42a 100644
--- a/secure_fw/spm/cmsis_psa/tfm_psa_api_veneers.c
+++ b/secure_fw/spm/cmsis_psa/tfm_psa_api_veneers.c
@@ -27,48 +27,54 @@
* - SVC here to take hardware context management advantages.
*/
+#if defined(__ICCARM__)
+
+#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
+
+#pragma required = tfm_spm_client_psa_framework_version
+#pragma required = tfm_spm_client_psa_version
+#pragma required = tfm_spm_client_psa_connect
+#pragma required = tfm_spm_client_psa_call
+#pragma required = tfm_spm_client_psa_close
+#pragma required = spm_interface_thread_dispatcher
+
+#endif /* CONFIG_TFM_PSA_API_THREAD_CALL */
+
+#endif
+
__tfm_psa_secure_gateway_attributes__
uint32_t tfm_psa_framework_version_veneer(void)
{
__ASM volatile(
#if !defined(__ICCARM__)
- ".syntax unified \n"
+ ".syntax unified \n"
#endif
#if !defined(__ARM_ARCH_8_1M_MAIN__)
- " ldr r2, [sp] \n"
- " ldr r3, ="M2S(STACK_SEAL_PATTERN)" \n"
- " cmp r2, r3 \n"
- " bne reent_panic1 \n"
+ " ldr r2, [sp] \n"
+ " ldr r3, ="M2S(STACK_SEAL_PATTERN)" \n"
+ " cmp r2, r3 \n"
+ " bne reent_panic1 \n"
#endif
#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
- " push {r0-r4, lr} \n"
- " ldr r0, =%a0 \n"
- " mov r1, sp \n"
- " movs r2, #0 \n"
- " bl %a2 \n"
- " pop {r0-r3} \n"
- " pop {r2, r3} \n"
- " mov lr, r3 \n"
+ " push {r0-r4, lr} \n"
+ " ldr r0, =tfm_spm_client_psa_framework_version \n"
+ " mov r1, sp \n"
+ " movs r2, #0 \n"
+ " bl spm_interface_thread_dispatcher \n"
+ " pop {r0-r3} \n"
+ " pop {r2, r3} \n"
+ " mov lr, r3 \n"
#else
- " svc %0 \n"
+ " svc "M2S(TFM_SVC_PSA_FRAMEWORK_VERSION)" \n"
#endif
- " bxns lr \n"
+ " bxns lr \n"
#if !defined(__ARM_ARCH_8_1M_MAIN__)
- "reent_panic1: \n"
- " svc %1 \n"
- " b . \n"
-#endif
- : :
-#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
- "i" (tfm_spm_client_psa_framework_version),
- "I" (TFM_SVC_PSA_PANIC),
- "i" (spm_interface_thread_dispatcher)
-#else
- "I" (TFM_SVC_PSA_FRAMEWORK_VERSION),
- "I" (TFM_SVC_PSA_PANIC)
+ "reent_panic1: \n"
+ " svc "M2S(TFM_SVC_PSA_PANIC)" \n"
+ " b . \n"
#endif
);
}
@@ -78,43 +84,34 @@
{
__ASM volatile(
#if !defined(__ICCARM__)
- ".syntax unified \n"
+ ".syntax unified \n"
#endif
#if !defined(__ARM_ARCH_8_1M_MAIN__)
- " ldr r2, [sp] \n"
- " ldr r3, ="M2S(STACK_SEAL_PATTERN)" \n"
- " cmp r2, r3 \n"
- " bne reent_panic2 \n"
+ " ldr r2, [sp] \n"
+ " ldr r3, ="M2S(STACK_SEAL_PATTERN)" \n"
+ " cmp r2, r3 \n"
+ " bne reent_panic2 \n"
#endif
#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
- " push {r0-r4, lr} \n"
- " ldr r0, =%a0 \n"
- " mov r1, sp \n"
- " movs r2, #0 \n"
- " bl %a2 \n"
- " pop {r0-r3} \n"
- " pop {r2, r3} \n"
- " mov lr, r3 \n"
+ " push {r0-r4, lr} \n"
+ " ldr r0, =tfm_spm_client_psa_version \n"
+ " mov r1, sp \n"
+ " movs r2, #0 \n"
+ " bl spm_interface_thread_dispatcher \n"
+ " pop {r0-r3} \n"
+ " pop {r2, r3} \n"
+ " mov lr, r3 \n"
#else
- " svc %0 \n"
+ " svc "M2S(TFM_SVC_PSA_VERSION)" \n"
#endif
- " bxns lr \n"
+ " bxns lr \n"
#if !defined(__ARM_ARCH_8_1M_MAIN__)
- "reent_panic2: \n"
- " svc %1 \n"
- " b . \n"
-#endif
- : :
-#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
- "i" (tfm_spm_client_psa_version),
- "I" (TFM_SVC_PSA_PANIC),
- "i" (spm_interface_thread_dispatcher)
-#else
- "I" (TFM_SVC_PSA_VERSION),
- "I" (TFM_SVC_PSA_PANIC)
+ "reent_panic2: \n"
+ " svc "M2S(TFM_SVC_PSA_PANIC)" \n"
+ " b . \n"
#endif
);
}
@@ -124,43 +121,40 @@
{
__ASM volatile(
#if !defined(__ICCARM__)
- ".syntax unified \n"
+ ".syntax unified \n"
#endif
#if !defined(__ARM_ARCH_8_1M_MAIN__)
- " ldr r2, [sp] \n"
- " ldr r3, ="M2S(STACK_SEAL_PATTERN)" \n"
- " cmp r2, r3 \n"
- " bne reent_panic3 \n"
+ " ldr r2, [sp] \n"
+ " ldr r3, ="M2S(STACK_SEAL_PATTERN)" \n"
+ " cmp r2, r3 \n"
+ " bne reent_panic3 \n"
#endif
#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
- " push {r0-r4, lr} \n"
- " ldr r0, =%a0 \n"
- " mov r1, sp \n"
- " movs r2, #0 \n"
- " bl %a2 \n"
- " pop {r0-r3} \n"
- " pop {r2, r3} \n"
- " mov lr, r3 \n"
+ " push {r0-r4, lr} \n"
+ " ldr r0, =tfm_spm_client_psa_connect \n"
+ " mov r1, sp \n"
+ " movs r2, #0 \n"
+ " bl spm_interface_thread_dispatcher \n"
+ " pop {r0-r3} \n"
+ " pop {r2, r3} \n"
+ " mov lr, r3 \n"
#else
- " svc %0 \n"
+ " svc "M2S(TFM_SVC_PSA_CONNECT)" \n"
#endif
- " bxns lr \n"
+ " bxns lr \n"
#if !defined(__ARM_ARCH_8_1M_MAIN__)
- "reent_panic3: \n"
- " svc %1 \n"
- " b . \n"
+ "reent_panic3: \n"
+ " svc "M2S(TFM_SVC_PSA_PANIC)" \n"
+ " b . \n"
#endif
: :
#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
- "i" (tfm_spm_client_psa_connect),
- "I" (TFM_SVC_PSA_PANIC),
- "i" (spm_interface_thread_dispatcher)
-#else
- "I" (TFM_SVC_PSA_CONNECT),
- "I" (TFM_SVC_PSA_PANIC)
+ "i" (tfm_spm_client_psa_connect),
+ "I" (TFM_SVC_PSA_PANIC),
+ "i" (spm_interface_thread_dispatcher)
#endif
);
}
@@ -173,45 +167,42 @@
{
__ASM volatile(
#if !defined(__ICCARM__)
- ".syntax unified \n"
+ ".syntax unified \n"
#endif
#if !defined(__ARM_ARCH_8_1M_MAIN__)
- " push {r2, r3} \n"
- " ldr r2, [sp, #8] \n"
- " ldr r3, ="M2S(STACK_SEAL_PATTERN)" \n"
- " cmp r2, r3 \n"
- " bne reent_panic4 \n"
- " pop {r2, r3} \n"
+ " push {r2, r3} \n"
+ " ldr r2, [sp, #8] \n"
+ " ldr r3, ="M2S(STACK_SEAL_PATTERN)" \n"
+ " cmp r2, r3 \n"
+ " bne reent_panic4 \n"
+ " pop {r2, r3} \n"
#endif
#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
- " push {r0-r4, lr} \n"
- " ldr r0, =%a0 \n"
- " mov r1, sp \n"
- " movs r2, #0 \n"
- " bl %a2 \n"
- " pop {r0-r3} \n"
- " pop {r2, r3} \n"
- " mov lr, r3 \n"
+ " push {r0-r4, lr} \n"
+ " ldr r0, =tfm_spm_client_psa_call \n"
+ " mov r1, sp \n"
+ " movs r2, #0 \n"
+ " bl spm_interface_thread_dispatcher \n"
+ " pop {r0-r3} \n"
+ " pop {r2, r3} \n"
+ " mov lr, r3 \n"
#else
- " svc %0 \n"
+ " svc "M2S(TFM_SVC_PSA_CALL)" \n"
#endif
- " bxns lr \n"
+ " bxns lr \n"
#if !defined(__ARM_ARCH_8_1M_MAIN__)
- "reent_panic4: \n"
- " svc %1 \n"
- " b . \n"
+ "reent_panic4: \n"
+ " svc "M2S(TFM_SVC_PSA_PANIC)" \n"
+ " b . \n"
#endif
: :
#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
- "i" (tfm_spm_client_psa_call),
- "I" (TFM_SVC_PSA_PANIC),
- "i" (spm_interface_thread_dispatcher)
-#else
- "I" (TFM_SVC_PSA_CALL),
- "I" (TFM_SVC_PSA_PANIC)
+ "i" (tfm_spm_client_psa_call),
+ "I" (TFM_SVC_PSA_PANIC),
+ "i" (spm_interface_thread_dispatcher)
#endif
);
}
@@ -221,43 +212,35 @@
{
__ASM volatile(
#if !defined(__ICCARM__)
- ".syntax unified \n"
+ ".syntax unified \n"
#endif
#if !defined(__ARM_ARCH_8_1M_MAIN__)
- " ldr r2, [sp] \n"
- " ldr r3, ="M2S(STACK_SEAL_PATTERN)" \n"
- " cmp r2, r3 \n"
- " bne reent_panic5 \n"
+ " ldr r2, [sp] \n"
+ " ldr r3, ="M2S(STACK_SEAL_PATTERN)" \n"
+ " cmp r2, r3 \n"
+ " bne reent_panic5 \n"
#endif
#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
- " push {r0-r4, lr} \n"
- " ldr r0, =%a0 \n"
- " mov r1, sp \n"
- " movs r2, #0 \n"
- " bl %a2 \n"
- " pop {r0-r3} \n"
- " pop {r2, r3} \n"
- " mov lr, r3 \n"
+ " push {r0-r4, lr} \n"
+ " ldr r0, =tfm_spm_client_psa_close \n"
+ " mov r1, sp \n"
+ " movs r2, #0 \n"
+ " bl spm_interface_thread_dispatcher \n"
+ " pop {r0-r3} \n"
+ " pop {r2, r3} \n"
+ " mov lr, r3 \n"
#else
- " svc %0 \n"
+ " svc "M2S(TFM_SVC_PSA_CLOSE)" \n"
#endif
- " bxns lr \n"
+ " bxns lr \n"
#if !defined(__ARM_ARCH_8_1M_MAIN__)
- "reent_panic5: \n"
- " svc %1 \n"
- " b . \n"
+ "reent_panic5: \n"
+ " svc "M2S(TFM_SVC_PSA_PANIC)" \n"
+ " b . \n"
#endif
: :
-#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
- "i" (tfm_spm_client_psa_close),
- "I" (TFM_SVC_PSA_PANIC),
- "i" (spm_interface_thread_dispatcher)
-#else
- "I" (TFM_SVC_PSA_CLOSE),
- "I" (TFM_SVC_PSA_PANIC)
-#endif
);
}
diff --git a/secure_fw/spm/include/tfm_arch_v8m.h b/secure_fw/spm/include/tfm_arch_v8m.h
index 0c2f519..f03b40a 100644
--- a/secure_fw/spm/include/tfm_arch_v8m.h
+++ b/secure_fw/spm/include/tfm_arch_v8m.h
@@ -45,7 +45,8 @@
#define EXC_NUM_SVCALL (11)
#define EXC_NUM_PENDSV (14)
-#define VTOR_BASE (0xE000ED08)
+#define ICSR_ADDR (0xE000ED04)
+#define VTOR_ADDR (0xE000ED08)
/* Disable NS exceptions by setting NS PRIMASK to 1 */
#define TFM_NS_EXC_DISABLE() __TZ_set_PRIMASK_NS(1)
diff --git a/secure_fw/spm/include/utilities.h b/secure_fw/spm/include/utilities.h
index aec3ea0..2f27487 100644
--- a/secure_fw/spm/include/utilities.h
+++ b/secure_fw/spm/include/utilities.h
@@ -37,8 +37,8 @@
/* FixMe: Replace ERROR_MSG() in platform code with a suitable API */
#define ERROR_MSG(msg) SPMLOG_ERRMSG(msg "\r\n")
-/* Preprocessor to reference C MACRO to string in inline asm */
-#define M2S_HELPER(x) #x
-#define M2S(m) M2S_HELPER(m)
+/* Stringify preprocessors, no leading underscore. ('STRINGIFY') */
+#define STRINGIFY_EXPAND(x) #x
+#define M2S(m) STRINGIFY_EXPAND(m)
#endif /* __TFM_UTILS_H__ */