xref: /kvm-unit-tests/lib/powerpc/asm/smp.h (revision 93c847c1e5cbe266496ee66dc83dcfa24c401c96)
1 #ifndef _ASMPOWERPC_SMP_H_
2 #define _ASMPOWERPC_SMP_H_
3 
4 #include <libcflat.h>
5 #include <asm/processor.h>
6 #include <asm/page.h>
7 
8 typedef void (*secondary_entry_fn)(int cpu_id);
9 
10 struct cpu {
11 	unsigned long server_no;
12 	unsigned long stack;
13 	unsigned long exception_stack;
14 	bool in_user;
15 	secondary_entry_fn entry;
16 	pgd_t *pgtable;
17 };
18 
19 extern int nr_cpus_present;
20 extern int nr_cpus_online;
21 extern struct cpu cpus[];
22 
23 register struct cpu *__current_cpu asm("r13");
current_cpu(void)24 static inline struct cpu *current_cpu(void)
25 {
26 	return __current_cpu;
27 }
28 
smp_processor_id(void)29 static inline int smp_processor_id(void)
30 {
31 	return current_cpu()->server_no;
32 }
33 
34 void cpu_init(struct cpu *cpu, int cpu_id);
35 
36 extern void halt(int cpu_id);
37 
38 extern bool start_all_cpus(secondary_entry_fn entry);
39 extern void stop_all_cpus(void);
40 
41 struct pt_regs;
42 void register_ipi(void (*fn)(struct pt_regs *, void *), void *data);
43 void unregister_ipi(void);
44 void cpu_init_ipis(void);
45 void local_ipi_enable(void);
46 void local_ipi_disable(void);
47 void send_ipi(int cpu_id);
48 
49 #endif /* _ASMPOWERPC_SMP_H_ */
50