1 /* ARMv8-M Secure Extensions intrinsics include file.
3 Copyright (C) 2015-2021 Free Software Foundation, Inc.
4 Contributed by ARM Ltd.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 3, or (at your
11 option) any later version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
28 #ifndef _GCC_ARM_CMSE_H
29 #define _GCC_ARM_CMSE_H
35 #if __ARM_FEATURE_CMSE & 1
39 #ifdef __ARM_BIG_ENDIAN
42 struct cmse_address_info
{
43 #if __ARM_FEATURE_CMSE & 2
44 unsigned idau_region
:8;
45 unsigned idau_region_valid
:1;
47 unsigned nonsecure_readwrite_ok
:1;
48 unsigned nonsecure_read_ok
:1;
52 unsigned readwrite_ok
:1;
54 #if __ARM_FEATURE_CMSE & 2
55 unsigned sau_region_valid
:1;
59 unsigned mpu_region_valid
:1;
60 #if __ARM_FEATURE_CMSE & 2
61 unsigned sau_region
:8;
65 unsigned mpu_region
:8;
68 } cmse_address_info_t
;
73 struct cmse_address_info
{
74 unsigned mpu_region
:8;
75 #if __ARM_FEATURE_CMSE & 2
76 unsigned sau_region
:8;
80 unsigned mpu_region_valid
:1;
81 #if __ARM_FEATURE_CMSE & 2
82 unsigned sau_region_valid
:1;
87 unsigned readwrite_ok
:1;
88 #if __ARM_FEATURE_CMSE & 2
89 unsigned nonsecure_read_ok
:1;
90 unsigned nonsecure_readwrite_ok
:1;
92 unsigned idau_region_valid
:1;
93 unsigned idau_region
:8;
99 } cmse_address_info_t
;
101 #endif /* __ARM_BIG_ENDIAN */
103 #define cmse_TT_fptr(p) (__cmse_TT_fptr ((__cmse_fptr)(p)))
105 typedef void (*__cmse_fptr
)(void);
107 #define __CMSE_TT_ASM(flags) \
109 cmse_address_info_t __result; \
110 __asm__ ("tt" # flags " %0,%1" \
117 __extension__
static __inline
__attribute__ ((__always_inline__
))
119 __cmse_TT_fptr (__cmse_fptr __p
)
122 __extension__
static __inline
__attribute__ ((__always_inline__
))
127 #define cmse_TTT_fptr(p) (__cmse_TTT_fptr ((__cmse_fptr)(p)))
129 __extension__
static __inline
__attribute__ ((__always_inline__
))
131 __cmse_TTT_fptr (__cmse_fptr __p
)
134 __extension__
static __inline
__attribute__ ((__always_inline__
))
139 #if __ARM_FEATURE_CMSE & 2
141 #define cmse_TTA_fptr(p) (__cmse_TTA_fptr ((__cmse_fptr)(p)))
143 __extension__
static __inline
__attribute__ ((__always_inline__
))
145 __cmse_TTA_fptr (__cmse_fptr __p
)
148 __extension__
static __inline
__attribute__ ((__always_inline__
))
153 #define cmse_TTAT_fptr(p) (__cmse_TTAT_fptr ((__cmse_fptr)(p)))
155 __extension__
static __inline cmse_address_info_t
156 __attribute__ ((__always_inline__
))
157 __cmse_TTAT_fptr (__cmse_fptr __p
)
160 __extension__
static __inline cmse_address_info_t
161 __attribute__ ((__always_inline__
))
162 cmse_TTAT (void *__p
)
165 /* FIXME: diagnose use outside cmse_nonsecure_entry functions. */
166 __extension__
static __inline
int __attribute__ ((__always_inline__
))
167 __attribute__ ((warn_unused_result
))
168 cmse_nonsecure_caller (void)
170 return __builtin_arm_cmse_nonsecure_caller ();
173 #define CMSE_AU_NONSECURE 2
174 #define CMSE_MPU_NONSECURE 16
175 #define CMSE_NONSECURE 18
177 #define cmse_nsfptr_create(p) ((__typeof__ ((p))) ((__INTPTR_TYPE__) (p) & ~1))
179 #define cmse_is_nsfptr(p) (!((__INTPTR_TYPE__) (p) & 1))
181 #endif /* __ARM_FEATURE_CMSE & 2 */
183 #define CMSE_MPU_UNPRIV 4
184 #define CMSE_MPU_READWRITE 1
185 #define CMSE_MPU_READ 8
188 __attribute__ ((warn_unused_result
))
189 cmse_check_address_range (void *, size_t, int);
191 #define cmse_check_pointed_object(p, f) \
192 ((__typeof__ ((p))) cmse_check_address_range ((p), sizeof (*(p)), (f)))
194 #endif /* __ARM_FEATURE_CMSE & 1 */
200 #endif /* _GCC_ARM_CMSE_H */