1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2016 Intel Corporation. All rights reserved.
4  *
5  * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
6  */
7 
8 /*
9  * Delayed or scheduled work. Work runs in the same context as it's timer
10  * interrupt source. It should execute quickly and must not sleep or wait.
11  */
12 
13 #ifndef __SOF_SCHEDULE_LL_SCHEDULE_H__
14 #define __SOF_SCHEDULE_LL_SCHEDULE_H__
15 
16 #include <rtos/task.h>
17 #include <sof/trace/trace.h>
18 #include <user/trace.h>
19 #include <stdint.h>
20 
21 struct ll_schedule_domain;
22 
23 /* ll tracing */
24 extern struct tr_ctx ll_tr;
25 
26 #define ll_sch_set_pdata(task, data) \
27 	do { (task)->priv_data = (data); } while (0)
28 
29 #define ll_sch_get_pdata(task) ((task)->priv_data)
30 
31 struct ll_task_pdata {
32 	uint64_t period;
33 	uint16_t ratio;		/**< ratio of periods compared to the registrable task */
34 	uint16_t skip_cnt;	/**< how many times the task was skipped for execution */
35 };
36 
37 #if !defined(__ZEPHYR__)
38 int scheduler_init_ll(struct ll_schedule_domain *domain);
39 
40 int schedule_task_init_ll(struct task *task,
41 			  const struct sof_uuid_entry *uid, uint16_t type,
42 			  uint16_t priority, enum task_state (*run)(void *data),
43 			  void *data, uint16_t core, uint32_t flags);
44 #else
45 int zephyr_ll_scheduler_init(struct ll_schedule_domain *domain);
46 
47 int zephyr_ll_task_init(struct task *task,
48 			const struct sof_uuid_entry *uid, uint16_t type,
49 			uint16_t priority, enum task_state (*run)(void *data),
50 			void *data, uint16_t core, uint32_t flags);
51 
52 #define scheduler_init_ll zephyr_ll_scheduler_init
53 #define schedule_task_init_ll zephyr_ll_task_init
54 
55 #endif
56 
57 #endif /* __SOF_SCHEDULE_LL_SCHEDULE_H__ */
58