From 3f67c67aaf850a57531b09312c7b7cfaf2db442b Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Wed, 7 Apr 2021 23:50:51 +0800 Subject: [PATCH] arch: Fix the stack boundary calculation and check All supported arch uses a push-down stack: The stack grows toward lower addresses in memory. The stack pointer register points to the lowest, valid working address (the "top" of the stack). Items on the stack are referenced as positive(include zero) word offsets from sp. Which means that for stack in the [begin, begin + size): 1.The initial SP point to begin + size 2.push equals sub and then store 3.pop equals load and then add Signed-off-by: Xiang Xiao --- arch/arm/src/arm/arm_assert.c | 4 ++-- arch/arm/src/arm/arm_head.S | 2 +- arch/arm/src/arm/arm_nommuhead.S | 2 +- arch/arm/src/arm/arm_vectors.S | 3 +-- arch/arm/src/armv6-m/arm_assert.c | 6 +++--- arch/arm/src/armv6-m/arm_vectors.c | 2 +- arch/arm/src/armv7-a/arm_assert.c | 4 ++-- arch/arm/src/armv7-a/arm_head.S | 6 +++--- arch/arm/src/armv7-a/arm_pghead.S | 4 ++-- arch/arm/src/armv7-a/arm_vectors.S | 6 ++---- arch/arm/src/armv7-m/arm_assert.c | 6 +++--- arch/arm/src/armv7-m/arm_vectors.c | 2 +- arch/arm/src/armv7-r/arm_assert.c | 6 +++--- arch/arm/src/armv7-r/arm_vectors.S | 6 ++---- arch/arm/src/armv8-m/arm_assert.c | 6 +++--- arch/arm/src/armv8-m/arm_vectors.c | 2 +- arch/arm/src/c5471/c5471_vectors.S | 3 +-- arch/arm/src/cxd56xx/cxd56_start.c | 4 ++-- arch/arm/src/efm32/efm32_start.c | 4 +--- arch/arm/src/eoss3/eoss3_start.c | 4 +--- arch/arm/src/imxrt/imxrt_start.c | 3 --- arch/arm/src/kinetis/kinetis_start.c | 4 +--- arch/arm/src/kl/kl_start.c | 3 +-- arch/arm/src/lc823450/lc823450_start.c | 4 +--- arch/arm/src/lpc17xx_40xx/lpc17_40_start.c | 4 +--- arch/arm/src/lpc214x/lpc214x_head.S | 2 +- arch/arm/src/lpc2378/lpc23xx_head.S | 2 +- arch/arm/src/max326xx/common/max326_start.c | 3 +-- arch/arm/src/nuc1xx/nuc_start.c | 3 +-- arch/arm/src/rp2040/rp2040_start.c | 3 +-- arch/arm/src/s32k1xx/s32k1xx_start.c | 4 +--- arch/arm/src/sam34/sam_start.c | 4 +--- arch/arm/src/samd2l2/sam_start.c | 3 +-- arch/arm/src/samd5e5/sam_start.c | 4 +--- arch/arm/src/samv7/sam_start.c | 1 - arch/arm/src/stm32/stm32_start.c | 4 +--- arch/arm/src/stm32f0l0g0/stm32_start.c | 3 +-- arch/arm/src/stm32f7/stm32_start.c | 1 - arch/arm/src/stm32h7/stm32_start.c | 1 - arch/arm/src/stm32l4/stm32l4_start.c | 1 - arch/arm/src/stm32l5/stm32l5_start.c | 1 - arch/arm/src/str71x/str71x_head.S | 2 +- arch/arm/src/tiva/cc13xx/cc13xx_start.c | 4 +--- arch/arm/src/tiva/common/lmxx_tm4c_start.c | 4 +--- arch/arm/src/xmc4/xmc4_start.c | 1 - arch/avr/src/at90usb/at90usb_exceptions.S | 4 ++-- arch/avr/src/at90usb/at90usb_head.S | 2 +- arch/avr/src/atmega/atmega_head.S | 2 +- arch/avr/src/avr/up_createstack.c | 2 +- arch/avr/src/avr/up_dumpstate.c | 8 ++++---- arch/avr/src/avr/up_usestack.c | 2 +- arch/avr/src/avr32/up_createstack.c | 4 ++-- arch/avr/src/avr32/up_dumpstate.c | 8 ++++---- arch/avr/src/avr32/up_nommuhead.S | 2 +- arch/avr/src/avr32/up_usestack.c | 4 ++-- arch/hc/src/m9s12/m9s12_assert.c | 6 +++--- arch/hc/src/m9s12/m9s12_start.S | 2 +- arch/mips/src/common/mips_createstack.c | 4 ++-- arch/mips/src/common/mips_usestack.c | 4 ++-- arch/mips/src/mips32/mips_dumpstate.c | 6 +++--- arch/mips/src/pic32mx/pic32mx_head.S | 4 ++-- arch/mips/src/pic32mz/pic32mz_head.S | 4 ++-- arch/misoc/src/lm32/lm32_createstack.c | 4 ++-- arch/misoc/src/lm32/lm32_dumpstate.c | 6 +++--- arch/misoc/src/lm32/lm32_usestack.c | 4 ++-- arch/misoc/src/minerva/minerva_createstack.c | 4 ++-- arch/misoc/src/minerva/minerva_dumpstate.c | 6 +++--- arch/misoc/src/minerva/minerva_usestack.c | 4 ++-- arch/or1k/include/arch.h | 2 -- arch/or1k/src/common/up_allocateheap.c | 2 +- arch/or1k/src/common/up_assert.c | 6 +++--- arch/or1k/src/common/up_createstack.c | 4 ++-- arch/or1k/src/common/up_usestack.c | 4 ++-- arch/or1k/src/mor1kx/mor1kx_start.c | 3 +-- arch/or1k/src/mor1kx/up_vectortab.S | 2 +- arch/renesas/src/common/up_createstack.c | 4 ++-- arch/renesas/src/common/up_usestack.c | 4 ++-- arch/renesas/src/m16c/m16c_dumpstate.c | 4 ++-- arch/renesas/src/rx65n/rx65n_dumpstate.c | 6 +++--- arch/renesas/src/rx65n/rx65n_head.S | 2 +- arch/renesas/src/rx65n/rx65n_vector.S | 5 ++--- arch/renesas/src/sh1/sh1_dumpstate.c | 6 +++--- arch/renesas/src/sh1/sh1_head.S | 6 +++--- arch/renesas/src/sh1/sh1_vector.S | 5 ++--- arch/risc-v/src/bl602/bl602_head.S | 5 ++--- arch/risc-v/src/bl602/bl602_irq.c | 2 +- arch/risc-v/src/c906/c906_head.S | 11 +++++------ arch/risc-v/src/c906/c906_irq.c | 2 +- arch/risc-v/src/c906/c906_memorymap.h | 5 +---- arch/risc-v/src/common/riscv_createstack.c | 4 ++-- arch/risc-v/src/common/riscv_usestack.c | 4 ++-- arch/risc-v/src/esp32c3/esp32c3_interrupt.S | 8 ++++---- arch/risc-v/src/esp32c3/esp32c3_memorymap.h | 3 +-- arch/risc-v/src/esp32c3/esp32c3_start.c | 2 +- arch/risc-v/src/fe310/fe310_head.S | 5 ++--- arch/risc-v/src/fe310/fe310_irq.c | 2 +- arch/risc-v/src/fe310/fe310_memorymap.h | 3 +-- arch/risc-v/src/k210/k210_head.S | 11 +++++------ arch/risc-v/src/k210/k210_irq.c | 2 +- arch/risc-v/src/k210/k210_memorymap.h | 6 ++---- arch/risc-v/src/litex/litex_head.S | 5 ++--- arch/risc-v/src/litex/litex_irq.c | 2 +- arch/risc-v/src/litex/litex_memorymap.h | 3 +-- arch/risc-v/src/rv32im/riscv_assert.c | 6 +++--- arch/risc-v/src/rv64gc/riscv_assert.c | 6 +++--- arch/x86/src/common/up_assert.c | 6 +++--- arch/x86/src/i486/up_createstack.c | 4 ++-- arch/x86/src/i486/up_usestack.c | 4 ++-- arch/x86/src/qemu/qemu_head.S | 4 ---- arch/x86_64/src/common/up_assert.c | 6 +++--- arch/x86_64/src/intel64/intel64_head.S | 4 ---- arch/x86_64/src/intel64/up_createstack.c | 7 +++---- arch/x86_64/src/intel64/up_usestack.c | 7 +++---- arch/xtensa/src/common/xtensa_createstack.c | 4 ++-- arch/xtensa/src/common/xtensa_dumpstate.c | 4 ++-- arch/xtensa/src/common/xtensa_usestack.c | 4 ++-- arch/z16/src/common/z16_createstack.c | 4 ++-- arch/z16/src/common/z16_usestack.c | 4 ++-- arch/z80/src/common/z80_createstack.c | 4 ++-- arch/z80/src/common/z80_usestack.c | 4 ++-- arch/z80/src/z8/z80_mem.h | 2 +- boards/arm/cxd56xx/common/src/cxd56_crashdump.c | 2 +- boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c | 2 +- boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c | 2 +- boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c | 2 +- boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c | 2 +- 126 files changed, 210 insertions(+), 281 deletions(-) diff --git a/arch/arm/src/arm/arm_assert.c b/arch/arm/src/arm/arm_assert.c index a84314a2a94..9a325fcd429 100644 --- a/arch/arm/src/arm/arm_assert.c +++ b/arch/arm/src/arm/arm_assert.c @@ -194,7 +194,7 @@ static void up_dumpstate(void) * stack? */ - if (sp < istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -240,7 +240,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); up_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/arm/src/arm/arm_head.S b/arch/arm/src/arm/arm_head.S index 42218ec3b4d..0cfa6d507bf 100644 --- a/arch/arm/src/arm/arm_head.S +++ b/arch/arm/src/arm/arm_head.S @@ -642,7 +642,7 @@ __start: .Linitparms: .long _sbss .long _ebss - .long _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 + .long _ebss+CONFIG_IDLETHREAD_STACKSIZE #if !defined(CONFIG_PAGING) && !defined(CONFIG_BOOT_RUNFROMFLASH) diff --git a/arch/arm/src/arm/arm_nommuhead.S b/arch/arm/src/arm/arm_nommuhead.S index 514e2129d6e..27c53b9ffe4 100644 --- a/arch/arm/src/arm/arm_nommuhead.S +++ b/arch/arm/src/arm/arm_nommuhead.S @@ -145,7 +145,7 @@ __start: .Lbssinit: .long _sbss .long _ebss - .long _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 + .long _ebss+CONFIG_IDLETHREAD_STACKSIZE #ifdef CONFIG_BOOT_RUNFROMFLASH .Ldatainit: diff --git a/arch/arm/src/arm/arm_vectors.S b/arch/arm/src/arm/arm_vectors.S index 2f16255aab3..f7d58bb0e87 100644 --- a/arch/arm/src/arm/arm_vectors.S +++ b/arch/arm/src/arm/arm_vectors.S @@ -429,8 +429,7 @@ arm_vectorfiq: g_intstackalloc: .skip (CONFIG_ARCH_INTERRUPTSTACK & ~3) g_intstackbase: - .skip 4 - .size g_intstackbase, 4 + .size g_intstackbase, 0 .size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~3) #endif diff --git a/arch/arm/src/armv6-m/arm_assert.c b/arch/arm/src/armv6-m/arm_assert.c index 1c311589624..1ed571067df 100644 --- a/arch/arm/src/armv6-m/arm_assert.c +++ b/arch/arm/src/armv6-m/arm_assert.c @@ -232,7 +232,7 @@ static void up_dumpstate(void) * stack? */ - if (sp < istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -266,7 +266,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp <= ustackbase && sp > ustackbase - ustacksize) + if (sp < ustackbase && sp >= ustackbase - ustacksize) { up_stackdump(sp, ustackbase); } @@ -288,7 +288,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); up_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/arm/src/armv6-m/arm_vectors.c b/arch/arm/src/armv6-m/arm_vectors.c index 35d3b88974e..b30cd346a5b 100644 --- a/arch/arm/src/armv6-m/arm_vectors.c +++ b/arch/arm/src/armv6-m/arm_vectors.c @@ -50,7 +50,7 @@ * Pre-processor Definitions ****************************************************************************/ -#define IDLE_STACK ((unsigned)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) +#define IDLE_STACK ((unsigned)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) #ifndef ARMV6M_PERIPHERAL_INTERRUPTS # error ARMV6M_PERIPHERAL_INTERRUPTS must be defined to the number of I/O interrupts to be supported diff --git a/arch/arm/src/armv7-a/arm_assert.c b/arch/arm/src/armv7-a/arm_assert.c index 015aa835782..547090367c3 100644 --- a/arch/arm/src/armv7-a/arm_assert.c +++ b/arch/arm/src/armv7-a/arm_assert.c @@ -263,7 +263,7 @@ static void up_dumpstate(void) #if CONFIG_ARCH_INTERRUPTSTACK > 7 /* Does the current stack pointer lie within the interrupt stack? */ - if (sp > istackbase - istacksize && sp < istackbase) + if (sp >= istackbase - istacksize && sp < istackbase) { /* Yes.. dump the interrupt stack */ @@ -292,7 +292,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase - ustacksize && sp < ustackbase) + if (sp >= ustackbase - ustacksize && sp < ustackbase) { _alert("User Stack\n", sp); up_stackdump(sp, ustackbase); diff --git a/arch/arm/src/armv7-a/arm_head.S b/arch/arm/src/armv7-a/arm_head.S index 9a46dda93d5..30f910b5cb1 100644 --- a/arch/arm/src/armv7-a/arm_head.S +++ b/arch/arm/src/armv7-a/arm_head.S @@ -736,11 +736,11 @@ arm_data_initialize: .Lstackpointer: #ifdef CONFIG_BOOT_SDRAM_DATA - .long IDLE_STACK_VBASE+CONFIG_IDLETHREAD_STACKSIZE-4 + .long IDLE_STACK_VBASE+CONFIG_IDLETHREAD_STACKSIZE #elif defined(CONFIG_SMP) - .long _enoinit+CONFIG_IDLETHREAD_STACKSIZE-4 + .long _enoinit+CONFIG_IDLETHREAD_STACKSIZE #else - .long _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 + .long _ebss+CONFIG_IDLETHREAD_STACKSIZE #endif .size .Lstackpointer, . -.Lstackpointer diff --git a/arch/arm/src/armv7-a/arm_pghead.S b/arch/arm/src/armv7-a/arm_pghead.S index 17dc211413b..2d744032528 100644 --- a/arch/arm/src/armv7-a/arm_pghead.S +++ b/arch/arm/src/armv7-a/arm_pghead.S @@ -762,9 +762,9 @@ arm_data_initialize: .Lstackpointer: #ifdef CONFIG_BOOT_SDRAM_DATA - .long IDLE_STACK_VBASE+CONFIG_IDLETHREAD_STACKSIZE-4 + .long IDLE_STACK_VBASE+CONFIG_IDLETHREAD_STACKSIZE #else - .long _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 + .long _ebss+CONFIG_IDLETHREAD_STACKSIZE #endif .size .Lstackpointer, . -.Lstackpointer diff --git a/arch/arm/src/armv7-a/arm_vectors.S b/arch/arm/src/armv7-a/arm_vectors.S index 03a102c9ad8..45a2670ca39 100644 --- a/arch/arm/src/armv7-a/arm_vectors.S +++ b/arch/arm/src/armv7-a/arm_vectors.S @@ -979,8 +979,7 @@ arm_vectorfiq: g_intstackalloc: .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: - .skip 4 - .size g_intstackbase, 4 + .size g_intstackbase, 0 .size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~7) /**************************************************************************** @@ -995,8 +994,7 @@ g_intstackbase: g_fiqstackalloc: .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_fiqstackbase: - .skip 4 - .size g_fiqstackbase, 4 + .size g_fiqstackbase, 0 .size g_fiqstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~7) #endif /* !CONFIG_SMP && CONFIG_ARCH_INTERRUPTSTACK > 7 */ diff --git a/arch/arm/src/armv7-m/arm_assert.c b/arch/arm/src/armv7-m/arm_assert.c index ee6c0d127f3..67276a0b274 100644 --- a/arch/arm/src/armv7-m/arm_assert.c +++ b/arch/arm/src/armv7-m/arm_assert.c @@ -244,7 +244,7 @@ static void up_dumpstate(void) * stack? */ - if (sp < istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -278,7 +278,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp <= ustackbase && sp > ustackbase - ustacksize) + if (sp < ustackbase && sp >= ustackbase - ustacksize) { up_stackdump(sp, ustackbase); } @@ -303,7 +303,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within the allocated stack\n"); up_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/arm/src/armv7-m/arm_vectors.c b/arch/arm/src/armv7-m/arm_vectors.c index 13f5559e776..248285a5f78 100644 --- a/arch/arm/src/armv7-m/arm_vectors.c +++ b/arch/arm/src/armv7-m/arm_vectors.c @@ -45,7 +45,7 @@ * Pre-processor Definitions ****************************************************************************/ -#define IDLE_STACK ((unsigned)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) +#define IDLE_STACK ((unsigned)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) #ifndef ARMV7M_PERIPHERAL_INTERRUPTS # error ARMV7M_PERIPHERAL_INTERRUPTS must be defined to the number of I/O interrupts to be supported diff --git a/arch/arm/src/armv7-r/arm_assert.c b/arch/arm/src/armv7-r/arm_assert.c index ed516c750be..d8ff0f3cd7a 100644 --- a/arch/arm/src/armv7-r/arm_assert.c +++ b/arch/arm/src/armv7-r/arm_assert.c @@ -245,7 +245,7 @@ static void up_dumpstate(void) if (rtcb->xcp.kstack) { kstackbase = (uint32_t)rtcb->xcp.kstack + - CONFIG_ARCH_KERNEL_STACKSIZE - 4; + CONFIG_ARCH_KERNEL_STACKSIZE; _alert("Kernel stack:\n"); _alert(" base: %08x\n", kstackbase); @@ -256,7 +256,7 @@ static void up_dumpstate(void) #if CONFIG_ARCH_INTERRUPTSTACK > 7 /* Does the current stack pointer lie within the interrupt stack? */ - if (sp > istackbase - istacksize && sp < istackbase) + if (sp >= istackbase - istacksize && sp < istackbase) { /* Yes.. dump the interrupt stack */ @@ -285,7 +285,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase - ustacksize && sp < ustackbase) + if (sp >= ustackbase - ustacksize && sp < ustackbase) { _alert("User Stack\n", sp); up_stackdump(sp, ustackbase); diff --git a/arch/arm/src/armv7-r/arm_vectors.S b/arch/arm/src/armv7-r/arm_vectors.S index 9d32873c733..992b30a9f3e 100644 --- a/arch/arm/src/armv7-r/arm_vectors.S +++ b/arch/arm/src/armv7-r/arm_vectors.S @@ -933,8 +933,7 @@ arm_vectorfiq: g_intstackalloc: .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: - .skip 4 - .size g_intstackbase, 4 + .size g_intstackbase, 0 .size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~7) /**************************************************************************** @@ -949,8 +948,7 @@ g_intstackbase: g_fiqstackalloc: .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_fiqstackbase: - .skip 4 - .size g_fiqstackbase, 4 + .size g_fiqstackbase, 0 .size g_fiqstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~7) #endif /* CONFIG_ARCH_INTERRUPTSTACK > 7 */ diff --git a/arch/arm/src/armv8-m/arm_assert.c b/arch/arm/src/armv8-m/arm_assert.c index bc6cb3a1d93..b768bca05ff 100644 --- a/arch/arm/src/armv8-m/arm_assert.c +++ b/arch/arm/src/armv8-m/arm_assert.c @@ -244,7 +244,7 @@ static void up_dumpstate(void) * stack? */ - if (sp < istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -278,7 +278,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp <= ustackbase && sp > ustackbase - ustacksize) + if (sp < ustackbase && sp >= ustackbase - ustacksize) { up_stackdump(sp, ustackbase); } @@ -303,7 +303,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within the allocated stack\n"); up_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/arm/src/armv8-m/arm_vectors.c b/arch/arm/src/armv8-m/arm_vectors.c index 3b1a0777daf..a2fbb1d968d 100644 --- a/arch/arm/src/armv8-m/arm_vectors.c +++ b/arch/arm/src/armv8-m/arm_vectors.c @@ -45,7 +45,7 @@ * Pre-processor Definitions ****************************************************************************/ -#define IDLE_STACK ((unsigned)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) +#define IDLE_STACK ((unsigned)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) #ifndef ARMV8M_PERIPHERAL_INTERRUPTS # error ARMV8M_PERIPHERAL_INTERRUPTS must be defined to the number of I/O interrupts to be supported diff --git a/arch/arm/src/c5471/c5471_vectors.S b/arch/arm/src/c5471/c5471_vectors.S index bc65435fcf6..58b0a6fd5ed 100644 --- a/arch/arm/src/c5471/c5471_vectors.S +++ b/arch/arm/src/c5471/c5471_vectors.S @@ -463,8 +463,7 @@ arm_vectoraddrexcptn: g_intstackalloc: .skip (CONFIG_ARCH_INTERRUPTSTACK & ~3) g_intstackbase: - .skip 4 - .size g_intstackbase, 4 + .size g_intstackbase, 0 .size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~3) #endif .end diff --git a/arch/arm/src/cxd56xx/cxd56_start.c b/arch/arm/src/cxd56xx/cxd56_start.c index a7fe1d8773a..0518be6c92e 100644 --- a/arch/arm/src/cxd56xx/cxd56_start.c +++ b/arch/arm/src/cxd56xx/cxd56_start.c @@ -271,10 +271,10 @@ void __start(void) __asm__ __volatile__("\tmsr msp, %0\n" : : "r" ((uint32_t)&_ebss + - CONFIG_IDLETHREAD_STACKSIZE - 4)); + CONFIG_IDLETHREAD_STACKSIZE)); __asm__ __volatile__("\tmsr psp, %0\n" : : "r" ((uint32_t)&_ebss + - CONFIG_IDLETHREAD_STACKSIZE - 4)); + CONFIG_IDLETHREAD_STACKSIZE)); #ifndef CONFIG_CXD56_SUBCORE cpuid = getreg32(CPU_ID); diff --git a/arch/arm/src/efm32/efm32_start.c b/arch/arm/src/efm32/efm32_start.c index e6304877bbc..090df585ca0 100644 --- a/arch/arm/src/efm32/efm32_start.c +++ b/arch/arm/src/efm32/efm32_start.c @@ -54,9 +54,7 @@ * ARM EABI requires 64 bit stack alignment. */ -#define IDLE_STACKSIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7) -#define IDLE_STACK ((uintptr_t)&_ebss + IDLE_STACKSIZE) -#define HEAP_BASE ((uintptr_t)&_ebss + IDLE_STACKSIZE) +#define HEAP_BASE ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/eoss3/eoss3_start.c b/arch/arm/src/eoss3/eoss3_start.c index c9c55d7af52..a3e36b68a44 100644 --- a/arch/arm/src/eoss3/eoss3_start.c +++ b/arch/arm/src/eoss3/eoss3_start.c @@ -47,9 +47,7 @@ * ARM EABI requires 64 bit stack alignment. */ -#define IDLE_STACKSIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7) -#define IDLE_STACK ((uintptr_t)&_ebss + IDLE_STACKSIZE) -#define HEAP_BASE ((uintptr_t)&_ebss + IDLE_STACKSIZE) +#define HEAP_BASE ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/imxrt/imxrt_start.c b/arch/arm/src/imxrt/imxrt_start.c index 96de31fb8da..205d46e74cf 100644 --- a/arch/arm/src/imxrt/imxrt_start.c +++ b/arch/arm/src/imxrt/imxrt_start.c @@ -66,9 +66,6 @@ * here. */ -#define IDLE_STACK ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE - 4) -#define HEAP_BASE ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) - /**************************************************************************** * Private Function prototypes ****************************************************************************/ diff --git a/arch/arm/src/kinetis/kinetis_start.c b/arch/arm/src/kinetis/kinetis_start.c index 4248adb0f85..23c0c24de8b 100644 --- a/arch/arm/src/kinetis/kinetis_start.c +++ b/arch/arm/src/kinetis/kinetis_start.c @@ -77,9 +77,7 @@ static void go_nx_start(void *pv, unsigned int nbytes) * NOTE: ARM EABI requires 64 bit stack alignment. */ -#define IDLE_STACKSIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7) -#define IDLE_STACK ((uintptr_t)&_ebss + IDLE_STACKSIZE) -#define HEAP_BASE ((uintptr_t)&_ebss + IDLE_STACKSIZE) +#define HEAP_BASE ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/kl/kl_start.c b/arch/arm/src/kl/kl_start.c index 8dcdbff297d..6669a495112 100644 --- a/arch/arm/src/kl/kl_start.c +++ b/arch/arm/src/kl/kl_start.c @@ -58,8 +58,7 @@ * 0x2000:3fff - End of SRAM and end of heap (assuming 16KB of SRAM) */ -#define IDLE_STACK ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) -#define HEAP_BASE ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) +#define IDLE_STACK ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/lc823450/lc823450_start.c b/arch/arm/src/lc823450/lc823450_start.c index fba7cf63c66..6bfe2fa1b90 100644 --- a/arch/arm/src/lc823450/lc823450_start.c +++ b/arch/arm/src/lc823450/lc823450_start.c @@ -76,9 +76,7 @@ * ARM EABI requires 64 bit stack alignment. */ -#define IDLE_STACKSIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7) -#define IDLE_STACK ((uintptr_t)&_ebss + IDLE_STACKSIZE) -#define HEAP_BASE ((uintptr_t)&_ebss + IDLE_STACKSIZE) +#define HEAP_BASE ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/lpc17xx_40xx/lpc17_40_start.c b/arch/arm/src/lpc17xx_40xx/lpc17_40_start.c index 868e614123b..eeef875f147 100644 --- a/arch/arm/src/lpc17xx_40xx/lpc17_40_start.c +++ b/arch/arm/src/lpc17xx_40xx/lpc17_40_start.c @@ -51,9 +51,7 @@ * ARM EABI requires 64 bit stack alignment. */ -#define IDLE_STACKSIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7) -#define IDLE_STACK ((uintptr_t)&_ebss + IDLE_STACKSIZE) -#define HEAP_BASE ((uintptr_t)&_ebss + IDLE_STACKSIZE) +#define HEAP_BASE ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/lpc214x/lpc214x_head.S b/arch/arm/src/lpc214x/lpc214x_head.S index 0c12c09313a..4df43afeab9 100644 --- a/arch/arm/src/lpc214x/lpc214x_head.S +++ b/arch/arm/src/lpc214x/lpc214x_head.S @@ -593,7 +593,7 @@ __start: LC0: .long _sbss .long _ebss - .long _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 + .long _ebss+CONFIG_IDLETHREAD_STACKSIZE LC2: .long _eronly /* Where .data defaults are stored in FLASH */ .long _sdata /* Where .data needs to reside in SDRAM */ diff --git a/arch/arm/src/lpc2378/lpc23xx_head.S b/arch/arm/src/lpc2378/lpc23xx_head.S index bc11ed0ece4..15a8f4597f6 100644 --- a/arch/arm/src/lpc2378/lpc23xx_head.S +++ b/arch/arm/src/lpc2378/lpc23xx_head.S @@ -210,7 +210,7 @@ __start: LC0: .long _sbss .long _ebss - .long _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 + .long _ebss+CONFIG_IDLETHREAD_STACKSIZE LC2: .long _eronly /* Where .data defaults are stored in FLASH */ .long _sdata /* Where .data needs to reside in SDRAM */ diff --git a/arch/arm/src/max326xx/common/max326_start.c b/arch/arm/src/max326xx/common/max326_start.c index 6be1ec5f036..db36b6dd96b 100644 --- a/arch/arm/src/max326xx/common/max326_start.c +++ b/arch/arm/src/max326xx/common/max326_start.c @@ -59,8 +59,7 @@ * 0x2001:7fff - End of SRAM and end of heap (assuming 96KB of SRAM) */ -#define IDLE_STACK ((uint32_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE - 4) -#define HEAP_BASE ((uint32_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) +#define IDLE_STACK ((uint32_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Name: showprogress diff --git a/arch/arm/src/nuc1xx/nuc_start.c b/arch/arm/src/nuc1xx/nuc_start.c index d1dcb6006be..5713c139a58 100644 --- a/arch/arm/src/nuc1xx/nuc_start.c +++ b/arch/arm/src/nuc1xx/nuc_start.c @@ -55,8 +55,7 @@ * 0x2000:3fff - End of SRAM and end of heap (assuming 16KB of SRAM) */ -#define IDLE_STACK ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) -#define HEAP_BASE ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) +#define IDLE_STACK ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/rp2040/rp2040_start.c b/arch/arm/src/rp2040/rp2040_start.c index 8c87ed403e3..8049158f684 100644 --- a/arch/arm/src/rp2040/rp2040_start.c +++ b/arch/arm/src/rp2040/rp2040_start.c @@ -43,8 +43,7 @@ * Pre-processor Definitions ****************************************************************************/ -#define IDLE_STACK ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) -#define HEAP_BASE ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) +#define IDLE_STACK ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/s32k1xx/s32k1xx_start.c b/arch/arm/src/s32k1xx/s32k1xx_start.c index aaf318f9778..14e90c95a81 100644 --- a/arch/arm/src/s32k1xx/s32k1xx_start.c +++ b/arch/arm/src/s32k1xx/s32k1xx_start.c @@ -89,9 +89,7 @@ * NOTE: ARM EABI requires 64 bit stack alignment. */ -#define IDLE_STACKSIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7) -#define IDLE_STACK ((uintptr_t)&_ebss + IDLE_STACKSIZE) -#define HEAP_BASE ((uintptr_t)&_ebss + IDLE_STACKSIZE) +#define HEAP_BASE ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Name: showprogress diff --git a/arch/arm/src/sam34/sam_start.c b/arch/arm/src/sam34/sam_start.c index 7a60db2a082..2cbca1c1592 100644 --- a/arch/arm/src/sam34/sam_start.c +++ b/arch/arm/src/sam34/sam_start.c @@ -50,9 +50,7 @@ * ARM EABI requires 64 bit stack alignment. */ -#define IDLE_STACKSIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7) -#define IDLE_STACK ((uintptr_t)&_ebss + IDLE_STACKSIZE) -#define HEAP_BASE ((uintptr_t)&_ebss + IDLE_STACKSIZE) +#define HEAP_BASE ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/samd2l2/sam_start.c b/arch/arm/src/samd2l2/sam_start.c index 311474a1fb4..0b22f6c6576 100644 --- a/arch/arm/src/samd2l2/sam_start.c +++ b/arch/arm/src/samd2l2/sam_start.c @@ -55,8 +55,7 @@ * 0x2000:ffff - End of SRAM and end of heap (assuming 64KB of SRAM) */ -#define IDLE_STACK ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) -#define HEAP_BASE ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) +#define IDLE_STACK ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/samd5e5/sam_start.c b/arch/arm/src/samd5e5/sam_start.c index 9921d691b4f..fbabe0c0c96 100644 --- a/arch/arm/src/samd5e5/sam_start.c +++ b/arch/arm/src/samd5e5/sam_start.c @@ -52,9 +52,7 @@ * ARM EABI requires 64 bit stack alignment. */ -#define IDLE_STACKSIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7) -#define IDLE_STACK ((uintptr_t)&_ebss + IDLE_STACKSIZE) -#define HEAP_BASE ((uintptr_t)&_ebss + IDLE_STACKSIZE) +#define HEAP_BASE ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/samv7/sam_start.c b/arch/arm/src/samv7/sam_start.c index e9ebaf0b263..baa596b697b 100644 --- a/arch/arm/src/samv7/sam_start.c +++ b/arch/arm/src/samv7/sam_start.c @@ -61,7 +61,6 @@ * 0x2005:ffff - End of internal SRAM and end of heap (a */ -#define IDLE_STACK ((uintptr_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) #define HEAP_BASE ((uintptr_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** diff --git a/arch/arm/src/stm32/stm32_start.c b/arch/arm/src/stm32/stm32_start.c index 5fabd5c09dc..1618eea7acf 100644 --- a/arch/arm/src/stm32/stm32_start.c +++ b/arch/arm/src/stm32/stm32_start.c @@ -49,9 +49,7 @@ * ARM EABI requires 64 bit stack alignment. */ -#define IDLE_STACKSIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7) -#define IDLE_STACK ((uintptr_t)&_ebss + IDLE_STACKSIZE) -#define HEAP_BASE ((uintptr_t)&_ebss + IDLE_STACKSIZE) +#define HEAP_BASE ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/stm32f0l0g0/stm32_start.c b/arch/arm/src/stm32f0l0g0/stm32_start.c index fa57870a393..705d6965332 100644 --- a/arch/arm/src/stm32f0l0g0/stm32_start.c +++ b/arch/arm/src/stm32f0l0g0/stm32_start.c @@ -42,8 +42,7 @@ * Pre-processor Definitions ****************************************************************************/ -#define IDLE_STACK ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) -#define HEAP_BASE ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) +#define IDLE_STACK ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/stm32f7/stm32_start.c b/arch/arm/src/stm32f7/stm32_start.c index e42308dbfe9..280771f0488 100644 --- a/arch/arm/src/stm32f7/stm32_start.c +++ b/arch/arm/src/stm32f7/stm32_start.c @@ -61,7 +61,6 @@ * 0x2005:ffff - End of internal SRAM and end of heap (a */ -#define IDLE_STACK ((uintptr_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) #define HEAP_BASE ((uintptr_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** diff --git a/arch/arm/src/stm32h7/stm32_start.c b/arch/arm/src/stm32h7/stm32_start.c index 60bc5ea0105..b42cb3f5cae 100644 --- a/arch/arm/src/stm32h7/stm32_start.c +++ b/arch/arm/src/stm32h7/stm32_start.c @@ -62,7 +62,6 @@ * 0x2005:ffff - End of internal SRAM and end of heap (a */ -#define IDLE_STACK ((uintptr_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) #define HEAP_BASE ((uintptr_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** diff --git a/arch/arm/src/stm32l4/stm32l4_start.c b/arch/arm/src/stm32l4/stm32l4_start.c index 087a5f7bfab..bbd38b6ee1d 100644 --- a/arch/arm/src/stm32l4/stm32l4_start.c +++ b/arch/arm/src/stm32l4/stm32l4_start.c @@ -62,7 +62,6 @@ #define SRAM2_START STM32L4_SRAM2_BASE #define SRAM2_END (SRAM2_START + STM32L4_SRAM2_SIZE) -#define IDLE_STACK ((uintptr_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) #define HEAP_BASE ((uintptr_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) /* g_idle_topstack: _sbss is the start of the BSS region as defined by the diff --git a/arch/arm/src/stm32l5/stm32l5_start.c b/arch/arm/src/stm32l5/stm32l5_start.c index aae96296776..715e8bea4ff 100644 --- a/arch/arm/src/stm32l5/stm32l5_start.c +++ b/arch/arm/src/stm32l5/stm32l5_start.c @@ -64,7 +64,6 @@ #define SRAM2_START STM32L5_SRAM2_BASE #define SRAM2_END (SRAM2_START + STM32L5_SRAM2_SIZE) -#define IDLE_STACK ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE - 4) #define HEAP_BASE ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) /* g_idle_topstack: _sbss is the start of the BSS region as defined by the diff --git a/arch/arm/src/str71x/str71x_head.S b/arch/arm/src/str71x/str71x_head.S index 6a404f6822b..a3d2ab3ed7a 100644 --- a/arch/arm/src/str71x/str71x_head.S +++ b/arch/arm/src/str71x/str71x_head.S @@ -589,7 +589,7 @@ dtor_end: LC0: .long _sbss .long _ebss - .long _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 + .long _ebss+CONFIG_IDLETHREAD_STACKSIZE LC2: .long _eronly /* Where .data defaults are stored in FLASH */ .long _sdata /* Where .data needs to reside in SDRAM */ diff --git a/arch/arm/src/tiva/cc13xx/cc13xx_start.c b/arch/arm/src/tiva/cc13xx/cc13xx_start.c index aeb69559d73..58846d7cbc7 100644 --- a/arch/arm/src/tiva/cc13xx/cc13xx_start.c +++ b/arch/arm/src/tiva/cc13xx/cc13xx_start.c @@ -54,9 +54,7 @@ * ARM EABI requires 64 bit stack alignment. */ -#define IDLE_STACKSIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7) -#define IDLE_STACK ((uintptr_t)&_ebss + IDLE_STACKSIZE) -#define HEAP_BASE ((uintptr_t)&_ebss + IDLE_STACKSIZE) +#define HEAP_BASE ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/tiva/common/lmxx_tm4c_start.c b/arch/arm/src/tiva/common/lmxx_tm4c_start.c index 4f016ca76dc..ae42409ce78 100644 --- a/arch/arm/src/tiva/common/lmxx_tm4c_start.c +++ b/arch/arm/src/tiva/common/lmxx_tm4c_start.c @@ -53,9 +53,7 @@ * ARM EABI requires 64 bit stack alignment. */ -#define IDLE_STACKSIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7) -#define IDLE_STACK ((uintptr_t)&_ebss + IDLE_STACKSIZE) -#define HEAP_BASE ((uintptr_t)&_ebss + IDLE_STACKSIZE) +#define HEAP_BASE ((uintptr_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/arm/src/xmc4/xmc4_start.c b/arch/arm/src/xmc4/xmc4_start.c index 39ba0d4cc10..2de7700c132 100644 --- a/arch/arm/src/xmc4/xmc4_start.c +++ b/arch/arm/src/xmc4/xmc4_start.c @@ -74,7 +74,6 @@ static void go_nx_start(void *pv, unsigned int nbytes) * 0x2002:ffff - End of internal SRAM and end of heap (a */ -#define IDLE_STACK ((uintptr_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) #define HEAP_BASE ((uintptr_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** diff --git a/arch/avr/src/at90usb/at90usb_exceptions.S b/arch/avr/src/at90usb/at90usb_exceptions.S index 1101478dd21..8ead72787c1 100644 --- a/arch/avr/src/at90usb/at90usb_exceptions.S +++ b/arch/avr/src/at90usb/at90usb_exceptions.S @@ -148,13 +148,13 @@ excpt_common: * Name: up_interruptstack ****************************************************************************************************/ -#if CONFIG_ARCH_INTERRUPTSTACK > 0 +#if CONFIG_ARCH_INTERRUPTSTACK > 3 .bss .align 4 .globl up_interruptstack .type up_interruptstack, object up_interruptstack: - .skip CONFIG_ARCH_INTERRUPTSTACK + .skip (CONFIG_ARCH_INTERRUPTSTACK & ~3) .Lintstackbase: .size up_interruptstack, .-up_interruptstack #endif diff --git a/arch/avr/src/at90usb/at90usb_head.S b/arch/avr/src/at90usb/at90usb_head.S index a32c9cdf638..c87a3ac209e 100644 --- a/arch/avr/src/at90usb/at90usb_head.S +++ b/arch/avr/src/at90usb/at90usb_head.S @@ -33,7 +33,7 @@ /* Stack is allocated just after uninitialized data and just before the heap */ -#define STACKBASE (_enoinit+CONFIG_IDLETHREAD_STACKSIZE-1) +#define STACKBASE (_enoinit+CONFIG_IDLETHREAD_STACKSIZE) /* The RAMPZ register is only available for CPUs with more than 64Kb of FLASH. * Only the AT90USB646, 647, 1286, and 1287 are supported by this file. diff --git a/arch/avr/src/atmega/atmega_head.S b/arch/avr/src/atmega/atmega_head.S index ff5cd6e9919..d9afcdb2ce1 100644 --- a/arch/avr/src/atmega/atmega_head.S +++ b/arch/avr/src/atmega/atmega_head.S @@ -36,7 +36,7 @@ /* Stack is allocated just after uninitialized data and just before the heap */ -#define STACKBASE (_enoinit+CONFIG_IDLETHREAD_STACKSIZE-1) +#define STACKBASE (_enoinit+CONFIG_IDLETHREAD_STACKSIZE) /* The RAMPZ register is only available for CPUs with more than 64Kb of FLASH. * At present, only the ATMega128 is supported so RAMPZ should always be diff --git a/arch/avr/src/avr/up_createstack.c b/arch/avr/src/avr/up_createstack.c index d70222470d0..a6c606c382b 100644 --- a/arch/avr/src/avr/up_createstack.c +++ b/arch/avr/src/avr/up_createstack.c @@ -189,7 +189,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * stack are referenced as positive word offsets from sp. */ - top_of_stack = (size_t)tcb->stack_alloc_ptr + stack_size - 1; + top_of_stack = (size_t)tcb->stack_alloc_ptr + stack_size; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/avr/src/avr/up_dumpstate.c b/arch/avr/src/avr/up_dumpstate.c index 7c938910d7f..5dfdbc85d38 100644 --- a/arch/avr/src/avr/up_dumpstate.c +++ b/arch/avr/src/avr/up_dumpstate.c @@ -145,7 +145,7 @@ void up_dumpstate(void) /* Get the limits on the interrupt stack memory */ #if CONFIG_ARCH_INTERRUPTSTACK > 0 - istackbase = (uint16_t)&g_intstackbase - 1; + istackbase = (uint16_t)&g_intstackbase; istacksize = CONFIG_ARCH_INTERRUPTSTACK; /* Show interrupt stack info */ @@ -162,7 +162,7 @@ void up_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -196,7 +196,7 @@ void up_dumpstate(void) * stack memory. */ - if (sp <= ustackbase && sp > ustackbase - ustacksize) + if (sp < ustackbase && sp >= ustackbase - ustacksize) { up_stackdump(sp, ustackbase); } @@ -217,7 +217,7 @@ void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); up_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/avr/src/avr/up_usestack.c b/arch/avr/src/avr/up_usestack.c index ae2a9e1dc73..bdde37c2396 100644 --- a/arch/avr/src/avr/up_usestack.c +++ b/arch/avr/src/avr/up_usestack.c @@ -105,7 +105,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * positive word offsets from sp. */ - top_of_stack = (size_t)tcb->stack_alloc_ptr + stack_size - 1; + top_of_stack = (size_t)tcb->stack_alloc_ptr + stack_size; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/avr/src/avr32/up_createstack.c b/arch/avr/src/avr32/up_createstack.c index 4dcd5f22c6b..6ef611e05af 100644 --- a/arch/avr/src/avr32/up_createstack.c +++ b/arch/avr/src/avr32/up_createstack.c @@ -195,14 +195,14 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * the stack are referenced as positive word offsets from sp. */ - top_of_stack = (size_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (size_t)tcb->stack_alloc_ptr + stack_size; /* The AVR32 stack must be aligned at word (4 byte) boundaries. If * necessary top_of_stack must be rounded down to the next boundary */ top_of_stack &= ~3; - size_of_stack = top_of_stack - (size_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (size_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/avr/src/avr32/up_dumpstate.c b/arch/avr/src/avr32/up_dumpstate.c index 799aa353bf2..6949d88aa6f 100644 --- a/arch/avr/src/avr32/up_dumpstate.c +++ b/arch/avr/src/avr32/up_dumpstate.c @@ -116,7 +116,7 @@ void up_dumpstate(void) #if CONFIG_ARCH_INTERRUPTSTACK > 3 istackbase = (uint32_t)&g_intstackbase; - istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4; + istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* Show interrupt stack info */ @@ -132,7 +132,7 @@ void up_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -166,7 +166,7 @@ void up_dumpstate(void) * stack memory. */ - if (sp <= ustackbase && sp > ustackbase - ustacksize) + if (sp < ustackbase && sp >= ustackbase - ustacksize) { up_stackdump(sp, ustackbase); } @@ -187,7 +187,7 @@ void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); up_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/avr/src/avr32/up_nommuhead.S b/arch/avr/src/avr32/up_nommuhead.S index 7453940da9d..82f1cd2d1cd 100644 --- a/arch/avr/src/avr32/up_nommuhead.S +++ b/arch/avr/src/avr32/up_nommuhead.S @@ -121,7 +121,7 @@ __start: lda.w pc, nx_start .Lstackbase: - .word _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 + .word _ebss+CONFIG_IDLETHREAD_STACKSIZE .Lup_lowinit: .word up_lowinit .size __start, .-__start diff --git a/arch/avr/src/avr32/up_usestack.c b/arch/avr/src/avr32/up_usestack.c index 8e308bf4507..ef3b1d422ae 100644 --- a/arch/avr/src/avr32/up_usestack.c +++ b/arch/avr/src/avr32/up_usestack.c @@ -106,7 +106,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * referenced as positive word offsets from sp. */ - top_of_stack = (size_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (size_t)tcb->stack_alloc_ptr + stack_size; /* The AVR32 stack must be aligned at word (4 byte) * boundaries. If necessary top_of_stack must be rounded @@ -114,7 +114,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) */ top_of_stack &= ~3; - size_of_stack = top_of_stack - (size_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (size_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/hc/src/m9s12/m9s12_assert.c b/arch/hc/src/m9s12/m9s12_assert.c index 76128b54536..365da432eb0 100644 --- a/arch/hc/src/m9s12/m9s12_assert.c +++ b/arch/hc/src/m9s12/m9s12_assert.c @@ -191,7 +191,7 @@ static void up_dumpstate(void) #if CONFIG_ARCH_INTERRUPTSTACK > 3 istackbase = (uint16_t)&g_intstackbase; - istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4; + istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* Show interrupt stack info */ @@ -204,7 +204,7 @@ static void up_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -238,7 +238,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); up_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/hc/src/m9s12/m9s12_start.S b/arch/hc/src/m9s12/m9s12_start.S index d800dc69343..443169a7766 100644 --- a/arch/hc/src/m9s12/m9s12_start.S +++ b/arch/hc/src/m9s12/m9s12_start.S @@ -226,7 +226,7 @@ __start: .Lebss: .hword _ebss .Lstackbase: - .hword _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 + .hword _ebss+CONFIG_IDLETHREAD_STACKSIZE .Leronly: .hword _eronly /* Where .data defaults are stored in FLASH */ .Lsdata: diff --git a/arch/mips/src/common/mips_createstack.c b/arch/mips/src/common/mips_createstack.c index 95ca80cb617..f3c9ea5fc20 100644 --- a/arch/mips/src/common/mips_createstack.c +++ b/arch/mips/src/common/mips_createstack.c @@ -212,7 +212,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * the stack are referenced as positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The MIPS stack must be aligned at word (4 byte) boundaries; for * floating point use, the stack must be aligned to 8-byte addresses. @@ -228,7 +228,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * The size need not be aligned. */ - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/mips/src/common/mips_usestack.c b/arch/mips/src/common/mips_usestack.c index 18211e70e8c..531e7c50a45 100644 --- a/arch/mips/src/common/mips_usestack.c +++ b/arch/mips/src/common/mips_usestack.c @@ -125,7 +125,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * as positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The MIPS stack must be aligned at word (4 byte) or double word (8 byte) * boundaries. If necessary top_of_stack must be rounded down to the @@ -140,7 +140,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * The size need not be aligned. */ - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/mips/src/mips32/mips_dumpstate.c b/arch/mips/src/mips32/mips_dumpstate.c index 370f8f90808..163d1eea491 100644 --- a/arch/mips/src/mips32/mips_dumpstate.c +++ b/arch/mips/src/mips32/mips_dumpstate.c @@ -146,7 +146,7 @@ void up_dumpstate(void) #if CONFIG_ARCH_INTERRUPTSTACK > 3 istackbase = (uint32_t)&g_intstackbase; - istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4; + istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* Show interrupt stack info */ @@ -159,7 +159,7 @@ void up_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -193,7 +193,7 @@ void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); up_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/mips/src/pic32mx/pic32mx_head.S b/arch/mips/src/pic32mx/pic32mx_head.S index ff0fd1b575d..3751caa9d51 100644 --- a/arch/mips/src/pic32mx/pic32mx_head.S +++ b/arch/mips/src/pic32mx/pic32mx_head.S @@ -78,7 +78,7 @@ */ #define PIC32MX_STACK_BASE _ebss -#define PIC32MX_STACK_TOP _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 +#define PIC32MX_STACK_TOP _ebss+CONFIG_IDLETHREAD_STACKSIZE #if CONFIG_ARCH_INTERRUPTSTACK > 3 # define PIC32MX_INTSTACK_BASE PIC32MX_STACK_TOP @@ -668,7 +668,7 @@ devconfig0: .sdata .type g_intstackbase, object g_intstackbase: - .long PIC32MX_INTSTACK_TOP-4 + .long PIC32MX_INTSTACK_TOP .size g_intstackbase, .-g_intstackbase /* g_nextlevel is the exception nesting level... the interrupt stack is not diff --git a/arch/mips/src/pic32mz/pic32mz_head.S b/arch/mips/src/pic32mz/pic32mz_head.S index 08aa23429b5..57b5e433a42 100644 --- a/arch/mips/src/pic32mz/pic32mz_head.S +++ b/arch/mips/src/pic32mz/pic32mz_head.S @@ -81,7 +81,7 @@ */ #define PIC32MZ_STACK_BASE _ebss -#define PIC32MZ_STACK_TOP _ebss + CONFIG_IDLETHREAD_STACKSIZE - 4 +#define PIC32MZ_STACK_TOP _ebss + CONFIG_IDLETHREAD_STACKSIZE #if CONFIG_ARCH_INTERRUPTSTACK > 3 # define PIC32MZ_INTSTACK_BASE PIC32MZ_STACK_TOP @@ -925,7 +925,7 @@ adevcfg0: .sdata .type g_intstackbase, object g_intstackbase: - .long PIC32MZ_INTSTACK_TOP-4 + .long PIC32MZ_INTSTACK_TOP .size g_intstackbase, .-g_intstackbase /* g_nextlevel is the exception nesting level... the interrupt stack is not diff --git a/arch/misoc/src/lm32/lm32_createstack.c b/arch/misoc/src/lm32/lm32_createstack.c index f4bb62a7cf3..8e354ab670d 100644 --- a/arch/misoc/src/lm32/lm32_createstack.c +++ b/arch/misoc/src/lm32/lm32_createstack.c @@ -227,7 +227,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * the stack are referenced as positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The LM32 stack must be aligned at word (4 byte) boundaries; for * floating point use, the stack must be aligned to 8-byte addresses. @@ -236,7 +236,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) */ top_of_stack = STACK_ALIGN_DOWN(top_of_stack); - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/misoc/src/lm32/lm32_dumpstate.c b/arch/misoc/src/lm32/lm32_dumpstate.c index 9274b2a7add..ad1cb886608 100644 --- a/arch/misoc/src/lm32/lm32_dumpstate.c +++ b/arch/misoc/src/lm32/lm32_dumpstate.c @@ -148,7 +148,7 @@ void lm32_dumpstate(void) #if CONFIG_ARCH_INTERRUPTSTACK > 3 istackbase = (uint32_t)&g_intstackbase; - istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4; + istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* Show interrupt stack info */ @@ -161,7 +161,7 @@ void lm32_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -195,7 +195,7 @@ void lm32_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); up_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/misoc/src/lm32/lm32_usestack.c b/arch/misoc/src/lm32/lm32_usestack.c index d1ef6a6e48a..13aa6af5d99 100644 --- a/arch/misoc/src/lm32/lm32_usestack.c +++ b/arch/misoc/src/lm32/lm32_usestack.c @@ -103,14 +103,14 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The i486 stack must be aligned at word (4 byte) boundaries. If necessary * top_of_stack must be rounded down to the next boundary */ top_of_stack &= ~3; - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/misoc/src/minerva/minerva_createstack.c b/arch/misoc/src/minerva/minerva_createstack.c index 702c48377f2..a46539a49ce 100644 --- a/arch/misoc/src/minerva/minerva_createstack.c +++ b/arch/misoc/src/minerva/minerva_createstack.c @@ -220,7 +220,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * the stack are referenced as positive word offsets from sp. */ - top_of_stack = (uint32_t) tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The MINERVA stack must be aligned at word (4 byte) boundaries; for * floating point use, the stack must be aligned to 8-byte addresses. @@ -229,7 +229,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) */ top_of_stack = STACK_ALIGN_DOWN(top_of_stack); - size_of_stack = top_of_stack - (uint32_t) tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/misoc/src/minerva/minerva_dumpstate.c b/arch/misoc/src/minerva/minerva_dumpstate.c index 99228e71d58..8f8023edc6d 100644 --- a/arch/misoc/src/minerva/minerva_dumpstate.c +++ b/arch/misoc/src/minerva/minerva_dumpstate.c @@ -155,7 +155,7 @@ void minerva_dumpstate(void) #if CONFIG_ARCH_INTERRUPTSTACK > 3 istackbase = (uint32_t) & g_intstackbase; - istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4; + istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* Show interrupt stack info */ @@ -166,7 +166,7 @@ void minerva_dumpstate(void) /* Does the current stack pointer lie within the interrupt stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -200,7 +200,7 @@ void minerva_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); up_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/misoc/src/minerva/minerva_usestack.c b/arch/misoc/src/minerva/minerva_usestack.c index 2f2662f7118..fbb2de14686 100644 --- a/arch/misoc/src/minerva/minerva_usestack.c +++ b/arch/misoc/src/minerva/minerva_usestack.c @@ -103,14 +103,14 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The i486 stack must be aligned at word (4 byte) boundaries. If necessary * top_of_stack must be rounded down to the next boundary */ top_of_stack &= ~3; - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/or1k/include/arch.h b/arch/or1k/include/arch.h index b78267a2372..00670ad00fb 100644 --- a/arch/or1k/include/arch.h +++ b/arch/or1k/include/arch.h @@ -40,8 +40,6 @@ * Pre-processor Definitions ****************************************************************************/ -#define IDLE_STACK ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) - #ifdef CONFIG_ARCH_ADDRENV #if CONFIG_MM_PGSIZE != 4096 # error Only pages sizes of 4096 are currently supported (CONFIG_ARCH_ADDRENV) diff --git a/arch/or1k/src/common/up_allocateheap.c b/arch/or1k/src/common/up_allocateheap.c index 17411f48223..165fc2cfbe2 100644 --- a/arch/or1k/src/common/up_allocateheap.c +++ b/arch/or1k/src/common/up_allocateheap.c @@ -124,7 +124,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) /* Return the heap settings */ - *heap_start = (FAR void *)g_idle_topstack + 4; + *heap_start = (FAR void *)g_idle_topstack; *heap_size = CONFIG_RAM_END - *(uint32_t *)heap_start; board_autoled_on(LED_HEAPALLOCATE); diff --git a/arch/or1k/src/common/up_assert.c b/arch/or1k/src/common/up_assert.c index ab96936f328..47fe7954c49 100644 --- a/arch/or1k/src/common/up_assert.c +++ b/arch/or1k/src/common/up_assert.c @@ -232,7 +232,7 @@ static void up_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -266,7 +266,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp <= ustackbase && sp > ustackbase - ustacksize) + if (sp < ustackbase && sp >= ustackbase - ustacksize) { up_stackdump(sp, ustackbase); } @@ -288,7 +288,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); up_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/or1k/src/common/up_createstack.c b/arch/or1k/src/common/up_createstack.c index 5a48e5fb113..22029475d0e 100644 --- a/arch/or1k/src/common/up_createstack.c +++ b/arch/or1k/src/common/up_createstack.c @@ -194,9 +194,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) size_t top_of_stack; size_t size_of_stack; - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; top_of_stack = STACK_ALIGN_DOWN(top_of_stack); - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/or1k/src/common/up_usestack.c b/arch/or1k/src/common/up_usestack.c index 6593e14aa61..1ccdaf20899 100644 --- a/arch/or1k/src/common/up_usestack.c +++ b/arch/or1k/src/common/up_usestack.c @@ -103,14 +103,14 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The i486 stack must be aligned at word (4 byte) boundaries. If necessary * top_of_stack must be rounded down to the next boundary */ top_of_stack &= ~3; - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/or1k/src/mor1kx/mor1kx_start.c b/arch/or1k/src/mor1kx/mor1kx_start.c index de872eb0ebd..e9525a7a389 100644 --- a/arch/or1k/src/mor1kx/mor1kx_start.c +++ b/arch/or1k/src/mor1kx/mor1kx_start.c @@ -42,8 +42,7 @@ * 0x0000:0000 - Beginning of DRAM. */ -#define IDLE_STACK ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4) -#define HEAP_BASE ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) +#define IDLE_STACK ((uint32_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** * Public Data diff --git a/arch/or1k/src/mor1kx/up_vectortab.S b/arch/or1k/src/mor1kx/up_vectortab.S index 790fe5662b3..807ab4158d1 100644 --- a/arch/or1k/src/mor1kx/up_vectortab.S +++ b/arch/or1k/src/mor1kx/up_vectortab.S @@ -251,7 +251,7 @@ _reset_vector: l.movhi r1,hi(_ebss); l.ori r1,r1,lo(_ebss); - l.addi r1,r1,CONFIG_IDLETHREAD_STACKSIZE-4; + l.addi r1,r1,CONFIG_IDLETHREAD_STACKSIZE; l.ori r2,r1,0; l.nop diff --git a/arch/renesas/src/common/up_createstack.c b/arch/renesas/src/common/up_createstack.c index 31a3ee9640f..dbdfb3dd46c 100644 --- a/arch/renesas/src/common/up_createstack.c +++ b/arch/renesas/src/common/up_createstack.c @@ -193,7 +193,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * referenced as positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The SH stack must be aligned at word (4 byte) * boundaries. If necessary top_of_stack must be rounded @@ -201,7 +201,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) */ top_of_stack &= ~3; - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/renesas/src/common/up_usestack.c b/arch/renesas/src/common/up_usestack.c index 4420a0e002b..bd7a120e5e6 100644 --- a/arch/renesas/src/common/up_usestack.c +++ b/arch/renesas/src/common/up_usestack.c @@ -105,14 +105,14 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * stack are referenced as positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The SH stack must be aligned at word (4 byte) boundaries. If necessary * top_of_stack must be rounded down to the next boundary */ top_of_stack &= ~3; - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/renesas/src/m16c/m16c_dumpstate.c b/arch/renesas/src/m16c/m16c_dumpstate.c index 7471284ff93..d876ff0c54d 100644 --- a/arch/renesas/src/m16c/m16c_dumpstate.c +++ b/arch/renesas/src/m16c/m16c_dumpstate.c @@ -165,7 +165,7 @@ void up_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -197,7 +197,7 @@ void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); m16c_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/renesas/src/rx65n/rx65n_dumpstate.c b/arch/renesas/src/rx65n/rx65n_dumpstate.c index 46b4e495644..0feab9c48e7 100644 --- a/arch/renesas/src/rx65n/rx65n_dumpstate.c +++ b/arch/renesas/src/rx65n/rx65n_dumpstate.c @@ -149,7 +149,7 @@ void up_dumpstate(void) #if CONFIG_ARCH_INTERRUPTSTACK > 3 istackbase = ebss; /* check how to declare ebss, as of now declared in chip.h */ - istacksize = CONFIG_ARCH_INTERRUPTSTACK; + istacksize = CONFIG_ARCH_INTERRUPTSTACK & ~3; /* Show interrupt stack info */ @@ -162,7 +162,7 @@ void up_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -194,7 +194,7 @@ void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); rx65n_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/renesas/src/rx65n/rx65n_head.S b/arch/renesas/src/rx65n/rx65n_head.S index 2549e9d9b6b..c9d2365e005 100644 --- a/arch/renesas/src/rx65n/rx65n_head.S +++ b/arch/renesas/src/rx65n/rx65n_head.S @@ -178,7 +178,7 @@ _loop_here: .type _g_idle_topstack, @object _g_idle_topstack: - .long _ebss + CONFIG_ARCH_INTERRUPTSTACK + CONFIG_IDLETHREAD_STACKSIZE + .long _ebss + (CONFIG_ARCH_INTERRUPTSTACK & ~3) + CONFIG_IDLETHREAD_STACKSIZE .size _g_idle_topstack, . - _g_idle_topstack .end diff --git a/arch/renesas/src/rx65n/rx65n_vector.S b/arch/renesas/src/rx65n/rx65n_vector.S index 4220b2cad6f..60290045045 100644 --- a/arch/renesas/src/rx65n/rx65n_vector.S +++ b/arch/renesas/src/rx65n/rx65n_vector.S @@ -792,10 +792,9 @@ _uprx65_groupal1_handler: .global _g_intstackbase .type _g_intstackbase, object _g_intstackalloc: - .skip ((CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4) + .skip (CONFIG_ARCH_INTERRUPTSTACK & ~3) _g_intstackbase: - .skip 2 - .size _g_intstackbase, 4 + .size _g_intstackbase, 0 .size _g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~3) #endif diff --git a/arch/renesas/src/sh1/sh1_dumpstate.c b/arch/renesas/src/sh1/sh1_dumpstate.c index dbc39cdf9a4..4a74de843b9 100644 --- a/arch/renesas/src/sh1/sh1_dumpstate.c +++ b/arch/renesas/src/sh1/sh1_dumpstate.c @@ -130,7 +130,7 @@ void up_dumpstate(void) #if CONFIG_ARCH_INTERRUPTSTACK > 3 istackbase = (uint32_t)&g_intstackbase; - istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4; + istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* Show interrupt stack info */ @@ -143,7 +143,7 @@ void up_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -177,7 +177,7 @@ void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); sh1_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/renesas/src/sh1/sh1_head.S b/arch/renesas/src/sh1/sh1_head.S index a26c15309ff..fa9058f02d4 100644 --- a/arch/renesas/src/sh1/sh1_head.S +++ b/arch/renesas/src/sh1/sh1_head.S @@ -178,9 +178,9 @@ __vector_table: */ .long __start /* 0-1: Power-on reset (hard, NMI high) PC & SP */ - .long _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 + .long _ebss+CONFIG_IDLETHREAD_STACKSIZE .long __start /* 2-3: Manual reset (soft, NMI low) PC & SP */ - .long _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 + .long _ebss+CONFIG_IDLETHREAD_STACKSIZE .rept SH1_NCMN_VECTORS-4 .long _up_invalid_handler @@ -344,7 +344,7 @@ __start: .align 2 .Lstack: - .long _ebss+CONFIG_IDLETHREAD_STACKSIZE-4 + .long _ebss+CONFIG_IDLETHREAD_STACKSIZE .Lwcr1: .long 0x5ffffa2 .Lbcr: diff --git a/arch/renesas/src/sh1/sh1_vector.S b/arch/renesas/src/sh1/sh1_vector.S index 26b785ca317..6f629bb9280 100644 --- a/arch/renesas/src/sh1/sh1_vector.S +++ b/arch/renesas/src/sh1/sh1_vector.S @@ -501,10 +501,9 @@ _up_fullcontextrestore: .globl _g_intstackbase .type _g_intstackbase, object _g_intstackalloc: - .skip ((CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4) + .skip (CONFIG_ARCH_INTERRUPTSTACK & ~3) _g_intstackbase: - .skip 2 - .size _g_intstackbase, 4 + .size _g_intstackbase, 0 .size _g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~3) #endif .end diff --git a/arch/risc-v/src/bl602/bl602_head.S b/arch/risc-v/src/bl602/bl602_head.S index c43a946fba8..fbc25dc9c36 100644 --- a/arch/risc-v/src/bl602/bl602_head.S +++ b/arch/risc-v/src/bl602/bl602_head.S @@ -158,9 +158,8 @@ exception_common: .type g_intstackalloc, object .type g_intstackbase, object g_intstackalloc: - .skip ((CONFIG_ARCH_INTERRUPTSTACK & ~3)) + .skip (CONFIG_ARCH_INTERRUPTSTACK & ~3) g_intstackbase: - .skip 4 - .size g_intstackbase, 4 + .size g_intstackbase, 0 .size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~3) #endif diff --git a/arch/risc-v/src/bl602/bl602_irq.c b/arch/risc-v/src/bl602/bl602_irq.c index 73841cc1574..869f1472dc6 100644 --- a/arch/risc-v/src/bl602/bl602_irq.c +++ b/arch/risc-v/src/bl602/bl602_irq.c @@ -83,7 +83,7 @@ void up_irqinitialize(void) size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3); riscv_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size), - intstack_size); + intstack_size); #endif /* currents_regs is non-NULL only while processing an interrupt */ diff --git a/arch/risc-v/src/c906/c906_head.S b/arch/risc-v/src/c906/c906_head.S index 7880e3510ff..8a8dc834733 100644 --- a/arch/risc-v/src/c906/c906_head.S +++ b/arch/risc-v/src/c906/c906_head.S @@ -191,7 +191,7 @@ exception_common: mv a1, sp /* context = sp */ -#if CONFIG_ARCH_INTERRUPTSTACK > 3 +#if CONFIG_ARCH_INTERRUPTSTACK > 7 /* Load mhartid (cpuid) */ csrr s0, mhartid @@ -203,7 +203,7 @@ exception_common: j 4f 3: la sp, g_intstackbase - addi sp, sp, -((CONFIG_ARCH_INTERRUPTSTACK) & ~7) + addi sp, sp, -(CONFIG_ARCH_INTERRUPTSTACK & ~7) 4: #endif @@ -272,9 +272,8 @@ exception_common: .type g_intstackalloc, object .type g_intstackbase, object g_intstackalloc: - .skip (((CONFIG_ARCH_INTERRUPTSTACK * 2) & ~7)) + .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: - .skip 8 - .size g_intstackbase, 8 - .size g_intstackalloc, ((CONFIG_ARCH_INTERRUPTSTACK * 2) & ~7) + .size g_intstackbase, 0 + .size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~7) #endif diff --git a/arch/risc-v/src/c906/c906_irq.c b/arch/risc-v/src/c906/c906_irq.c index b8482b9f200..97de29460fc 100644 --- a/arch/risc-v/src/c906/c906_irq.c +++ b/arch/risc-v/src/c906/c906_irq.c @@ -75,7 +75,7 @@ void up_irqinitialize(void) #if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 7 size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~7); riscv_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size), - intstack_size); + intstack_size); #endif /* Set priority for all global interrupts to 1 (lowest) */ diff --git a/arch/risc-v/src/c906/c906_memorymap.h b/arch/risc-v/src/c906/c906_memorymap.h index e416cc1906b..b51cf3805db 100644 --- a/arch/risc-v/src/c906/c906_memorymap.h +++ b/arch/risc-v/src/c906/c906_memorymap.h @@ -44,10 +44,7 @@ extern uintptr_t *_default_stack_limit; #define C906_IDLESTACK_BASE _default_stack_limit #endif -#define C906_IDLESTACK_SIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7) - -#define C906_IDLESTACK0_TOP (C906_IDLESTACK_BASE + C906_IDLESTACK_SIZE) - +#define C906_IDLESTACK0_TOP (C906_IDLESTACK_BASE + CONFIG_IDLETHREAD_STACKSIZE) #define C906_IDLESTACK_TOP (C906_IDLESTACK0_TOP) #endif /* _ARCH_RISCV_SRC_C906_C906_MEMORYMAP_H */ diff --git a/arch/risc-v/src/common/riscv_createstack.c b/arch/risc-v/src/common/riscv_createstack.c index bb96d669b2b..4754520b7ce 100644 --- a/arch/risc-v/src/common/riscv_createstack.c +++ b/arch/risc-v/src/common/riscv_createstack.c @@ -208,7 +208,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * the stack are referenced as positive word offsets from sp. */ - top_of_stack = (uintptr_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uintptr_t)tcb->stack_alloc_ptr + stack_size; /* The RISC-V stack must be aligned at word (4 byte) boundaries; for * floating point use, the stack must be aligned to 8-byte addresses. @@ -217,7 +217,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) */ top_of_stack = STACK_ALIGN_DOWN(top_of_stack); - size_of_stack = top_of_stack - (uintptr_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uintptr_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/risc-v/src/common/riscv_usestack.c b/arch/risc-v/src/common/riscv_usestack.c index ba294ccd0ef..7cdb9fbd4c4 100644 --- a/arch/risc-v/src/common/riscv_usestack.c +++ b/arch/risc-v/src/common/riscv_usestack.c @@ -118,7 +118,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * as positive word offsets from sp. */ - top_of_stack = (uintptr_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uintptr_t)tcb->stack_alloc_ptr + stack_size; /* The RISC-V stack must be aligned at word (4 byte) or double word * (8 byte) boundaries. If necessary top_of_stack must be rounded down to @@ -126,7 +126,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) */ top_of_stack = STACK_ALIGN_DOWN(top_of_stack); - size_of_stack = top_of_stack - (uintptr_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uintptr_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/risc-v/src/esp32c3/esp32c3_interrupt.S b/arch/risc-v/src/esp32c3/esp32c3_interrupt.S index 957f2de1a9d..abdb0aad60f 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_interrupt.S +++ b/arch/risc-v/src/esp32c3/esp32c3_interrupt.S @@ -42,14 +42,14 @@ .section .noinit -#if CONFIG_ARCH_INTERRUPTSTACK > 15 +#if CONFIG_ARCH_INTERRUPTSTACK > 3 .align 4 .type g_intstackalloc, @object .type g_intstackbase, @object g_intstackalloc: - .skip CONFIG_ARCH_INTERRUPTSTACK + .skip (CONFIG_ARCH_INTERRUPTSTACK & ~3) g_intstackbase: - .size g_intstackalloc, CONFIG_ARCH_INTERRUPTSTACK + .size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~3) #endif /**************************************************************************** @@ -111,7 +111,7 @@ _interrupt_handler: csrr a0, mcause /* exception cause */ mv a1, sp /* context = sp */ -#if CONFIG_ARCH_INTERRUPTSTACK > 15 +#if CONFIG_ARCH_INTERRUPTSTACK > 3 lui sp, %hi(g_intstackbase) addi sp, sp, %lo(g_intstackbase) #endif diff --git a/arch/risc-v/src/esp32c3/esp32c3_memorymap.h b/arch/risc-v/src/esp32c3/esp32c3_memorymap.h index 296345f5b82..e1b3183f16e 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_memorymap.h +++ b/arch/risc-v/src/esp32c3/esp32c3_memorymap.h @@ -37,7 +37,6 @@ #define ESP32C3_IDLESTACK_BASE g_idlestack #endif -#define ESP32C3_IDLESTACK_SIZE (CONFIG_IDLETHREAD_STACKSIZE & ~3) -#define ESP32C3_IDLESTACK_TOP (ESP32C3_IDLESTACK_BASE + ESP32C3_IDLESTACK_SIZE) +#define ESP32C3_IDLESTACK_TOP (ESP32C3_IDLESTACK_BASE + CONFIG_IDLETHREAD_STACKSIZE) #endif /* _ARCH_RISCV_SRC_ESP32C3_ESP32C3_MEMORYMAP_H */ diff --git a/arch/risc-v/src/esp32c3/esp32c3_start.c b/arch/risc-v/src/esp32c3/esp32c3_start.c index a10c2a5a931..2ce266f5c6c 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_start.c +++ b/arch/risc-v/src/esp32c3/esp32c3_start.c @@ -51,7 +51,7 @@ /* Address of the IDLE thread */ -uint8_t g_idlestack[ESP32C3_IDLESTACK_SIZE] +uint8_t g_idlestack[CONFIG_IDLETHREAD_STACKSIZE] __attribute__((aligned(16), section(".noinit"))); uint32_t g_idle_topstack = ESP32C3_IDLESTACK_TOP; diff --git a/arch/risc-v/src/fe310/fe310_head.S b/arch/risc-v/src/fe310/fe310_head.S index b3500d02488..713ab35afa0 100644 --- a/arch/risc-v/src/fe310/fe310_head.S +++ b/arch/risc-v/src/fe310/fe310_head.S @@ -196,9 +196,8 @@ exception_common: .type g_intstackalloc, object .type g_intstackbase, object g_intstackalloc: - .skip ((CONFIG_ARCH_INTERRUPTSTACK & ~3)) + .skip (CONFIG_ARCH_INTERRUPTSTACK & ~3) g_intstackbase: - .skip 4 - .size g_intstackbase, 4 + .size g_intstackbase, 0 .size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~3) #endif diff --git a/arch/risc-v/src/fe310/fe310_irq.c b/arch/risc-v/src/fe310/fe310_irq.c index aa14a49d9cf..55b1e2d66a6 100644 --- a/arch/risc-v/src/fe310/fe310_irq.c +++ b/arch/risc-v/src/fe310/fe310_irq.c @@ -62,7 +62,7 @@ void up_irqinitialize(void) #if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3 size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3); riscv_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size), - intstack_size); + intstack_size); #endif /* Set priority for all global interrupts to 1 (lowest) */ diff --git a/arch/risc-v/src/fe310/fe310_memorymap.h b/arch/risc-v/src/fe310/fe310_memorymap.h index 3cb72b524f8..74ed375cf21 100644 --- a/arch/risc-v/src/fe310/fe310_memorymap.h +++ b/arch/risc-v/src/fe310/fe310_memorymap.h @@ -44,7 +44,6 @@ #define FE310_IDLESTACK_BASE _ebss #endif -#define FE310_IDLESTACK_SIZE (CONFIG_IDLETHREAD_STACKSIZE & ~3) -#define FE310_IDLESTACK_TOP (FE310_IDLESTACK_BASE + FE310_IDLESTACK_SIZE) +#define FE310_IDLESTACK_TOP (FE310_IDLESTACK_BASE + CONFIG_IDLETHREAD_STACKSIZE) #endif /* _ARCH_RISCV_SRC_FE310_FE310_MEMORYMAP_H */ diff --git a/arch/risc-v/src/k210/k210_head.S b/arch/risc-v/src/k210/k210_head.S index 7c2aa36ea9e..17402da0db2 100644 --- a/arch/risc-v/src/k210/k210_head.S +++ b/arch/risc-v/src/k210/k210_head.S @@ -143,7 +143,7 @@ normal_irq: mv a1, sp /* context = sp */ -#if CONFIG_ARCH_INTERRUPTSTACK > 3 +#if CONFIG_ARCH_INTERRUPTSTACK > 7 /* Load mhartid (cpuid) */ csrr s0, mhartid @@ -155,7 +155,7 @@ normal_irq: j 4f 3: la sp, g_intstackbase - addi sp, sp, -((CONFIG_ARCH_INTERRUPTSTACK) & ~7) + addi sp, sp, -(CONFIG_ARCH_INTERRUPTSTACK & ~7) 4: #endif @@ -223,9 +223,8 @@ normal_irq: .type g_intstackalloc, object .type g_intstackbase, object g_intstackalloc: - .skip (((CONFIG_ARCH_INTERRUPTSTACK * 2) & ~7)) + .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: - .skip 8 - .size g_intstackbase, 8 - .size g_intstackalloc, ((CONFIG_ARCH_INTERRUPTSTACK * 2) & ~7) + .size g_intstackbase, 0 + .size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~7) #endif diff --git a/arch/risc-v/src/k210/k210_irq.c b/arch/risc-v/src/k210/k210_irq.c index c00cc2394a1..82a1671aac7 100644 --- a/arch/risc-v/src/k210/k210_irq.c +++ b/arch/risc-v/src/k210/k210_irq.c @@ -83,7 +83,7 @@ void up_irqinitialize(void) #if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 7 size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~7); riscv_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size), - intstack_size); + intstack_size); #endif /* Set priority for all global interrupts to 1 (lowest) */ diff --git a/arch/risc-v/src/k210/k210_memorymap.h b/arch/risc-v/src/k210/k210_memorymap.h index 71efc19d86c..22dc10c1ed7 100644 --- a/arch/risc-v/src/k210/k210_memorymap.h +++ b/arch/risc-v/src/k210/k210_memorymap.h @@ -43,10 +43,8 @@ #define K210_IDLESTACK_BASE _ebss #endif -#define K210_IDLESTACK_SIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7) - -#define K210_IDLESTACK0_TOP (K210_IDLESTACK_BASE + K210_IDLESTACK_SIZE) -#define K210_IDLESTACK1_TOP (K210_IDLESTACK0_TOP + K210_IDLESTACK_SIZE) +#define K210_IDLESTACK0_TOP (K210_IDLESTACK_BASE + CONFIG_IDLETHREAD_STACKSIZE) +#define K210_IDLESTACK1_TOP (K210_IDLESTACK0_TOP + CONFIG_IDLETHREAD_STACKSIZE) #define K210_IDLESTACK_TOP (K210_IDLESTACK1_TOP) diff --git a/arch/risc-v/src/litex/litex_head.S b/arch/risc-v/src/litex/litex_head.S index bcfb0f87e86..162b337eb61 100644 --- a/arch/risc-v/src/litex/litex_head.S +++ b/arch/risc-v/src/litex/litex_head.S @@ -196,9 +196,8 @@ exception_common: .type g_intstackalloc, object .type g_intstackbase, object g_intstackalloc: - .skip ((CONFIG_ARCH_INTERRUPTSTACK & ~3)) + .skip (CONFIG_ARCH_INTERRUPTSTACK & ~3) g_intstackbase: - .skip 4 - .size g_intstackbase, 4 + .size g_intstackbase, 0 .size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~3) #endif diff --git a/arch/risc-v/src/litex/litex_irq.c b/arch/risc-v/src/litex/litex_irq.c index a0e8be9b011..59c760c2f25 100644 --- a/arch/risc-v/src/litex/litex_irq.c +++ b/arch/risc-v/src/litex/litex_irq.c @@ -61,7 +61,7 @@ void up_irqinitialize(void) #if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3 size_t intstack_size = (CONFIG_ARCH_INTERRUPTSTACK & ~3); riscv_stack_color((FAR void *)((uintptr_t)&g_intstackbase - intstack_size), - intstack_size); + intstack_size); #endif /* litex vexriscv dont have priority and threshold control */ diff --git a/arch/risc-v/src/litex/litex_memorymap.h b/arch/risc-v/src/litex/litex_memorymap.h index 506c32780e9..d2512af37f8 100644 --- a/arch/risc-v/src/litex/litex_memorymap.h +++ b/arch/risc-v/src/litex/litex_memorymap.h @@ -42,7 +42,6 @@ #define LITEX_IDLESTACK_BASE _ebss #endif -#define LITEX_IDLESTACK_SIZE (CONFIG_IDLETHREAD_STACKSIZE & ~3) -#define LITEX_IDLESTACK_TOP (LITEX_IDLESTACK_BASE + LITEX_IDLESTACK_SIZE) +#define LITEX_IDLESTACK_TOP (LITEX_IDLESTACK_BASE + CONFIG_IDLETHREAD_STACKSIZE) #endif /* _ARCH_RISCV_SRC_LITEX_LITEX_MEMORYMAP_H */ diff --git a/arch/risc-v/src/rv32im/riscv_assert.c b/arch/risc-v/src/rv32im/riscv_assert.c index a5eb5b34a7a..e89665b3a2a 100644 --- a/arch/risc-v/src/rv32im/riscv_assert.c +++ b/arch/risc-v/src/rv32im/riscv_assert.c @@ -191,7 +191,7 @@ static void riscv_dumpstate(void) #if CONFIG_ARCH_INTERRUPTSTACK > 3 istackbase = (uint32_t)&g_intstackbase; - istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4; + istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* Show interrupt stack info */ @@ -204,7 +204,7 @@ static void riscv_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -238,7 +238,7 @@ static void riscv_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); riscv_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/risc-v/src/rv64gc/riscv_assert.c b/arch/risc-v/src/rv64gc/riscv_assert.c index 0d10c356c2e..e6eb128d8c6 100644 --- a/arch/risc-v/src/rv64gc/riscv_assert.c +++ b/arch/risc-v/src/rv64gc/riscv_assert.c @@ -202,7 +202,7 @@ static void up_dumpstate(void) #if CONFIG_ARCH_INTERRUPTSTACK > 7 istackbase = (uintptr_t)&g_intstackbase; - istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~7) - 8; + istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~7); /* Show interrupt stack info */ @@ -215,7 +215,7 @@ static void up_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -247,7 +247,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); up_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/x86/src/common/up_assert.c b/arch/x86/src/common/up_assert.c index 1a73dab72ee..084143080d3 100644 --- a/arch/x86/src/common/up_assert.c +++ b/arch/x86/src/common/up_assert.c @@ -152,7 +152,7 @@ static void up_dumpstate(void) #if CONFIG_ARCH_INTERRUPTSTACK > 3 istackbase = (uint32_t)&g_intstackbase; - istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4; + istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* Show interrupt stack info */ @@ -165,7 +165,7 @@ static void up_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -199,7 +199,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); up_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/x86/src/i486/up_createstack.c b/arch/x86/src/i486/up_createstack.c index 7d12e0de6f4..31b23726997 100644 --- a/arch/x86/src/i486/up_createstack.c +++ b/arch/x86/src/i486/up_createstack.c @@ -194,14 +194,14 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * the stack are referenced as positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The i486 stack must be aligned at word (4 byte) boundaries. If * necessary top_of_stack must be rounded down to the next boundary */ top_of_stack &= ~3; - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/x86/src/i486/up_usestack.c b/arch/x86/src/i486/up_usestack.c index 55a7bd60a10..1e73f624c04 100644 --- a/arch/x86/src/i486/up_usestack.c +++ b/arch/x86/src/i486/up_usestack.c @@ -105,14 +105,14 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The i486 stack must be aligned at word (4 byte) boundaries. If necessary * top_of_stack must be rounded down to the next boundary */ top_of_stack &= ~3; - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/x86/src/qemu/qemu_head.S b/arch/x86/src/qemu/qemu_head.S index bf2126f2c93..2069374fcca 100644 --- a/arch/x86/src/qemu/qemu_head.S +++ b/arch/x86/src/qemu/qemu_head.S @@ -38,10 +38,6 @@ * heap continues from there until the end of memory. See g_idle_topstack below. */ -#define STACKBASE ((_ebss + 0x1f) & 0xffffffe0) -#define IDLE_STACK (STACKBASE+CONFIG_IDLETHREAD_STACKSIZE) -#define HEAP_BASE (STACKBASE+CONFIG_IDLETHREAD_STACKSIZE) - /**************************************************************************** * Macros ****************************************************************************/ diff --git a/arch/x86_64/src/common/up_assert.c b/arch/x86_64/src/common/up_assert.c index 6cc87a13dbb..ec285193ddd 100644 --- a/arch/x86_64/src/common/up_assert.c +++ b/arch/x86_64/src/common/up_assert.c @@ -130,7 +130,7 @@ static void up_dumpstate(void) #if CONFIG_ARCH_INTERRUPTSTACK > 3 istackbase = (uint64_t)&g_intstackbase; - istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3) - 8; + istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* Show interrupt stack info */ @@ -143,7 +143,7 @@ static void up_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -172,7 +172,7 @@ static void up_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { #if !defined(CONFIG_ARCH_INTERRUPTSTACK) || CONFIG_ARCH_INTERRUPTSTACK < 4 _alert("ERROR: Stack pointer is not within allocated stack\n"); diff --git a/arch/x86_64/src/intel64/intel64_head.S b/arch/x86_64/src/intel64/intel64_head.S index d43839e6f5e..302643c163b 100644 --- a/arch/x86_64/src/intel64/intel64_head.S +++ b/arch/x86_64/src/intel64/intel64_head.S @@ -40,10 +40,6 @@ * heap continues from there until the end of memory. See g_idle_topstack below. */ -#define STACKBASE ((_ebss + 0x1f) & 0xffffffe0) -#define IDLE_STACK (STACKBASE+CONFIG_IDLETHREAD_STACKSIZE) -#define HEAP_BASE (STACKBASE+CONFIG_IDLETHREAD_STACKSIZE) - /**************************************************************************** * Macros ****************************************************************************/ diff --git a/arch/x86_64/src/intel64/up_createstack.c b/arch/x86_64/src/intel64/up_createstack.c index c0941712ddb..e56e739f5f2 100644 --- a/arch/x86_64/src/intel64/up_createstack.c +++ b/arch/x86_64/src/intel64/up_createstack.c @@ -194,7 +194,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * the stack are referenced as positive quad-words offsets from sp. */ - top_of_stack = (uint64_t)tcb->stack_alloc_ptr + stack_size - 8; + top_of_stack = (uint64_t)tcb->stack_alloc_ptr + stack_size; /* The intel64 stack must be aligned at word (16 byte) boundaries. If * necessary top_of_stack must be rounded down to the next boundary. @@ -202,9 +202,8 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * only frame pointer will be pushed, not instruction pointer. */ - top_of_stack &= ~0xff; - top_of_stack -= 0x8; - size_of_stack = top_of_stack - (uint64_t)tcb->stack_alloc_ptr + 8; + top_of_stack &= ~0x0f; + size_of_stack = top_of_stack - (uint64_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/x86_64/src/intel64/up_usestack.c b/arch/x86_64/src/intel64/up_usestack.c index 52675cdde91..26ee3b7ab9f 100644 --- a/arch/x86_64/src/intel64/up_usestack.c +++ b/arch/x86_64/src/intel64/up_usestack.c @@ -105,7 +105,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * referenced as positive word offsets from sp. */ - top_of_stack = (uint64_t)tcb->stack_alloc_ptr + stack_size - 8; + top_of_stack = (uint64_t)tcb->stack_alloc_ptr + stack_size; /* The intel64 stack must be aligned at word (16 byte) boundaries. If * necessary top_of_stack must be rounded down to the next boundary. @@ -113,9 +113,8 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * frame pointer will be pushed, not instruction pointer. */ - top_of_stack &= ~0xff; - top_of_stack -= 0x8; - size_of_stack = top_of_stack - (uint64_t)tcb->stack_alloc_ptr + 8; + top_of_stack &= ~0x0f; + size_of_stack = top_of_stack - (uint64_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/xtensa/src/common/xtensa_createstack.c b/arch/xtensa/src/common/xtensa_createstack.c index f6a754317e0..9a42dfbab65 100644 --- a/arch/xtensa/src/common/xtensa_createstack.c +++ b/arch/xtensa/src/common/xtensa_createstack.c @@ -208,7 +208,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * the stack are referenced as positive word offsets from sp. */ - top_of_stack = (uintptr_t)tcb->stack_alloc_ptr + stack_size - 16; + top_of_stack = (uintptr_t)tcb->stack_alloc_ptr + stack_size; #if XCHAL_CP_NUM > 0 /* Allocate the co-processor save area at the top of the (push down) @@ -243,7 +243,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) */ top_of_stack = STACK_ALIGN_DOWN(top_of_stack); - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 16; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/xtensa/src/common/xtensa_dumpstate.c b/arch/xtensa/src/common/xtensa_dumpstate.c index 4e1599589f8..6efb9e0e559 100644 --- a/arch/xtensa/src/common/xtensa_dumpstate.c +++ b/arch/xtensa/src/common/xtensa_dumpstate.c @@ -318,7 +318,7 @@ void xtensa_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp >= istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -362,7 +362,7 @@ void xtensa_dumpstate(void) * stack memory. */ - if (sp > ustackbase || sp <= ustackbase - ustacksize) + if (sp >= ustackbase || sp < ustackbase - ustacksize) { _alert("ERROR: Stack pointer is not within allocated stack\n"); xtensa_stackdump(ustackbase - ustacksize, ustackbase); diff --git a/arch/xtensa/src/common/xtensa_usestack.c b/arch/xtensa/src/common/xtensa_usestack.c index 5f88c826693..e3b6677cc5f 100644 --- a/arch/xtensa/src/common/xtensa_usestack.c +++ b/arch/xtensa/src/common/xtensa_usestack.c @@ -111,14 +111,14 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * as positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 16; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The XTENSA stack must be aligned at 16 bytes boundaries. If necessary * top_of_stack must be rounded down to the next boundary. */ top_of_stack = STACK_ALIGN_DOWN(top_of_stack); - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 16; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/z16/src/common/z16_createstack.c b/arch/z16/src/common/z16_createstack.c index 3d137623455..86300692df0 100644 --- a/arch/z16/src/common/z16_createstack.c +++ b/arch/z16/src/common/z16_createstack.c @@ -188,14 +188,14 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * the stack are referenced as positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* Align the stack to word (4 byte) boundaries. This is probably * a greater alignment than is required. */ top_of_stack &= ~3; - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/z16/src/common/z16_usestack.c b/arch/z16/src/common/z16_usestack.c index 8ade8224b20..bfdc548febb 100644 --- a/arch/z16/src/common/z16_usestack.c +++ b/arch/z16/src/common/z16_usestack.c @@ -105,14 +105,14 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * the stack are referenced as positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* Align the stack to word (4 byte) boundaries. This is probably * a greater alignment than is required. */ top_of_stack &= ~3; - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/z80/src/common/z80_createstack.c b/arch/z80/src/common/z80_createstack.c index bf70d66011d..3585f3cd338 100644 --- a/arch/z80/src/common/z80_createstack.c +++ b/arch/z80/src/common/z80_createstack.c @@ -193,14 +193,14 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * referenced as positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The Z80 stack does not need to be aligned. Here is is aligned at * word (4 byte) boundary. */ top_of_stack &= ~3; - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/z80/src/common/z80_usestack.c b/arch/z80/src/common/z80_usestack.c index b2242471402..260d8842514 100644 --- a/arch/z80/src/common/z80_usestack.c +++ b/arch/z80/src/common/z80_usestack.c @@ -104,14 +104,14 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) * the stack are* referenced as positive word offsets from sp. */ - top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size - 4; + top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size; /* The Z80 stack does not need to be aligned. Here is is aligned at * word (4 byte) boundary. */ top_of_stack &= ~3; - size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr + 4; + size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr; /* Save the adjusted stack values in the struct tcb_s */ diff --git a/arch/z80/src/z8/z80_mem.h b/arch/z80/src/z8/z80_mem.h index c1dad234080..380b58a4398 100644 --- a/arch/z80/src/z8/z80_mem.h +++ b/arch/z80/src/z8/z80_mem.h @@ -49,7 +49,7 @@ extern far unsigned long far_heapbot; #ifndef CONFIG_HEAP1_END extern far unsigned long far_stacktop; # define CONFIG_HEAP1_END \ - (((uint16_t)&far_stacktop) - CONFIG_IDLETHREAD_STACKSIZE + 1) + (((uint16_t)&far_stacktop) - CONFIG_IDLETHREAD_STACKSIZE) #endif /************************************************************************************ diff --git a/boards/arm/cxd56xx/common/src/cxd56_crashdump.c b/boards/arm/cxd56xx/common/src/cxd56_crashdump.c index 4925de0a711..b8e6e15f7b3 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_crashdump.c +++ b/boards/arm/cxd56xx/common/src/cxd56_crashdump.c @@ -188,7 +188,7 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, /* Get the limits on the interrupt stack memory */ pdump->info.stacks.interrupt.top = (uint32_t)&g_intstackbase; - pdump->info.stacks.interrupt.size = (CONFIG_ARCH_INTERRUPTSTACK & ~3); + pdump->info.stacks.interrupt.size = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* If In interrupt Context save the interrupt stack data centered * about the interrupt stack pointer diff --git a/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c b/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c index f0d13d4fe71..550bca50aef 100644 --- a/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c +++ b/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c @@ -456,7 +456,7 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, /* Get the limits on the interrupt stack memory */ pdump->info.stacks.interrupt.top = (uint32_t)&g_intstackbase; - pdump->info.stacks.interrupt.size = (CONFIG_ARCH_INTERRUPTSTACK & ~3); + pdump->info.stacks.interrupt.size = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* If In interrupt Context save the interrupt stack data centered * about the interrupt stack pointer diff --git a/boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c b/boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c index efc305edad2..74362bb3564 100644 --- a/boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c +++ b/boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c @@ -456,7 +456,7 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, /* Get the limits on the interrupt stack memory */ pdump->info.stacks.interrupt.top = (uint32_t)&g_intstackbase; - pdump->info.stacks.interrupt.size = (CONFIG_ARCH_INTERRUPTSTACK & ~3); + pdump->info.stacks.interrupt.size = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* If In interrupt Context save the interrupt stack data centered * about the interrupt stack pointer diff --git a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c index 780cf55e16b..0118242fe93 100644 --- a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c +++ b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c @@ -410,7 +410,7 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, /* Get the limits on the interrupt stack memory */ pdump->info.stacks.interrupt.top = (uint32_t)&istack; - pdump->info.stacks.interrupt.size = (CONFIG_ARCH_INTERRUPTSTACK); + pdump->info.stacks.interrupt.size = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* If In interrupt Context save the interrupt stack data centered * about the interrupt stack pointer diff --git a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c index 8a2e89640b8..cda6328620d 100644 --- a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c +++ b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c @@ -408,7 +408,7 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, /* Get the limits on the interrupt stack memory */ pdump->info.stacks.interrupt.top = (uint32_t)&istack; - pdump->info.stacks.interrupt.size = (CONFIG_ARCH_INTERRUPTSTACK); + pdump->info.stacks.interrupt.size = (CONFIG_ARCH_INTERRUPTSTACK & ~3); /* If In interrupt Context save the interrupt stack data centered * about the interrupt stack pointer