Skip to content

Commit ef232f3

Browse files
XenuIsWatchingkartben
authored andcommitted
arch: arm: fix compile issue if MEM_ATTR=n and ARM_MPU=y
It's possible to have MEM_ATTR=n and ARM_MPU=y. This fixes the compile issue with it by compiling out the calls to define the DT mpu regions. Signed-off-by: Ryan McClelland <[email protected]>
1 parent 4b27b54 commit ef232f3

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

arch/arm/core/mpu/arm_mpu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static int region_allocate_and_init(const uint8_t index,
9393
(reg).dt_addr, \
9494
(reg).dt_size, \
9595
_ATTR)
96-
96+
#ifdef CONFIG_MEM_ATTR
9797
/* This internal function programs the MPU regions defined in the DT when using
9898
* the `zephyr,memory-attr = <( DT_MEM_ARM(...) )>` property.
9999
*/
@@ -158,7 +158,7 @@ static int mpu_configure_regions_from_dt(uint8_t *reg_index)
158158

159159
return 0;
160160
}
161-
161+
#endif /* CONFIG_MEM_ATTR */
162162
/* This internal function programs an MPU region
163163
* of a given configuration at a given MPU index.
164164
*/
@@ -459,13 +459,13 @@ int z_arm_mpu_init(void)
459459

460460
/* Update the number of programmed MPU regions. */
461461
static_regions_num = mpu_config.num_regions;
462-
462+
#ifdef CONFIG_MEM_ATTR
463463
/* DT-defined MPU regions. */
464464
if (mpu_configure_regions_from_dt(&static_regions_num) == -EINVAL) {
465465
__ASSERT(0, "Failed to allocate MPU regions from DT\n");
466466
return -EINVAL;
467467
}
468-
468+
#endif /* CONFIG_MEM_ATTR */
469469
/* Clear all regions before enabling MPU */
470470
for (int i = static_regions_num; i < get_num_regions(); i++) {
471471
mpu_clear_region(i);

arch/arm/core/mpu/nxp_mpu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static int region_allocate_and_init(const uint8_t index,
151151
.end = (reg).dt_addr + (reg).dt_size, \
152152
.attr = _ATTR, \
153153
}
154-
154+
#ifdef CONFIG_MEM_ATTR
155155
/* This internal function programs the MPU regions defined in the DT when using
156156
* the `zephyr,memory-attr = <( DT_MEM_ARM(...) )>` property.
157157
*/
@@ -198,7 +198,7 @@ static int mpu_configure_regions_from_dt(uint8_t *reg_index)
198198

199199
return 0;
200200
}
201-
201+
#endif /* CONFIG_MEM_ATTR */
202202
/**
203203
* This internal function is utilized by the MPU driver to combine a given
204204
* region attribute configuration and size and fill-in a driver-specific
@@ -700,13 +700,13 @@ int z_arm_mpu_init(void)
700700

701701
/* Update the number of programmed MPU regions. */
702702
static_regions_num = mpu_config.num_regions;
703-
703+
#ifdef CONFIG_MEM_ATTR
704704
/* DT-defined MPU regions. */
705705
if (mpu_configure_regions_from_dt(&static_regions_num) == -EINVAL) {
706706
__ASSERT(0, "Failed to allocate MPU regions from DT\n");
707707
return -EINVAL;
708708
}
709-
709+
#endif /* CONFIG_MEM_ATTR */
710710
arm_core_mpu_enable();
711711

712712
return 0;

arch/arm64/core/cortex_r/arm_mpu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static ALWAYS_INLINE void region_init(const uint32_t index,
196196
.limit = (reg).dt_addr + (reg).dt_size, \
197197
.attr = _ATTR, \
198198
}
199-
199+
#ifdef CONFIG_MEM_ATTR
200200
/* This internal function programs the MPU regions defined in the DT when using
201201
* the `zephyr,memory-attr = <( DT_MEM_ARM(...) )>` property.
202202
*/
@@ -247,7 +247,7 @@ static int mpu_configure_regions_from_dt(uint8_t *reg_index)
247247

248248
return 0;
249249
}
250-
250+
#endif /* CONFIG_MEM_ATTR */
251251
/*
252252
* @brief MPU default configuration
253253
*
@@ -303,13 +303,13 @@ FUNC_NO_STACK_PROTECTOR void z_arm64_mm_init(bool is_primary_core)
303303

304304
/* Update the number of programmed MPU regions. */
305305
tmp_static_num = mpu_config.num_regions;
306-
306+
#ifdef CONFIG_MEM_ATTR
307307
/* DT-defined MPU regions. */
308308
if (mpu_configure_regions_from_dt(&tmp_static_num) == -EINVAL) {
309309
__ASSERT(0, "Failed to allocate MPU regions from DT\n");
310310
return;
311311
}
312-
312+
#endif
313313
arm_core_mpu_enable();
314314

315315
if (!is_primary_core) {

0 commit comments

Comments
 (0)