diff options
Diffstat (limited to 'nuttx/arch/arm/src/sam3u')
-rw-r--r-- | nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c | 26 | ||||
-rw-r--r-- | nuttx/arch/arm/src/sam3u/sam3u_vectors.S | 10 |
2 files changed, 22 insertions, 14 deletions
diff --git a/nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c b/nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c index 86d5fbf36..576fae802 100644 --- a/nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c +++ b/nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c @@ -109,9 +109,12 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) { #if defined(CONFIG_NUTTX_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) - /* Get the unaligned size of the user-space heap */ + /* Get the unaligned size and position of the user-space heap. + * This heap begins after the user-space .bss section at an offset + * of CONFIG_MM_KERNEL_HEAPSIZE (subject to alignment). + */ - uintptr_t ubase = (uintptr_t)g_heapbase + CONFIG_MM_KERNEL_HEAPSIZE; + uintptr_t ubase = (uintptr_t)USERSPACE->us_bssend + CONFIG_MM_KERNEL_HEAPSIZE; size_t usize = CONFIG_DRAM_END - ubase; int log2; @@ -142,8 +145,8 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) /* Return the heap settings */ up_ledon(LED_HEAPALLOCATE); - *heap_start = (FAR void*)g_heapbase; - *heap_size = CONFIG_DRAM_END - g_heapbase; + *heap_start = (FAR void*)g_idle_topstack; + *heap_size = CONFIG_DRAM_END - g_idle_topstack; #endif } @@ -160,9 +163,12 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) #if defined(CONFIG_NUTTX_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) void up_allocate_kheap(FAR void **heap_start, size_t *heap_size) { - /* Get the unaligned size of the user-space heap */ + /* Get the unaligned size and position of the user-space heap. + * This heap begins after the user-space .bss section at an offset + * of CONFIG_MM_KERNEL_HEAPSIZE (subject to alignment). + */ - uintptr_t ubase = (uintptr_t)g_heapbase + CONFIG_MM_KERNEL_HEAPSIZE; + uintptr_t ubase = (uintptr_t)USERSPACE->us_bssend + CONFIG_MM_KERNEL_HEAPSIZE; size_t usize = CONFIG_DRAM_END - ubase; int log2; @@ -179,10 +185,12 @@ void up_allocate_kheap(FAR void **heap_start, size_t *heap_size) usize = (1 << log2); ubase = CONFIG_DRAM_END - usize; - /* Return the kernel heap settings */ + /* Return the kernel heap settings (i.e., the part of the heap region + * that was not dedicated to the user heap). + */ - *heap_start = (FAR void*)g_heapbase; - *heap_size = ubase - (uintptr_t)g_heapbase; + *heap_start = (FAR void*)USERSPACE->us_bssend; + *heap_size = ubase - (uintptr_t)USERSPACE->us_bssend; } #endif diff --git a/nuttx/arch/arm/src/sam3u/sam3u_vectors.S b/nuttx/arch/arm/src/sam3u/sam3u_vectors.S index ec0287e34..eba6edd3a 100644 --- a/nuttx/arch/arm/src/sam3u/sam3u_vectors.S +++ b/nuttx/arch/arm/src/sam3u/sam3u_vectors.S @@ -443,13 +443,13 @@ g_intstackbase: * and is of size CONFIG_IDLETHREAD_STACKSIZE. The IDLE thread is the thread that * the system boots on and, eventually, becomes the idle, do nothing task that runs * only when there is nothing else to run. The heap continues from there until the - * end of memory. See g_heapbase below. + * end of memory. See g_idle_topstack below. */ - .globl g_heapbase - .type g_heapbase, object -g_heapbase: + .globl g_idle_topstack + .type g_idle_topstack, object +g_idle_topstack: .word HEAP_BASE - .size g_heapbase, .-g_heapbase + .size g_idle_topstack, .-g_idle_topstack .end |