1 /*
2  * Copyright (c) 2021-2024, Arm Limited. All rights reserved.
3  * Copyright (c) 2023 Cypress Semiconductor Corporation (an Infineon
4  * company) or an affiliate of Cypress Semiconductor Corporation. All rights
5  * reserved.
6  *
7  * SPDX-License-Identifier: BSD-3-Clause
8  *
9  */
10 #include <stdint.h>
11 
12 #include "compiler_ext_defs.h"
13 #include "security_defs.h"
14 #include "tfm_arch.h"
15 #include "tfm_hal_platform.h"
16 
ns_agent_tz_main(uint32_t c_entry)17 __naked void ns_agent_tz_main(uint32_t c_entry)
18 {
19     __ASM volatile(
20         SYNTAX_UNIFIED
21         "   ldr      r2, [sp]                       \n"
22         "   ldr      r3, ="M2S(STACK_SEAL_PATTERN)" \n" /* SEAL double-check */
23         "   cmp      r2, r3                         \n"
24         "   bne      ns_agent_nspe_jump_panic       \n"
25 #if (CONFIG_TFM_FLOAT_ABI > 0)
26 /* IAR throws an error if the S0-S31 syntax is used.
27  * Splitting the command into two parts solved the issue.
28  */
29 #if defined(__ICCARM__)
30         "   vscclrm  {S0-S30, VPR}                  \n"
31         "   vscclrm  {S31, VPR}                     \n"
32 #else
33         "   vscclrm  {S0-S31, VPR}                  \n"
34 #endif
35         "   mov      r1, #0                         \n"
36         "   vmsr     fpscr_nzcvqc, r1               \n"
37         "   mrs      r1, control                    \n"
38         "   bic      r1, r1, #4                     \n"
39         "   msr      control, r1                    \n"
40         "   isb                                     \n"
41 #endif
42         "   clrm     {r1-r12, r14, apsr}            \n"
43         "   bic      r0, r0, #1                     \n"
44         "   bxns     r0                             \n"
45         "ns_agent_nspe_jump_panic:                  \n"
46         "   b        .                              \n"
47     );
48 }
49