From afb5a66847e31eebacb60ebbe1c1e42cfc70c7c5 Mon Sep 17 00:00:00 2001 From: Inochi Amaoto Date: Thu, 9 May 2024 20:15:23 +0800 Subject: [PATCH] arch/risc-v: unify idle stack calculation As the stack layout is unified, it is possible to use a unify formula to calculate the top of idle stack. Signed-off-by: Inochi Amaoto --- arch/risc-v/src/bl602/bl602_start.c | 2 -- arch/risc-v/src/bl808/bl808_start.c | 7 ------- arch/risc-v/src/c906/c906_start.c | 12 ------------ arch/risc-v/src/common/espressif/esp_start.c | 2 -- arch/risc-v/src/common/riscv_cpuidlestack.c | 3 +++ arch/risc-v/src/esp32c3-legacy/esp32c3_start.c | 2 -- arch/risc-v/src/fe310/fe310_start.c | 12 ------------ arch/risc-v/src/hpm6000/hpm_start.c | 12 ------------ arch/risc-v/src/hpm6750/hpm6750_start.c | 12 ------------ arch/risc-v/src/jh7110/jh7110_start.c | 7 ------- arch/risc-v/src/k210/k210_start.c | 7 ------- arch/risc-v/src/k230/k230_start.c | 7 ------- arch/risc-v/src/litex/litex_start.c | 12 ------------ arch/risc-v/src/mpfs/mpfs_start.c | 12 ------------ arch/risc-v/src/qemu-rv/qemu_rv_start.c | 7 ------- arch/risc-v/src/rv32m1/rv32m1_start.c | 12 ------------ 16 files changed, 3 insertions(+), 125 deletions(-) diff --git a/arch/risc-v/src/bl602/bl602_start.c b/arch/risc-v/src/bl602/bl602_start.c index 464e2e20fc..63e99b6dec 100644 --- a/arch/risc-v/src/bl602/bl602_start.c +++ b/arch/risc-v/src/bl602/bl602_start.c @@ -66,8 +66,6 @@ static struct boot2_partition_table_s g_boot2_partition_table used_data; * Public Data ****************************************************************************/ -uintptr_t g_idle_topstack = (uintptr_t)_ebss + SMP_STACK_SIZE; - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/risc-v/src/bl808/bl808_start.c b/arch/risc-v/src/bl808/bl808_start.c index b96cf2d7f8..d882f0671b 100644 --- a/arch/risc-v/src/bl808/bl808_start.c +++ b/arch/risc-v/src/bl808/bl808_start.c @@ -58,13 +58,6 @@ extern void __trap_vec(void); * Public Data ****************************************************************************/ -/* NOTE: g_idle_topstack needs to point the top of the idle stack - * for last CPU and this value is used in up_initial_state() - */ - -uintptr_t g_idle_topstack = BL808_IDLESTACK_BASE + - SMP_STACK_SIZE * CONFIG_SMP_NCPUS; - /**************************************************************************** * Private Functions ****************************************************************************/ diff --git a/arch/risc-v/src/c906/c906_start.c b/arch/risc-v/src/c906/c906_start.c index 8b7dd53c44..d4774a2a01 100644 --- a/arch/risc-v/src/c906/c906_start.c +++ b/arch/risc-v/src/c906/c906_start.c @@ -48,18 +48,6 @@ * Public Data ****************************************************************************/ -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -uintptr_t g_idle_topstack = C906_IDLESTACK_TOP; - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/risc-v/src/common/espressif/esp_start.c b/arch/risc-v/src/common/espressif/esp_start.c index bc18fe5d0e..28c33c53c3 100644 --- a/arch/risc-v/src/common/espressif/esp_start.c +++ b/arch/risc-v/src/common/espressif/esp_start.c @@ -174,8 +174,6 @@ HDR_ATTR static void (*_entry_point)(void) = __start; * Public Data ****************************************************************************/ -uintptr_t g_idle_topstack = (uintptr_t)_ebss + SMP_STACK_SIZE; - /**************************************************************************** * Private Functions ****************************************************************************/ diff --git a/arch/risc-v/src/common/riscv_cpuidlestack.c b/arch/risc-v/src/common/riscv_cpuidlestack.c index 0358a3464e..18f211bfda 100644 --- a/arch/risc-v/src/common/riscv_cpuidlestack.c +++ b/arch/risc-v/src/common/riscv_cpuidlestack.c @@ -47,6 +47,9 @@ * Public Data ****************************************************************************/ +uintptr_t g_idle_topstack = (uintptr_t)_ebss + + SMP_STACK_SIZE * CONFIG_SMP_NCPUS; + const uint8_t *g_cpux_idlestack[CONFIG_SMP_NCPUS]; /**************************************************************************** diff --git a/arch/risc-v/src/esp32c3-legacy/esp32c3_start.c b/arch/risc-v/src/esp32c3-legacy/esp32c3_start.c index c2b2cc731f..ae808190f9 100644 --- a/arch/risc-v/src/esp32c3-legacy/esp32c3_start.c +++ b/arch/risc-v/src/esp32c3-legacy/esp32c3_start.c @@ -127,8 +127,6 @@ HDR_ATTR static void (*_entry_point)(void) = __start; * Public Data ****************************************************************************/ -uintptr_t g_idle_topstack = (uintptr_t)_ebss + SMP_STACK_SIZE; - /**************************************************************************** * Private Functions ****************************************************************************/ diff --git a/arch/risc-v/src/fe310/fe310_start.c b/arch/risc-v/src/fe310/fe310_start.c index 279ce82d0f..7e08910d3f 100644 --- a/arch/risc-v/src/fe310/fe310_start.c +++ b/arch/risc-v/src/fe310/fe310_start.c @@ -47,18 +47,6 @@ * Public Data ****************************************************************************/ -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -uintptr_t g_idle_topstack = FE310_IDLESTACK_TOP; - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/risc-v/src/hpm6000/hpm_start.c b/arch/risc-v/src/hpm6000/hpm_start.c index d368b9027a..331e5d2098 100644 --- a/arch/risc-v/src/hpm6000/hpm_start.c +++ b/arch/risc-v/src/hpm6000/hpm_start.c @@ -42,18 +42,6 @@ * Public Data ****************************************************************************/ -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -uintptr_t g_idle_topstack = HPM_IDLESTACK_TOP; - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/risc-v/src/hpm6750/hpm6750_start.c b/arch/risc-v/src/hpm6750/hpm6750_start.c index a751c8cf4f..108fe5ff28 100644 --- a/arch/risc-v/src/hpm6750/hpm6750_start.c +++ b/arch/risc-v/src/hpm6750/hpm6750_start.c @@ -42,18 +42,6 @@ * Public Data ****************************************************************************/ -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -uintptr_t g_idle_topstack = HPM6750_IDLESTACK_TOP; - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/risc-v/src/jh7110/jh7110_start.c b/arch/risc-v/src/jh7110/jh7110_start.c index 1dac2fdf53..334bac41fa 100644 --- a/arch/risc-v/src/jh7110/jh7110_start.c +++ b/arch/risc-v/src/jh7110/jh7110_start.c @@ -52,13 +52,6 @@ extern void __trap_vec(void); * Public Data ****************************************************************************/ -/* NOTE: g_idle_topstack needs to point the top of the idle stack - * for last CPU and this value is used in up_initial_state() - */ - -uintptr_t g_idle_topstack = JH7110_IDLESTACK_BASE + - SMP_STACK_SIZE * CONFIG_SMP_NCPUS; - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/risc-v/src/k210/k210_start.c b/arch/risc-v/src/k210/k210_start.c index b85525abf0..7d3fa35e03 100644 --- a/arch/risc-v/src/k210/k210_start.c +++ b/arch/risc-v/src/k210/k210_start.c @@ -48,13 +48,6 @@ * Public Data ****************************************************************************/ -/* NOTE: g_idle_topstack needs to point the top of the idle stack - * for CPU0 and this value is used in up_initial_state() - */ - -uintptr_t g_idle_topstack = K210_IDLESTACK_BASE + - SMP_STACK_SIZE * CONFIG_SMP_NCPUS; - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/risc-v/src/k230/k230_start.c b/arch/risc-v/src/k230/k230_start.c index aa56852270..a389558f3c 100644 --- a/arch/risc-v/src/k230/k230_start.c +++ b/arch/risc-v/src/k230/k230_start.c @@ -101,13 +101,6 @@ static void k230_copy_init_data(void) * Public Data ****************************************************************************/ -/* NOTE: g_idle_topstack needs to point the top of the idle stack - * for last CPU and this value is used in up_initial_state() - */ - -uintptr_t g_idle_topstack = K230_IDLESTACK_BASE + - SMP_STACK_SIZE * CONFIG_SMP_NCPUS; - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/risc-v/src/litex/litex_start.c b/arch/risc-v/src/litex/litex_start.c index 00f33769c1..8d5c0b6531 100644 --- a/arch/risc-v/src/litex/litex_start.c +++ b/arch/risc-v/src/litex/litex_start.c @@ -56,18 +56,6 @@ * Public Data ****************************************************************************/ -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -uintptr_t g_idle_topstack = LITEX_IDLESTACK_TOP; - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/risc-v/src/mpfs/mpfs_start.c b/arch/risc-v/src/mpfs/mpfs_start.c index eae7c5399b..02b74cec06 100644 --- a/arch/risc-v/src/mpfs/mpfs_start.c +++ b/arch/risc-v/src/mpfs/mpfs_start.c @@ -57,18 +57,6 @@ * Public Data ****************************************************************************/ -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -uintptr_t g_idle_topstack = MPFS_IDLESTACK_TOP; - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/risc-v/src/qemu-rv/qemu_rv_start.c b/arch/risc-v/src/qemu-rv/qemu_rv_start.c index 757e78d767..6335562beb 100644 --- a/arch/risc-v/src/qemu-rv/qemu_rv_start.c +++ b/arch/risc-v/src/qemu-rv/qemu_rv_start.c @@ -109,13 +109,6 @@ static bool boot_secondary = false; * Public Data ****************************************************************************/ -/* NOTE: g_idle_topstack needs to point the top of the idle stack - * for last CPU and this value is used in up_initial_state() - */ - -uintptr_t g_idle_topstack = QEMU_RV_IDLESTACK_BASE + - SMP_STACK_SIZE * CONFIG_SMP_NCPUS; - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/risc-v/src/rv32m1/rv32m1_start.c b/arch/risc-v/src/rv32m1/rv32m1_start.c index fb9c6ef996..2a841ddebe 100644 --- a/arch/risc-v/src/rv32m1/rv32m1_start.c +++ b/arch/risc-v/src/rv32m1/rv32m1_start.c @@ -50,18 +50,6 @@ * Public Data ****************************************************************************/ -/* g_idle_topstack: _sbss is the start of the BSS region as defined by the - * linker script. _ebss lies at the end of the BSS region. The idle task - * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. - * The IDLE thread is the thread that the system boots on and, eventually, - * becomes the IDLE, do nothing task that runs only when there is nothing - * else to run. The heap continues from there until the end of memory. - * g_idle_topstack is a read-only variable the provides this computed - * address. - */ - -uintptr_t g_idle_topstack = RV32M1_IDLESTACK_TOP; - /**************************************************************************** * Public Functions ****************************************************************************/