Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/arm/arm_cmse.h @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* ARMv8-M Secure Extensions intrinsics include file. | |
2 | |
3 Copyright (C) 2015-2017 Free Software Foundation, Inc. | |
4 Contributed by ARM Ltd. | |
5 | |
6 This file is part of GCC. | |
7 | |
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. | |
12 | |
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. | |
17 | |
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. | |
21 | |
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/>. */ | |
26 | |
27 | |
28 #ifndef _GCC_ARM_CMSE_H | |
29 #define _GCC_ARM_CMSE_H | |
30 | |
31 #ifdef __cplusplus | |
32 extern "C" { | |
33 #endif | |
34 | |
35 #if __ARM_FEATURE_CMSE & 1 | |
36 | |
37 #include <stddef.h> | |
38 #include <stdint.h> | |
39 | |
40 #ifdef __ARM_BIG_ENDIAN | |
41 | |
42 typedef union { | |
43 struct cmse_address_info { | |
44 #if __ARM_FEATURE_CMSE & 2 | |
45 unsigned idau_region:8; | |
46 unsigned idau_region_valid:1; | |
47 unsigned secure:1; | |
48 unsigned nonsecure_readwrite_ok:1; | |
49 unsigned nonsecure_read_ok:1; | |
50 #else | |
51 unsigned :12; | |
52 #endif | |
53 unsigned readwrite_ok:1; | |
54 unsigned read_ok:1; | |
55 #if __ARM_FEATURE_CMSE & 2 | |
56 unsigned sau_region_valid:1; | |
57 #else | |
58 unsigned :1; | |
59 #endif | |
60 unsigned mpu_region_valid:1; | |
61 #if __ARM_FEATURE_CMSE & 2 | |
62 unsigned sau_region:8; | |
63 #else | |
64 unsigned :8; | |
65 #endif | |
66 unsigned mpu_region:8; | |
67 } flags; | |
68 unsigned value; | |
69 } cmse_address_info_t; | |
70 | |
71 #else | |
72 | |
73 typedef union { | |
74 struct cmse_address_info { | |
75 unsigned mpu_region:8; | |
76 #if __ARM_FEATURE_CMSE & 2 | |
77 unsigned sau_region:8; | |
78 #else | |
79 unsigned :8; | |
80 #endif | |
81 unsigned mpu_region_valid:1; | |
82 #if __ARM_FEATURE_CMSE & 2 | |
83 unsigned sau_region_valid:1; | |
84 #else | |
85 unsigned :1; | |
86 #endif | |
87 unsigned read_ok:1; | |
88 unsigned readwrite_ok:1; | |
89 #if __ARM_FEATURE_CMSE & 2 | |
90 unsigned nonsecure_read_ok:1; | |
91 unsigned nonsecure_readwrite_ok:1; | |
92 unsigned secure:1; | |
93 unsigned idau_region_valid:1; | |
94 unsigned idau_region:8; | |
95 #else | |
96 unsigned :12; | |
97 #endif | |
98 } flags; | |
99 unsigned value; | |
100 } cmse_address_info_t; | |
101 | |
102 #endif /* __ARM_BIG_ENDIAN */ | |
103 | |
104 #define cmse_TT_fptr(p) (__cmse_TT_fptr ((__cmse_fptr)(p))) | |
105 | |
106 typedef void (*__cmse_fptr)(void); | |
107 | |
108 #define __CMSE_TT_ASM(flags) \ | |
109 { \ | |
110 cmse_address_info_t __result; \ | |
111 __asm__ ("tt" # flags " %0,%1" \ | |
112 : "=r"(__result) \ | |
113 : "r"(__p) \ | |
114 : "memory"); \ | |
115 return __result; \ | |
116 } | |
117 | |
118 __extension__ static __inline __attribute__ ((__always_inline__)) | |
119 cmse_address_info_t | |
120 __cmse_TT_fptr (__cmse_fptr __p) | |
121 __CMSE_TT_ASM () | |
122 | |
123 __extension__ static __inline __attribute__ ((__always_inline__)) | |
124 cmse_address_info_t | |
125 cmse_TT (void *__p) | |
126 __CMSE_TT_ASM () | |
127 | |
128 #define cmse_TTT_fptr(p) (__cmse_TTT_fptr ((__cmse_fptr)(p))) | |
129 | |
130 __extension__ static __inline __attribute__ ((__always_inline__)) | |
131 cmse_address_info_t | |
132 __cmse_TTT_fptr (__cmse_fptr __p) | |
133 __CMSE_TT_ASM (t) | |
134 | |
135 __extension__ static __inline __attribute__ ((__always_inline__)) | |
136 cmse_address_info_t | |
137 cmse_TTT (void *__p) | |
138 __CMSE_TT_ASM (t) | |
139 | |
140 #if __ARM_FEATURE_CMSE & 2 | |
141 | |
142 #define cmse_TTA_fptr(p) (__cmse_TTA_fptr ((__cmse_fptr)(p))) | |
143 | |
144 __extension__ static __inline __attribute__ ((__always_inline__)) | |
145 cmse_address_info_t | |
146 __cmse_TTA_fptr (__cmse_fptr __p) | |
147 __CMSE_TT_ASM (a) | |
148 | |
149 __extension__ static __inline __attribute__ ((__always_inline__)) | |
150 cmse_address_info_t | |
151 cmse_TTA (void *__p) | |
152 __CMSE_TT_ASM (a) | |
153 | |
154 #define cmse_TTAT_fptr(p) (__cmse_TTAT_fptr ((__cmse_fptr)(p))) | |
155 | |
156 __extension__ static __inline cmse_address_info_t | |
157 __attribute__ ((__always_inline__)) | |
158 __cmse_TTAT_fptr (__cmse_fptr __p) | |
159 __CMSE_TT_ASM (at) | |
160 | |
161 __extension__ static __inline cmse_address_info_t | |
162 __attribute__ ((__always_inline__)) | |
163 cmse_TTAT (void *__p) | |
164 __CMSE_TT_ASM (at) | |
165 | |
166 /* FIXME: diagnose use outside cmse_nonsecure_entry functions. */ | |
167 __extension__ static __inline int __attribute__ ((__always_inline__)) | |
168 cmse_nonsecure_caller (void) | |
169 { | |
170 return __builtin_arm_cmse_nonsecure_caller (); | |
171 } | |
172 | |
173 #define CMSE_AU_NONSECURE 2 | |
174 #define CMSE_MPU_NONSECURE 16 | |
175 #define CMSE_NONSECURE 18 | |
176 | |
177 #define cmse_nsfptr_create(p) ((typeof ((p))) ((intptr_t) (p) & ~1)) | |
178 | |
179 #define cmse_is_nsfptr(p) (!((intptr_t) (p) & 1)) | |
180 | |
181 #endif /* __ARM_FEATURE_CMSE & 2 */ | |
182 | |
183 #define CMSE_MPU_UNPRIV 4 | |
184 #define CMSE_MPU_READWRITE 1 | |
185 #define CMSE_MPU_READ 8 | |
186 | |
187 __extension__ void * | |
188 cmse_check_address_range (void *, size_t, int); | |
189 | |
190 #define cmse_check_pointed_object(p, f) \ | |
191 ((typeof ((p))) cmse_check_address_range ((p), sizeof (*(p)), (f))) | |
192 | |
193 #endif /* __ARM_FEATURE_CMSE & 1 */ | |
194 | |
195 #ifdef __cplusplus | |
196 } | |
197 #endif | |
198 | |
199 #endif /* _GCC_ARM_CMSE_H */ |