diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2011-04-08 19:39:50 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2011-04-08 19:39:50 +0000 |
commit | 13d4c2bba6675c3b8aa5183bba8e3a1acc0eb7d1 (patch) | |
tree | a704724c68762e6962852b8ea6e01a5a2b15f1ac /nuttx/arch/arm/src/sam3u | |
parent | 64ef7ee5f7750a589f7e14740ce2d1cd6c8b7448 (diff) |
Add user access to the heap
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@3485 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/arch/arm/src/sam3u')
-rwxr-xr-x | nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c | 23 | ||||
-rwxr-xr-x | nuttx/arch/arm/src/sam3u/sam3u_internal.h | 16 | ||||
-rwxr-xr-x | nuttx/arch/arm/src/sam3u/sam3u_mpuinit.c | 17 |
3 files changed, 53 insertions, 3 deletions
diff --git a/nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c b/nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c index c8ea98ade2..b27f28564e 100755 --- a/nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c +++ b/nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c @@ -50,6 +50,7 @@ #include "chip.h" #include "up_arch.h" #include "up_internal.h" +#include "sam3u_internal.h" /**************************************************************************** * Private Definitions @@ -102,9 +103,17 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) { + size_t size = CONFIG_DRAM_END - g_heapbase; + + /* Return the heap settings */ + up_ledon(LED_HEAPALLOCATE); *heap_start = (FAR void*)g_heapbase; - *heap_size = CONFIG_DRAM_END - g_heapbase; + *heap_size = size; + + /* Allow access to the heap memory */ + + sam3u_mpuheap((uintptr_)g_heapbase, size); } /************************************************************************ @@ -119,10 +128,22 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) #if CONFIG_MM_REGIONS > 1 void up_addregion(void) { + /* Add the region */ + kmm_addregion((FAR void*)SAM3U_INTSRAM1_BASE, CONFIG_SAM3U_SRAM1_SIZE); + /* Allow access to the heap memory */ + + sam3u_mpuheap(SAM3U_INTSRAM1_BASE, CONFIG_SAM3U_SRAM1_SIZE) + + /* Add the region */ + #if CONFIG_MM_REGIONS > 2 kmm_addregion((FAR void*)SAM3U_NFCSRAM_BASE, CONFIG_SAM3U_NFCSRAM_SIZE); + + /* Allow access to the heap memory */ + + sam3u_mpuheap(SAM3U_NFCSRAM_BASE, CONFIG_SAM3U_NFCSRAM_SIZE) #endif } #endif diff --git a/nuttx/arch/arm/src/sam3u/sam3u_internal.h b/nuttx/arch/arm/src/sam3u/sam3u_internal.h index 2d6bfcf4a9..cba96e5c1d 100755 --- a/nuttx/arch/arm/src/sam3u/sam3u_internal.h +++ b/nuttx/arch/arm/src/sam3u/sam3u_internal.h @@ -463,6 +463,22 @@ EXTERN void sam3u_userspace(void); #ifndef CONFIG_NUTTX_KERNEL EXTERN void sam3u_mpuinitialize(void); +#else +# define sam3u_mpuinitialize() +#endif + +/**************************************************************************** + * Name: sam3u_mpuheap + * + * Description: + * Map a heap region. + * + ****************************************************************************/ + +#ifndef CONFIG_NUTTX_KERNEL +EXTERN void sam3u_mpuheap(uintptr_t start, size_t size); +#else +# define sam3u_mpuheap(start,size) #endif /************************************************************************************ diff --git a/nuttx/arch/arm/src/sam3u/sam3u_mpuinit.c b/nuttx/arch/arm/src/sam3u/sam3u_mpuinit.c index 2dacd36c81..462f4e80db 100755 --- a/nuttx/arch/arm/src/sam3u/sam3u_mpuinit.c +++ b/nuttx/arch/arm/src/sam3u/sam3u_mpuinit.c @@ -97,13 +97,26 @@ void sam3u_mpuinitialize(void) /* Configure user flash and SRAM space */ - mpu_userflash(0, CONFIG_USER_TEXTSTART, CONFIG_USER_TEXTEND - CONFIG_USER_TEXTSTART); - mpu_userintsram(1, datastart, dataend - datastart); + mpu_userflash(CONFIG_USER_TEXTSTART, CONFIG_USER_TEXTEND - CONFIG_USER_TEXTSTART); + mpu_userintsram(datastart, dataend - datastart); /* Then enable the MPU */ mpu_control(true, false, true); } +/**************************************************************************** + * Name: sam3u_mpuheap + * + * Description: + * Map a heap region (probably needs to extension to handle external SRAM). + * + ****************************************************************************/ + +void sam3u_mpuheap(uintptr_t start, size_t size) +{ + mpu_userintsram(start, size); +} + #endif /* CONFIG_NUTTX_KERNEL */ |