TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_arch_v6m_v7m.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 #ifndef __TFM_ARCH_V6M_V7M_H__
8 #define __TFM_ARCH_V6M_V7M_H__
9 
10 #include <stdint.h>
11 #include <stdbool.h>
12 #include "cmsis_compiler.h"
13 #include "utilities.h"
14 
15 #if !TFM_MULTI_CORE_TOPOLOGY
16 #error "Armv6-M/Armv7-M can only support multi-core TF-M now."
17 #endif
18 
19 #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
20 #define EXC_RETURN_FPU_FRAME_BASIC (1 << 4)
21 #endif
22 
23 /* Initial EXC_RETURN value in LR when a thread is loaded at the first time */
24 #define EXC_RETURN_THREAD_S_PSP 0xFFFFFFFD
25 
27  uint32_t r8;
28  uint32_t r9;
29  uint32_t r10;
30  uint32_t r11;
31  uint32_t r4;
32  uint32_t r5;
33  uint32_t r6;
34  uint32_t r7;
35  uint32_t sp;
36  uint32_t lr;
37 };
38 
48 __STATIC_INLINE bool is_return_secure_stack(uint32_t lr)
49 {
50  (void)lr;
51 
52  return true;
53 }
54 
55 #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
56 
65 __STATIC_INLINE bool is_stack_alloc_fp_space(uint32_t lr)
66 {
67  return (lr & EXC_RETURN_FPU_FRAME_BASIC) ? false : true;
68 }
69 #elif defined(__ARM_ARCH_6M__)
70 
78 __STATIC_INLINE bool is_stack_alloc_fp_space(uint32_t lr)
79 {
80  (void)lr;
81 
82  return false;
83 }
84 #endif
85 
91 __STATIC_INLINE void tfm_arch_set_psplim(uint32_t psplim)
92 {
93  /*
94  * Defined as an empty function now.
95  * The PSP limit value can be used in more strict memory check.
96  */
97  (void)psplim;
98 }
99 
107 __STATIC_INLINE uintptr_t tfm_arch_seal_thread_stack(uintptr_t stk)
108 {
109  TFM_CORE_ASSERT((stk & 0x7) == 0);
110  return stk;
111 }
112 
118 __STATIC_INLINE void tfm_arch_update_ctx(struct tfm_arch_ctx_t *p_actx)
119 {
120  __set_PSP(p_actx->sp);
121 }
122 
128 __STATIC_INLINE void tfm_arch_init_secure_msp(uint32_t msplim)
129 {
130  /*
131  * Defined as an empty function now.
132  * The MSP limit value can be used in more strict memory check.
133  */
134  (void)msplim;
135 }
136 
137 #endif
__STATIC_INLINE void tfm_arch_set_psplim(uint32_t psplim)
Set PSP limit value.
__STATIC_INLINE bool is_stack_alloc_fp_space(uint32_t lr)
Check whether the stack frame for this exception has space allocated for Floating Point(FP) state inf...
Definition: tfm_arch_v8m.h:97
#define EXC_RETURN_FPU_FRAME_BASIC
Definition: tfm_arch_v8m.h:21
__STATIC_INLINE void tfm_arch_init_secure_msp(uint32_t msplim)
Secure the MSP.
__STATIC_INLINE void tfm_arch_update_ctx(struct tfm_arch_ctx_t *p_actx)
Update architecture context value into hardware.
#define TFM_CORE_ASSERT(cond)
Definition: utilities.h:21
__STATIC_INLINE bool is_return_secure_stack(uint32_t lr)
Check whether Secure or Non-secure stack is used to restore stack frame on exception return...
__STATIC_INLINE uintptr_t tfm_arch_seal_thread_stack(uintptr_t stk)
Seal the thread stack.