xref: /kvm-unit-tests/lib/riscv/asm/smp.h (revision 9c92b28e6b7b504c6319dbd2110c9f9a843ea48a)
1*9c92b28eSAndrew Jones /* SPDX-License-Identifier: GPL-2.0-only */
2*9c92b28eSAndrew Jones #ifndef _ASMRISCV_SMP_H_
3*9c92b28eSAndrew Jones #define _ASMRISCV_SMP_H_
4*9c92b28eSAndrew Jones #include <asm/barrier.h>
5*9c92b28eSAndrew Jones #include <asm/processor.h>
6*9c92b28eSAndrew Jones 
7*9c92b28eSAndrew Jones #define smp_wait_for_event()	cpu_relax()
8*9c92b28eSAndrew Jones #define smp_send_event()	cpu_relax()
9*9c92b28eSAndrew Jones 
10*9c92b28eSAndrew Jones static inline int smp_processor_id(void)
11*9c92b28eSAndrew Jones {
12*9c92b28eSAndrew Jones 	return current_thread_info()->cpu;
13*9c92b28eSAndrew Jones }
14*9c92b28eSAndrew Jones 
15*9c92b28eSAndrew Jones typedef void (*secondary_func_t)(void);
16*9c92b28eSAndrew Jones 
17*9c92b28eSAndrew Jones struct secondary_data {
18*9c92b28eSAndrew Jones 	unsigned long stvec;
19*9c92b28eSAndrew Jones 	secondary_func_t func;
20*9c92b28eSAndrew Jones } __attribute__((aligned(16)));
21*9c92b28eSAndrew Jones 
22*9c92b28eSAndrew Jones void secondary_entry(unsigned long hartid, unsigned long sp_phys);
23*9c92b28eSAndrew Jones secondary_func_t secondary_cinit(struct secondary_data *data);
24*9c92b28eSAndrew Jones 
25*9c92b28eSAndrew Jones void smp_boot_secondary(int cpu, void (*func)(void));
26*9c92b28eSAndrew Jones void smp_boot_secondary_nofail(int cpu, void (*func)(void));
27*9c92b28eSAndrew Jones 
28*9c92b28eSAndrew Jones #endif /* _ASMRISCV_SMP_H_ */
29