From 0d36830a37fcdb64c2b2d00990e084e7f8d63456 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 14 Mar 2013 14:42:52 +0000 Subject: 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 --- nuttx/arch/arm/src/arm/up_assert.c | 2 +- nuttx/arch/arm/src/arm/up_head.S | 12 +- nuttx/arch/arm/src/arm/up_nommuhead.S | 12 +- nuttx/arch/arm/src/armv6-m/up_assert.c | 2 +- nuttx/arch/arm/src/armv7-m/mpu.h | 10 +- nuttx/arch/arm/src/armv7-m/up_assert.c | 2 +- nuttx/arch/arm/src/common/up_allocateheap.c | 4 +- nuttx/arch/arm/src/common/up_internal.h | 2 +- nuttx/arch/arm/src/dm320/dm320_allocateheap.c | 4 +- nuttx/arch/arm/src/imx/imx_allocateheap.c | 4 +- nuttx/arch/arm/src/kinetis/kinetis_vectors.S | 10 +- nuttx/arch/arm/src/lm/lm_vectors.S | 10 +- nuttx/arch/arm/src/lpc17xx/lpc17_allocateheap.c | 26 ++-- nuttx/arch/arm/src/lpc17xx/lpc17_vectors.S | 10 +- nuttx/arch/arm/src/lpc214x/lpc214x_head.S | 12 +- nuttx/arch/arm/src/lpc2378/lpc23xx_head.S | 12 +- nuttx/arch/arm/src/lpc31xx/lpc31_allocateheap.c | 4 +- nuttx/arch/arm/src/lpc43xx/lpc43_allocateheap.c | 8 +- nuttx/arch/arm/src/nuc1xx/nuc_start.c | 2 +- nuttx/arch/arm/src/sam3u/sam3u_allocateheap.c | 26 ++-- nuttx/arch/arm/src/sam3u/sam3u_vectors.S | 10 +- nuttx/arch/arm/src/stm32/stm32_allocateheap.c | 8 +- nuttx/arch/arm/src/stm32/stm32_vectors.S | 10 +- nuttx/arch/arm/src/str71x/str71x_head.S | 12 +- nuttx/arch/avr/src/at90usb/at90usb_head.S | 10 +- nuttx/arch/avr/src/atmega/atmega_head.S | 10 +- nuttx/arch/avr/src/avr/avr_internal.h | 2 +- nuttx/arch/avr/src/avr/up_dumpstate.c | 2 +- nuttx/arch/avr/src/avr32/avr32_internal.h | 2 +- nuttx/arch/avr/src/avr32/up_dumpstate.c | 2 +- nuttx/arch/avr/src/avr32/up_nommuhead.S | 10 +- nuttx/arch/avr/src/common/up_allocateheap.c | 4 +- nuttx/arch/hc/src/common/up_allocateheap.c | 4 +- nuttx/arch/hc/src/common/up_internal.h | 2 +- nuttx/arch/hc/src/m9s12/m9s12_assert.c | 2 +- nuttx/arch/hc/src/m9s12/m9s12_start.S | 12 +- nuttx/arch/mips/src/common/up_allocateheap.c | 4 +- nuttx/arch/mips/src/common/up_internal.h | 2 +- nuttx/arch/mips/src/mips32/up_dumpstate.c | 2 +- nuttx/arch/mips/src/pic32mx/pic32mx-head.S | 10 +- nuttx/arch/sh/src/common/up_allocateheap.c | 4 +- nuttx/arch/sh/src/common/up_internal.h | 2 +- nuttx/arch/sh/src/m16c/chip.h | 24 ++-- nuttx/arch/sh/src/m16c/m16c_dumpstate.c | 2 +- nuttx/arch/sh/src/m16c/m16c_head.S | 8 +- nuttx/arch/sh/src/sh1/sh1_dumpstate.c | 2 +- nuttx/arch/sh/src/sh1/sh1_head.S | 10 +- nuttx/arch/x86/src/common/up_allocateheap.c | 4 +- nuttx/arch/x86/src/common/up_assert.c | 2 +- nuttx/arch/x86/src/common/up_internal.h | 2 +- nuttx/arch/x86/src/qemu/qemu_head.S | 10 +- nuttx/configs/open1788/kernel/Makefile | 6 +- nuttx/configs/open1788/knsh/Make.defs | 26 ++-- nuttx/configs/open1788/scripts/kernel-space.ld | 32 +---- nuttx/configs/open1788/scripts/memory.ld | 77 +++++++++++ nuttx/configs/open1788/scripts/user-space.ld | 37 +---- nuttx/configs/sam3u-ek/kernel/Makefile | 6 +- nuttx/configs/sam3u-ek/knsh/Make.defs | 28 ++-- nuttx/configs/sam3u-ek/scripts/kernel-space.ld | 29 +--- nuttx/configs/sam3u-ek/scripts/memory.ld | 152 +++++++++++++++++++++ nuttx/configs/sam3u-ek/scripts/user-space.ld | 33 +---- nuttx/configs/zkit-arm-1769/include/board.h | 1 + nuttx/configs/zkit-arm-1769/src/Makefile | 2 +- nuttx/configs/zkit-arm-1769/src/zkitarm_internal.h | 7 +- 64 files changed, 478 insertions(+), 322 deletions(-) create mode 100644 nuttx/configs/open1788/scripts/memory.ld create mode 100644 nuttx/configs/sam3u-ek/scripts/memory.ld 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 diff --git a/nuttx/arch/avr/src/at90usb/at90usb_head.S b/nuttx/arch/avr/src/at90usb/at90usb_head.S index be747632b..1e705ba71 100755 --- a/nuttx/arch/avr/src/at90usb/at90usb_head.S +++ b/nuttx/arch/avr/src/at90usb/at90usb_head.S @@ -266,14 +266,14 @@ __do_clear_bss: * Heap Base ****************************************************************************/ - /* This global variable is unsigned long g_heapbase and is exported from + /* This global variable is unsigned long g_idle_topstack and is exported from * here only because of its coupling to other uses of _enoinit in this file */ .data - .globl g_heapbase - .type g_heapbase, object -g_heapbase: + .globl g_idle_topstack + .type g_idle_topstack, object +g_idle_topstack: .word _enoinit+CONFIG_IDLETHREAD_STACKSIZE - .size g_heapbase, .-g_heapbase + .size g_idle_topstack, .-g_idle_topstack .end diff --git a/nuttx/arch/avr/src/atmega/atmega_head.S b/nuttx/arch/avr/src/atmega/atmega_head.S index 95de2f100..89c3cd1f9 100755 --- a/nuttx/arch/avr/src/atmega/atmega_head.S +++ b/nuttx/arch/avr/src/atmega/atmega_head.S @@ -260,14 +260,14 @@ __do_clear_bss: * Heap Base ****************************************************************************/ - /* This global variable is unsigned long g_heapbase and is exported from + /* This global variable is unsigned long g_idle_topstack and is exported from * here only because of its coupling to other uses of _enoinit in this file */ .data - .globl g_heapbase - .type g_heapbase, object -g_heapbase: + .globl g_idle_topstack + .type g_idle_topstack, object +g_idle_topstack: .word _enoinit+CONFIG_IDLETHREAD_STACKSIZE - .size g_heapbase, .-g_heapbase + .size g_idle_topstack, .-g_idle_topstack .end diff --git a/nuttx/arch/avr/src/avr/avr_internal.h b/nuttx/arch/avr/src/avr/avr_internal.h index 031000cd1..2c78791e4 100644 --- a/nuttx/arch/avr/src/avr/avr_internal.h +++ b/nuttx/arch/avr/src/avr/avr_internal.h @@ -81,7 +81,7 @@ extern volatile uint8_t *current_regs; * heap is CONFIG_DRAM_END */ -extern uint16_t g_heapbase; +extern uint16_t g_idle_topstack; #endif /* __ASSEMBLY__ */ diff --git a/nuttx/arch/avr/src/avr/up_dumpstate.c b/nuttx/arch/avr/src/avr/up_dumpstate.c index 62e80255f..6ba50d238 100644 --- a/nuttx/arch/avr/src/avr/up_dumpstate.c +++ b/nuttx/arch/avr/src/avr/up_dumpstate.c @@ -181,7 +181,7 @@ void up_dumpstate(void) if (rtcb->pid == 0) { - ustackbase = g_heapbase - 1; + ustackbase = g_idle_topstack - 1; ustacksize = CONFIG_IDLETHREAD_STACKSIZE; } else diff --git a/nuttx/arch/avr/src/avr32/avr32_internal.h b/nuttx/arch/avr/src/avr32/avr32_internal.h index 3d45f6c54..bcac8074a 100644 --- a/nuttx/arch/avr/src/avr32/avr32_internal.h +++ b/nuttx/arch/avr/src/avr32/avr32_internal.h @@ -79,7 +79,7 @@ extern volatile uint32_t *current_regs; * heap is CONFIG_DRAM_END */ -extern uint32_t g_heapbase; +extern uint32_t g_idle_topstack; #endif /* __ASSEMBLY__ */ diff --git a/nuttx/arch/avr/src/avr32/up_dumpstate.c b/nuttx/arch/avr/src/avr32/up_dumpstate.c index 32db56f0d..90cb22837 100644 --- a/nuttx/arch/avr/src/avr32/up_dumpstate.c +++ b/nuttx/arch/avr/src/avr32/up_dumpstate.c @@ -158,7 +158,7 @@ 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/avr/src/avr32/up_nommuhead.S b/nuttx/arch/avr/src/avr32/up_nommuhead.S index 316e68aaf..149b1f26f 100644 --- a/nuttx/arch/avr/src/avr32/up_nommuhead.S +++ b/nuttx/arch/avr/src/avr32/up_nommuhead.S @@ -141,17 +141,17 @@ __start: .word up_lowinit .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 other * uses of _ebss in this file */ .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/avr/src/common/up_allocateheap.c b/nuttx/arch/avr/src/common/up_allocateheap.c index 3a67ff6a7..3893e3a2d 100644 --- a/nuttx/arch/avr/src/common/up_allocateheap.c +++ b/nuttx/arch/avr/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/hc/src/common/up_allocateheap.c b/nuttx/arch/hc/src/common/up_allocateheap.c index b107baaa5..f0c8f58a4 100644 --- a/nuttx/arch/hc/src/common/up_allocateheap.c +++ b/nuttx/arch/hc/src/common/up_allocateheap.c @@ -81,6 +81,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/hc/src/common/up_internal.h b/nuttx/arch/hc/src/common/up_internal.h index 0de737fb6..87503c56f 100644 --- a/nuttx/arch/hc/src/common/up_internal.h +++ b/nuttx/arch/hc/src/common/up_internal.h @@ -141,7 +141,7 @@ extern volatile uint8_t *current_regs; * The end of the heap is CONFIG_DRAM_END */ -extern uint16_t g_heapbase; +extern uint16_t g_idle_topstack; /* Address of the saved user stack pointer */ diff --git a/nuttx/arch/hc/src/m9s12/m9s12_assert.c b/nuttx/arch/hc/src/m9s12/m9s12_assert.c index 62ad33d2d..9f97ec4db 100644 --- a/nuttx/arch/hc/src/m9s12/m9s12_assert.c +++ b/nuttx/arch/hc/src/m9s12/m9s12_assert.c @@ -169,7 +169,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/hc/src/m9s12/m9s12_start.S b/nuttx/arch/hc/src/m9s12/m9s12_start.S index 66c1b80f9..c79388030 100755 --- a/nuttx/arch/hc/src/m9s12/m9s12_start.S +++ b/nuttx/arch/hc/src/m9s12/m9s12_start.S @@ -233,7 +233,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. */ @@ -262,12 +262,12 @@ __start: * 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: .hword _ebss+CONFIG_IDLETHREAD_STACKSIZE - .size g_heapbase, .-g_heapbase + .size g_idle_topstack, .-g_idle_topstack .end diff --git a/nuttx/arch/mips/src/common/up_allocateheap.c b/nuttx/arch/mips/src/common/up_allocateheap.c index b8c449ff1..f6dc51511 100644 --- a/nuttx/arch/mips/src/common/up_allocateheap.c +++ b/nuttx/arch/mips/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/mips/src/common/up_internal.h b/nuttx/arch/mips/src/common/up_internal.h index 927538dea..1950a74e6 100644 --- a/nuttx/arch/mips/src/common/up_internal.h +++ b/nuttx/arch/mips/src/common/up_internal.h @@ -138,7 +138,7 @@ extern volatile uint32_t *current_regs; * of the heap is CONFIG_DRAM_END */ -extern uint32_t g_heapbase; +extern uint32_t g_idle_topstack; /* Address of the saved user stack pointer */ diff --git a/nuttx/arch/mips/src/mips32/up_dumpstate.c b/nuttx/arch/mips/src/mips32/up_dumpstate.c index 064aa0681..bdd21726b 100644 --- a/nuttx/arch/mips/src/mips32/up_dumpstate.c +++ b/nuttx/arch/mips/src/mips32/up_dumpstate.c @@ -167,7 +167,7 @@ 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/mips/src/pic32mx/pic32mx-head.S b/nuttx/arch/mips/src/pic32mx/pic32mx-head.S index 2e1a34080..471effc3f 100644 --- a/nuttx/arch/mips/src/pic32mx/pic32mx-head.S +++ b/nuttx/arch/mips/src/pic32mx/pic32mx-head.S @@ -122,7 +122,7 @@ .global g_nestlevel #endif #endif - .global g_heapbase + .global g_idle_topstack /* Imported symbols */ @@ -698,13 +698,13 @@ g_nestlevel: #endif #endif -/* This global variable is unsigned int g_heapbase and is exported here only +/* This global variable is unsigned int g_idle_topstack and is exported here only * because of its coupling to idle thread stack. */ .sdata - .type g_heapbase, object -g_heapbase: + .type g_idle_topstack, object +g_idle_topstack: .long PIC32MX_HEAP_BASE - .size g_heapbase, .-g_heapbase + .size g_idle_topstack, .-g_idle_topstack diff --git a/nuttx/arch/sh/src/common/up_allocateheap.c b/nuttx/arch/sh/src/common/up_allocateheap.c index ad1935d9a..734a50483 100644 --- a/nuttx/arch/sh/src/common/up_allocateheap.c +++ b/nuttx/arch/sh/src/common/up_allocateheap.c @@ -81,6 +81,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/sh/src/common/up_internal.h b/nuttx/arch/sh/src/common/up_internal.h index f56e97c97..99c273ca6 100644 --- a/nuttx/arch/sh/src/common/up_internal.h +++ b/nuttx/arch/sh/src/common/up_internal.h @@ -140,7 +140,7 @@ extern volatile uint32_t *current_regs; * CONFIG_DRAM_END */ -extern uint32_t g_heapbase; +extern uint32_t g_idle_topstack; #endif /**************************************************************************** diff --git a/nuttx/arch/sh/src/m16c/chip.h b/nuttx/arch/sh/src/m16c/chip.h index 0a91d6041..02140df79 100644 --- a/nuttx/arch/sh/src/m16c/chip.h +++ b/nuttx/arch/sh/src/m16c/chip.h @@ -253,20 +253,20 @@ #ifndef __ASSEMBLY__ -extern uint16_t g_snbss; /* Start of near .bss */ -extern uint16_t g_enbss; /* End+1 of near .bss */ -extern uint16_t g_sndata; /* Start of near .data */ -extern uint16_t g_endata; /* End+1 of near .data */ -extern uint32_t g_enronly; /* Start of relocated read-only data in FLASH */ +extern uint16_t g_snbss; /* Start of near .bss */ +extern uint16_t g_enbss; /* End+1 of near .bss */ +extern uint16_t g_sndata; /* Start of near .data */ +extern uint16_t g_endata; /* End+1 of near .data */ +extern uint32_t g_enronly; /* Start of relocated read-only data in FLASH */ #ifdef CONFIG_M16C_HAVEFARRAM - extern uint32_t g_sfbss; /* Start of far .bss */ - extern uint32_t g_efbss; /* End+1 of far .bss */ - extern uint32_t g_sfdata; /* Start of far .data */ - extern uint32_t g_efdata; /* End_1 of far .data */ - extern uint32_t g_efronly; /* Start of relocated read-only data in FLASH */ + extern uint32_t g_sfbss; /* Start of far .bss */ + extern uint32_t g_efbss; /* End+1 of far .bss */ + extern uint32_t g_sfdata; /* Start of far .data */ + extern uint32_t g_efdata; /* End_1 of far .data */ + extern uint32_t g_efronly; /* Start of relocated read-only data in FLASH */ #endif -extern uint32_t g_svarvect; /* Start of variable vectors */ -extern uint32_t g_heapbase; /* Start of the heap */ +extern uint32_t g_svarvect; /* Start of variable vectors */ +extern uint32_t g_idle_topstack; /* Start of the heap */ /* Address of the saved user stack pointer */ diff --git a/nuttx/arch/sh/src/m16c/m16c_dumpstate.c b/nuttx/arch/sh/src/m16c/m16c_dumpstate.c index 3570a9ebe..8083f62bd 100644 --- a/nuttx/arch/sh/src/m16c/m16c_dumpstate.c +++ b/nuttx/arch/sh/src/m16c/m16c_dumpstate.c @@ -171,7 +171,7 @@ void up_dumpstate(void) if (rtcb->pid == 0) { - ustackbase = g_heapbase - 1; + ustackbase = g_idle_topstack - 1; ustacksize = CONFIG_IDLETHREAD_STACKSIZE; } else diff --git a/nuttx/arch/sh/src/m16c/m16c_head.S b/nuttx/arch/sh/src/m16c/m16c_head.S index 4e6b0e2c8..470946313 100644 --- a/nuttx/arch/sh/src/m16c/m16c_head.S +++ b/nuttx/arch/sh/src/m16c/m16c_head.S @@ -147,11 +147,11 @@ _g_svarvect: .long _svarvect .size _g_svarvect, .-_g_svarvect - .globl _g_heapbase - .type _g_heapbase, object -_g_heapbase: + .globl _g_idle_topstack + .type _g_idle_topstack, object +_g_idle_topstack: .long _enbss+CONFIG_ARCH_INTERRUPTSTACK+CONFIG_IDLETHREAD_STACKSIZE - .size _g_heapbase, .-_g_heapbase + .size _g_idle_topstack, .-_g_idle_topstack /************************************************************************************ * Code diff --git a/nuttx/arch/sh/src/sh1/sh1_dumpstate.c b/nuttx/arch/sh/src/sh1/sh1_dumpstate.c index 3d101c92d..8990f6615 100644 --- a/nuttx/arch/sh/src/sh1/sh1_dumpstate.c +++ b/nuttx/arch/sh/src/sh1/sh1_dumpstate.c @@ -160,7 +160,7 @@ 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/sh/src/sh1/sh1_head.S b/nuttx/arch/sh/src/sh1/sh1_head.S index 9a52b9bb3..774d22784 100644 --- a/nuttx/arch/sh/src/sh1/sh1_head.S +++ b/nuttx/arch/sh/src/sh1/sh1_head.S @@ -507,18 +507,18 @@ __start0: .section .data - /* 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 the stack * 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/x86/src/common/up_allocateheap.c b/nuttx/arch/x86/src/common/up_allocateheap.c index b56f9b59a..55f60f056 100644 --- a/nuttx/arch/x86/src/common/up_allocateheap.c +++ b/nuttx/arch/x86/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/x86/src/common/up_assert.c b/nuttx/arch/x86/src/common/up_assert.c index 173ca6623..ed83eb6ce 100644 --- a/nuttx/arch/x86/src/common/up_assert.c +++ b/nuttx/arch/x86/src/common/up_assert.c @@ -128,7 +128,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/x86/src/common/up_internal.h b/nuttx/arch/x86/src/common/up_internal.h index c27717c38..3351e24c4 100644 --- a/nuttx/arch/x86/src/common/up_internal.h +++ b/nuttx/arch/x86/src/common/up_internal.h @@ -140,7 +140,7 @@ extern volatile uint32_t *current_regs; * heap is CONFIG_DRAM_END */ -extern uint32_t g_heapbase; +extern uint32_t g_idle_topstack; /* Address of the saved user stack pointer */ diff --git a/nuttx/arch/x86/src/qemu/qemu_head.S b/nuttx/arch/x86/src/qemu/qemu_head.S index 2b86c1835..22c490469 100755 --- a/nuttx/arch/x86/src/qemu/qemu_head.S +++ b/nuttx/arch/x86/src/qemu/qemu_head.S @@ -50,7 +50,7 @@ * the end of BSS 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. + * heap continues from there until the end of memory. See g_idle_topstack below. */ #define STACKBASE ((_ebss + 0x1f) & 0xffffffe0) @@ -78,7 +78,7 @@ .global __start /* Making entry point visible to linker */ .global os_start /* os_start is defined elsewhere */ .global up_lowsetup /* up_lowsetup is defined elsewhere */ - .global g_heapbase /* The start of the heap */ + .global g_idle_topstack /* The start of the heap */ /**************************************************************************** * .text @@ -154,8 +154,8 @@ hang: * until the end of memory. */ - .type g_heapbase, @object -g_heapbase: + .type g_idle_topstack, @object +g_idle_topstack: .long _ebss - .size g_heapbase, . - g_heapbase + .size g_idle_topstack, . - g_idle_topstack .end diff --git a/nuttx/configs/open1788/kernel/Makefile b/nuttx/configs/open1788/kernel/Makefile index 16731a24d..fb6850f36 100644 --- a/nuttx/configs/open1788/kernel/Makefile +++ b/nuttx/configs/open1788/kernel/Makefile @@ -50,11 +50,13 @@ ENTRYPT = $(patsubst "%",%,$(CONFIG_USER_ENTRYPOINT)) ifeq ($(WINTOOL),y) # Windows-native toolchains USER_LIBPATHS = ${shell for path in $(USERLIBS); do dir=`dirname $(TOPDIR)$(DELIM)$$path`;echo "-L\"`cygpath -w $$dir`\"";done} - USER_LDSCRIPT = -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld}" + USER_LDSCRIPT = -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld}" + USER_LDSCRIPT += -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld}" else # Linux/Cygwin-native toolchain USER_LIBPATHS = $(addprefix -L$(TOPDIR)$(DELIM),$(dir $(USERLIBS))) - USER_LDSCRIPT = -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld + USER_LDSCRIPT = -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld + USER_LDSCRIPT += -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld endif USER_LDFLAGS = --undefined=$(ENTRYPT) --entry=$(ENTRYPT) $(USER_LDSCRIPT) diff --git a/nuttx/configs/open1788/knsh/Make.defs b/nuttx/configs/open1788/knsh/Make.defs index bf5073832..4ec863d1b 100644 --- a/nuttx/configs/open1788/knsh/Make.defs +++ b/nuttx/configs/open1788/knsh/Make.defs @@ -35,23 +35,25 @@ include ${TOPDIR}/.config include ${TOPDIR}/tools/Config.mk -include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs +include ${TOPDIR}$(DELIM)arch$(DELIM)arm$(DELIM)src$(DELIM)armv7-m$(DELIM)Toolchain.defs ifeq ($(WINTOOL),y) # Windows-native toolchains - DIRLINK = $(TOPDIR)/tools/copydir.sh - DIRUNLINK = $(TOPDIR)/tools/unlink.sh - MKDEP = $(TOPDIR)/tools/mknulldeps.sh - ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" - ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" - ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/kernel-space.ld}" + DIRLINK = $(TOPDIR)$(DELIM)tools$(DELIM)copydir.sh + DIRUNLINK = $(TOPDIR)$(DELIM)tools$(DELIM)unlink.sh + MKDEP = $(TOPDIR)$(DELIM)tools$(DELIM)mknulldeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)$(DELIM)include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)$(DELIM)include}" -isystem "${shell cygpath -w $(TOPDIR)$(DELIM)include$(DELIM)cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld}" + ARCHSCRIPT += -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)kernel-space.ld}" MAXOPTIMIZATION = -O2 else # Linux/Cygwin-native toolchain - MKDEP = $(TOPDIR)/tools/mkdeps.sh - ARCHINCLUDES = -I. -isystem $(TOPDIR)/include - ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx - ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/kernel-space.ld + MKDEP = $(TOPDIR)$(DELIM)tools$(DELIM)mkdeps.sh + ARCHINCLUDES = -I. -isystem $(TOPDIR)$(DELIM)include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)$(DELIM)include -isystem $(TOPDIR)$(DELIM)include$(DELIM)cxx + ARCHSCRIPT = -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld + ARCHSCRIPT += -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)kernel-space.ld endif CC = $(CROSSDEV)gcc @@ -87,7 +89,7 @@ CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) AFLAGS = $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common -NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 OBJEXT = .o diff --git a/nuttx/configs/open1788/scripts/kernel-space.ld b/nuttx/configs/open1788/scripts/kernel-space.ld index 84cf9212c..e80fa7d11 100755 --- a/nuttx/configs/open1788/scripts/kernel-space.ld +++ b/nuttx/configs/open1788/scripts/kernel-space.ld @@ -1,7 +1,7 @@ /**************************************************************************** * configs/open1788/scripts/kernel-space.ld * - * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -33,36 +33,10 @@ * ****************************************************************************/ -/* The LPC1788 has 512Kb of FLASH beginning at address 0x0000:0000 and - * 96Kb of total SRAM: 64Kb of SRAM in the CPU block beginning at address - * 0x10000000 and 32Kb of Peripheral SRAM in two banks, 8Kb at addresses - * 0x20000000 bank0 first and 8kb at 0x20002000 at bank0 second. And 16Kb - * at 0x20004000 on bank1. - * - * For MPU support, the kernel-mode NuttX section is assumed to be 64Kb of - * FLASH and 4Kb of SRAM. That, of course, can be optimized as needed (See - * also configs/open1788/scripts/kernel-space.ld). +/* NOTE: This depends on the memory.ld script having been included prior to + * this script. */ -MEMORY -{ - /* 256Kb FLASH */ - - kflash (rx) : ORIGIN = 0x00000000, LENGTH = 64K - uflash (rx) : ORIGIN = 0x00010000, LENGTH = 448K - - /* 64Kb of SRAM in the CPU block */ - - ksram (rwx) : ORIGIN = 0x10000000, LENGTH = 4K - usram (rwx) : ORIGIN = 0x10001000, LENGTH = 60K - - /* Other peripheral memory (free, nothing is linked here) */ - - ahbram8_b0a(rwx) : ORIGIN = 0x20000000, LENGTH = 8K - ahbram8_b0b(rwx) : ORIGIN = 0x20002000, LENGTH = 8K - ahbram16(rwx) : ORIGIN = 0x20004000, LENGTH = 16K -} - OUTPUT_ARCH(arm) ENTRY(_stext) SECTIONS diff --git a/nuttx/configs/open1788/scripts/memory.ld b/nuttx/configs/open1788/scripts/memory.ld new file mode 100644 index 000000000..d1ae3aa6e --- /dev/null +++ b/nuttx/configs/open1788/scripts/memory.ld @@ -0,0 +1,77 @@ +/**************************************************************************** + * configs/open1788/knsh/memory.ld + * + * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/* The LPC1788 has 512Kb of FLASH beginning at address 0x0000:0000 and + * 96Kb of total SRAM: 64Kb of SRAM in the CPU block beginning at address + * 0x10000000 and 32Kb of Peripheral SRAM in two banks, 8Kb at addresses + * 0x20000000 bank0 first and 8kb at 0x20002000 at bank0 second. And 16Kb + * at 0x20004000 on bank1. + * + * For MPU support, the kernel-mode NuttX section is assumed to be 64Kb of + * FLASH and 4Kb of SRAM. That, of course, can be optimized as needed (See + * also configs/open1788/scripts/kernel-space.ld). A detailed memory map + * for the CPU SRAM region is as follows: + * + * 0x10000 0000: Kernel .data region. Typical size: 0.1KB + * ------- ---- Kernel .bss region. Typical size: 1.8KB + * 0x10000 0800: Kernel IDLE thread stack (approximate). Size is + * determined by CONFIG_IDLETHREAD_STACKSIZE and + * adjustments for alignment. Typical is 1KB. + * ------- ---- Padded to 4KB + * 0x10000 1000: User .data region. Size is variable. + * ------- ---- User .bss region Size is variable. + * ------- ---- Beginning of kernel heap + * 0x10000 8000: Beginning of user heap. Can vary with other settings. + * 0x10001 0000: End+1 of CPU RAM + */ + +MEMORY +{ + /* 256Kb FLASH */ + + kflash (rx) : ORIGIN = 0x00000000, LENGTH = 64K + uflash (rx) : ORIGIN = 0x00010000, LENGTH = 448K + + /* 64Kb of SRAM in the CPU block */ + + ksram (rwx) : ORIGIN = 0x10000000, LENGTH = 4K + usram (rwx) : ORIGIN = 0x10001000, LENGTH = 60K + + /* Other peripheral memory (free, nothing is linked here) */ + + ahbram8_b0a(rwx) : ORIGIN = 0x20000000, LENGTH = 8K + ahbram8_b0b(rwx) : ORIGIN = 0x20002000, LENGTH = 8K + ahbram16(rwx) : ORIGIN = 0x20004000, LENGTH = 16K +} diff --git a/nuttx/configs/open1788/scripts/user-space.ld b/nuttx/configs/open1788/scripts/user-space.ld index 149be92f1..e2979e4a3 100644 --- a/nuttx/configs/open1788/scripts/user-space.ld +++ b/nuttx/configs/open1788/scripts/user-space.ld @@ -1,7 +1,7 @@ /**************************************************************************** * configs/open1788/scripts/user-space.ld * - * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -33,39 +33,13 @@ * ****************************************************************************/ -/* The LPC1788 has 512Kb of FLASH beginning at address 0x0000:0000 and - * 96Kb of total SRAM: 64Kb of SRAM in the CPU block beginning at address - * 0x10000000 and 32Kb of Peripheral SRAM in two banks, 8Kb at addresses - * 0x20000000 bank0 first and 8kb at 0x20002000 at bank0 second. And 16Kb - * at 0x20004000 on bank1. - * - * For MPU support, the kernel-mode NuttX section is assumed to be 64Kb of - * FLASH and 4Kb of SRAM. That, of course, can be optimized as needed (See - * also configs/open1788/scripts/kernel-space.ld). +/* NOTE: This depends on the memory.ld script having been included prior to + * this script. */ -MEMORY -{ - /* 256Kb FLASH */ - - kflash (rx) : ORIGIN = 0x00000000, LENGTH = 64K - uflash (rx) : ORIGIN = 0x00010000, LENGTH = 448K - - /* 64Kb of SRAM in the CPU block */ - - ksram (rwx) : ORIGIN = 0x10000000, LENGTH = 4K - usram (rwx) : ORIGIN = 0x10001000, LENGTH = 60K - - /* Other peripheral memory (free, nothing is linked here) */ - - ahbram8_b0a(rwx) : ORIGIN = 0x20000000, LENGTH = 8K - ahbram8_b0b(rwx) : ORIGIN = 0x20002000, LENGTH = 8K - ahbram16(rwx) : ORIGIN = 0x20004000, LENGTH = 16K -} - /* Make sure that the critical memory management functions are in user-space. - * Currently, the plan is that the memory manager will reside in user-space - * but be usable both by kernel- and user-space code + * the user heap memory manager will reside in user-space but be usable both + * by kernel- and user-space code */ EXTERN(umm_initialize) @@ -79,7 +53,6 @@ EXTERN(zalloc) EXTERN(free) OUTPUT_ARCH(arm) - SECTIONS { .userspace : { diff --git a/nuttx/configs/sam3u-ek/kernel/Makefile b/nuttx/configs/sam3u-ek/kernel/Makefile index da4510a00..a4cff7987 100644 --- a/nuttx/configs/sam3u-ek/kernel/Makefile +++ b/nuttx/configs/sam3u-ek/kernel/Makefile @@ -50,11 +50,13 @@ ENTRYPT = $(patsubst "%",%,$(CONFIG_USER_ENTRYPOINT)) ifeq ($(WINTOOL),y) # Windows-native toolchains USER_LIBPATHS = ${shell for path in $(USERLIBS); do dir=`dirname $(TOPDIR)$(DELIM)$$path`;echo "-L\"`cygpath -w $$dir`\"";done} - USER_LDSCRIPT = -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld}" + USER_LDSCRIPT = -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld}" + USER_LDSCRIPT += -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld}" else # Linux/Cygwin-native toolchain USER_LIBPATHS = $(addprefix -L$(TOPDIR)$(DELIM),$(dir $(USERLIBS))) - USER_LDSCRIPT = -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld + USER_LDSCRIPT = -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld + USER_LDSCRIPT += -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld endif USER_LDFLAGS = --undefined=$(ENTRYPT) --entry=$(ENTRYPT) $(USER_LDSCRIPT) diff --git a/nuttx/configs/sam3u-ek/knsh/Make.defs b/nuttx/configs/sam3u-ek/knsh/Make.defs index ac74d2fdb..9b06e7ec6 100644 --- a/nuttx/configs/sam3u-ek/knsh/Make.defs +++ b/nuttx/configs/sam3u-ek/knsh/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # configs/sam3u-ek/knsh/Make.defs # -# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,23 +35,25 @@ include ${TOPDIR}/.config include ${TOPDIR}/tools/Config.mk -include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs +include ${TOPDIR}$(DELIM)arch$(DELIM)arm$(DELIM)src$(DELIM)armv7-m$(DELIM)Toolchain.defs ifeq ($(WINTOOL),y) # Windows-native toolchains - DIRLINK = $(TOPDIR)/tools/copydir.sh - DIRUNLINK = $(TOPDIR)/tools/unlink.sh - MKDEP = $(TOPDIR)/tools/mknulldeps.sh - ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" - ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" - ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/kernel-space.ld}" + DIRLINK = $(TOPDIR)$(DELIM)tools$(DELIM)copydir.sh + DIRUNLINK = $(TOPDIR)$(DELIM)tools$(DELIM)unlink.sh + MKDEP = $(TOPDIR)$(DELIM)tools$(DELIM)mknulldeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)$(DELIM)include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)$(DELIM)include}" -isystem "${shell cygpath -w $(TOPDIR)$(DELIM)include$(DELIM)cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld}" + ARCHSCRIPT += -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)kernel-space.ld}" MAXOPTIMIZATION = -O2 else # Linux/Cygwin-native toolchain - MKDEP = $(TOPDIR)/tools/mkdeps.sh - ARCHINCLUDES = -I. -isystem $(TOPDIR)/include - ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx - ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/kernel-space.ld + MKDEP = $(TOPDIR)$(DELIM)tools$(DELIM)mkdeps.sh + ARCHINCLUDES = -I. -isystem $(TOPDIR)$(DELIM)include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)$(DELIM)include -isystem $(TOPDIR)$(DELIM)include$(DELIM)cxx + ARCHSCRIPT = -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld + ARCHSCRIPT += -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)kernel-space.ld endif CC = $(CROSSDEV)gcc @@ -87,7 +89,7 @@ CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) AFLAGS = $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common -NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 OBJEXT = .o diff --git a/nuttx/configs/sam3u-ek/scripts/kernel-space.ld b/nuttx/configs/sam3u-ek/scripts/kernel-space.ld index 8a6f1a344..75fef5ca8 100755 --- a/nuttx/configs/sam3u-ek/scripts/kernel-space.ld +++ b/nuttx/configs/sam3u-ek/scripts/kernel-space.ld @@ -33,35 +33,10 @@ * ****************************************************************************/ -/* The AT91SAM3U-4 has 256Kb of FLASH beginning at address 0x0008:0000, - * 32Kb of SRAM beginning at address 0x2000:0000, and 16Kb of SRAM beginning - * at address 0x2008:000 (used only for heap). When booting from FLASH, - * FLASH memory is aliased to address 0x0000:0000 where the code expects to - * begin execution by jumping to the entry point in the 0x0800:0000 address - * range. - * - * For MPU support, the kernel-mode NuttX section is assumed to be 64Kb of - * FLASH and 4Kb of SRAM. That, of course, can be optimized as needed (See - * also configs/sam3u-ek/scripts/user-space.ld). +/* NOTE: This depends on the memory.ld script having been included prior to + * this script. */ -MEMORY -{ - /* 256Kb FLASH */ - - kflash (rx) : ORIGIN = 0x00080000, LENGTH = 64K - uflash (rx) : ORIGIN = 0x00090000, LENGTH = 192K - - /* 32Kb SRAM */ - - ksram1 (rwx) : ORIGIN = 0x20000000, LENGTH = 4K - usram1 (rwx) : ORIGIN = 0x20001000, LENGTH = 28K - - /* 16Kb SRAM */ - - sram2 (rwx) : ORIGIN = 0x20080000, LENGTH = 16K -} - OUTPUT_ARCH(arm) ENTRY(_stext) SECTIONS diff --git a/nuttx/configs/sam3u-ek/scripts/memory.ld b/nuttx/configs/sam3u-ek/scripts/memory.ld new file mode 100644 index 000000000..d187ed40c --- /dev/null +++ b/nuttx/configs/sam3u-ek/scripts/memory.ld @@ -0,0 +1,152 @@ +/**************************************************************************** + * configs/sam3u-ek/scripts/user-space.ld + * + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/* The AT91SAM3U-4 has 256Kb of FLASH beginning at address 0x0008:0000, + * 32Kb of SRAM beginning at address 0x2000:0000, and 16Kb of SRAM beginning + * at address 0x2008:000 (used only for heap). When booting from FLASH, + * FLASH memory is aliased to address 0x0000:0000 where the code expects to + * begin execution by jumping to the entry point in the 0x0800:0000 address + * range. + * + * For MPU support, the kernel-mode NuttX section is assumed to be 64Kb of + * FLASH and 4Kb of SRAM. That, of course, can be optimized as needed (See + * also configs/sam3u-ek/scripts/kernel-space.ld). + */ + +MEMORY +{ + /* 256Kb FLASH */ + + kflash (rx) : ORIGIN = 0x00080000, LENGTH = 64K + uflash (rx) : ORIGIN = 0x00090000, LENGTH = 192K + + /* 32Kb SRAM */ + + ksram1 (rwx) : ORIGIN = 0x20000000, LENGTH = 4K + usram1 (rwx) : ORIGIN = 0x20001000, LENGTH = 28K + + /* 16Kb SRAM */ + + sram2 (rwx) : ORIGIN = 0x20080000, LENGTH = 16K +} + +/* Make sure that the critical memory management functions are in user-space. + * Currently, the plan is that the memory manager will reside in user-space + * but be usable both by kernel- and user-space code + */ + +EXTERN(umm_initialize) +EXTERN(umm_addregion) +EXTERN(umm_trysemaphore) +EXTERN(umm_givesemaphore) + +EXTERN(malloc) +EXTERN(realloc) +EXTERN(zalloc) +EXTERN(free) + +OUTPUT_ARCH(arm) + +SECTIONS +{ + .userspace : { + *(.userspace) + } > uflash + + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > uflash + + .init_section : { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > uflash + + .ARM.extab : { + *(.ARM.extab*) + } > uflash + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > uflash + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + _edata = ABSOLUTE(.); + } > usram1 AT > uflash + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + _ebss = ABSOLUTE(.); + } > usram1 + + /* Stabs debugging sections. */ + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/nuttx/configs/sam3u-ek/scripts/user-space.ld b/nuttx/configs/sam3u-ek/scripts/user-space.ld index d187ed40c..53b402257 100644 --- a/nuttx/configs/sam3u-ek/scripts/user-space.ld +++ b/nuttx/configs/sam3u-ek/scripts/user-space.ld @@ -33,38 +33,13 @@ * ****************************************************************************/ -/* The AT91SAM3U-4 has 256Kb of FLASH beginning at address 0x0008:0000, - * 32Kb of SRAM beginning at address 0x2000:0000, and 16Kb of SRAM beginning - * at address 0x2008:000 (used only for heap). When booting from FLASH, - * FLASH memory is aliased to address 0x0000:0000 where the code expects to - * begin execution by jumping to the entry point in the 0x0800:0000 address - * range. - * - * For MPU support, the kernel-mode NuttX section is assumed to be 64Kb of - * FLASH and 4Kb of SRAM. That, of course, can be optimized as needed (See - * also configs/sam3u-ek/scripts/kernel-space.ld). +/* NOTE: This depends on the memory.ld script having been included prior to + * this script. */ -MEMORY -{ - /* 256Kb FLASH */ - - kflash (rx) : ORIGIN = 0x00080000, LENGTH = 64K - uflash (rx) : ORIGIN = 0x00090000, LENGTH = 192K - - /* 32Kb SRAM */ - - ksram1 (rwx) : ORIGIN = 0x20000000, LENGTH = 4K - usram1 (rwx) : ORIGIN = 0x20001000, LENGTH = 28K - - /* 16Kb SRAM */ - - sram2 (rwx) : ORIGIN = 0x20080000, LENGTH = 16K -} - /* Make sure that the critical memory management functions are in user-space. - * Currently, the plan is that the memory manager will reside in user-space - * but be usable both by kernel- and user-space code + * the user heap memory manager will reside in user-space but be usable both + * by kernel- and user-space code */ EXTERN(umm_initialize) diff --git a/nuttx/configs/zkit-arm-1769/include/board.h b/nuttx/configs/zkit-arm-1769/include/board.h index d18e6b1a2..e6d486bf2 100644 --- a/nuttx/configs/zkit-arm-1769/include/board.h +++ b/nuttx/configs/zkit-arm-1769/include/board.h @@ -189,6 +189,7 @@ #define BOARD_BUTTON_4 3 #define BOARD_BUTTON_5 4 #define BOARD_NUM_BUTTONS 5 + #define BOARD_BUTTON_BUTTON1_BIT (1 << BOARD_BUTTON_1) #define BOARD_BUTTON_BUTTON2_BIT (1 << BOARD_BUTTON_2) #define BOARD_BUTTON_BUTTON3_BIT (1 << BOARD_BUTTON_3) diff --git a/nuttx/configs/zkit-arm-1769/src/Makefile b/nuttx/configs/zkit-arm-1769/src/Makefile index 856705614..491e364f4 100644 --- a/nuttx/configs/zkit-arm-1769/src/Makefile +++ b/nuttx/configs/zkit-arm-1769/src/Makefile @@ -41,7 +41,7 @@ -include $(TOPDIR)/Make.defs ASRCS = -CSRCS = up_boot.c up_leds.c up_ssp.c +CSRCS = up_boot.c up_leds.c up_ssp.c up_buttons.c ifeq ($(CONFIG_NSH_ARCHINIT),y) CSRCS += up_nsh.c diff --git a/nuttx/configs/zkit-arm-1769/src/zkitarm_internal.h b/nuttx/configs/zkit-arm-1769/src/zkitarm_internal.h index 19eb5b438..919cefcdf 100644 --- a/nuttx/configs/zkit-arm-1769/src/zkitarm_internal.h +++ b/nuttx/configs/zkit-arm-1769/src/zkitarm_internal.h @@ -139,8 +139,13 @@ #define ZKITARM_LED1 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN19) #define ZKITARM_LED2 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN21) -#define ZKITARM_KEY5 (GPIO_INTBOTH | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN13) +#define ZKITARM_KEY1 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT1 | GPIO_PIN19) +#define ZKITARM_KEY2 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT1 | GPIO_PIN27) +#define ZKITARM_KEY3 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT1 | GPIO_PIN28) +#define ZKITARM_KEY4 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT1 | GPIO_PIN31) +#define ZKITARM_KEY5 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN13) +#define ZKITARM_INT_KEY5 (GPIO_INTBOTH | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN13) #define ZKITARM_KEY5_IRQ LPC17_IRQ_P2p13 /* SD Slot -- cgit v1.2.3