You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2024/05/11 15:58:06 UTC
(nuttx) branch master updated (09bfaa7292 -> bc022f8cd8)
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
from 09bfaa7292 fix nxstyle
new afb5a66847 arch/risc-v: unify idle stack calculation
new bc022f8cd8 arch/risc-v: remove g_cpux_idlestack
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
arch/risc-v/src/bl602/bl602_start.c | 6 ------
arch/risc-v/src/bl808/bl808_start.c | 11 -----------
arch/risc-v/src/c906/c906_start.c | 16 ----------------
arch/risc-v/src/common/espressif/esp_start.c | 6 ------
arch/risc-v/src/common/riscv_common_memorymap.h | 3 ++-
arch/risc-v/src/common/riscv_cpuidlestack.c | 5 +++--
arch/risc-v/src/common/riscv_initialstate.c | 2 +-
arch/risc-v/src/common/riscv_internal.h | 12 ------------
arch/risc-v/src/esp32c3-legacy/esp32c3_start.c | 6 ------
arch/risc-v/src/fe310/fe310_start.c | 16 ----------------
arch/risc-v/src/hpm6000/hpm_start.c | 16 ----------------
arch/risc-v/src/hpm6750/hpm6750_start.c | 16 ----------------
arch/risc-v/src/jh7110/jh7110_start.c | 11 -----------
arch/risc-v/src/k210/k210_start.c | 11 -----------
arch/risc-v/src/k230/k230_start.c | 9 ---------
arch/risc-v/src/litex/litex_start.c | 16 ----------------
arch/risc-v/src/mpfs/mpfs_start.c | 16 ----------------
arch/risc-v/src/qemu-rv/qemu_rv_start.c | 9 ---------
arch/risc-v/src/rv32m1/rv32m1_start.c | 16 ----------------
19 files changed, 6 insertions(+), 197 deletions(-)
(nuttx) 01/02: arch/risc-v: unify idle stack calculation
Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit afb5a66847e31eebacb60ebbe1c1e42cfc70c7c5
Author: Inochi Amaoto <in...@outlook.com>
AuthorDate: Thu May 9 20:15:23 2024 +0800
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 <in...@outlook.com>
---
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
****************************************************************************/
(nuttx) 02/02: arch/risc-v: remove g_cpux_idlestack
Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit bc022f8cd841b6b9f6507b7aca6abbab931345b3
Author: Inochi Amaoto <in...@outlook.com>
AuthorDate: Tue Apr 30 15:11:59 2024 +0800
arch/risc-v: remove g_cpux_idlestack
As all the board allocate idle stack from _ebss. The idle stack
layout is fix and can be computed directly by using _ebss. There
is no need to use g_cpux_idlestack array anymore, remove it.
Signed-off-by: Inochi Amaoto <in...@outlook.com>
---
arch/risc-v/src/bl602/bl602_start.c | 4 ----
arch/risc-v/src/bl808/bl808_start.c | 4 ----
arch/risc-v/src/c906/c906_start.c | 4 ----
arch/risc-v/src/common/espressif/esp_start.c | 4 ----
arch/risc-v/src/common/riscv_common_memorymap.h | 3 ++-
arch/risc-v/src/common/riscv_cpuidlestack.c | 4 +---
arch/risc-v/src/common/riscv_initialstate.c | 2 +-
arch/risc-v/src/common/riscv_internal.h | 12 ------------
arch/risc-v/src/esp32c3-legacy/esp32c3_start.c | 4 ----
arch/risc-v/src/fe310/fe310_start.c | 4 ----
arch/risc-v/src/hpm6000/hpm_start.c | 4 ----
arch/risc-v/src/hpm6750/hpm6750_start.c | 4 ----
arch/risc-v/src/jh7110/jh7110_start.c | 4 ----
arch/risc-v/src/k210/k210_start.c | 4 ----
arch/risc-v/src/k230/k230_start.c | 2 --
arch/risc-v/src/litex/litex_start.c | 4 ----
arch/risc-v/src/mpfs/mpfs_start.c | 4 ----
arch/risc-v/src/qemu-rv/qemu_rv_start.c | 2 --
arch/risc-v/src/rv32m1/rv32m1_start.c | 4 ----
19 files changed, 4 insertions(+), 73 deletions(-)
diff --git a/arch/risc-v/src/bl602/bl602_start.c b/arch/risc-v/src/bl602/bl602_start.c
index 63e99b6dec..104a72bc2f 100644
--- a/arch/risc-v/src/bl602/bl602_start.c
+++ b/arch/risc-v/src/bl602/bl602_start.c
@@ -148,10 +148,6 @@ void bfl_main(void)
asm volatile("csrw mtvec, %0" ::"r"((uintptr_t)exception_common + 2));
- /* Setup base stack */
-
- riscv_set_basestack((uintptr_t)_ebss, SMP_STACK_SIZE);
-
/* Configure the UART so we can get debug output */
bl602_lowsetup();
diff --git a/arch/risc-v/src/bl808/bl808_start.c b/arch/risc-v/src/bl808/bl808_start.c
index d882f0671b..7e0663b603 100644
--- a/arch/risc-v/src/bl808/bl808_start.c
+++ b/arch/risc-v/src/bl808/bl808_start.c
@@ -267,10 +267,6 @@ void bl808_start(int mhartid)
bl808_clear_bss();
- /* Setup base stack */
-
- riscv_set_basestack(BL808_IDLESTACK_BASE, SMP_STACK_SIZE);
-
/* Copy the RAM Disk */
bl808_copy_ramdisk();
diff --git a/arch/risc-v/src/c906/c906_start.c b/arch/risc-v/src/c906/c906_start.c
index d4774a2a01..a6ec7d9d38 100644
--- a/arch/risc-v/src/c906/c906_start.c
+++ b/arch/risc-v/src/c906/c906_start.c
@@ -79,10 +79,6 @@ void __c906_start(uint32_t mhartid)
*dest++ = 0;
}
- /* Setup base stack */
-
- riscv_set_basestack(C906_IDLESTACK_BASE, SMP_STACK_SIZE);
-
/* Move the initialized data section from his temporary holding spot in
* FLASH into the correct place in SRAM. The correct place in SRAM is
* give by _sdata and _edata. The temporary location is in FLASH at the
diff --git a/arch/risc-v/src/common/espressif/esp_start.c b/arch/risc-v/src/common/espressif/esp_start.c
index 28c33c53c3..7ad3c87da8 100644
--- a/arch/risc-v/src/common/espressif/esp_start.c
+++ b/arch/risc-v/src/common/espressif/esp_start.c
@@ -453,10 +453,6 @@ void __esp_start(void)
*dest++ = 0;
}
- /* Setup base stack */
-
- riscv_set_basestack((uintptr_t)_ebss, SMP_STACK_SIZE);
-
/* Setup the syscall table needed by the ROM code */
esp_setup_syscall_table();
diff --git a/arch/risc-v/src/common/riscv_common_memorymap.h b/arch/risc-v/src/common/riscv_common_memorymap.h
index c80382d0e0..efe3e050d6 100644
--- a/arch/risc-v/src/common/riscv_common_memorymap.h
+++ b/arch/risc-v/src/common/riscv_common_memorymap.h
@@ -67,7 +67,8 @@ EXTERN uintptr_t g_idle_topstack;
/* Address of per-cpu idle stack base */
-EXTERN const uint8_t *g_cpux_idlestack[CONFIG_SMP_NCPUS];
+#define g_cpux_idlestack(cpuid) \
+ (g_idle_topstack - SMP_STACK_SIZE * ((cpuid) + 1))
/* Address of the saved user stack pointer */
diff --git a/arch/risc-v/src/common/riscv_cpuidlestack.c b/arch/risc-v/src/common/riscv_cpuidlestack.c
index 18f211bfda..6bde88ace6 100644
--- a/arch/risc-v/src/common/riscv_cpuidlestack.c
+++ b/arch/risc-v/src/common/riscv_cpuidlestack.c
@@ -50,8 +50,6 @@
uintptr_t g_idle_topstack = (uintptr_t)_ebss +
SMP_STACK_SIZE * CONFIG_SMP_NCPUS;
-const uint8_t *g_cpux_idlestack[CONFIG_SMP_NCPUS];
-
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -109,7 +107,7 @@ int up_cpu_idlestack(int cpu, struct tcb_s *tcb, size_t stack_size)
/* Get the top of the stack */
- stack_alloc = (uintptr_t)g_cpux_idlestack[cpu];
+ stack_alloc = (uintptr_t)g_cpux_idlestack(cpu);
DEBUGASSERT(stack_alloc != 0 && STACK_ISALIGNED(stack_alloc));
tcb->adj_stack_size = SMP_STACK_SIZE;
diff --git a/arch/risc-v/src/common/riscv_initialstate.c b/arch/risc-v/src/common/riscv_initialstate.c
index 0fd258404a..f13203a519 100644
--- a/arch/risc-v/src/common/riscv_initialstate.c
+++ b/arch/risc-v/src/common/riscv_initialstate.c
@@ -97,7 +97,7 @@ void up_initial_state(struct tcb_s *tcb)
if (tcb->pid == IDLE_PROCESS_ID)
{
- tcb->stack_alloc_ptr = (void *)g_cpux_idlestack[riscv_mhartid()];
+ tcb->stack_alloc_ptr = (void *)g_cpux_idlestack(riscv_mhartid());
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
tcb->adj_stack_size = SMP_STACK_SIZE;
diff --git a/arch/risc-v/src/common/riscv_internal.h b/arch/risc-v/src/common/riscv_internal.h
index c54c8b3fea..d2a09e456e 100644
--- a/arch/risc-v/src/common/riscv_internal.h
+++ b/arch/risc-v/src/common/riscv_internal.h
@@ -331,18 +331,6 @@ int riscv_check_pmp_access(uintptr_t attr, uintptr_t base, uintptr_t size);
int riscv_configured_pmp_regions(void);
int riscv_next_free_pmp_region(void);
-/* RISC-V Memorymap Config **************************************************/
-
-static inline void riscv_set_basestack(uintptr_t base, uintptr_t size)
-{
- unsigned int i;
-
- for (i = 0; i < CONFIG_SMP_NCPUS; i++)
- {
- g_cpux_idlestack[i] = (const uint8_t *)(base + size * i);
- }
-}
-
/* RISC-V SBI wrappers ******************************************************/
#ifdef CONFIG_ARCH_USE_S_MODE
diff --git a/arch/risc-v/src/esp32c3-legacy/esp32c3_start.c b/arch/risc-v/src/esp32c3-legacy/esp32c3_start.c
index ae808190f9..29f5dc9feb 100644
--- a/arch/risc-v/src/esp32c3-legacy/esp32c3_start.c
+++ b/arch/risc-v/src/esp32c3-legacy/esp32c3_start.c
@@ -288,10 +288,6 @@ void __esp32c3_start(void)
*dest++ = 0;
}
- /* Setup base stack */
-
- riscv_set_basestack((uintptr_t)_ebss, SMP_STACK_SIZE);
-
/* Setup the syscall table needed by the ROM code */
setup_syscall_table();
diff --git a/arch/risc-v/src/fe310/fe310_start.c b/arch/risc-v/src/fe310/fe310_start.c
index 7e08910d3f..885ea5b3d0 100644
--- a/arch/risc-v/src/fe310/fe310_start.c
+++ b/arch/risc-v/src/fe310/fe310_start.c
@@ -69,10 +69,6 @@ void __fe310_start(void)
*dest++ = 0;
}
- /* Setup base stack */
-
- riscv_set_basestack(FE310_IDLESTACK_BASE, SMP_STACK_SIZE);
-
/* Move the initialized data section from his temporary holding spot in
* FLASH into the correct place in SRAM. The correct place in SRAM is
* give by _sdata and _edata. The temporary location is in FLASH at the
diff --git a/arch/risc-v/src/hpm6000/hpm_start.c b/arch/risc-v/src/hpm6000/hpm_start.c
index 331e5d2098..051249c066 100644
--- a/arch/risc-v/src/hpm6000/hpm_start.c
+++ b/arch/risc-v/src/hpm6000/hpm_start.c
@@ -64,10 +64,6 @@ void __hpm_start(void)
*dest++ = 0;
}
- /* Setup base stack */
-
- riscv_set_basestack(HPM_IDLESTACK_BASE, CONFIG_IDLETHREAD_STACKSIZE);
-
/* Move the initialized data section from his temporary holding spot in
* FLASH into the correct place in SRAM. The correct place in SRAM is
* give by _sdata and _edata. The temporary location is in FLASH at the
diff --git a/arch/risc-v/src/hpm6750/hpm6750_start.c b/arch/risc-v/src/hpm6750/hpm6750_start.c
index 108fe5ff28..7afdaed2fe 100644
--- a/arch/risc-v/src/hpm6750/hpm6750_start.c
+++ b/arch/risc-v/src/hpm6750/hpm6750_start.c
@@ -64,10 +64,6 @@ void __hpm6750_start(void)
*dest++ = 0;
}
- /* Setup base stack */
-
- riscv_set_basestack(HPM6750_IDLESTACK_BASE, SMP_STACK_SIZE);
-
/* Move the initialized data section from his temporary holding spot in
* FLASH into the correct place in SRAM. The correct place in SRAM is
* give by _sdata and _edata. The temporary location is in FLASH at the
diff --git a/arch/risc-v/src/jh7110/jh7110_start.c b/arch/risc-v/src/jh7110/jh7110_start.c
index 334bac41fa..a55844ffa1 100644
--- a/arch/risc-v/src/jh7110/jh7110_start.c
+++ b/arch/risc-v/src/jh7110/jh7110_start.c
@@ -133,10 +133,6 @@ void jh7110_start(int mhartid)
{
jh7110_clear_bss();
- /* Setup base stack */
-
- riscv_set_basestack(JH7110_IDLESTACK_BASE, SMP_STACK_SIZE);
-
/* Initialize the per CPU areas */
riscv_percpu_add_hart(mhartid);
diff --git a/arch/risc-v/src/k210/k210_start.c b/arch/risc-v/src/k210/k210_start.c
index 7d3fa35e03..65855c55a5 100644
--- a/arch/risc-v/src/k210/k210_start.c
+++ b/arch/risc-v/src/k210/k210_start.c
@@ -79,10 +79,6 @@ void __k210_start(uint32_t mhartid)
*dest++ = 0;
}
- /* Setup base stack */
-
- riscv_set_basestack(K210_IDLESTACK_BASE, SMP_STACK_SIZE);
-
/* Move the initialized data section from his temporary holding spot in
* FLASH into the correct place in SRAM. The correct place in SRAM is
* give by _sdata and _edata. The temporary location is in FLASH at the
diff --git a/arch/risc-v/src/k230/k230_start.c b/arch/risc-v/src/k230/k230_start.c
index a389558f3c..abc378188c 100644
--- a/arch/risc-v/src/k230/k230_start.c
+++ b/arch/risc-v/src/k230/k230_start.c
@@ -115,8 +115,6 @@ void k230_start(int mhartid, const char *dtb)
{
k230_clear_bss();
- riscv_set_basestack(K230_IDLESTACK_BASE, SMP_STACK_SIZE);
-
#ifdef CONFIG_RISCV_PERCPU_SCRATCH
riscv_percpu_add_hart(mhartid);
#else
diff --git a/arch/risc-v/src/litex/litex_start.c b/arch/risc-v/src/litex/litex_start.c
index 8d5c0b6531..a3107a40a7 100644
--- a/arch/risc-v/src/litex/litex_start.c
+++ b/arch/risc-v/src/litex/litex_start.c
@@ -81,10 +81,6 @@ void __litex_start(int hart_index, const void * fdt, int arg)
*dest++ = 0;
}
- /* Setup base stack */
-
- riscv_set_basestack(LITEX_IDLESTACK_BASE, SMP_STACK_SIZE);
-
/* Move the initialized data section from his temporary holding spot in
* FLASH into the correct place in SRAM. The correct place in SRAM is
* give by _sdata and _edata. The temporary location is in FLASH at the
diff --git a/arch/risc-v/src/mpfs/mpfs_start.c b/arch/risc-v/src/mpfs/mpfs_start.c
index 02b74cec06..1b92822472 100644
--- a/arch/risc-v/src/mpfs/mpfs_start.c
+++ b/arch/risc-v/src/mpfs/mpfs_start.c
@@ -86,10 +86,6 @@ void __mpfs_start(uint64_t mhartid)
*dest++ = 0;
}
- /* Setup base stack */
-
- riscv_set_basestack(MPFS_IDLESTACK_BASE, MPFS_IDLESTACK_SIZE);
-
/* Move the initialized data section from his temporary holding spot in
* FLASH into the correct place in SRAM. The correct place in SRAM is
* give by _sdata and _edata. The temporary location is in FLASH at the
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 6335562beb..c9d9bf736b 100644
--- a/arch/risc-v/src/qemu-rv/qemu_rv_start.c
+++ b/arch/risc-v/src/qemu-rv/qemu_rv_start.c
@@ -140,8 +140,6 @@ void qemu_rv_start(int mhartid, const char *dtb)
qemu_rv_clear_bss();
- riscv_set_basestack(QEMU_RV_IDLESTACK_BASE, SMP_STACK_SIZE);
-
#ifdef CONFIG_RISCV_PERCPU_SCRATCH
riscv_percpu_add_hart(mhartid);
#endif
diff --git a/arch/risc-v/src/rv32m1/rv32m1_start.c b/arch/risc-v/src/rv32m1/rv32m1_start.c
index 2a841ddebe..c6ae0926d5 100644
--- a/arch/risc-v/src/rv32m1/rv32m1_start.c
+++ b/arch/risc-v/src/rv32m1/rv32m1_start.c
@@ -101,10 +101,6 @@ void __rv32m1_start(void)
*dest++ = 0;
}
- /* Setup base stack */
-
- riscv_set_basestack(RV32M1_IDLESTACK_BASE, RV32M1_IDLESTACK_TOP);
-
/* Move the initialized data section from his temporary holding spot in
* FLASH into the correct place in SRAM. The correct place in SRAM is
* give by _sdata and _edata. The temporary location is in FLASH at the