diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-14 14:42:52 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-14 14:42:52 +0000 |
commit | 0d36830a37fcdb64c2b2d00990e084e7f8d63456 (patch) | |
tree | 78cc505c6874907ce2a37ab2b94d15c848c0ce50 /nuttx/arch/arm/src | |
parent | 5be9588ed42d1a4ed297bdc76d9e05e582e78969 (diff) | |
download | px4-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')
24 files changed, 115 insertions, 99 deletions
diff --git a/nuttx/arch/arm/src/arm/up_assert.c b/nuttx/arch/arm/src/arm/up_assert.c index d97aba5ea..e5bf00d6e 100644 --- a/nuttx/arch/arm/src/arm/up_assert.c +++ b/nuttx/arch/arm/src/arm/up_assert.c @@ -174,7 +174,7 @@ static void up_dumpstate(void) if (rtcb->pid == 0) { - ustackbase = g_heapbase - 4; + ustackbase = g_idle_topstack - 4; ustacksize = CONFIG_IDLETHREAD_STACKSIZE; } else diff --git a/nuttx/arch/arm/src/arm/up_head.S b/nuttx/arch/arm/src/arm/up_head.S index 46efd8772..ef911d0b6 100644 --- a/nuttx/arch/arm/src/arm/up_head.S +++ b/nuttx/arch/arm/src/arm/up_head.S @@ -610,7 +610,7 @@ __start: * * The idle task stack starts at the end of BSS and is of size * CONFIG_IDLETHREAD_STACKSIZE. The heap continues from there until the - * end of memory. See g_heapbase below. + * end of memory. See g_idle_topstack below. */ .Linitparms: @@ -645,17 +645,17 @@ __start: /* Data section variables */ - /* This global variable is unsigned long g_heapbase and is + /* This global variable is unsigned long g_idle_topstack and is * exported from here only because of its coupling to .Linitparms * above. */ .data .align 4 - .globl g_heapbase - .type g_heapbase, object -g_heapbase: + .globl g_idle_topstack + .type g_idle_topstack, object +g_idle_topstack: .long _ebss+CONFIG_IDLETHREAD_STACKSIZE - .size g_heapbase, .-g_heapbase + .size g_idle_topstack, .-g_idle_topstack .end diff --git a/nuttx/arch/arm/src/arm/up_nommuhead.S b/nuttx/arch/arm/src/arm/up_nommuhead.S index aac95b73a..e3f5a94e6 100644 --- a/nuttx/arch/arm/src/arm/up_nommuhead.S +++ b/nuttx/arch/arm/src/arm/up_nommuhead.S @@ -135,7 +135,7 @@ __start: * _ebss is the end of the BSS regsion (see ld.script) * The idle task stack starts at the end of BSS and is * of size CONFIG_IDLETHREAD_STACKSIZE. The heap continues - * from there until the end of memory. See g_heapbase + * from there until the end of memory. See g_idle_topstack * below. */ @@ -150,18 +150,18 @@ LC2: .long _eronly /* Where .data defaults are stored in FLASH */ #endif .size __start, .-__start - /* This global variable is unsigned long g_heapbase and is + /* This global variable is unsigned long g_idle_topstack and is * exported from here only because of its coupling to LCO * above. */ .data .align 4 - .globl g_heapbase - .type g_heapbase, object -g_heapbase: + .globl g_idle_topstack + .type g_idle_topstack, object +g_idle_topstack: .long _ebss+CONFIG_IDLETHREAD_STACKSIZE - .size g_heapbase, .-g_heapbase + .size g_idle_topstack, .-g_idle_topstack .end diff --git a/nuttx/arch/arm/src/armv6-m/up_assert.c b/nuttx/arch/arm/src/armv6-m/up_assert.c index 15ba1f53f..de5e5f6a1 100644 --- a/nuttx/arch/arm/src/armv6-m/up_assert.c +++ b/nuttx/arch/arm/src/armv6-m/up_assert.c @@ -181,7 +181,7 @@ static void up_dumpstate(void) if (rtcb->pid == 0) { - ustackbase = g_heapbase - 4; + ustackbase = g_idle_topstack - 4; ustacksize = CONFIG_IDLETHREAD_STACKSIZE; } else diff --git a/nuttx/arch/arm/src/armv7-m/mpu.h b/nuttx/arch/arm/src/armv7-m/mpu.h index 74bfe7a9e..7e2e6bb77 100644 --- a/nuttx/arch/arm/src/armv7-m/mpu.h +++ b/nuttx/arch/arm/src/armv7-m/mpu.h @@ -66,7 +66,7 @@ /* MPU Type Register Bit Definitions */ #define MPU_TYPE_SEPARATE (1 << 0) /* Bit 0: 0:unified or 1:separate memory maps */ -#define MPU_TYPE_DREGION_SHIFT (8) /* Bits 8-15: Number MPU data regsion */ +#define MPU_TYPE_DREGION_SHIFT (8) /* Bits 8-15: Number MPU data regions */ #define MPU_TYPE_DREGION_MASK (0xff << MPU_TYPE_DREGION_SHIFT) #define MPU_TYPE_IREGION_SHIFT (16) /* Bits 16-23: Number MPU instruction regions */ #define MPU_TYPE_IREGION_MASK (0xff << MPU_TYPE_IREGION_SHIFT) @@ -104,11 +104,11 @@ # define MPU_RASR_SRD_5 (0x20 << MPU_RASR_SRD_SHIFT) # define MPU_RASR_SRD_6 (0x40 << MPU_RASR_SRD_SHIFT) # define MPU_RASR_SRD_7 (0x80 << MPU_RASR_SRD_SHIFT) -#define MPU_RASR_ATTR_SHIFT (21) /* Bits 19-21: TEX Address Permisson */ -#define MPU_RASR_ATTR__MASK (7 << MPU_RASR_ATTR_SHIFT) -#define MPU_RASR_S (1 << 18) /* Bit 18: Shareable */ -#define MPU_RASR_C (1 << 17) /* Bit 17: Cacheable */ #define MPU_RASR_B (1 << 16) /* Bit 16: Bufferable */ +#define MPU_RASR_C (1 << 17) /* Bit 17: Cacheable */ +#define MPU_RASR_S (1 << 18) /* Bit 18: Shareable */ +#define MPU_RASR_ATTR_SHIFT (19) /* Bits 19-21: TEX Address Permisson */ +#define MPU_RASR_ATTR_MASK (7 << MPU_RASR_ATTR_SHIFT) #define MPU_RASR_AP_SHIFT (24) /* Bits 24-26: Access permission */ #define MPU_RASR_AP_MASK (7 << MPU_RASR_AP_SHIFT) # define MPU_RASR_AP_NONO (0 << MPU_RASR_AP_SHIFT) /* P:None U:None */ diff --git a/nuttx/arch/arm/src/armv7-m/up_assert.c b/nuttx/arch/arm/src/armv7-m/up_assert.c index 394c6858f..a4a58639c 100644 --- a/nuttx/arch/arm/src/armv7-m/up_assert.c +++ b/nuttx/arch/arm/src/armv7-m/up_assert.c @@ -180,7 +180,7 @@ static void up_dumpstate(void) if (rtcb->pid == 0) { - ustackbase = g_heapbase - 4; + ustackbase = g_idle_topstack - 4; ustacksize = CONFIG_IDLETHREAD_STACKSIZE; } else diff --git a/nuttx/arch/arm/src/common/up_allocateheap.c b/nuttx/arch/arm/src/common/up_allocateheap.c index 12cbfcfa8..617bffd2e 100644 --- a/nuttx/arch/arm/src/common/up_allocateheap.c +++ b/nuttx/arch/arm/src/common/up_allocateheap.c @@ -82,6 +82,6 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) { 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; } diff --git a/nuttx/arch/arm/src/common/up_internal.h b/nuttx/arch/arm/src/common/up_internal.h index 6e874b2ca..1a7c1e304 100644 --- a/nuttx/arch/arm/src/common/up_internal.h +++ b/nuttx/arch/arm/src/common/up_internal.h @@ -166,7 +166,7 @@ extern volatile uint32_t *current_regs; * CONFIG_DRAM_END */ -extern const uint32_t g_heapbase; +extern const uint32_t g_idle_topstack; /* Address of the saved user stack pointer */ diff --git a/nuttx/arch/arm/src/dm320/dm320_allocateheap.c b/nuttx/arch/arm/src/dm320/dm320_allocateheap.c index 1383b93da..27a7e7a90 100644 --- a/nuttx/arch/arm/src/dm320/dm320_allocateheap.c +++ b/nuttx/arch/arm/src/dm320/dm320_allocateheap.c @@ -85,6 +85,6 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) { up_ledon(LED_HEAPALLOCATE); - *heap_start = (FAR void*)g_heapbase; - *heap_size = (DM320_SDRAM_VADDR + CONFIG_DRAM_SIZE) - g_heapbase; + *heap_start = (FAR void*)g_idle_topstack; + *heap_size = (DM320_SDRAM_VADDR + CONFIG_DRAM_SIZE) - g_idle_topstack; } diff --git a/nuttx/arch/arm/src/imx/imx_allocateheap.c b/nuttx/arch/arm/src/imx/imx_allocateheap.c index 37b05eb7f..f94a7fe44 100644 --- a/nuttx/arch/arm/src/imx/imx_allocateheap.c +++ b/nuttx/arch/arm/src/imx/imx_allocateheap.c @@ -86,8 +86,8 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) { up_ledon(LED_HEAPALLOCATE); - *heap_start = (FAR void*)g_heapbase; - *heap_size = (IMX_SDRAM_VSECTION + CONFIG_DRAM_SIZE) - g_heapbase; + *heap_start = (FAR void*)g_idle_topstack; + *heap_size = (IMX_SDRAM_VSECTION + CONFIG_DRAM_SIZE) - g_idle_topstack; } /**************************************************************************** diff --git a/nuttx/arch/arm/src/kinetis/kinetis_vectors.S b/nuttx/arch/arm/src/kinetis/kinetis_vectors.S index 7fa223615..11ac46221 100644 --- a/nuttx/arch/arm/src/kinetis/kinetis_vectors.S +++ b/nuttx/arch/arm/src/kinetis/kinetis_vectors.S @@ -738,13 +738,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 diff --git a/nuttx/arch/arm/src/lm/lm_vectors.S b/nuttx/arch/arm/src/lm/lm_vectors.S index 1d3553b4e..0f4300065 100644 --- a/nuttx/arch/arm/src/lm/lm_vectors.S +++ b/nuttx/arch/arm/src/lm/lm_vectors.S @@ -336,13 +336,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: .long _ebss+CONFIG_IDLETHREAD_STACKSIZE - .size g_heapbase, .-g_heapbase + .size g_idle_topstack, .-g_idle_topstack .end diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_allocateheap.c b/nuttx/arch/arm/src/lpc17xx/lpc17_allocateheap.c index f316570f5..047edf5e3 100644 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_allocateheap.c +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_allocateheap.c @@ -198,9 +198,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; @@ -231,8 +234,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 } @@ -249,9 +252,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; @@ -268,10 +274,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/lpc17xx/lpc17_vectors.S b/nuttx/arch/arm/src/lpc17xx/lpc17_vectors.S index 25d2e7f19..eca382b1b 100644 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_vectors.S +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_vectors.S @@ -417,13 +417,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 diff --git a/nuttx/arch/arm/src/lpc214x/lpc214x_head.S b/nuttx/arch/arm/src/lpc214x/lpc214x_head.S index 678481154..ea2ea1220 100644 --- a/nuttx/arch/arm/src/lpc214x/lpc214x_head.S +++ b/nuttx/arch/arm/src/lpc214x/lpc214x_head.S @@ -604,7 +604,7 @@ __start: * _ebss is the end of the BSS regsion (see ld.script) * The idle task stack starts at the end of BSS and is * of size CONFIG_IDLETHREAD_STACKSIZE. The heap continues - * from there until the end of memory. See g_heapbase + * from there until the end of memory. See g_idle_topstack * below. */ @@ -617,18 +617,18 @@ LC2: .long _eronly /* Where .data defaults are stored in FLASH */ .long _edata .size __start, .-__start - /* This global variable is unsigned long g_heapbase and is + /* This global variable is unsigned long g_idle_topstack and is * exported from here only because of its coupling to LCO * above. */ .data .align 4 - .globl g_heapbase - .type g_heapbase, object -g_heapbase: + .globl g_idle_topstack + .type g_idle_topstack, object +g_idle_topstack: .long _ebss+CONFIG_IDLETHREAD_STACKSIZE - .size g_heapbase, .-g_heapbase + .size g_idle_topstack, .-g_idle_topstack .end diff --git a/nuttx/arch/arm/src/lpc2378/lpc23xx_head.S b/nuttx/arch/arm/src/lpc2378/lpc23xx_head.S index a4cab8f05..578b77753 100755 --- a/nuttx/arch/arm/src/lpc2378/lpc23xx_head.S +++ b/nuttx/arch/arm/src/lpc2378/lpc23xx_head.S @@ -204,7 +204,7 @@ __start: * _ebss is the end of the BSS regsion (see ld.script) * The idle task stack starts at the end of BSS and is * of size CONFIG_IDLETHREAD_STACKSIZE. The heap continues - * from there until the end of memory. See g_heapbase + * from there until the end of memory. See g_idle_topstack * below. */ @@ -217,18 +217,18 @@ LC2: .long _eronly /* Where .data defaults are stored in FLASH */ .long _edata .size __start, .-__start - /* This global variable is unsigned long g_heapbase and is + /* This global variable is unsigned long g_idle_topstack and is * exported from here only because of its coupling to LCO * above. */ .data .align 4 - .globl g_heapbase - .type g_heapbase, object -g_heapbase: + .globl g_idle_topstack + .type g_idle_topstack, object +g_idle_topstack: .long _ebss+CONFIG_IDLETHREAD_STACKSIZE - .size g_heapbase, .-g_heapbase + .size g_idle_topstack, .-g_idle_topstack .end diff --git a/nuttx/arch/arm/src/lpc31xx/lpc31_allocateheap.c b/nuttx/arch/arm/src/lpc31xx/lpc31_allocateheap.c index f57c343ef..7c2c8696a 100644 --- a/nuttx/arch/arm/src/lpc31xx/lpc31_allocateheap.c +++ b/nuttx/arch/arm/src/lpc31xx/lpc31_allocateheap.c @@ -180,8 +180,8 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) { up_ledon(LED_HEAPALLOCATE); - *heap_start = (FAR void*)g_heapbase; - *heap_size = LPC31_HEAP_VEND - g_heapbase; + *heap_start = (FAR void*)g_idle_topstack; + *heap_size = LPC31_HEAP_VEND - g_idle_topstack; } /************************************************************************ diff --git a/nuttx/arch/arm/src/lpc43xx/lpc43_allocateheap.c b/nuttx/arch/arm/src/lpc43xx/lpc43_allocateheap.c index c33f9f1ed..4d9d7b21c 100644 --- a/nuttx/arch/arm/src/lpc43xx/lpc43_allocateheap.c +++ b/nuttx/arch/arm/src/lpc43xx/lpc43_allocateheap.c @@ -211,10 +211,10 @@ * 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 configured end of memory. - * g_heapbase is the beginning of this heap region (not necessarily aligned). + * g_idle_topstack is the beginning of this heap region (not necessarily aligned). */ -const uint32_t g_heapbase = (uint32_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE; +const uint32_t g_idle_topstack = (uint32_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE; /**************************************************************************** * Private Functions @@ -244,8 +244,8 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) /* Start with the first SRAM region */ 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; } /************************************************************************ diff --git a/nuttx/arch/arm/src/nuc1xx/nuc_start.c b/nuttx/arch/arm/src/nuc1xx/nuc_start.c index 67c06c7a5..fa5f249a3 100644 --- a/nuttx/arch/arm/src/nuc1xx/nuc_start.c +++ b/nuttx/arch/arm/src/nuc1xx/nuc_start.c @@ -77,7 +77,7 @@ * Public Data ****************************************************************************/ -const uint32_t g_heapbase = HEAP_BASE; +const uint32_t g_idle_topstack = HEAP_BASE; /**************************************************************************** * Private Functions 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 diff --git a/nuttx/arch/arm/src/stm32/stm32_allocateheap.c b/nuttx/arch/arm/src/stm32/stm32_allocateheap.c index 149de8648..6a29fb16c 100644 --- a/nuttx/arch/arm/src/stm32/stm32_allocateheap.c +++ b/nuttx/arch/arm/src/stm32/stm32_allocateheap.c @@ -88,7 +88,7 @@ #endif /* For the STM312F10xxx family, all internal SRAM is in one contiguous block - * starting at g_heapbase and extending through CONFIG_DRAM_END (my apologies for + * starting at g_idle_topstack and extending through CONFIG_DRAM_END (my apologies for * the bad naming). In addition, external FSMC SRAM may be available. */ @@ -198,7 +198,7 @@ * * 3) 64Kb of CCM SRAM beginning at address 0x1000:0000 * - * As determined by ld.script, g_heapbase lies in the 112Kb memory + * As determined by ld.script, g_idle_topstack lies in the 112Kb memory * region and that extends to 0x2001:0000. But the first and second memory * regions are contiguous and treated as one in this logic that extends to * 0x2002:0000. @@ -370,8 +370,8 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) { up_ledon(LED_HEAPALLOCATE); - *heap_start = (FAR void*)g_heapbase; - *heap_size = SRAM1_END - g_heapbase; + *heap_start = (FAR void*)g_idle_topstack; + *heap_size = SRAM1_END - g_idle_topstack; } /**************************************************************************** diff --git a/nuttx/arch/arm/src/stm32/stm32_vectors.S b/nuttx/arch/arm/src/stm32/stm32_vectors.S index ab29c2e14..6b9c0affe 100644 --- a/nuttx/arch/arm/src/stm32/stm32_vectors.S +++ b/nuttx/arch/arm/src/stm32/stm32_vectors.S @@ -426,14 +426,14 @@ 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: .long _ebss+CONFIG_IDLETHREAD_STACKSIZE - .size g_heapbase, .-g_heapbase + .size g_idle_topstack, .-g_idle_topstack .end diff --git a/nuttx/arch/arm/src/str71x/str71x_head.S b/nuttx/arch/arm/src/str71x/str71x_head.S index e83affa37..710fd57a5 100644 --- a/nuttx/arch/arm/src/str71x/str71x_head.S +++ b/nuttx/arch/arm/src/str71x/str71x_head.S @@ -599,7 +599,7 @@ dtor_end: * _ebss is the end of the BSS regsion (see ld.script) * The idle task stack starts at the end of BSS and is * of size CONFIG_IDLETHREAD_STACKSIZE. The heap continues - * from there until the end of memory. See g_heapbase + * from there until the end of memory. See g_idle_topstack * below. */ @@ -612,18 +612,18 @@ LC2: .long _eronly /* Where .data defaults are stored in FLASH */ .long _edata .size __start, .-__start - /* This global variable is unsigned long g_heapbase and is + /* This global variable is unsigned long g_idle_topstack and is * exported from here only because of its coupling to LCO * above. */ .data .align 4 - .globl g_heapbase - .type g_heapbase, object -g_heapbase: + .globl g_idle_topstack + .type g_idle_topstack, object +g_idle_topstack: .long _ebss+CONFIG_IDLETHREAD_STACKSIZE - .size g_heapbase, .-g_heapbase + .size g_idle_topstack, .-g_idle_topstack .end |