xref: /openbmc/linux/arch/riscv/include/asm/cpu_ops.h (revision 842ed298)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2020 Western Digital Corporation or its affiliates.
4  * Based on arch/arm64/include/asm/cpu_ops.h
5  */
6 #ifndef __ASM_CPU_OPS_H
7 #define __ASM_CPU_OPS_H
8 
9 #include <linux/init.h>
10 #include <linux/sched.h>
11 #include <linux/threads.h>
12 
13 /**
14  * struct cpu_operations - Callback operations for hotplugging CPUs.
15  *
16  * @name:		Name of the boot protocol.
17  * @cpu_prepare:	Early one-time preparation step for a cpu. If there
18  *			is a mechanism for doing so, tests whether it is
19  *			possible to boot the given HART.
20  * @cpu_start:		Boots a cpu into the kernel.
21  * @cpu_disable:	Prepares a cpu to die. May fail for some
22  *			mechanism-specific reason, which will cause the hot
23  *			unplug to be aborted. Called from the cpu to be killed.
24  * @cpu_stop:		Makes a cpu leave the kernel. Must not fail. Called from
25  *			the cpu being stopped.
26  * @cpu_is_stopped:	Ensures a cpu has left the kernel. Called from another
27  *			cpu.
28  */
29 struct cpu_operations {
30 	const char	*name;
31 	int		(*cpu_prepare)(unsigned int cpu);
32 	int		(*cpu_start)(unsigned int cpu,
33 				     struct task_struct *tidle);
34 #ifdef CONFIG_HOTPLUG_CPU
35 	int		(*cpu_disable)(unsigned int cpu);
36 	void		(*cpu_stop)(void);
37 	int		(*cpu_is_stopped)(unsigned int cpu);
38 #endif
39 };
40 
41 extern const struct cpu_operations *cpu_ops[NR_CPUS];
42 void __init cpu_set_ops(int cpu);
43 void cpu_update_secondary_bootdata(unsigned int cpuid,
44 				   struct task_struct *tidle);
45 
46 #endif /* ifndef __ASM_CPU_OPS_H */
47