This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 44bc681daac643bc2456381f49152a1769f6602c Author: Masayuki Ishikawa <masayuki.ishik...@gmail.com> AuthorDate: Mon Apr 19 08:00:10 2021 +0900 arch: fe310: Add coloration for the idle stack Summary: - This commit adds coloration for the idle stack - Also, apply la pseudo-instruction instead of lui and addi Impact: - fe310 only Testing: - Tested with nsh with QEMU and dev board Signed-off-by: Masayuki Ishikawa <masayuki.ishik...@jp.sony.com> --- arch/risc-v/src/fe310/fe310_head.S | 23 ++++++++++++++++++----- arch/risc-v/src/fe310/fe310_memorymap.h | 7 ++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/arch/risc-v/src/fe310/fe310_head.S b/arch/risc-v/src/fe310/fe310_head.S index 86f9116..53790f7 100644 --- a/arch/risc-v/src/fe310/fe310_head.S +++ b/arch/risc-v/src/fe310/fe310_head.S @@ -26,6 +26,8 @@ #include <arch/rv32im/irq.h> #include "chip.h" +#include "fe310_memorymap.h" +#include "riscv_internal.h" /**************************************************************************** * Public Symbols @@ -44,8 +46,7 @@ __start: /* Set stack pointer to the idle thread stack */ - lui sp, %hi(FE310_IDLESTACK_TOP) - addi sp, sp, %lo(FE310_IDLESTACK_TOP) + la sp, FE310_IDLESTACK_TOP /* Disable all interrupts (i.e. timer, external) in mie */ @@ -53,9 +54,21 @@ __start: /* Initialize the Machine Trap Vector */ - lui t0, %hi(__trap_vec) - addi t0, t0, %lo(__trap_vec) - csrw mtvec, t0 + la t0, __trap_vec + csrw mtvec, t0 + +#ifdef CONFIG_STACK_COLORATION + /* t0 = start of IDLE stack; t1 = top of the stack; t2 = coloration */ + + la t0, FE310_IDLESTACK_BASE + la t1, FE310_IDLESTACK_TOP + li t2, STACK_COLOR + +1: + sw t2, 0(t0) + addi t0, t0, 4 + bne t0, t1, 1b +#endif /* Jump to __fe310_start */ diff --git a/arch/risc-v/src/fe310/fe310_memorymap.h b/arch/risc-v/src/fe310/fe310_memorymap.h index 74ed375..31792f1 100644 --- a/arch/risc-v/src/fe310/fe310_memorymap.h +++ b/arch/risc-v/src/fe310/fe310_memorymap.h @@ -36,12 +36,13 @@ * Pre-processor Definitions ****************************************************************************/ -/* Idle thread stack starts from _ebss */ +/* Idle thread stack starts from _default_stack_limit */ #ifndef __ASSEMBLY__ -#define FE310_IDLESTACK_BASE (uint32_t)&_ebss +extern uintptr_t *_default_stack_limit; +#define FE310_IDLESTACK_BASE (uintptr_t)&_default_stack_limit #else -#define FE310_IDLESTACK_BASE _ebss +#define FE310_IDLESTACK_BASE _default_stack_limit #endif #define FE310_IDLESTACK_TOP (FE310_IDLESTACK_BASE + CONFIG_IDLETHREAD_STACKSIZE)