diff --git a/arch/x86_64/src/common/up_allocateheap.c b/arch/x86_64/src/common/up_allocateheap.c index 41eaaf8dbaa..c031b2fcea2 100644 --- a/arch/x86_64/src/common/up_allocateheap.c +++ b/arch/x86_64/src/common/up_allocateheap.c @@ -50,6 +50,9 @@ * Public Functions ****************************************************************************/ +const uintptr_t g_idle_topstack = (uintptr_t)&_ebss + + CONFIG_IDLETHREAD_STACKSIZE; + /**************************************************************************** * Name: up_allocate_heap * @@ -71,7 +74,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) /* Calculate the end of .bss section */ - uintptr_t hstart = (((uintptr_t)&_ebss + PAGE_SIZE - 1) & PAGE_MASK); + uintptr_t hstart = (g_idle_topstack + PAGE_SIZE - 1) & PAGE_MASK; *heap_start = (void *)hstart; /* The size is the rest of the RAM */ diff --git a/arch/x86_64/src/common/up_internal.h b/arch/x86_64/src/common/up_internal.h index bc1d9acf6d3..76f24b337c1 100644 --- a/arch/x86_64/src/common/up_internal.h +++ b/arch/x86_64/src/common/up_internal.h @@ -120,7 +120,7 @@ extern volatile uint64_t *g_current_regs; * end of the heap is CONFIG_RAM_END */ -extern uint64_t g_idle_topstack; +extern const uintptr_t g_idle_topstack; /* Address of the saved user stack pointer */ diff --git a/arch/x86_64/src/intel64/intel64_head.S b/arch/x86_64/src/intel64/intel64_head.S index 302643c163b..c478b212647 100644 --- a/arch/x86_64/src/intel64/intel64_head.S +++ b/arch/x86_64/src/intel64/intel64_head.S @@ -290,8 +290,7 @@ clear_bss: jne clear_bss // Properly setup RSP to idle stack - movabs $idle_stack, %rbx - add $CONFIG_IDLETHREAD_STACKSIZE, %rbx + movabs $g_idle_topstack, %rbx mov %rbx, %rsp @@ -468,35 +467,3 @@ pt_low: .fill X86_NUM_PAGE_ENTRY * X86_NUM_PAGE_ENTRY, X86_PAGE_ENTRY_SIZE, 0 .fill X86_NUM_PAGE_ENTRY * X86_NUM_PAGE_ENTRY, X86_PAGE_ENTRY_SIZE, 0 -/**************************************************************************** - * .bss - ****************************************************************************/ - -/* The stack for the IDLE task thread is declared in .bss. NuttX boots and - * initializes on the IDLE thread, then at the completion of OS startup, this - * thread becomes the thread that executes when there is nothing else to - * do in the system (see up_idle()). - */ - - .section .bss - - .type idle_stack, @object - .comm idle_stack, CONFIG_IDLETHREAD_STACKSIZE, 32 - .size idle_stack, CONFIG_IDLETHREAD_STACKSIZE - -/**************************************************************************** - * .rodata - ****************************************************************************/ - - .section .rodata, "a" - -/* HEAP BASE: _sbss is the start of the BSS region (see ld.script) _ebss is - * the end of the BSS region (see liker script). The heap continues from there - * until the end of memory. - */ - - .type g_idle_topstack, @object -g_idle_topstack: - .quad _ebss - .size g_idle_topstack, . - g_idle_topstack - .end