forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arch/riscv: Boot secondary CPUs for SMP support
Secondary CPUs are now initialised and made available to the system. If the system has more CPUs than configured via CONFIG_MP_NUM_CPUS, those are still left looping as before. Some implementations of `soc_interrupt_init` also changed to use `arch_irq_lock` instead of `irq_lock`. Signed-off-by: Ederson de Souza <[email protected]>
- Loading branch information
1 parent
be28de6
commit d9ab355
Showing
5 changed files
with
66 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ zephyr_library_sources( | |
reboot.c | ||
reset.S | ||
switch.S | ||
smp.c | ||
thread.c | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2021 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <kernel.h> | ||
|
||
volatile struct { | ||
arch_cpustart_t fn; | ||
void *arg; | ||
} riscv_cpu_init[CONFIG_MP_NUM_CPUS]; | ||
|
||
volatile uintptr_t riscv_cpu_wake_flag; | ||
volatile void *riscv_cpu_sp; | ||
|
||
void arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz, | ||
arch_cpustart_t fn, void *arg) | ||
{ | ||
riscv_cpu_init[cpu_num].fn = fn; | ||
riscv_cpu_init[cpu_num].arg = arg; | ||
|
||
riscv_cpu_sp = Z_THREAD_STACK_BUFFER(stack) + sz; | ||
riscv_cpu_wake_flag = cpu_num; | ||
|
||
while (riscv_cpu_wake_flag != 0U) { | ||
; | ||
} | ||
} | ||
|
||
void z_riscv_secondary_cpu_init(int cpu_num) | ||
{ | ||
#if defined(CONFIG_RISCV_SOC_INTERRUPT_INIT) | ||
soc_interrupt_init(); | ||
#endif | ||
#ifdef CONFIG_PMP_STACK_GUARD | ||
z_riscv_configure_interrupt_stack_guard(); | ||
#endif | ||
riscv_cpu_init[cpu_num].fn(riscv_cpu_init[cpu_num].arg); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters