25#if defined ( __ICCARM__ )
26 #pragma system_include
27#elif defined (__clang__)
28 #pragma clang system_header
31#ifndef ARM_MPU_ARMV8_H
32#define ARM_MPU_ARMV8_H
35#define ARM_MPU_ATTR_DEVICE ( 0U )
38#define ARM_MPU_ATTR_NON_CACHEABLE ( 4U )
46#define ARM_MPU_ATTR_MEMORY_(NT, WB, RA, WA) \
47 ((((NT) & 1U) << 3U) | (((WB) & 1U) << 2U) | (((RA) & 1U) << 1U) | ((WA) & 1U))
50#define ARM_MPU_ATTR_DEVICE_nGnRnE (0U)
53#define ARM_MPU_ATTR_DEVICE_nGnRE (1U)
56#define ARM_MPU_ATTR_DEVICE_nGRE (2U)
59#define ARM_MPU_ATTR_DEVICE_GRE (3U)
65#define ARM_MPU_ATTR(O, I) ((((O) & 0xFU) << 4U) | ((((O) & 0xFU) != 0U) ? ((I) & 0xFU) : (((I) & 0x3U) << 2U)))
68#define ARM_MPU_SH_NON (0U)
71#define ARM_MPU_SH_OUTER (2U)
74#define ARM_MPU_SH_INNER (3U)
80#define ARM_MPU_AP_(RO, NP) ((((RO) & 1U) << 1U) | ((NP) & 1U))
89#define ARM_MPU_RBAR(BASE, SH, RO, NP, XN) \
90 (((BASE) & MPU_RBAR_BASE_Msk) | \
91 (((SH) << MPU_RBAR_SH_Pos) & MPU_RBAR_SH_Msk) | \
92 ((ARM_MPU_AP_(RO, NP) << MPU_RBAR_AP_Pos) & MPU_RBAR_AP_Msk) | \
93 (((XN) << MPU_RBAR_XN_Pos) & MPU_RBAR_XN_Msk))
99#define ARM_MPU_RLAR(LIMIT, IDX) \
100 (((LIMIT) & MPU_RLAR_LIMIT_Msk) | \
101 (((IDX) << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \
104#if defined(MPU_RLAR_PXN_Pos)
111#define ARM_MPU_RLAR_PXN(LIMIT, PXN, IDX) \
112 (((LIMIT) & MPU_RLAR_LIMIT_Msk) | \
113 (((PXN) << MPU_RLAR_PXN_Pos) & MPU_RLAR_PXN_Msk) | \
114 (((IDX) << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \
134#ifdef SCB_SHCSR_MEMFAULTENA_Msk
146#ifdef SCB_SHCSR_MEMFAULTENA_Msk
162#ifdef SCB_SHCSR_MEMFAULTENA_Msk
174#ifdef SCB_SHCSR_MEMFAULTENA_Msk
190 const uint8_t
reg = idx / 4U;
191 const uint32_t pos = ((idx % 4U) * 8U);
192 const uint32_t mask = 0xFFU << pos;
194 if (
reg >= (
sizeof(mpu->
MAIR) /
sizeof(mpu->
MAIR[0]))) {
198 mpu->
MAIR[
reg] = ((mpu->
MAIR[
reg] & ~mask) | ((attr << pos) & mask));
278__STATIC_INLINE void ARM_MPU_SetRegion_NS(uint32_t rnr, uint32_t rbar, uint32_t rlar)
292 for (i = 0U; i < len; ++i)
#define MPU_TYPE_RALIASES
#define SCB
SCB configuration struct.
#define MPU
Memory Protection Unit.
#define MPU_CTRL_ENABLE_Msk
MPU CTRL: ENABLE Mask.
#define SCB_SHCSR_MEMFAULTENA_Msk
SCB SHCSR: MEMFAULTENA Mask.
#define __DSB()
Data Synchronization Barrier.
#define __DMB()
Data Memory Barrier.
#define __ISB()
Instruction Synchronization Barrier.
__IOM uint32_t RLAR
Offset: 0x010 (R/W) MPU Region Limit Address Register.
__IOM uint32_t RNR
Offset: 0x008 (R/W) MPU Region Number Register.
__IOM uint32_t RBAR
Offset: 0x00C (R/W) MPU Region Base Address Register.
__STATIC_INLINE void ARM_MPU_ClrRegionEx(MPU_Type *mpu, uint32_t rnr)
Clear and disable the given MPU region of the given MPU.
__STATIC_INLINE void ARM_MPU_SetMemAttrEx(MPU_Type *mpu, uint8_t idx, uint8_t attr)
Set the memory attribute encoding to the given MPU.
__STATIC_INLINE void ARM_MPU_SetRegionEx(MPU_Type *mpu, uint32_t rnr, uint32_t rbar, uint32_t rlar)
Configure the given MPU region of the given MPU.
__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control)
Enable the MPU.
__STATIC_INLINE void ARM_MPU_Disable(void)
Disable the MPU.
__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rnr, uint32_t rbar, uint32_t rlar)
Configure the given MPU region.
__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr)
Clear and disable the given MPU region.
__STATIC_INLINE void ARM_MPU_SetMemAttr(uint8_t idx, uint8_t attr)
Set the memory attribute encoding.
__STATIC_INLINE void ARM_MPU_LoadEx(MPU_Type *mpu, uint32_t rnr, ARM_MPU_Region_t const *table, uint32_t cnt)
Load the given number of MPU regions from a table to the given MPU.
__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t *dst, const uint32_t *__RESTRICT src, uint32_t len)
Memcpy with strictly ordered memory access, e.g.
__STATIC_INLINE void ARM_MPU_Load(uint32_t rnr, ARM_MPU_Region_t const *table, uint32_t cnt)
Load the given number of MPU regions from a table.
Struct for a single MPU Region.
uint32_t RLAR
Region Limit Address Register value.
Structure type to access the Memory Protection Unit (MPU).