41 lines
841 B
C
41 lines
841 B
C
|
/*
|
||
|
* 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);
|
||
|
}
|