riscv: Set up the idle threads' per-core stacks

Use per-core stacks for idle thread stacks.
This commit is contained in:
Yanyan Shen
2019-08-06 16:52:44 +10:00
committed by Yanyan Shen
parent 1c53fea9d3
commit 99e9092b23

View File

@@ -16,6 +16,7 @@
* Copyright 2015, 2016 Hesham Almatary <heshamelmatary@gmail.com>
*/
#include <config.h>
#include <object.h>
#include <machine.h>
#include <arch/model/statedata.h>
@@ -36,7 +37,16 @@ BOOT_CODE void Arch_configureIdleThread(tcb_t *tcb)
/* Enable interrupts and keep working in supervisor mode */
setRegister(tcb, SSTATUS, (word_t) SSTATUS_SPP | SSTATUS_SPIE);
#ifdef ENABLE_SMP_SUPPORT
for (int i = 0; i < CONFIG_MAX_NUM_NODES; i++) {
if (NODE_STATE_ON_CORE(ksIdleThread, i) == tcb) {
setRegister(tcb, SP, (word_t)kernel_stack_alloc + (i + 1) * BIT(CONFIG_KERNEL_STACK_BITS));
break;
}
}
#else
setRegister(tcb, SP, (word_t)kernel_stack_alloc + BIT(CONFIG_KERNEL_STACK_BITS));
#endif
}
void Arch_switchToIdleThread(void)