1 /*
2  * Copyright (C) 2019-2022 Intel Corporation.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <asm/per_cpu.h>
8 #include <schedule.h>
9 
sched_noop_init(struct sched_control * ctl)10 static int32_t sched_noop_init(struct sched_control *ctl)
11 {
12 	struct sched_noop_control *noop_ctl = &per_cpu(sched_noop_ctl, ctl->pcpu_id);
13 	ctl->priv = noop_ctl;
14 
15 	return 0;
16 }
17 
sched_noop_pick_next(struct sched_control * ctl)18 static struct thread_object *sched_noop_pick_next(struct sched_control *ctl)
19 {
20 	struct sched_noop_control *noop_ctl = (struct sched_noop_control *)ctl->priv;
21 	struct thread_object *next = NULL;
22 
23 	if (noop_ctl->noop_thread_obj != NULL) {
24 		next = noop_ctl->noop_thread_obj;
25 	} else {
26 		next = &get_cpu_var(idle);
27 	}
28 	return next;
29 }
30 
sched_noop_sleep(struct thread_object * obj)31 static void sched_noop_sleep(struct thread_object *obj)
32 {
33 	struct sched_noop_control *noop_ctl = (struct sched_noop_control *)obj->sched_ctl->priv;
34 
35 	if (noop_ctl->noop_thread_obj == obj) {
36 		noop_ctl->noop_thread_obj = NULL;
37 	}
38 }
39 
sched_noop_wake(struct thread_object * obj)40 static void sched_noop_wake(struct thread_object *obj)
41 {
42 	struct sched_noop_control *noop_ctl = (struct sched_noop_control *)obj->sched_ctl->priv;
43 
44 	if (noop_ctl->noop_thread_obj == NULL) {
45 		noop_ctl->noop_thread_obj = obj;
46 	}
47 }
48 
49 struct acrn_scheduler sched_noop = {
50 	.name		= "sched_noop",
51 	.init		= sched_noop_init,
52 	.pick_next	= sched_noop_pick_next,
53 	.sleep		= sched_noop_sleep,
54 	.wake		= sched_noop_wake,
55 };
56