1 /**************************************************************************//**
3 * @brief CMSIS compiler specific macros, functions, instructions
5 * @date 19. December 2022
6 ******************************************************************************/
8 * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
10 * SPDX-License-Identifier: Apache-2.0
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
16 * www.apache.org/licenses/LICENSE-2.0
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.
25 #if defined ( __ICCARM__ )
26 #pragma system_include /* treat file as system include file for MISRA check */
27 #elif defined (__clang__)
28 #pragma clang system_header /* treat file as system include file */
31 #ifndef __CMSIS_CP15_H
32 #define __CMSIS_CP15_H
35 \return Auxiliary Control register value
37 __STATIC_FORCEINLINE uint32_t __get_ACTLR(void)
40 __get_CP(15, 0, result, 1, 0, 1);
45 \param [in] actlr Auxiliary Control value to set
47 __STATIC_FORCEINLINE void __set_ACTLR(uint32_t actlr)
49 __set_CP(15, 0, actlr, 1, 0, 1);
53 \return Coprocessor Access Control register value
55 __STATIC_FORCEINLINE uint32_t __get_CPACR(void)
58 __get_CP(15, 0, result, 1, 0, 2);
63 \param [in] cpacr Coprocessor Access Control value to set
65 __STATIC_FORCEINLINE void __set_CPACR(uint32_t cpacr)
67 __set_CP(15, 0, cpacr, 1, 0, 2);
71 \return Data Fault Status Register value
73 __STATIC_FORCEINLINE uint32_t __get_DFSR(void)
76 __get_CP(15, 0, result, 5, 0, 0);
81 \param [in] dfsr Data Fault Status value to set
83 __STATIC_FORCEINLINE void __set_DFSR(uint32_t dfsr)
85 __set_CP(15, 0, dfsr, 5, 0, 0);
89 \return Instruction Fault Status Register value
91 __STATIC_FORCEINLINE uint32_t __get_IFSR(void)
94 __get_CP(15, 0, result, 5, 0, 1);
99 \param [in] ifsr Instruction Fault Status value to set
101 __STATIC_FORCEINLINE void __set_IFSR(uint32_t ifsr)
103 __set_CP(15, 0, ifsr, 5, 0, 1);
107 \return Interrupt Status Register value
109 __STATIC_FORCEINLINE uint32_t __get_ISR(void)
112 __get_CP(15, 0, result, 12, 1, 0);
117 \return Configuration Base Address register value
119 __STATIC_FORCEINLINE uint32_t __get_CBAR(void)
122 __get_CP(15, 4, result, 15, 0, 0);
128 This function returns the value of the Translation Table Base Register 0.
130 \return Translation Table Base Register 0 value
132 __STATIC_FORCEINLINE uint32_t __get_TTBR0(void)
135 __get_CP(15, 0, result, 2, 0, 0);
141 This function assigns the given value to the Translation Table Base Register 0.
143 \param [in] ttbr0 Translation Table Base Register 0 value to set
145 __STATIC_FORCEINLINE void __set_TTBR0(uint32_t ttbr0)
147 __set_CP(15, 0, ttbr0, 2, 0, 0);
152 This function returns the value of the Domain Access Control Register.
154 \return Domain Access Control Register value
156 __STATIC_FORCEINLINE uint32_t __get_DACR(void)
159 __get_CP(15, 0, result, 3, 0, 0);
165 This function assigns the given value to the Domain Access Control Register.
167 \param [in] dacr Domain Access Control Register value to set
169 __STATIC_FORCEINLINE void __set_DACR(uint32_t dacr)
171 __set_CP(15, 0, dacr, 3, 0, 0);
176 This function assigns the given value to the System Control Register.
178 \param [in] sctlr System Control Register value to set
180 __STATIC_FORCEINLINE void __set_SCTLR(uint32_t sctlr)
182 __set_CP(15, 0, sctlr, 1, 0, 0);
186 \return System Control Register value
188 __STATIC_FORCEINLINE uint32_t __get_SCTLR(void)
191 __get_CP(15, 0, result, 1, 0, 0);
196 \param [in] actrl Auxiliary Control Register value to set
198 __STATIC_FORCEINLINE void __set_ACTRL(uint32_t actrl)
200 __set_CP(15, 0, actrl, 1, 0, 1);
204 \return Auxiliary Control Register value
206 __STATIC_FORCEINLINE uint32_t __get_ACTRL(void)
209 __get_CP(15, 0, result, 1, 0, 1);
215 This function returns the value of the Multiprocessor Affinity Register.
217 \return Multiprocessor Affinity Register value
219 __STATIC_FORCEINLINE uint32_t __get_MPIDR(void)
222 __get_CP(15, 0, result, 0, 0, 5);
228 This function returns the value of the Vector Base Address Register.
230 \return Vector Base Address Register
232 __STATIC_FORCEINLINE uint32_t __get_VBAR(void)
235 __get_CP(15, 0, result, 12, 0, 0);
241 This function assigns the given value to the Vector Base Address Register.
243 \param [in] vbar Vector Base Address Register value to set
245 __STATIC_FORCEINLINE void __set_VBAR(uint32_t vbar)
247 __set_CP(15, 0, vbar, 12, 0, 0);
252 This function returns the value of the Monitor Vector Base Address Register.
254 \return Monitor Vector Base Address Register
256 __STATIC_FORCEINLINE uint32_t __get_MVBAR(void)
259 __get_CP(15, 0, result, 12, 0, 1);
265 This function assigns the given value to the Monitor Vector Base Address Register.
267 \param [in] mvbar Monitor Vector Base Address Register value to set
269 __STATIC_FORCEINLINE void __set_MVBAR(uint32_t mvbar)
271 __set_CP(15, 0, mvbar, 12, 0, 1);
274 #if (defined(__CORTEX_A) && (__CORTEX_A == 7U) && \
275 defined(__TIM_PRESENT) && (__TIM_PRESENT == 1U)) || \
278 /** \brief Set CNTFRQ
280 This function assigns the given value to PL1 Physical Timer Counter Frequency Register (CNTFRQ).
282 \param [in] value CNTFRQ Register value to set
284 __STATIC_FORCEINLINE void __set_CNTFRQ(uint32_t value)
286 __set_CP(15, 0, value, 14, 0, 0);
289 /** \brief Get CNTFRQ
291 This function returns the value of the PL1 Physical Timer Counter Frequency Register (CNTFRQ).
293 \return CNTFRQ Register value
295 __STATIC_FORCEINLINE uint32_t __get_CNTFRQ(void)
298 __get_CP(15, 0, result, 14, 0 , 0);
302 /** \brief Set CNTP_TVAL
304 This function assigns the given value to PL1 Physical Timer Value Register (CNTP_TVAL).
306 \param [in] value CNTP_TVAL Register value to set
308 __STATIC_FORCEINLINE void __set_CNTP_TVAL(uint32_t value)
310 __set_CP(15, 0, value, 14, 2, 0);
313 /** \brief Get CNTP_TVAL
315 This function returns the value of the PL1 Physical Timer Value Register (CNTP_TVAL).
317 \return CNTP_TVAL Register value
319 __STATIC_FORCEINLINE uint32_t __get_CNTP_TVAL(void)
322 __get_CP(15, 0, result, 14, 2, 0);
326 /** \brief Get CNTPCT
328 This function returns the value of the 64 bits PL1 Physical Count Register (CNTPCT).
330 \return CNTPCT Register value
332 __STATIC_FORCEINLINE uint64_t __get_CNTPCT(void)
335 __get_CP64(15, 0, result, 14);
339 /** \brief Set CNTP_CVAL
341 This function assigns the given value to 64bits PL1 Physical Timer CompareValue Register (CNTP_CVAL).
343 \param [in] value CNTP_CVAL Register value to set
345 __STATIC_FORCEINLINE void __set_CNTP_CVAL(uint64_t value)
347 __set_CP64(15, 2, value, 14);
350 /** \brief Get CNTP_CVAL
352 This function returns the value of the 64 bits PL1 Physical Timer CompareValue Register (CNTP_CVAL).
354 \return CNTP_CVAL Register value
356 __STATIC_FORCEINLINE uint64_t __get_CNTP_CVAL(void)
359 __get_CP64(15, 2, result, 14);
363 /** \brief Set CNTP_CTL
365 This function assigns the given value to PL1 Physical Timer Control Register (CNTP_CTL).
367 \param [in] value CNTP_CTL Register value to set
369 __STATIC_FORCEINLINE void __set_CNTP_CTL(uint32_t value)
371 __set_CP(15, 0, value, 14, 2, 1);
374 /** \brief Get CNTP_CTL register
375 \return CNTP_CTL Register value
377 __STATIC_FORCEINLINE uint32_t __get_CNTP_CTL(void)
380 __get_CP(15, 0, result, 14, 2, 1);
386 /** \brief Set TLBIALL
390 __STATIC_FORCEINLINE void __set_TLBIALL(uint32_t value)
392 __set_CP(15, 0, value, 8, 7, 0);
395 /** \brief Set BPIALL.
397 Branch Predictor Invalidate All
399 __STATIC_FORCEINLINE void __set_BPIALL(uint32_t value)
401 __set_CP(15, 0, value, 7, 5, 6);
404 /** \brief Set ICIALLU
406 Instruction Cache Invalidate All
408 __STATIC_FORCEINLINE void __set_ICIALLU(uint32_t value)
410 __set_CP(15, 0, value, 7, 5, 0);
413 /** \brief Set ICIMVAC
415 Instruction Cache Invalidate
417 __STATIC_FORCEINLINE void __set_ICIMVAC(uint32_t value)
419 __set_CP(15, 0, value, 7, 5, 1);
422 /** \brief Set DCCMVAC
426 __STATIC_FORCEINLINE void __set_DCCMVAC(uint32_t value)
428 __set_CP(15, 0, value, 7, 10, 1);
431 /** \brief Set DCIMVAC
433 Data cache invalidate
435 __STATIC_FORCEINLINE void __set_DCIMVAC(uint32_t value)
437 __set_CP(15, 0, value, 7, 6, 1);
440 /** \brief Set DCCIMVAC
442 Data cache clean and invalidate
444 __STATIC_FORCEINLINE void __set_DCCIMVAC(uint32_t value)
446 __set_CP(15, 0, value, 7, 14, 1);
449 /** \brief Set CSSELR
451 __STATIC_FORCEINLINE void __set_CSSELR(uint32_t value)
453 // __ASM volatile("MCR p15, 2, %0, c0, c0, 0" : : "r"(value) : "memory");
454 __set_CP(15, 2, value, 0, 0, 0);
457 /** \brief Get CSSELR
458 \return CSSELR Register value
460 __STATIC_FORCEINLINE uint32_t __get_CSSELR(void)
463 // __ASM volatile("MRC p15, 2, %0, c0, c0, 0" : "=r"(result) : : "memory");
464 __get_CP(15, 2, result, 0, 0, 0);
468 /** \brief Set CCSIDR
469 \deprecated CCSIDR itself is read-only. Use __set_CSSELR to select cache level instead.
472 __STATIC_FORCEINLINE void __set_CCSIDR(uint32_t value)
477 /** \brief Get CCSIDR
478 \return CCSIDR Register value
480 __STATIC_FORCEINLINE uint32_t __get_CCSIDR(void)
483 // __ASM volatile("MRC p15, 1, %0, c0, c0, 0" : "=r"(result) : : "memory");
484 __get_CP(15, 1, result, 0, 0, 0);
489 \return CLIDR Register value
491 __STATIC_FORCEINLINE uint32_t __get_CLIDR(void)
494 // __ASM volatile("MRC p15, 1, %0, c0, c0, 1" : "=r"(result) : : "memory");
495 __get_CP(15, 1, result, 0, 0, 1);
501 __STATIC_FORCEINLINE void __set_DCISW(uint32_t value)
503 // __ASM volatile("MCR p15, 0, %0, c7, c6, 2" : : "r"(value) : "memory")
504 __set_CP(15, 0, value, 7, 6, 2);
509 __STATIC_FORCEINLINE void __set_DCCSW(uint32_t value)
511 // __ASM volatile("MCR p15, 0, %0, c7, c10, 2" : : "r"(value) : "memory")
512 __set_CP(15, 0, value, 7, 10, 2);
515 /** \brief Set DCCISW
517 __STATIC_FORCEINLINE void __set_DCCISW(uint32_t value)
519 // __ASM volatile("MCR p15, 0, %0, c7, c14, 2" : : "r"(value) : "memory")
520 __set_CP(15, 0, value, 7, 14, 2);