1 /*
2  * Copyright (c) 2023 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_INCLUDE_KERNEL_SMP_H_
8 #define ZEPHYR_INCLUDE_KERNEL_SMP_H_
9 
10 #include <stdbool.h>
11 
12 typedef void (*smp_init_fn)(void *arg);
13 
14 /**
15  * @brief Start a CPU.
16  *
17  * This routine is used to manually start the CPU specified
18  * by @a id. It may be called to restart a CPU that had been
19  * stopped or powered down, as well as some other scenario.
20  * After the CPU has finished initialization, the CPU will be
21  * ready to participate in thread scheduling and execution.
22  *
23  * @note This function must not be used on currently running
24  *       CPU. The target CPU must be in off state, or in
25  *       certain architectural state(s) where the CPU is
26  *       permitted to go through the power up process.
27  *       Detection of such state(s) must be provided by
28  *       the platform layers.
29  *
30  * @note This initializes per-CPU kernel structs and also
31  *       initializes timers needed for MP operations.
32  *       Use @ref k_smp_cpu_resume if these are not
33  *       desired.
34  *
35  * @param id ID of target CPU.
36  * @param fn Function to be called before letting scheduler
37  *           run.
38  * @param arg Argument to @a fn.
39  */
40 void k_smp_cpu_start(int id, smp_init_fn fn, void *arg);
41 
42 /**
43  * @brief Resume a previously suspended CPU.
44  *
45  * This function works like @ref k_smp_cpu_start, but does not
46  * re-initialize the kernel's internal tracking data for
47  * the target CPU. Therefore, @ref k_smp_cpu_start must have
48  * previously been called for the target CPU, and it must have
49  * verifiably reached an idle/off state (detection of which
50  * must be provided by the platform layers). It may be used
51  * in cases where platform layers require, for example, that
52  * data on the interrupt or idle stack be preserved.
53  *
54  * @note This function must not be used on currently running
55  *       CPU. The target CPU must be in suspended state, or
56  *       in certain architectural state(s) where the CPU is
57  *       permitted to go through the resume process.
58  *       Detection of such state(s) must be provided by
59  *       the platform layers.
60  *
61  * @param id ID of target CPU.
62  * @param fn Function to be called before resuming context.
63  * @param arg Argument to @a fn.
64  * @param reinit_timer True if timer needs to be re-initialized.
65  * @param invoke_sched True if scheduler is invoked after the CPU
66  *                     has started.
67  */
68 void k_smp_cpu_resume(int id, smp_init_fn fn, void *arg,
69 		      bool reinit_timer, bool invoke_sched);
70 
71 #endif /* ZEPHYR_INCLUDE_KERNEL_SMP_H_ */
72