summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-12 17:50:59 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-12 17:50:59 +0000
commiteb1679e6fac9aa613baf90f285ef3e5e5413ea18 (patch)
treeb9f69b868329c2e8d196a76f18025e9fd93adfd9
parent774fdc43f3bea13b7852d82536ff96ccbb7ebf03 (diff)
downloadpx4-nuttx-eb1679e6fac9aa613baf90f285ef3e5e5413ea18.tar.gz
px4-nuttx-eb1679e6fac9aa613baf90f285ef3e5e5413ea18.tar.bz2
px4-nuttx-eb1679e6fac9aa613baf90f285ef3e5e5413ea18.zip
More updates to MPU control logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5735 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/ChangeLog2
-rw-r--r--nuttx/arch/arm/src/armv7-m/mpu.h40
-rw-r--r--nuttx/arch/arm/src/armv7-m/up_mpu.c31
-rw-r--r--nuttx/arch/arm/src/lpc17xx/lpc17_allocateheap.c4
-rw-r--r--nuttx/arch/arm/src/lpc17xx/lpc17_start.c2
-rw-r--r--nuttx/arch/arm/src/lpc17xx/lpc17_userspace.c2
-rw-r--r--nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c4
7 files changed, 63 insertions, 22 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 31b51ad86..67c45a41a 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -4320,3 +4320,5 @@
for better supportability. (2013-03-11)
* configs/open1788/kernel, knsh, and scripts: Add a kernel mode build
configuration for the WaveShare Open1788 board. (2013-03-11)
+ * arch/arm/src/armv7-m/up_mpu.c: Several fixes to MPU logic.
+ (2013-03-12).
diff --git a/nuttx/arch/arm/src/armv7-m/mpu.h b/nuttx/arch/arm/src/armv7-m/mpu.h
index 8d4cd1829..74bfe7a9e 100644
--- a/nuttx/arch/arm/src/armv7-m/mpu.h
+++ b/nuttx/arch/arm/src/armv7-m/mpu.h
@@ -127,7 +127,8 @@
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
-extern "C" {
+extern "C"
+{
#else
#define EXTERN extern
#endif
@@ -140,10 +141,10 @@ extern "C" {
*
****************************************************************************/
-EXTERN unsigned int mpu_allocregion(void);
+unsigned int mpu_allocregion(void);
/****************************************************************************
- * Name: mpu_log2regionsize
+ * Name: mpu_log2regionceil
*
* Description:
* Determine the smallest value of l2size (log base 2 size) such that the
@@ -153,7 +154,20 @@ EXTERN unsigned int mpu_allocregion(void);
*
****************************************************************************/
-EXTERN uint8_t mpu_log2regionsize(size_t size);
+uint8_t mpu_log2regionceil(size_t size);
+
+/****************************************************************************
+ * Name: mpu_log2regionfloor
+ *
+ * Description:
+ * Determine the largest value of l2size (log base 2 size) such that the
+ * following is true:
+ *
+ * size >= (1 << l2size)
+ *
+ ****************************************************************************/
+
+uint8_t mpu_log2regionfloor(size_t size);
/****************************************************************************
* Name: mpu_subregion
@@ -165,11 +179,11 @@ EXTERN uint8_t mpu_log2regionsize(size_t size);
*
* Assumption:
* l2size has the same properties as the return value from
- * mpu_log2regionsize()
+ * mpu_log2regionceil()
*
****************************************************************************/
-EXTERN uint32_t mpu_subregion(size_t size, uint8_t l2size);
+uint32_t mpu_subregion(size_t size, uint8_t l2size);
/************************************************************************************
* Inline Functions
@@ -249,7 +263,7 @@ static inline void mpu_userflash(uintptr_t base, size_t size)
/* Select the region size and the sub-region map */
- l2size = mpu_log2regionsize(size);
+ l2size = mpu_log2regionceil(size);
subregions = mpu_subregion(size, l2size);
/* The configure the region */
@@ -287,7 +301,7 @@ static inline void mpu_privflash(uintptr_t base, size_t size)
/* Select the region size and the sub-region map */
- l2size = mpu_log2regionsize(size);
+ l2size = mpu_log2regionceil(size);
subregions = mpu_subregion(size, l2size);
/* The configure the region */
@@ -325,7 +339,7 @@ static inline void mpu_userintsram(uintptr_t base, size_t size)
/* Select the region size and the sub-region map */
- l2size = mpu_log2regionsize(size);
+ l2size = mpu_log2regionceil(size);
subregions = mpu_subregion(size, l2size);
/* The configure the region */
@@ -364,7 +378,7 @@ static inline void mpu_privintsram(uintptr_t base, size_t size)
/* Select the region size and the sub-region map */
- l2size = mpu_log2regionsize(size);
+ l2size = mpu_log2regionceil(size);
subregions = mpu_subregion(size, l2size);
/* The configure the region */
@@ -403,7 +417,7 @@ static inline void mpu_userextsram(uintptr_t base, size_t size)
/* Select the region size and the sub-region map */
- l2size = mpu_log2regionsize(size);
+ l2size = mpu_log2regionceil(size);
subregions = mpu_subregion(size, l2size);
/* The configure the region */
@@ -443,7 +457,7 @@ static inline void mpu_privextsram(uintptr_t base, size_t size)
/* Select the region size and the sub-region map */
- l2size = mpu_log2regionsize(size);
+ l2size = mpu_log2regionceil(size);
subregions = mpu_subregion(size, l2size);
/* The configure the region */
@@ -483,7 +497,7 @@ static inline void mpu_peripheral(uintptr_t base, size_t size)
/* Select the region size and the sub-region map */
- l2size = mpu_log2regionsize(size);
+ l2size = mpu_log2regionceil(size);
subregions = mpu_subregion(size, l2size);
/* The configure the region */
diff --git a/nuttx/arch/arm/src/armv7-m/up_mpu.c b/nuttx/arch/arm/src/armv7-m/up_mpu.c
index 88d69e8b0..1c3416c88 100644
--- a/nuttx/arch/arm/src/armv7-m/up_mpu.c
+++ b/nuttx/arch/arm/src/armv7-m/up_mpu.c
@@ -101,7 +101,7 @@ unsigned int mpu_allocregion(void)
}
/****************************************************************************
- * Name: mpu_log2regionsize
+ * Name: mpu_log2regionceil
*
* Description:
* Determine the smallest value of l2size (log base 2 size) such that the
@@ -111,9 +111,9 @@ unsigned int mpu_allocregion(void)
*
****************************************************************************/
-uint8_t mpu_log2regionsize(size_t size)
+uint8_t mpu_log2regionceil(size_t size)
{
- uint32_t l2size;
+ uint8_t l2size;
/* The minimum permitted region size is 16 bytes (log2(16) = 4. */
@@ -122,6 +122,29 @@ uint8_t mpu_log2regionsize(size_t size)
}
/****************************************************************************
+ * Name: mpu_log2regionfloor
+ *
+ * Description:
+ * Determine the largest value of l2size (log base 2 size) such that the
+ * following is true:
+ *
+ * size >= (1 << l2size)
+ *
+ ****************************************************************************/
+
+uint8_t mpu_log2regionfloor(size_t size)
+{
+ uint8_t l2size = mpu_log2regionceil(size);
+
+ if (l2size > 4 && size < (1 << l2size))
+ {
+ l2size--;
+ }
+
+ return l2size;
+}
+
+/****************************************************************************
* Name: mpu_subregion
*
* Description:
@@ -131,7 +154,7 @@ uint8_t mpu_log2regionsize(size_t size)
*
* Assumption:
* l2size has the same properties as the return value from
- * mpu_log2regionsize()
+ * mpu_log2regionceil()
*
****************************************************************************/
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_allocateheap.c b/nuttx/arch/arm/src/lpc17xx/lpc17_allocateheap.c
index 9b699c6a6..edd5100b3 100644
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_allocateheap.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_allocateheap.c
@@ -211,7 +211,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
* is aligned to the MPU requirement.
*/
- log2 = (int)mpu_log2regionsize(usize);
+ log2 = (int)mpu_log2regionfloor(usize);
DEBUGASSERT((CONFIG_DRAM_END & ((1 << log2) - 1)) == 0);
usize = (1 << log2);
@@ -262,7 +262,7 @@ void up_allocate_kheap(FAR void **heap_start, size_t *heap_size)
* is aligned to the MPU requirement.
*/
- log2 = (int)mpu_log2regionsize(usize);
+ log2 = (int)mpu_log2regionfloor(usize);
DEBUGASSERT((CONFIG_DRAM_END & ((1 << log2) - 1)) == 0);
usize = (1 << log2);
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_start.c b/nuttx/arch/arm/src/lpc17xx/lpc17_start.c
index e3e4013d0..57496ab2a 100644
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_start.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_start.c
@@ -210,6 +210,7 @@ void __start(void)
{
*dest++ = 0;
}
+
showprogress('B');
/* Move the intialized data section from his temporary holding spot in
@@ -222,6 +223,7 @@ void __start(void)
{
*dest++ = *src++;
}
+
showprogress('C');
/* Perform early serial initialization */
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_userspace.c b/nuttx/arch/arm/src/lpc17xx/lpc17_userspace.c
index ffc935af3..a9bddfc8c 100644
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_userspace.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_userspace.c
@@ -50,7 +50,7 @@
#ifdef CONFIG_NUTTX_KERNEL
/****************************************************************************
- * Private Definitions
+ * Pre-processor Definitions
****************************************************************************/
/****************************************************************************
diff --git a/nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c b/nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c
index 8f269491e..0c122aeae 100644
--- a/nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c
+++ b/nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c
@@ -122,7 +122,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
* is aligned to the MPU requirement.
*/
- log2 = (int)mpu_log2regionsize(usize);
+ log2 = (int)mpu_log2regionfloor(usize);
DEBUGASSERT((CONFIG_DRAM_END & ((1 << log2) - 1)) == 0);
usize = (1 << log2);
@@ -173,7 +173,7 @@ void up_allocate_kheap(FAR void **heap_start, size_t *heap_size)
* is aligned to the MPU requirement.
*/
- log2 = (int)mpu_log2regionsize(usize);
+ log2 = (int)mpu_log2regionfloor(usize);
DEBUGASSERT((CONFIG_DRAM_END & ((1 << log2) - 1)) == 0);
usize = (1 << log2);