1 /* ARMv8-M Secure Extensions intrinsics include file.
3 Copyright (C) 2015-2017 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
40 #ifdef __ARM_BIG_ENDIAN
43 struct cmse_address_info
{
44 #if __ARM_FEATURE_CMSE & 2
45 unsigned idau_region
:8;
46 unsigned idau_region_valid
:1;
48 unsigned nonsecure_readwrite_ok
:1;
49 unsigned nonsecure_read_ok
:1;
53 unsigned readwrite_ok
:1;
55 #if __ARM_FEATURE_CMSE & 2
56 unsigned sau_region_valid
:1;
60 unsigned mpu_region_valid
:1;
61 #if __ARM_FEATURE_CMSE & 2
62 unsigned sau_region
:8;
66 unsigned mpu_region
:8;
69 } cmse_address_info_t
;
74 struct cmse_address_info
{
75 unsigned mpu_region
:8;
76 #if __ARM_FEATURE_CMSE & 2
77 unsigned sau_region
:8;
81 unsigned mpu_region_valid
:1;
82 #if __ARM_FEATURE_CMSE & 2
83 unsigned sau_region_valid
:1;
88 unsigned readwrite_ok
:1;
89 #if __ARM_FEATURE_CMSE & 2
90 unsigned nonsecure_read_ok
:1;
91 unsigned nonsecure_readwrite_ok
:1;
93 unsigned idau_region_valid
:1;
94 unsigned idau_region
:8;
100 } cmse_address_info_t
;
102 #endif /* __ARM_BIG_ENDIAN */
104 #define cmse_TT_fptr(p) (__cmse_TT_fptr ((__cmse_fptr)(p)))
106 typedef void (*__cmse_fptr
)(void);
108 #define __CMSE_TT_ASM(flags) \
110 cmse_address_info_t __result; \
111 __asm__ ("tt" # flags " %0,%1" \
118 __extension__
static __inline
__attribute__ ((__always_inline__
))
120 __cmse_TT_fptr (__cmse_fptr __p
)
123 __extension__
static __inline
__attribute__ ((__always_inline__
))
128 #define cmse_TTT_fptr(p) (__cmse_TTT_fptr ((__cmse_fptr)(p)))
130 __extension__
static __inline
__attribute__ ((__always_inline__
))
132 __cmse_TTT_fptr (__cmse_fptr __p
)
135 __extension__
static __inline
__attribute__ ((__always_inline__
))
140 #if __ARM_FEATURE_CMSE & 2
142 #define cmse_TTA_fptr(p) (__cmse_TTA_fptr ((__cmse_fptr)(p)))
144 __extension__
static __inline
__attribute__ ((__always_inline__
))
146 __cmse_TTA_fptr (__cmse_fptr __p
)
149 __extension__
static __inline
__attribute__ ((__always_inline__
))
154 #define cmse_TTAT_fptr(p) (__cmse_TTAT_fptr ((__cmse_fptr)(p)))
156 __extension__
static __inline cmse_address_info_t
157 __attribute__ ((__always_inline__
))
158 __cmse_TTAT_fptr (__cmse_fptr __p
)
161 __extension__
static __inline cmse_address_info_t
162 __attribute__ ((__always_inline__
))
163 cmse_TTAT (void *__p
)
166 /* FIXME: diagnose use outside cmse_nonsecure_entry functions. */
167 __extension__
static __inline
int __attribute__ ((__always_inline__
))
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_t) (p) & ~1))
179 #define cmse_is_nsfptr(p) (!((intptr_t) (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 cmse_check_address_range (void *, size_t, int);
190 #define cmse_check_pointed_object(p, f) \
191 ((typeof ((p))) cmse_check_address_range ((p), sizeof (*(p)), (f)))
193 #endif /* __ARM_FEATURE_CMSE & 1 */
199 #endif /* _GCC_ARM_CMSE_H */