Sound Open Firmware
Loading...
Searching...
No Matches
task.h
Go to the documentation of this file.
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#ifndef __ZEPHYR_RTOS_TASK_H__
9#define __ZEPHYR_RTOS_TASK_H__
10
11#include <rtos/panic.h>
12#include <sof/list.h>
13#include <stdbool.h>
14#include <stdint.h>
15#include <rtos/kernel.h>
16#include <sof/lib/perf_cnt.h>
17
18struct comp_dev;
19struct sof;
20struct schedule_data;
21
23#define SOF_TASK_PRI_HIGH 0 /* priority level 0 - high */
24#define SOF_TASK_PRI_MED 4 /* priority level 4 - medium */
25#define SOF_TASK_PRI_LOW 9 /* priority level 9 - low */
26
28#define SOF_TASK_DEADLINE_IDLE UINT64_MAX
29#define SOF_TASK_DEADLINE_ALMOST_IDLE (SOF_TASK_DEADLINE_IDLE - 1)
30#define SOF_TASK_DEADLINE_NOW 0
31
33#define SOF_TASK_SKIP_COUNT 0xFFFFu
34
47
49struct task_ops {
50 enum task_state (*run)(void *data);
51 void (*complete)(void *data);
52 uint64_t (*get_deadline)(void *data);
53};
54
56struct task {
57 uint64_t start;
58 const struct sof_uuid_entry *uid;
59 uint16_t type;
60 int16_t priority;
61 uint16_t core;
62 uint16_t flags;
65 void *data;
66 struct list_item list;
67 void *priv_data;
68 struct task_ops ops;
69 struct k_work_delayable z_delayed_work;
70 uint32_t cycles_sum;
71 uint32_t cycles_max;
72 uint32_t cycles_cnt;
73#if CONFIG_PERFORMANCE_COUNTERS
74 struct perf_cnt_data pcd;
75#endif
76};
77
78static inline bool task_is_active(struct task *task)
79{
80 switch (task->state) {
86 return true;
87 default:
88 return false;
89 }
90}
91
92static inline enum task_state task_run(struct task *task)
93{
95
96 return task->ops.run(task->data);
97}
98
99static inline void task_complete(struct task *task)
100{
101 if (task->ops.complete)
103}
104
105static inline uint64_t task_get_deadline(struct task *task)
106{
108
109 return task->ops.get_deadline(task->data);
110}
111
114
115#endif /* __ZEPHYR_RTOS_TASK_H__ */
uint32_t data[]
Definition debug_stream_slot.h:2
#define list_item(item, type, member)
Definition list.h:80
#define assert(x)
Definition panic.h:19
Simple performance counters.
Audio component base device "class".
Definition component.h:645
Definition perf_cnt.h:19
Holds information about scheduler.
Definition schedule.h:167
Connects UUID with component description.
Definition uuid.h:77
General firmware context.
Definition sof.h:44
Task operations.
Definition task.h:49
enum task_state(* run)(void *data)
task's main operation
Definition task.h:50
uint64_t(* get_deadline)(void *data)
returns current deadline
Definition task.h:52
void(* complete)(void *data)
executed on completion
Definition task.h:51
Task used by schedulers.
Definition task.h:56
uint32_t cycles_sum
Definition task.h:70
const struct sof_uuid_entry * uid
Uuid.
Definition task.h:58
struct list_item list
used by schedulers to hold tasks
Definition task.h:66
struct schedule_data * sch
scheduler bound to task
Definition task.h:63
uint32_t cycles_max
Definition task.h:71
uint16_t core
execution core
Definition task.h:61
enum task_state state
current state
Definition task.h:64
uint16_t type
type of the task (LL or EDF)
Definition task.h:59
void * data
custom data passed to all ops
Definition task.h:65
struct task_ops ops
task operations
Definition task.h:68
int16_t priority
priority of the task (used by LL); lower runs first
Definition task.h:60
struct k_work_delayable z_delayed_work
Definition task.h:69
void * priv_data
task private data
Definition task.h:67
uint64_t start
start time in [ms] since now (LL only)
Definition task.h:57
uint16_t flags
custom flags
Definition task.h:62
uint32_t cycles_cnt
Definition task.h:72
task_state
Task states.
Definition task.h:36
@ SOF_TASK_STATE_INIT
Definition task.h:37
@ SOF_TASK_STATE_FREE
Definition task.h:43
@ SOF_TASK_STATE_RUNNING
Definition task.h:40
@ SOF_TASK_STATE_COMPLETED
Definition task.h:42
@ SOF_TASK_STATE_PENDING
Definition task.h:39
@ SOF_TASK_STATE_CANCEL
Definition task.h:44
@ SOF_TASK_STATE_QUEUED
Definition task.h:38
@ SOF_TASK_STATE_PREEMPTED
Definition task.h:41
@ SOF_TASK_STATE_RESCHEDULE
Definition task.h:45
int start_complete(void)
int task_main_start(struct sof *sof)
static uint64_t task_get_deadline(struct task *task)
Definition task.h:105
static bool task_is_active(struct task *task)
Definition task.h:78
static void task_complete(struct task *task)
Definition task.h:99
static enum task_state task_run(struct task *task)
Definition task.h:92