summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/sam3u
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-14 14:42:52 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-14 14:42:52 +0000
commit0d36830a37fcdb64c2b2d00990e084e7f8d63456 (patch)
tree78cc505c6874907ce2a37ab2b94d15c848c0ce50 /nuttx/arch/arm/src/sam3u
parent5be9588ed42d1a4ed297bdc76d9e05e582e78969 (diff)
downloadpx4-nuttx-0d36830a37fcdb64c2b2d00990e084e7f8d63456.tar.gz
px4-nuttx-0d36830a37fcdb64c2b2d00990e084e7f8d63456.tar.bz2
px4-nuttx-0d36830a37fcdb64c2b2d00990e084e7f8d63456.zip
Rename g_heapbase to g_idle_topstack; Fix kernel build heap allocation which cannot use g_heapbase
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5739 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/sam3u')
-rw-r--r--nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c26
-rw-r--r--nuttx/arch/arm/src/sam3u/sam3u_vectors.S10
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