2019-06-02 03:14:06 +08:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//
|
|
|
|
// Copyright(c) 2018 Intel Corporation. All rights reserved.
|
|
|
|
//
|
|
|
|
// Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
|
|
|
|
// Liam Girdwood <liam.r.girdwood@linux.intel.com>
|
|
|
|
// Keyon Jie <yang.jie@linux.intel.com>
|
|
|
|
// Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
|
2018-06-01 10:29:05 +08:00
|
|
|
|
|
|
|
#include <sof/audio/component.h>
|
2019-07-17 02:31:41 +08:00
|
|
|
#include <sof/schedule/task.h>
|
2018-06-01 10:29:05 +08:00
|
|
|
#include <stdint.h>
|
2019-07-17 02:31:41 +08:00
|
|
|
#include <sof/lib/wait.h>
|
2019-09-09 17:54:38 +08:00
|
|
|
#include <stdlib.h>
|
2018-06-01 10:29:05 +08:00
|
|
|
|
2019-09-17 20:34:12 +08:00
|
|
|
static struct schedulers *testbench_schedulers_ptr; /* Initialized as NULL */
|
2019-09-09 17:54:38 +08:00
|
|
|
|
|
|
|
struct schedulers **arch_schedulers_get(void)
|
|
|
|
{
|
2019-09-17 20:34:12 +08:00
|
|
|
return &testbench_schedulers_ptr;
|
2019-09-09 17:54:38 +08:00
|
|
|
}
|
2018-06-01 10:29:05 +08:00
|
|
|
|
2020-03-02 23:39:24 +08:00
|
|
|
int schedule_task_init(struct task *task, uint32_t uid, uint16_t type,
|
|
|
|
uint16_t priority, enum task_state (*run)(void *data),
|
|
|
|
void *data, uint16_t core, uint32_t flags)
|
2018-06-01 10:29:05 +08:00
|
|
|
{
|
2019-11-28 23:45:28 +08:00
|
|
|
if (type >= SOF_SCHEDULE_COUNT)
|
|
|
|
return -EINVAL;
|
2019-09-17 20:34:12 +08:00
|
|
|
|
2020-03-02 23:39:24 +08:00
|
|
|
task->uid = uid;
|
2020-01-31 22:48:16 +08:00
|
|
|
task->type = SOF_SCHEDULE_EDF; /* Note: Force EDF scheduler */
|
2019-03-12 15:51:23 +08:00
|
|
|
task->priority = priority;
|
|
|
|
task->core = core;
|
2019-09-17 20:34:12 +08:00
|
|
|
task->flags = flags;
|
2019-03-12 15:51:23 +08:00
|
|
|
task->state = SOF_TASK_STATE_INIT;
|
2019-11-29 17:46:33 +08:00
|
|
|
task->ops.run = run;
|
2019-03-12 15:51:23 +08:00
|
|
|
task->data = data;
|
|
|
|
|
2019-11-28 23:45:28 +08:00
|
|
|
return 0;
|
2019-09-17 20:34:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void scheduler_register(struct schedule_data *scheduler)
|
|
|
|
{
|
|
|
|
struct schedulers **sch = arch_schedulers_get();
|
|
|
|
|
|
|
|
if (!*sch) {
|
|
|
|
/* init schedulers list */
|
2020-01-31 22:48:16 +08:00
|
|
|
*sch = calloc(1, sizeof(**sch));
|
2019-09-17 20:34:12 +08:00
|
|
|
list_init(&(*sch)->list);
|
|
|
|
}
|
|
|
|
|
|
|
|
list_item_append(&scheduler->list, &(*sch)->list);
|
2018-06-01 10:29:05 +08:00
|
|
|
}
|
|
|
|
|
2019-09-09 17:54:38 +08:00
|
|
|
void scheduler_init(int type, const struct scheduler_ops *ops, void *data)
|
2018-06-01 10:29:05 +08:00
|
|
|
{
|
2019-09-17 20:34:12 +08:00
|
|
|
struct schedule_data *sch;
|
|
|
|
|
2020-01-31 22:48:16 +08:00
|
|
|
sch = calloc(1, sizeof(*sch));
|
2019-09-09 17:54:38 +08:00
|
|
|
list_init(&sch->list);
|
2020-01-31 22:48:16 +08:00
|
|
|
sch->type = SOF_SCHEDULE_EDF; /* Note: Force EDF scheduler */
|
2019-09-09 17:54:38 +08:00
|
|
|
sch->ops = ops;
|
|
|
|
sch->data = data;
|
2019-09-17 20:34:12 +08:00
|
|
|
|
|
|
|
scheduler_register(sch);
|
2018-06-01 10:29:05 +08:00
|
|
|
}
|