[rtems commit] bsp/lpc24xx: More flexible region configuration
Sebastian Huber
sebh at rtems.org
Fri Jun 15 13:58:31 UTC 2012
Module: rtems
Branch: master
Commit: a94bcc5a3e0108b81c298c3ced91861f38bf9b39
Changeset: http://git.rtems.org/rtems/commit/?id=a94bcc5a3e0108b81c298c3ced91861f38bf9b39
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Jun 15 13:44:08 2012 +0200
bsp/lpc24xx: More flexible region configuration
---
.../lib/libbsp/arm/lpc24xx/include/start-config.h | 5 +-
.../lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c | 11 +-
.../libbsp/arm/lpc24xx/startup/start-config-mpu.c | 97 ++++++++++++--------
3 files changed, 67 insertions(+), 46 deletions(-)
diff --git a/c/src/lib/libbsp/arm/lpc24xx/include/start-config.h b/c/src/lib/libbsp/arm/lpc24xx/include/start-config.h
index 648fa13..9d6173f 100644
--- a/c/src/lib/libbsp/arm/lpc24xx/include/start-config.h
+++ b/c/src/lib/libbsp/arm/lpc24xx/include/start-config.h
@@ -105,7 +105,10 @@ extern BSP_START_DATA_SECTION const size_t
lpc24xx_start_config_emc_static_chip_count;
extern BSP_START_DATA_SECTION const ARMV7M_MPU_Region
- lpc24xx_start_config_mpu_regions [LPC24XX_MPU_REGION_COUNT];
+ lpc24xx_start_config_mpu_region [];
+
+extern BSP_START_DATA_SECTION const size_t
+ lpc24xx_start_config_mpu_region_count;
#ifdef __cplusplus
}
diff --git a/c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c b/c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c
index 56373ec..3b19853 100644
--- a/c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c
+++ b/c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c
@@ -495,16 +495,15 @@ static BSP_START_TEXT_SECTION void lpc24xx_init_mpu(void)
{
#ifdef ARM_MULTILIB_ARCH_V7M
volatile ARMV7M_MPU *mpu = _ARMV7M_MPU;
- size_t n = sizeof(lpc24xx_start_config_mpu_regions)
- / sizeof(lpc24xx_start_config_mpu_regions [0]);
+ size_t region_count = lpc24xx_start_config_mpu_region_count;
size_t i = 0;
- for (i = 0; i < n; ++i) {
- mpu->rbar = lpc24xx_start_config_mpu_regions [i].rbar;
- mpu->rasr = lpc24xx_start_config_mpu_regions [i].rasr;
+ for (i = 0; i < region_count; ++i) {
+ mpu->rbar = lpc24xx_start_config_mpu_region [i].rbar;
+ mpu->rasr = lpc24xx_start_config_mpu_region [i].rasr;
}
- if (n > 0) {
+ if (region_count > 0) {
mpu->ctrl = ARMV7M_MPU_CTRL_ENABLE;
}
#endif
diff --git a/c/src/lib/libbsp/arm/lpc24xx/startup/start-config-mpu.c b/c/src/lib/libbsp/arm/lpc24xx/startup/start-config-mpu.c
index b428de6..b2cffbd 100644
--- a/c/src/lib/libbsp/arm/lpc24xx/startup/start-config-mpu.c
+++ b/c/src/lib/libbsp/arm/lpc24xx/startup/start-config-mpu.c
@@ -24,44 +24,63 @@
#ifdef ARM_MULTILIB_ARCH_V7M
BSP_START_DATA_SECTION const ARMV7M_MPU_Region
- lpc24xx_start_config_mpu_regions [LPC24XX_MPU_REGION_COUNT] = {
- ARMV7M_MPU_REGION_INITIALIZER(
- 0,
- 0x00000000,
- ARMV7M_MPU_SIZE_512_KB,
- ARMV7M_MPU_ATTR_RX
- ),
- ARMV7M_MPU_REGION_INITIALIZER(
- 1,
- 0x10000000,
- ARMV7M_MPU_SIZE_64_KB,
- ARMV7M_MPU_ATTR_RWX
- ),
- ARMV7M_MPU_REGION_INITIALIZER(
- 2,
- 0x20000000,
- ARMV7M_MPU_SIZE_32_KB,
- ARMV7M_MPU_ATTR_RWX
- ),
- ARMV7M_MPU_REGION_INITIALIZER(
- 3,
- 0xa0000000,
- ARMV7M_MPU_SIZE_32_MB,
- ARMV7M_MPU_ATTR_RWX
- ),
- ARMV7M_MPU_REGION_INITIALIZER(
- 4,
- 0x20080000,
- ARMV7M_MPU_SIZE_128_KB,
- ARMV7M_MPU_ATTR_IO
- ),
- ARMV7M_MPU_REGION_INITIALIZER(
- 5,
- 0x40000000,
- ARMV7M_MPU_SIZE_1_MB,
- ARMV7M_MPU_ATTR_IO
- ),
- ARMV7M_MPU_REGION_DISABLED_INITIALIZER(6),
- ARMV7M_MPU_REGION_DISABLED_INITIALIZER(7)
+ lpc24xx_start_config_mpu_region [] = {
+ #if defined(LPC24XX_EMC_IS42S32800D7) \
+ || defined(LPC24XX_EMC_W9825G2JB75I) \
+ || defined(LPC24XX_EMC_IS42S32800B)
+ ARMV7M_MPU_REGION_INITIALIZER(
+ 0,
+ 0x00000000,
+ ARMV7M_MPU_SIZE_512_KB,
+ ARMV7M_MPU_ATTR_RX
+ ),
+ ARMV7M_MPU_REGION_INITIALIZER(
+ 1,
+ 0x10000000,
+ ARMV7M_MPU_SIZE_64_KB,
+ ARMV7M_MPU_ATTR_RWX
+ ),
+ ARMV7M_MPU_REGION_INITIALIZER(
+ 2,
+ 0x20000000,
+ ARMV7M_MPU_SIZE_32_KB,
+ ARMV7M_MPU_ATTR_RWX
+ ),
+ ARMV7M_MPU_REGION_INITIALIZER(
+ 3,
+ 0xa0000000,
+ ARMV7M_MPU_SIZE_32_MB,
+ ARMV7M_MPU_ATTR_RWX
+ ),
+ ARMV7M_MPU_REGION_INITIALIZER(
+ 4,
+ 0x20080000,
+ ARMV7M_MPU_SIZE_128_KB,
+ ARMV7M_MPU_ATTR_IO
+ ),
+ ARMV7M_MPU_REGION_INITIALIZER(
+ 5,
+ 0x40000000,
+ ARMV7M_MPU_SIZE_1_MB,
+ ARMV7M_MPU_ATTR_IO
+ ),
+ #if defined(LPC24XX_EMC_M29W320E70) \
+ || defined(LPC24XX_EMC_SST39VF3201)
+ ARMV7M_MPU_REGION_INITIALIZER(
+ 6,
+ 0x80000000,
+ ARMV7M_MPU_SIZE_4_MB,
+ ARMV7M_MPU_ATTR_RWX
+ ),
+ #else
+ ARMV7M_MPU_REGION_DISABLED_INITIALIZER(6),
+ #endif
+ ARMV7M_MPU_REGION_DISABLED_INITIALIZER(7)
+ #endif
};
+
+ BSP_START_DATA_SECTION const size_t
+ lpc24xx_start_config_mpu_region_count =
+ sizeof(lpc24xx_start_config_mpu_region)
+ / sizeof(lpc24xx_start_config_mpu_region [0]);
#endif
More information about the vc
mailing list