diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-04-08 19:39:50 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-04-08 19:39:50 +0000 |
commit | 5d710c2d57fc344e67abe7fb3907a4a81ec3be13 (patch) | |
tree | a704724c68762e6962852b8ea6e01a5a2b15f1ac /nuttx/arch/arm/src/cortexm3 | |
parent | 47ebc42ac1eebdd9b33d22adfd91c56b50016ef9 (diff) | |
download | px4-nuttx-5d710c2d57fc344e67abe7fb3907a4a81ec3be13.tar.gz px4-nuttx-5d710c2d57fc344e67abe7fb3907a4a81ec3be13.tar.bz2 px4-nuttx-5d710c2d57fc344e67abe7fb3907a4a81ec3be13.zip |
Add user access to the heap
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3485 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/cortexm3')
-rw-r--r-- | nuttx/arch/arm/src/cortexm3/mpu.h | 79 | ||||
-rw-r--r-- | nuttx/arch/arm/src/cortexm3/up_mpu.c | 24 |
2 files changed, 72 insertions, 31 deletions
diff --git a/nuttx/arch/arm/src/cortexm3/mpu.h b/nuttx/arch/arm/src/cortexm3/mpu.h index 7cb5970d3..1902a4ee3 100644 --- a/nuttx/arch/arm/src/cortexm3/mpu.h +++ b/nuttx/arch/arm/src/cortexm3/mpu.h @@ -133,6 +133,16 @@ extern "C" { #endif /**************************************************************************** + * Name: mpu_allocregion + * + * Description: + * Allocate the next region + * + ****************************************************************************/ + +EXTERN unsigned int mpu_allocregion(void); + +/**************************************************************************** * Name: mpu_log2regionsize * * Description: @@ -222,11 +232,12 @@ static inline void mpu_control(bool enable, bool hfnmiena, bool privdefena) * ****************************************************************************/ -static inline void mpu_userflash(int region, uintptr_t base, size_t size) +static inline void mpu_userflash(uintptr_t base, size_t size) { - uint32_t regval; - uint8_t l2size; - uint8_t subregions; + unsigned int region = mpu_allocregion(); + uint32_t regval; + uint8_t l2size; + uint8_t subregions; /* Select the region */ @@ -259,15 +270,16 @@ static inline void mpu_userflash(int region, uintptr_t base, size_t size) * ****************************************************************************/ -static inline void mpu_privflash(int region, uintptr_t base, size_t size) +static inline void mpu_privflash(uintptr_t base, size_t size) { - uint32_t regval; - uint8_t l2size; - uint8_t subregions; + unsigned int region = mpu_allocregion(); + uint32_t regval; + uint8_t l2size; + uint8_t subregions; /* Select the region */ - putreg32(region, MPU_RNR); + putreg32(mpu_allocregion(), MPU_RNR); /* Select the region base address */ @@ -296,11 +308,12 @@ static inline void mpu_privflash(int region, uintptr_t base, size_t size) * ****************************************************************************/ -static inline void mpu_userintsram(int region, uintptr_t base, size_t size) +static inline void mpu_userintsram(uintptr_t base, size_t size) { - uint32_t regval; - uint8_t l2size; - uint8_t subregions; + unsigned int region = mpu_allocregion(); + uint32_t regval; + uint8_t l2size; + uint8_t subregions; /* Select the region */ @@ -334,11 +347,12 @@ static inline void mpu_userintsram(int region, uintptr_t base, size_t size) * ****************************************************************************/ -static inline void mpu_privintsram(int region, uintptr_t base, size_t size) +static inline void mpu_privintsram(uintptr_t base, size_t size) { - uint32_t regval; - uint8_t l2size; - uint8_t subregions; + unsigned int region = mpu_allocregion(); + uint32_t regval; + uint8_t l2size; + uint8_t subregions; /* Select the region */ @@ -372,11 +386,12 @@ static inline void mpu_privintsram(int region, uintptr_t base, size_t size) * ****************************************************************************/ -static inline void mpu_userextsram(int region, uintptr_t base, size_t size) +static inline void mpu_userextsram(uintptr_t base, size_t size) { - uint32_t regval; - uint8_t l2size; - uint8_t subregions; + unsigned int region = mpu_allocregion(); + uint32_t regval; + uint8_t l2size; + uint8_t subregions; /* Select the region */ @@ -411,11 +426,12 @@ static inline void mpu_userextsram(int region, uintptr_t base, size_t size) * ****************************************************************************/ -static inline void mpu_privextsram(int region, uintptr_t base, size_t size) +static inline void mpu_privextsram(uintptr_t base, size_t size) { - uint32_t regval; - uint8_t l2size; - uint8_t subregions; + unsigned int region = mpu_allocregion(); + uint32_t regval; + uint8_t l2size; + uint8_t subregions; /* Select the region */ @@ -450,11 +466,12 @@ static inline void mpu_privextsram(int region, uintptr_t base, size_t size) * ****************************************************************************/ -static inline void mpu_peripheral(int region, uintptr_t base, size_t size) +static inline void mpu_peripheral(uintptr_t base, size_t size) { - uint32_t regval; - uint8_t l2size; - uint8_t subregions; + unsigned int region = mpu_allocregion(); + uint32_t regval; + uint8_t l2size; + uint8_t subregions; /* Select the region */ @@ -476,7 +493,9 @@ static inline void mpu_peripheral(int region, uintptr_t base, size_t size) ((uint32_t)subregions << MPU_RASR_SRD_SHIFT) | /* Sub-regions */ MPU_RASR_S | /* Shareable */ MPU_RASR_B | /* Bufferable */ - MPU_RASR_AP_RWNO; /* P:RW U:None */ + MPU_RASR_AP_RWNO | /* P:RW U:None */ + MPU_RASR_XN | /* Instruction access disable */ + putreg32(regval, MPU_RASR); } diff --git a/nuttx/arch/arm/src/cortexm3/up_mpu.c b/nuttx/arch/arm/src/cortexm3/up_mpu.c index 12edb9263..215f373d4 100644 --- a/nuttx/arch/arm/src/cortexm3/up_mpu.c +++ b/nuttx/arch/arm/src/cortexm3/up_mpu.c @@ -58,11 +58,15 @@ * regions (0xff), and 0 means all subregions but one (0x00). */ -static void uint8_t g_regionmap[9] = +static const void uint8_t g_regionmap[9] = { 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00 }; +/* The next available region number */ + +static uint8_t g_region; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -72,6 +76,24 @@ static void uint8_t g_regionmap[9] = ****************************************************************************/ /**************************************************************************** + * Name: mpu_allocregion + * + * Description: + * Allocate the next region + * + * Assumptions: + * - Regions are never deallocated + * - Regions are only allocated early in initialization, so nothing + * special is require; + * + ****************************************************************************/ + +unsigned int mpu_allocregion(void) +{ + return (unsigned int)g_region++; +} + +/**************************************************************************** * Name: mpu_log2regionsize * * Description: |