]> begriffs open source - cmsis/blob - CMSIS/Core_A/Include/cmsis_cp15.h
Core(A): Refactored all Coprocessor 15 related core functions into a common header...
[cmsis] / CMSIS / Core_A / Include / cmsis_cp15.h
1 /**************************************************************************//**
2  * @file     cmsis_armclang.h
3  * @brief    CMSIS compiler specific macros, functions, instructions
4  * @version  V1.00
5  * @date     05. Apr 2017
6  ******************************************************************************/
7 /*
8  * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
9  *
10  * SPDX-License-Identifier: Apache-2.0
11  *
12  * Licensed under the Apache License, Version 2.0 (the License); you may
13  * not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  * www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */
24
25 #ifndef __CMSIS_CP15_H
26 #define __CMSIS_CP15_H
27
28 /** \brief  Get ACTLR
29     \return               Auxiliary Control register value
30  */
31 __STATIC_FORCEINLINE uint32_t __get_ACTLR(void)
32 {
33   uint32_t result;
34 //   __ASM volatile("MRC p15, 0, %0, c1, c0, 1" : "=r" (result) : : "memory" );
35   __get_CP(15, 0, result, 1, 0, 1);
36   return(result);
37 }
38
39 /** \brief  Set ACTLR
40     \param [in]    actlr  Auxiliary Control value to set
41  */
42 __STATIC_FORCEINLINE void __set_ACTLR(uint32_t actlr)
43 {
44   // __ASM volatile ("MCR p15, 0, %0, c1, c0, 1" : : "r" (actlr) : "memory");
45   __set_CP(15, 0, actlr, 1, 0, 1);
46 }
47
48 /** \brief  Get CPACR
49     \return               Coprocessor Access Control register value
50  */
51 __STATIC_FORCEINLINE uint32_t __get_CPACR(void)
52 {
53   uint32_t result;
54 //   __ASM volatile("MRC p15, 0, %0, c1, c0, 2" : "=r"(result) : : "memory");
55   __get_CP(15, 0, result, 1, 0, 2);
56   return result;
57 }
58
59 /** \brief  Set CPACR
60     \param [in]    cpacr  Coprocessor Access Control value to set
61  */
62 __STATIC_FORCEINLINE void __set_CPACR(uint32_t cpacr)
63 {
64 //   __ASM volatile("MCR p15, 0, %0, c1, c0, 2" : : "r"(cpacr) : "memory");
65   __set_CP(15, 0, cpacr, 1, 0, 2);
66 }
67
68 /** \brief  Get DFSR
69     \return               Data Fault Status Register value
70  */
71 __STATIC_FORCEINLINE uint32_t __get_DFSR(void)
72 {
73   uint32_t result;
74 //   __ASM volatile("MRC p15, 0, %0, c5, c0, 0" : "=r"(result) : : "memory");
75   __get_CP(15, 0, result, 5, 0, 0);
76   return result;
77 }
78
79 /** \brief  Set DFSR
80     \param [in]    dfsr  Data Fault Status value to set
81  */
82 __STATIC_FORCEINLINE void __set_DFSR(uint32_t dfsr)
83 {
84 //   __ASM volatile("MCR p15, 0, %0, c5, c0, 0" : : "r"(dfsr) : "memory");
85   __set_CP(15, 0, dfsr, 5, 0, 0);
86 }
87
88 /** \brief  Get IFSR
89     \return               Instruction Fault Status Register value
90  */
91 __STATIC_FORCEINLINE uint32_t __get_IFSR(void)
92 {
93   uint32_t result;
94 //   __ASM volatile("MRC p15, 0, %0, c5, c0, 1" : "=r"(result) : : "memory");
95   __get_CP(15, 0, result, 5, 0, 1);
96   return result;
97 }
98
99 /** \brief  Set IFSR
100     \param [in]    ifsr  Instruction Fault Status value to set
101  */
102 __STATIC_FORCEINLINE void __set_IFSR(uint32_t ifsr)
103 {
104 //   __ASM volatile("MCR p15, 0, %0, c5, c0, 1" : : "r"(ifsr) : "memory");
105   __set_CP(15, 0, ifsr, 5, 0, 1);
106 }
107
108 /** \brief  Get ISR
109     \return               Interrupt Status Register value
110  */
111 __STATIC_FORCEINLINE uint32_t __get_ISR(void)
112 {
113   uint32_t result;
114 //   __ASM volatile("MRC p15, 0, %0, c12, c1, 0" : "=r"(result) : : "memory");
115   __get_CP(15, 0, result, 12, 1, 0);
116   return result;
117 }
118
119 /** \brief  Get CBAR
120     \return               Configuration Base Address register value
121  */
122 __STATIC_FORCEINLINE uint32_t __get_CBAR()
123 {
124   uint32_t result;
125 //   __ASM volatile("MRC p15, 4, %0, c15, c0, 0" : "=r"(result) : : "memory");
126   __get_CP(15, 4, result, 15, 0, 0);
127   return result;
128 }
129
130 /** \brief  Get TTBR0
131
132     This function returns the value of the Translation Table Base Register 0.
133
134     \return               Translation Table Base Register 0 value
135  */
136 __STATIC_FORCEINLINE uint32_t __get_TTBR0()
137 {
138   uint32_t result;
139 //   __ASM volatile("MRC p15, 0, %0, c2, c0, 0" : "=r"(result) : : "memory");
140   __get_CP(15, 0, result, 2, 0, 0);
141   return result;
142 }
143
144 /** \brief  Set TTBR0
145
146     This function assigns the given value to the Translation Table Base Register 0.
147
148     \param [in]    ttbr0  Translation Table Base Register 0 value to set
149  */
150 __STATIC_FORCEINLINE void __set_TTBR0(uint32_t ttbr0)
151 {
152 //   __ASM volatile("MCR p15, 0, %0, c2, c0, 0" : : "r"(ttbr0) : "memory");
153   __set_CP(15, 0, ttbr0, 2, 0, 0);
154 }
155
156 /** \brief  Get DACR
157
158     This function returns the value of the Domain Access Control Register.
159
160     \return               Domain Access Control Register value
161  */
162 __STATIC_FORCEINLINE uint32_t __get_DACR()
163 {
164   uint32_t result;
165 //   __ASM volatile("MRC p15, 0, %0, c3, c0, 0" : "=r"(result) : : "memory");
166   __get_CP(15, 0, result, 3, 0, 0);
167   return result;
168 }
169
170 /** \brief  Set DACR
171
172     This function assigns the given value to the Domain Access Control Register.
173
174     \param [in]    dacr   Domain Access Control Register value to set
175  */
176 __STATIC_FORCEINLINE void __set_DACR(uint32_t dacr)
177 {
178 //   __ASM volatile("MCR p15, 0, %0, c3, c0, 0" : : "r"(dacr) : "memory");
179   __set_CP(15, 0, dacr, 3, 0, 0);
180 }
181
182 /** \brief  Set SCTLR
183
184     This function assigns the given value to the System Control Register.
185
186     \param [in]    sctlr  System Control Register value to set
187  */
188 __STATIC_FORCEINLINE void __set_SCTLR(uint32_t sctlr)
189 {
190 //   __ASM volatile("MCR p15, 0, %0, c1, c0, 0" : : "r"(sctlr) : "memory");
191   __set_CP(15, 0, sctlr, 1, 0, 0);
192 }
193
194 /** \brief  Get SCTLR
195     \return               System Control Register value
196  */
197 __STATIC_FORCEINLINE uint32_t __get_SCTLR()
198 {
199   uint32_t result;
200 //   __ASM volatile("MRC p15, 0, %0, c1, c0, 0" : "=r"(result) : : "memory");
201   __get_CP(15, 0, result, 1, 0, 0);
202   return result;
203 }
204
205 /** \brief  Set ACTRL
206     \param [in]    actrl  Auxiliary Control Register value to set
207  */
208 __STATIC_FORCEINLINE void __set_ACTRL(uint32_t actrl)
209 {
210 //   __ASM volatile("MCR p15, 0, %0, c1, c0, 1" : : "r"(actrl) : "memory");
211   __set_CP(15, 0, actrl, 1, 0, 1);
212 }
213
214 /** \brief  Get ACTRL
215     \return               Auxiliary Control Register value
216  */
217 __STATIC_FORCEINLINE uint32_t __get_ACTRL(void)
218 {
219   uint32_t result;
220 //   __ASM volatile("MRC p15, 0, %0, c1, c0, 1" : "=r"(result) : : "memory");
221   __get_CP(15, 0, result, 1, 0, 1);
222   return result;
223 }
224
225 /** \brief  Get MPIDR
226
227     This function returns the value of the Multiprocessor Affinity Register.
228
229     \return               Multiprocessor Affinity Register value
230  */
231 __STATIC_FORCEINLINE uint32_t __get_MPIDR(void)
232 {
233   uint32_t result;
234 //   __ASM volatile("MRC p15, 0, %0, c0, c0, 5" : "=r"(result) : : "memory");
235   __get_CP(15, 0, result, 0, 0, 5);
236   return result;
237 }
238
239  /** \brief  Get VBAR
240
241     This function returns the value of the Vector Base Address Register.
242
243     \return               Vector Base Address Register
244  */
245 __STATIC_FORCEINLINE uint32_t __get_VBAR(void)
246 {
247   uint32_t result;
248 //   __ASM volatile("MRC p15, 0, %0, c12, c0, 0" : "=r"(result) : : "memory");
249   __get_CP(15, 0, result, 12, 0, 0);
250   return result;
251 }
252
253 /** \brief  Set VBAR
254
255     This function assigns the given value to the Vector Base Address Register.
256
257     \param [in]    vbar  Vector Base Address Register value to set
258  */
259 __STATIC_FORCEINLINE void __set_VBAR(uint32_t vbar)
260 {
261 //   __ASM volatile("MCR p15, 0, %0, c12, c0, 1" : : "r"(vbar) : "memory");
262   __set_CP(15, 0, vbar, 12, 0, 1);
263 }
264
265 #if defined(__CORTEX_A) && (__CORTEX_A == 7U) && \
266     defined(__TIM_PRESENT) && (__TIM_PRESENT == 1U)
267
268 /** \brief  Set CNTFRQ
269
270   This function assigns the given value to PL1 Physical Timer Counter Frequency Register (CNTFRQ).
271
272   \param [in]    value  CNTFRQ Register value to set
273 */
274 __STATIC_FORCEINLINE void __set_CNTFRQ(uint32_t value)
275 {
276   // __ASM volatile("MCR p15, 0, %0, c14, c0, 0" : : "r"(value) : "memory");
277   __set_CP(15, 0, value, 14, 0, 0);
278 }
279
280 /** \brief  Get CNTFRQ
281
282     This function returns the value of the PL1 Physical Timer Counter Frequency Register (CNTFRQ).
283
284     \return               CNTFRQ Register value
285  */
286 __STATIC_FORCEINLINE uint32_t __get_CNTFRQ()
287 {
288   uint32_t result;
289   // __ASM volatile("MRC p15, 0, %0, c14, c0, 0" : "=r"(result) : : "memory");
290   __get_CP(15, 0, result, 14, 0 , 0);
291   return result;
292 }
293
294 /** \brief  Set CNTP_TVAL
295
296   This function assigns the given value to PL1 Physical Timer Value Register (CNTP_TVAL).
297
298   \param [in]    value  CNTP_TVAL Register value to set
299 */
300 __STATIC_FORCEINLINE void __set_CNTP_TVAL(uint32_t value)
301 {
302   // __ASM volatile("MCR p15, 0, %0, c14, c2, 0" : : "r"(value) : "memory");
303   __set_CP(15, 0, value, 14, 2, 0);
304 }
305
306 /** \brief  Get CNTP_TVAL
307
308     This function returns the value of the PL1 Physical Timer Value Register (CNTP_TVAL).
309
310     \return               CNTP_TVAL Register value
311  */
312 __STATIC_FORCEINLINE uint32_t __get_CNTP_TVAL()
313 {
314   uint32_t result;
315   // __ASM volatile("MRC p15, 0, %0, c14, c2, 0" : "=r"(result) : : "memory");
316   __get_CP(15, 0, result, 14, 2, 0);
317   return result;
318 }
319
320 /** \brief  Set CNTP_CTL
321
322   This function assigns the given value to PL1 Physical Timer Control Register (CNTP_CTL).
323
324   \param [in]    value  CNTP_CTL Register value to set
325 */
326 __STATIC_FORCEINLINE void __set_CNTP_CTL(uint32_t value)
327 {
328   // __ASM volatile("MCR p15, 0, %0, c14, c2, 1" : : "r"(value) : "memory");
329   __set_CP(15, 0, value, 14, 2, 1);
330 }
331
332 /** \brief  Get CNTP_CTL register
333     \return               CNTP_CTL Register value
334  */
335 __STATIC_FORCEINLINE uint32_t __get_CNTP_CTL()
336 {
337   uint32_t result;
338   // __ASM volatile("MRC p15, 0, %0, c14, c2, 1" : "=r"(result) : : "memory");
339   __get_CP(15, 0, result, 14, 2, 1);
340   return result;
341 }
342
343 #endif
344
345 /** \brief  Set TLBIALL
346
347   TLB Invalidate All
348  */
349 __STATIC_FORCEINLINE void __set_TLBIALL(uint32_t value)
350 {
351 //   __ASM volatile("MCR p15, 0, %0, c8, c7, 0" : : "r"(value) : "memory");
352   __set_CP(15, 0, value, 8, 7, 0);
353 }
354
355 /** \brief  Set BPIALL.
356
357   Branch Predictor Invalidate All
358  */
359 __STATIC_FORCEINLINE void __set_BPIALL(uint32_t value)
360 {
361 //   __ASM volatile("MCR p15, 0, %0, c7, c5, 6" : : "r"(value) : "memory");
362   __set_CP(15, 0, value, 7, 5, 6);
363 }
364
365 /** \brief  Set ICIALLU
366
367   Instruction Cache Invalidate All
368  */
369 __STATIC_FORCEINLINE void __set_ICIALLU(uint32_t value)
370 {
371 //   __ASM volatile("MCR p15, 0, %0, c7, c5, 0" : : "r"(value) : "memory");
372   __set_CP(15, 0, value, 7, 5, 0);
373 }
374
375 /** \brief  Set DCCMVAC
376
377   Data cache clean
378  */
379 __STATIC_FORCEINLINE void __set_DCCMVAC(uint32_t value)
380 {
381 //   __ASM volatile("MCR p15, 0, %0, c7, c10, 1" : : "r"(value) : "memory");
382   __set_CP(15, 0, value, 7, 10, 1);
383 }
384
385 /** \brief  Set DCIMVAC
386
387   Data cache invalidate
388  */
389 __STATIC_FORCEINLINE void __set_DCIMVAC(uint32_t value)
390 {
391 //   __ASM volatile("MCR p15, 0, %0, c7, c6, 1" : : "r"(value) : "memory");
392   __set_CP(15, 0, value, 7, 6, 1);
393 }
394
395 /** \brief  Set DCCIMVAC
396
397   Data cache clean and invalidate
398  */
399 __STATIC_FORCEINLINE void __set_DCCIMVAC(uint32_t value)
400 {
401 //   __ASM volatile("MCR p15, 0, %0, c7, c14, 1" : : "r"(value) : "memory");
402   __set_CP(15, 0, value, 7, 14, 1);
403 }
404
405 #endif