TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_nspm_ipc.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include <stdbool.h>
9 #include "tfm_spm_hal.h"
10 #include "psa/error.h"
11 #include "tfm_nspm.h"
12 #include "utilities.h"
13 #include "ext/tz_context.h"
14 
15 #define DEFAULT_NS_CLIENT_ID ((int32_t)-1)
16 
18 {
19  return DEFAULT_NS_CLIENT_ID;
20 }
21 
22 /* TF-M implementation of the CMSIS TZ RTOS thread context management API */
23 
26 /* This veneer is TF-M internal, not a secure service */
28 uint32_t TZ_InitContextSystem_S(void)
29 {
30  return 1U;
31 }
32 
37 /* This veneer is TF-M internal, not a secure service */
40 {
41  /* add attribute 'noinline' to avoid a build error. */
42  (void)module;
43  return 1U;
44 }
45 
49 /* This veneer is TF-M internal, not a secure service */
52 {
53  (void)id;
54  return 1U;
55 }
56 
60 /* This veneer is TF-M internal, not a secure service */
63 {
64  (void)id;
65  return 1U;
66 }
67 
71 /* This veneer is TF-M internal, not a secure service */
74 {
75  (void)id;
76  return 1U;
77 }
78 
79 /*
80  * 'r0' impliedly holds the address of non-secure entry,
81  * given during non-secure partition initialization.
82  */
83 __attribute__((naked, section("SFN")))
85 {
86  __ASM volatile(
87 #ifndef __ICCARM__
88  ".syntax unified \n"
89 #endif
90  "mov r4, r0 \n"
91  "movs r2, #1 \n" /* Clear Bit[0] for S to NS transition */
92  "bics r4, r2 \n"
93  "mov r0, r4 \n"
94  "mov r1, r4 \n"
95  "mov r2, r4 \n"
96  "mov r3, r4 \n"
97  "mov r5, r4 \n"
98  "mov r6, r4 \n"
99  "mov r7, r4 \n"
100  "mov r8, r4 \n"
101  "mov r9, r4 \n"
102  "mov r10, r4 \n"
103  "mov r11, r4 \n"
104  "mov r12, r4 \n"
105  "bxns r0 \n"
106  );
107 }
108 
110 {
111  /* SCB_NS.VTOR points to the Non-secure vector table base address */
112  SCB_NS->VTOR = tfm_spm_hal_get_ns_VTOR();
113 
114  /* Setups Main stack pointer of the non-secure code */
115  uint32_t ns_msp = tfm_spm_hal_get_ns_MSP();
116 
117  __TZ_set_MSP_NS(ns_msp);
118 }
__tfm_nspm_secure_gateway_attributes__ uint32_t TZ_InitContextSystem_S(void)
Definition: tfm_nspm_ipc.c:28
void tfm_nspm_thread_entry(void)
Definition: tfm_nspm_ipc.c:84
__tfm_nspm_secure_gateway_attributes__ uint32_t TZ_LoadContext_S(TZ_MemoryId_t id)
Definition: tfm_nspm_ipc.c:62
int32_t tfm_nspm_get_current_client_id(void)
Get the client ID of the current NS client.
Definition: tfm_nspm_ipc.c:17
__tfm_nspm_secure_gateway_attributes__ uint32_t TZ_StoreContext_S(TZ_MemoryId_t id)
Definition: tfm_nspm_ipc.c:73
#define __tfm_nspm_secure_gateway_attributes__
Attributes for secure gateway functions for NSPM.
Definition: tfm_nspm.h:33
__tfm_nspm_secure_gateway_attributes__ uint32_t TZ_FreeModuleContext_S(TZ_MemoryId_t id)
Definition: tfm_nspm_ipc.c:51
#define DEFAULT_NS_CLIENT_ID
Definition: tfm_nspm_ipc.c:15
Standard error codes for the SPM and RoT Services.
uint32_t TZ_MemoryId_t
Definition: tz_context.h:42
void configure_ns_code(void)
Definition: tfm_nspm_ipc.c:109
__tfm_nspm_secure_gateway_attributes__ TZ_MemoryId_t TZ_AllocModuleContext_S(TZ_ModuleId_t module)
Definition: tfm_nspm_ipc.c:39
uint32_t TZ_ModuleId_t
Definition: tz_context.h:38