1*225f4ba4SMatthias Ringwald /******************************************************************************
2*225f4ba4SMatthias Ringwald * @file mpu_armv7.h
3*225f4ba4SMatthias Ringwald * @brief CMSIS MPU API for Armv7-M MPU
4*225f4ba4SMatthias Ringwald * @version V5.0.4
5*225f4ba4SMatthias Ringwald * @date 10. January 2018
6*225f4ba4SMatthias Ringwald ******************************************************************************/
7*225f4ba4SMatthias Ringwald /*
8*225f4ba4SMatthias Ringwald * Copyright (c) 2017-2018 Arm Limited. All rights reserved.
9*225f4ba4SMatthias Ringwald *
10*225f4ba4SMatthias Ringwald * SPDX-License-Identifier: Apache-2.0
11*225f4ba4SMatthias Ringwald *
12*225f4ba4SMatthias Ringwald * Licensed under the Apache License, Version 2.0 (the License); you may
13*225f4ba4SMatthias Ringwald * not use this file except in compliance with the License.
14*225f4ba4SMatthias Ringwald * You may obtain a copy of the License at
15*225f4ba4SMatthias Ringwald *
16*225f4ba4SMatthias Ringwald * www.apache.org/licenses/LICENSE-2.0
17*225f4ba4SMatthias Ringwald *
18*225f4ba4SMatthias Ringwald * Unless required by applicable law or agreed to in writing, software
19*225f4ba4SMatthias Ringwald * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20*225f4ba4SMatthias Ringwald * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21*225f4ba4SMatthias Ringwald * See the License for the specific language governing permissions and
22*225f4ba4SMatthias Ringwald * limitations under the License.
23*225f4ba4SMatthias Ringwald */
24*225f4ba4SMatthias Ringwald
25*225f4ba4SMatthias Ringwald #if defined ( __ICCARM__ )
26*225f4ba4SMatthias Ringwald #pragma system_include /* treat file as system include file for MISRA check */
27*225f4ba4SMatthias Ringwald #elif defined (__clang__)
28*225f4ba4SMatthias Ringwald #pragma clang system_header /* treat file as system include file */
29*225f4ba4SMatthias Ringwald #endif
30*225f4ba4SMatthias Ringwald
31*225f4ba4SMatthias Ringwald #ifndef ARM_MPU_ARMV7_H
32*225f4ba4SMatthias Ringwald #define ARM_MPU_ARMV7_H
33*225f4ba4SMatthias Ringwald
34*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U) ///!< MPU Region Size 32 Bytes
35*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U) ///!< MPU Region Size 64 Bytes
36*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U) ///!< MPU Region Size 128 Bytes
37*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U) ///!< MPU Region Size 256 Bytes
38*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U) ///!< MPU Region Size 512 Bytes
39*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U) ///!< MPU Region Size 1 KByte
40*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU) ///!< MPU Region Size 2 KBytes
41*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU) ///!< MPU Region Size 4 KBytes
42*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU) ///!< MPU Region Size 8 KBytes
43*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU) ///!< MPU Region Size 16 KBytes
44*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU) ///!< MPU Region Size 32 KBytes
45*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU) ///!< MPU Region Size 64 KBytes
46*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U) ///!< MPU Region Size 128 KBytes
47*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U) ///!< MPU Region Size 256 KBytes
48*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U) ///!< MPU Region Size 512 KBytes
49*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U) ///!< MPU Region Size 1 MByte
50*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U) ///!< MPU Region Size 2 MBytes
51*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U) ///!< MPU Region Size 4 MBytes
52*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U) ///!< MPU Region Size 8 MBytes
53*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U) ///!< MPU Region Size 16 MBytes
54*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U) ///!< MPU Region Size 32 MBytes
55*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U) ///!< MPU Region Size 64 MBytes
56*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU) ///!< MPU Region Size 128 MBytes
57*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU) ///!< MPU Region Size 256 MBytes
58*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU) ///!< MPU Region Size 512 MBytes
59*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU) ///!< MPU Region Size 1 GByte
60*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU) ///!< MPU Region Size 2 GBytes
61*225f4ba4SMatthias Ringwald #define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU) ///!< MPU Region Size 4 GBytes
62*225f4ba4SMatthias Ringwald
63*225f4ba4SMatthias Ringwald #define ARM_MPU_AP_NONE 0U ///!< MPU Access Permission no access
64*225f4ba4SMatthias Ringwald #define ARM_MPU_AP_PRIV 1U ///!< MPU Access Permission privileged access only
65*225f4ba4SMatthias Ringwald #define ARM_MPU_AP_URO 2U ///!< MPU Access Permission unprivileged access read-only
66*225f4ba4SMatthias Ringwald #define ARM_MPU_AP_FULL 3U ///!< MPU Access Permission full access
67*225f4ba4SMatthias Ringwald #define ARM_MPU_AP_PRO 5U ///!< MPU Access Permission privileged access read-only
68*225f4ba4SMatthias Ringwald #define ARM_MPU_AP_RO 6U ///!< MPU Access Permission read-only access
69*225f4ba4SMatthias Ringwald
70*225f4ba4SMatthias Ringwald /** MPU Region Base Address Register Value
71*225f4ba4SMatthias Ringwald *
72*225f4ba4SMatthias Ringwald * \param Region The region to be configured, number 0 to 15.
73*225f4ba4SMatthias Ringwald * \param BaseAddress The base address for the region.
74*225f4ba4SMatthias Ringwald */
75*225f4ba4SMatthias Ringwald #define ARM_MPU_RBAR(Region, BaseAddress) \
76*225f4ba4SMatthias Ringwald (((BaseAddress) & MPU_RBAR_ADDR_Msk) | \
77*225f4ba4SMatthias Ringwald ((Region) & MPU_RBAR_REGION_Msk) | \
78*225f4ba4SMatthias Ringwald (MPU_RBAR_VALID_Msk))
79*225f4ba4SMatthias Ringwald
80*225f4ba4SMatthias Ringwald /**
81*225f4ba4SMatthias Ringwald * MPU Memory Access Attributes
82*225f4ba4SMatthias Ringwald *
83*225f4ba4SMatthias Ringwald * \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
84*225f4ba4SMatthias Ringwald * \param IsShareable Region is shareable between multiple bus masters.
85*225f4ba4SMatthias Ringwald * \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
86*225f4ba4SMatthias Ringwald * \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
87*225f4ba4SMatthias Ringwald */
88*225f4ba4SMatthias Ringwald #define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \
89*225f4ba4SMatthias Ringwald ((((TypeExtField ) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \
90*225f4ba4SMatthias Ringwald (((IsShareable ) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \
91*225f4ba4SMatthias Ringwald (((IsCacheable ) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \
92*225f4ba4SMatthias Ringwald (((IsBufferable ) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk))
93*225f4ba4SMatthias Ringwald
94*225f4ba4SMatthias Ringwald /**
95*225f4ba4SMatthias Ringwald * MPU Region Attribute and Size Register Value
96*225f4ba4SMatthias Ringwald *
97*225f4ba4SMatthias Ringwald * \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
98*225f4ba4SMatthias Ringwald * \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
99*225f4ba4SMatthias Ringwald * \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_.
100*225f4ba4SMatthias Ringwald * \param SubRegionDisable Sub-region disable field.
101*225f4ba4SMatthias Ringwald * \param Size Region size of the region to be configured, for example 4K, 8K.
102*225f4ba4SMatthias Ringwald */
103*225f4ba4SMatthias Ringwald #define ARM_MPU_RASR_EX(DisableExec, AccessPermission, AccessAttributes, SubRegionDisable, Size) \
104*225f4ba4SMatthias Ringwald ((((DisableExec ) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \
105*225f4ba4SMatthias Ringwald (((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \
106*225f4ba4SMatthias Ringwald (((AccessAttributes) ) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk)))
107*225f4ba4SMatthias Ringwald
108*225f4ba4SMatthias Ringwald /**
109*225f4ba4SMatthias Ringwald * MPU Region Attribute and Size Register Value
110*225f4ba4SMatthias Ringwald *
111*225f4ba4SMatthias Ringwald * \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
112*225f4ba4SMatthias Ringwald * \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
113*225f4ba4SMatthias Ringwald * \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
114*225f4ba4SMatthias Ringwald * \param IsShareable Region is shareable between multiple bus masters.
115*225f4ba4SMatthias Ringwald * \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
116*225f4ba4SMatthias Ringwald * \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
117*225f4ba4SMatthias Ringwald * \param SubRegionDisable Sub-region disable field.
118*225f4ba4SMatthias Ringwald * \param Size Region size of the region to be configured, for example 4K, 8K.
119*225f4ba4SMatthias Ringwald */
120*225f4ba4SMatthias Ringwald #define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \
121*225f4ba4SMatthias Ringwald ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size)
122*225f4ba4SMatthias Ringwald
123*225f4ba4SMatthias Ringwald /**
124*225f4ba4SMatthias Ringwald * MPU Memory Access Attribute for strongly ordered memory.
125*225f4ba4SMatthias Ringwald * - TEX: 000b
126*225f4ba4SMatthias Ringwald * - Shareable
127*225f4ba4SMatthias Ringwald * - Non-cacheable
128*225f4ba4SMatthias Ringwald * - Non-bufferable
129*225f4ba4SMatthias Ringwald */
130*225f4ba4SMatthias Ringwald #define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U)
131*225f4ba4SMatthias Ringwald
132*225f4ba4SMatthias Ringwald /**
133*225f4ba4SMatthias Ringwald * MPU Memory Access Attribute for device memory.
134*225f4ba4SMatthias Ringwald * - TEX: 000b (if non-shareable) or 010b (if shareable)
135*225f4ba4SMatthias Ringwald * - Shareable or non-shareable
136*225f4ba4SMatthias Ringwald * - Non-cacheable
137*225f4ba4SMatthias Ringwald * - Bufferable (if shareable) or non-bufferable (if non-shareable)
138*225f4ba4SMatthias Ringwald *
139*225f4ba4SMatthias Ringwald * \param IsShareable Configures the device memory as shareable or non-shareable.
140*225f4ba4SMatthias Ringwald */
141*225f4ba4SMatthias Ringwald #define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U))
142*225f4ba4SMatthias Ringwald
143*225f4ba4SMatthias Ringwald /**
144*225f4ba4SMatthias Ringwald * MPU Memory Access Attribute for normal memory.
145*225f4ba4SMatthias Ringwald * - TEX: 1BBb (reflecting outer cacheability rules)
146*225f4ba4SMatthias Ringwald * - Shareable or non-shareable
147*225f4ba4SMatthias Ringwald * - Cacheable or non-cacheable (reflecting inner cacheability rules)
148*225f4ba4SMatthias Ringwald * - Bufferable or non-bufferable (reflecting inner cacheability rules)
149*225f4ba4SMatthias Ringwald *
150*225f4ba4SMatthias Ringwald * \param OuterCp Configures the outer cache policy.
151*225f4ba4SMatthias Ringwald * \param InnerCp Configures the inner cache policy.
152*225f4ba4SMatthias Ringwald * \param IsShareable Configures the memory as shareable or non-shareable.
153*225f4ba4SMatthias Ringwald */
154*225f4ba4SMatthias Ringwald #define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) & 2U), ((InnerCp) & 1U))
155*225f4ba4SMatthias Ringwald
156*225f4ba4SMatthias Ringwald /**
157*225f4ba4SMatthias Ringwald * MPU Memory Access Attribute non-cacheable policy.
158*225f4ba4SMatthias Ringwald */
159*225f4ba4SMatthias Ringwald #define ARM_MPU_CACHEP_NOCACHE 0U
160*225f4ba4SMatthias Ringwald
161*225f4ba4SMatthias Ringwald /**
162*225f4ba4SMatthias Ringwald * MPU Memory Access Attribute write-back, write and read allocate policy.
163*225f4ba4SMatthias Ringwald */
164*225f4ba4SMatthias Ringwald #define ARM_MPU_CACHEP_WB_WRA 1U
165*225f4ba4SMatthias Ringwald
166*225f4ba4SMatthias Ringwald /**
167*225f4ba4SMatthias Ringwald * MPU Memory Access Attribute write-through, no write allocate policy.
168*225f4ba4SMatthias Ringwald */
169*225f4ba4SMatthias Ringwald #define ARM_MPU_CACHEP_WT_NWA 2U
170*225f4ba4SMatthias Ringwald
171*225f4ba4SMatthias Ringwald /**
172*225f4ba4SMatthias Ringwald * MPU Memory Access Attribute write-back, no write allocate policy.
173*225f4ba4SMatthias Ringwald */
174*225f4ba4SMatthias Ringwald #define ARM_MPU_CACHEP_WB_NWA 3U
175*225f4ba4SMatthias Ringwald
176*225f4ba4SMatthias Ringwald
177*225f4ba4SMatthias Ringwald /**
178*225f4ba4SMatthias Ringwald * Struct for a single MPU Region
179*225f4ba4SMatthias Ringwald */
180*225f4ba4SMatthias Ringwald typedef struct {
181*225f4ba4SMatthias Ringwald uint32_t RBAR; //!< The region base address register value (RBAR)
182*225f4ba4SMatthias Ringwald uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR
183*225f4ba4SMatthias Ringwald } ARM_MPU_Region_t;
184*225f4ba4SMatthias Ringwald
185*225f4ba4SMatthias Ringwald /** Enable the MPU.
186*225f4ba4SMatthias Ringwald * \param MPU_Control Default access permissions for unconfigured regions.
187*225f4ba4SMatthias Ringwald */
ARM_MPU_Enable(uint32_t MPU_Control)188*225f4ba4SMatthias Ringwald __STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control)
189*225f4ba4SMatthias Ringwald {
190*225f4ba4SMatthias Ringwald __DSB();
191*225f4ba4SMatthias Ringwald __ISB();
192*225f4ba4SMatthias Ringwald MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
193*225f4ba4SMatthias Ringwald #ifdef SCB_SHCSR_MEMFAULTENA_Msk
194*225f4ba4SMatthias Ringwald SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
195*225f4ba4SMatthias Ringwald #endif
196*225f4ba4SMatthias Ringwald }
197*225f4ba4SMatthias Ringwald
198*225f4ba4SMatthias Ringwald /** Disable the MPU.
199*225f4ba4SMatthias Ringwald */
ARM_MPU_Disable(void)200*225f4ba4SMatthias Ringwald __STATIC_INLINE void ARM_MPU_Disable(void)
201*225f4ba4SMatthias Ringwald {
202*225f4ba4SMatthias Ringwald __DSB();
203*225f4ba4SMatthias Ringwald __ISB();
204*225f4ba4SMatthias Ringwald #ifdef SCB_SHCSR_MEMFAULTENA_Msk
205*225f4ba4SMatthias Ringwald SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
206*225f4ba4SMatthias Ringwald #endif
207*225f4ba4SMatthias Ringwald MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk;
208*225f4ba4SMatthias Ringwald }
209*225f4ba4SMatthias Ringwald
210*225f4ba4SMatthias Ringwald /** Clear and disable the given MPU region.
211*225f4ba4SMatthias Ringwald * \param rnr Region number to be cleared.
212*225f4ba4SMatthias Ringwald */
ARM_MPU_ClrRegion(uint32_t rnr)213*225f4ba4SMatthias Ringwald __STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr)
214*225f4ba4SMatthias Ringwald {
215*225f4ba4SMatthias Ringwald MPU->RNR = rnr;
216*225f4ba4SMatthias Ringwald MPU->RASR = 0U;
217*225f4ba4SMatthias Ringwald }
218*225f4ba4SMatthias Ringwald
219*225f4ba4SMatthias Ringwald /** Configure an MPU region.
220*225f4ba4SMatthias Ringwald * \param rbar Value for RBAR register.
221*225f4ba4SMatthias Ringwald * \param rsar Value for RSAR register.
222*225f4ba4SMatthias Ringwald */
ARM_MPU_SetRegion(uint32_t rbar,uint32_t rasr)223*225f4ba4SMatthias Ringwald __STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr)
224*225f4ba4SMatthias Ringwald {
225*225f4ba4SMatthias Ringwald MPU->RBAR = rbar;
226*225f4ba4SMatthias Ringwald MPU->RASR = rasr;
227*225f4ba4SMatthias Ringwald }
228*225f4ba4SMatthias Ringwald
229*225f4ba4SMatthias Ringwald /** Configure the given MPU region.
230*225f4ba4SMatthias Ringwald * \param rnr Region number to be configured.
231*225f4ba4SMatthias Ringwald * \param rbar Value for RBAR register.
232*225f4ba4SMatthias Ringwald * \param rsar Value for RSAR register.
233*225f4ba4SMatthias Ringwald */
ARM_MPU_SetRegionEx(uint32_t rnr,uint32_t rbar,uint32_t rasr)234*225f4ba4SMatthias Ringwald __STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr)
235*225f4ba4SMatthias Ringwald {
236*225f4ba4SMatthias Ringwald MPU->RNR = rnr;
237*225f4ba4SMatthias Ringwald MPU->RBAR = rbar;
238*225f4ba4SMatthias Ringwald MPU->RASR = rasr;
239*225f4ba4SMatthias Ringwald }
240*225f4ba4SMatthias Ringwald
241*225f4ba4SMatthias Ringwald /** Memcopy with strictly ordered memory access, e.g. for register targets.
242*225f4ba4SMatthias Ringwald * \param dst Destination data is copied to.
243*225f4ba4SMatthias Ringwald * \param src Source data is copied from.
244*225f4ba4SMatthias Ringwald * \param len Amount of data words to be copied.
245*225f4ba4SMatthias Ringwald */
orderedCpy(volatile uint32_t * dst,const uint32_t * __RESTRICT src,uint32_t len)246*225f4ba4SMatthias Ringwald __STATIC_INLINE void orderedCpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len)
247*225f4ba4SMatthias Ringwald {
248*225f4ba4SMatthias Ringwald uint32_t i;
249*225f4ba4SMatthias Ringwald for (i = 0U; i < len; ++i)
250*225f4ba4SMatthias Ringwald {
251*225f4ba4SMatthias Ringwald dst[i] = src[i];
252*225f4ba4SMatthias Ringwald }
253*225f4ba4SMatthias Ringwald }
254*225f4ba4SMatthias Ringwald
255*225f4ba4SMatthias Ringwald /** Load the given number of MPU regions from a table.
256*225f4ba4SMatthias Ringwald * \param table Pointer to the MPU configuration table.
257*225f4ba4SMatthias Ringwald * \param cnt Amount of regions to be configured.
258*225f4ba4SMatthias Ringwald */
ARM_MPU_Load(ARM_MPU_Region_t const * table,uint32_t cnt)259*225f4ba4SMatthias Ringwald __STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt)
260*225f4ba4SMatthias Ringwald {
261*225f4ba4SMatthias Ringwald const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
262*225f4ba4SMatthias Ringwald while (cnt > MPU_TYPE_RALIASES) {
263*225f4ba4SMatthias Ringwald orderedCpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize);
264*225f4ba4SMatthias Ringwald table += MPU_TYPE_RALIASES;
265*225f4ba4SMatthias Ringwald cnt -= MPU_TYPE_RALIASES;
266*225f4ba4SMatthias Ringwald }
267*225f4ba4SMatthias Ringwald orderedCpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize);
268*225f4ba4SMatthias Ringwald }
269*225f4ba4SMatthias Ringwald
270*225f4ba4SMatthias Ringwald #endif
271