More updates to MPU control logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5735 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
73ef58fda6
commit
e6c40405c4
@ -4320,3 +4320,5 @@
|
|||||||
for better supportability. (2013-03-11)
|
for better supportability. (2013-03-11)
|
||||||
* configs/open1788/kernel, knsh, and scripts: Add a kernel mode build
|
* configs/open1788/kernel, knsh, and scripts: Add a kernel mode build
|
||||||
configuration for the WaveShare Open1788 board. (2013-03-11)
|
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).
|
||||||
|
@ -127,7 +127,8 @@
|
|||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
#define EXTERN extern "C"
|
#define EXTERN extern "C"
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#else
|
#else
|
||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
#endif
|
#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:
|
* Description:
|
||||||
* Determine the smallest value of l2size (log base 2 size) such that the
|
* 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
|
* Name: mpu_subregion
|
||||||
@ -165,11 +179,11 @@ EXTERN uint8_t mpu_log2regionsize(size_t size);
|
|||||||
*
|
*
|
||||||
* Assumption:
|
* Assumption:
|
||||||
* l2size has the same properties as the return value from
|
* 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
|
* 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 */
|
/* Select the region size and the sub-region map */
|
||||||
|
|
||||||
l2size = mpu_log2regionsize(size);
|
l2size = mpu_log2regionceil(size);
|
||||||
subregions = mpu_subregion(size, l2size);
|
subregions = mpu_subregion(size, l2size);
|
||||||
|
|
||||||
/* The configure the region */
|
/* 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 */
|
/* Select the region size and the sub-region map */
|
||||||
|
|
||||||
l2size = mpu_log2regionsize(size);
|
l2size = mpu_log2regionceil(size);
|
||||||
subregions = mpu_subregion(size, l2size);
|
subregions = mpu_subregion(size, l2size);
|
||||||
|
|
||||||
/* The configure the region */
|
/* 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 */
|
/* Select the region size and the sub-region map */
|
||||||
|
|
||||||
l2size = mpu_log2regionsize(size);
|
l2size = mpu_log2regionceil(size);
|
||||||
subregions = mpu_subregion(size, l2size);
|
subregions = mpu_subregion(size, l2size);
|
||||||
|
|
||||||
/* The configure the region */
|
/* 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 */
|
/* Select the region size and the sub-region map */
|
||||||
|
|
||||||
l2size = mpu_log2regionsize(size);
|
l2size = mpu_log2regionceil(size);
|
||||||
subregions = mpu_subregion(size, l2size);
|
subregions = mpu_subregion(size, l2size);
|
||||||
|
|
||||||
/* The configure the region */
|
/* 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 */
|
/* Select the region size and the sub-region map */
|
||||||
|
|
||||||
l2size = mpu_log2regionsize(size);
|
l2size = mpu_log2regionceil(size);
|
||||||
subregions = mpu_subregion(size, l2size);
|
subregions = mpu_subregion(size, l2size);
|
||||||
|
|
||||||
/* The configure the region */
|
/* 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 */
|
/* Select the region size and the sub-region map */
|
||||||
|
|
||||||
l2size = mpu_log2regionsize(size);
|
l2size = mpu_log2regionceil(size);
|
||||||
subregions = mpu_subregion(size, l2size);
|
subregions = mpu_subregion(size, l2size);
|
||||||
|
|
||||||
/* The configure the region */
|
/* 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 */
|
/* Select the region size and the sub-region map */
|
||||||
|
|
||||||
l2size = mpu_log2regionsize(size);
|
l2size = mpu_log2regionceil(size);
|
||||||
subregions = mpu_subregion(size, l2size);
|
subregions = mpu_subregion(size, l2size);
|
||||||
|
|
||||||
/* The configure the region */
|
/* The configure the region */
|
||||||
|
@ -101,7 +101,7 @@ unsigned int mpu_allocregion(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mpu_log2regionsize
|
* Name: mpu_log2regionceil
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Determine the smallest value of l2size (log base 2 size) such that the
|
* 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. */
|
/* The minimum permitted region size is 16 bytes (log2(16) = 4. */
|
||||||
|
|
||||||
@ -121,6 +121,29 @@ uint8_t mpu_log2regionsize(size_t size)
|
|||||||
return l2size;
|
return l2size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* 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
|
* Name: mpu_subregion
|
||||||
*
|
*
|
||||||
@ -131,7 +154,7 @@ uint8_t mpu_log2regionsize(size_t size)
|
|||||||
*
|
*
|
||||||
* Assumption:
|
* Assumption:
|
||||||
* l2size has the same properties as the return value from
|
* l2size has the same properties as the return value from
|
||||||
* mpu_log2regionsize()
|
* mpu_log2regionceil()
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
|
|||||||
* is aligned to the MPU requirement.
|
* is aligned to the MPU requirement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
log2 = (int)mpu_log2regionsize(usize);
|
log2 = (int)mpu_log2regionfloor(usize);
|
||||||
DEBUGASSERT((CONFIG_DRAM_END & ((1 << log2) - 1)) == 0);
|
DEBUGASSERT((CONFIG_DRAM_END & ((1 << log2) - 1)) == 0);
|
||||||
|
|
||||||
usize = (1 << log2);
|
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.
|
* is aligned to the MPU requirement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
log2 = (int)mpu_log2regionsize(usize);
|
log2 = (int)mpu_log2regionfloor(usize);
|
||||||
DEBUGASSERT((CONFIG_DRAM_END & ((1 << log2) - 1)) == 0);
|
DEBUGASSERT((CONFIG_DRAM_END & ((1 << log2) - 1)) == 0);
|
||||||
|
|
||||||
usize = (1 << log2);
|
usize = (1 << log2);
|
||||||
|
@ -210,6 +210,7 @@ void __start(void)
|
|||||||
{
|
{
|
||||||
*dest++ = 0;
|
*dest++ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
showprogress('B');
|
showprogress('B');
|
||||||
|
|
||||||
/* Move the intialized data section from his temporary holding spot in
|
/* Move the intialized data section from his temporary holding spot in
|
||||||
@ -222,6 +223,7 @@ void __start(void)
|
|||||||
{
|
{
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
}
|
}
|
||||||
|
|
||||||
showprogress('C');
|
showprogress('C');
|
||||||
|
|
||||||
/* Perform early serial initialization */
|
/* Perform early serial initialization */
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
#ifdef CONFIG_NUTTX_KERNEL
|
#ifdef CONFIG_NUTTX_KERNEL
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -122,7 +122,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
|
|||||||
* is aligned to the MPU requirement.
|
* is aligned to the MPU requirement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
log2 = (int)mpu_log2regionsize(usize);
|
log2 = (int)mpu_log2regionfloor(usize);
|
||||||
DEBUGASSERT((CONFIG_DRAM_END & ((1 << log2) - 1)) == 0);
|
DEBUGASSERT((CONFIG_DRAM_END & ((1 << log2) - 1)) == 0);
|
||||||
|
|
||||||
usize = (1 << log2);
|
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.
|
* is aligned to the MPU requirement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
log2 = (int)mpu_log2regionsize(usize);
|
log2 = (int)mpu_log2regionfloor(usize);
|
||||||
DEBUGASSERT((CONFIG_DRAM_END & ((1 << log2) - 1)) == 0);
|
DEBUGASSERT((CONFIG_DRAM_END & ((1 << log2) - 1)) == 0);
|
||||||
|
|
||||||
usize = (1 << log2);
|
usize = (1 << log2);
|
||||||
|
Loading…
Reference in New Issue
Block a user