mirror of https://github.com/thesofproject/sof.git
task: remove edf specific elements from context switching layer
The context switching layer is a common mechanism for all pre-emptive schedulers and should not depend on data types defined for any specific one. Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
This commit is contained in:
parent
e01c696337
commit
94733aa588
|
@ -18,8 +18,6 @@
|
||||||
#ifndef __ARCH_SCHEDULE_TASK_H__
|
#ifndef __ARCH_SCHEDULE_TASK_H__
|
||||||
#define __ARCH_SCHEDULE_TASK_H__
|
#define __ARCH_SCHEDULE_TASK_H__
|
||||||
|
|
||||||
struct task;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Returns main task data.
|
* \brief Returns main task data.
|
||||||
* \return Pointer to pointer of main task data.
|
* \return Pointer to pointer of main task data.
|
||||||
|
@ -33,23 +31,32 @@ volatile void *task_context_get(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Switches system context.
|
* \brief Switches system context.
|
||||||
* \param[in,out] task Task context to be set.
|
* \param[in,out] task_ctx Task context to be set.
|
||||||
*/
|
*/
|
||||||
void task_context_set(void *task_ctx);
|
void task_context_set(void *task_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initializes task context.
|
* \brief Allocates task context.
|
||||||
* \param[in,out] task Task with context to be initialized.
|
* \param[in,out] task_ctx Assigned to allocated structure on return.
|
||||||
* \param[in,out] entry Entry point for task execution.
|
|
||||||
* \param[in,out] data Parameter data for entry point.
|
|
||||||
*/
|
*/
|
||||||
int task_context_init(struct task *task, void *entry, void *data);
|
int task_context_alloc(void **task_ctx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Initializes task context.
|
||||||
|
* \param[in,out] task_ctx Task context to be initialized.
|
||||||
|
* \param[in] entry Entry point for task execution.
|
||||||
|
* \param[in] arg0 First argument to be passed to entry function.
|
||||||
|
* \param[in] arg1 Second argument to be passed to entry function.
|
||||||
|
* \param[in] task_core Id of the core that task will be executed on.
|
||||||
|
*/
|
||||||
|
int task_context_init(void *task_ctx, void *entry, void *arg0, void *arg1,
|
||||||
|
int task_core);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Frees task context.
|
* \brief Frees task context.
|
||||||
* \param[in,out] task Task with context to be freed.
|
* \param[in,out] task_ctx Task with context to be freed.
|
||||||
*/
|
*/
|
||||||
void task_context_free(struct task *task);
|
void task_context_free(void *task_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Performs cache operation on task's context.
|
* \brief Performs cache operation on task's context.
|
||||||
|
|
|
@ -62,23 +62,26 @@ void task_context_set(void *task_ctx)
|
||||||
ctx->td.xtos_active_task = task_ctx;
|
ctx->td.xtos_active_task = task_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int task_context_init(struct task *task, void *entry, void *data)
|
int task_context_alloc(void **task_ctx)
|
||||||
{
|
{
|
||||||
struct edf_task_pdata *edf_pdata = edf_sch_get_pdata(task);
|
*task_ctx = rzalloc(RZONE_SYS_RUNTIME, SOF_MEM_CAPS_RAM,
|
||||||
xtos_task_context *ctx;
|
sizeof(xtos_task_context));
|
||||||
UserFrame *sp;
|
if (!*task_ctx)
|
||||||
|
|
||||||
/* allocate task context */
|
|
||||||
ctx = rzalloc(RZONE_SYS_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*ctx));
|
|
||||||
if (!ctx)
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int task_context_init(void *task_ctx, void *entry, void *arg0, void *arg1,
|
||||||
|
int task_core)
|
||||||
|
{
|
||||||
|
xtos_task_context *ctx = task_ctx;
|
||||||
|
UserFrame *sp;
|
||||||
|
|
||||||
/* allocate stack */
|
/* allocate stack */
|
||||||
ctx->stack_base = rballoc(RZONE_BUFFER, SOF_MEM_CAPS_RAM,
|
ctx->stack_base = rballoc(RZONE_BUFFER, SOF_MEM_CAPS_RAM,
|
||||||
SOF_TASK_DEFAULT_STACK_SIZE);
|
SOF_TASK_DEFAULT_STACK_SIZE);
|
||||||
if (!ctx->stack_base)
|
if (!ctx->stack_base)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
ctx->stack_size = SOF_TASK_DEFAULT_STACK_SIZE;
|
ctx->stack_size = SOF_TASK_DEFAULT_STACK_SIZE;
|
||||||
|
|
||||||
bzero(ctx->stack_base, ctx->stack_size);
|
bzero(ctx->stack_base, ctx->stack_size);
|
||||||
|
@ -98,31 +101,27 @@ int task_context_init(struct task *task, void *entry, void *data)
|
||||||
sp->ps = PS_WOECALL4_ABI | PS_UM;
|
sp->ps = PS_WOECALL4_ABI | PS_UM;
|
||||||
|
|
||||||
/* a6 and a7 are the first parameters */
|
/* a6 and a7 are the first parameters */
|
||||||
sp->a6 = (uint32_t)task;
|
sp->a6 = (uint32_t)arg0;
|
||||||
sp->a7 = (uint32_t)data;
|
sp->a7 = (uint32_t)arg1;
|
||||||
|
|
||||||
ctx->stack_pointer = sp;
|
ctx->stack_pointer = sp;
|
||||||
|
|
||||||
/* flush for slave core */
|
/* flush for slave core */
|
||||||
if (cpu_is_slave(task->core))
|
if (cpu_is_slave(task_core))
|
||||||
task_context_cache(ctx, CACHE_WRITEBACK_INV);
|
task_context_cache(ctx, CACHE_WRITEBACK_INV);
|
||||||
|
|
||||||
edf_pdata->ctx = ctx;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void task_context_free(struct task *task)
|
void task_context_free(void *task_ctx)
|
||||||
{
|
{
|
||||||
struct edf_task_pdata *edf_pdata = edf_sch_get_pdata(task);
|
xtos_task_context *ctx = task_ctx;
|
||||||
xtos_task_context *ctx = edf_pdata->ctx;
|
|
||||||
|
|
||||||
rfree(ctx->stack_base);
|
rfree(ctx->stack_base);
|
||||||
ctx->stack_size = 0;
|
ctx->stack_size = 0;
|
||||||
ctx->stack_pointer = NULL;
|
ctx->stack_pointer = NULL;
|
||||||
|
|
||||||
rfree(ctx);
|
rfree(ctx);
|
||||||
edf_pdata->ctx = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void task_context_cache(void *task_ctx, int cmd)
|
void task_context_cache(void *task_ctx, int cmd)
|
||||||
|
|
|
@ -155,7 +155,7 @@ static void schedule_edf_task(void *data, struct task *task, uint64_t start,
|
||||||
|
|
||||||
static int schedule_edf_task_init(void *data, struct task *task)
|
static int schedule_edf_task_init(void *data, struct task *task)
|
||||||
{
|
{
|
||||||
struct edf_task_pdata *edf_pdata;
|
struct edf_task_pdata *edf_pdata = NULL;
|
||||||
|
|
||||||
if (edf_sch_get_pdata(task))
|
if (edf_sch_get_pdata(task))
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
|
@ -170,20 +170,26 @@ static int schedule_edf_task_init(void *data, struct task *task)
|
||||||
|
|
||||||
edf_sch_set_pdata(task, edf_pdata);
|
edf_sch_set_pdata(task, edf_pdata);
|
||||||
|
|
||||||
if (task_context_init(task, &schedule_edf_task_run, data) < 0) {
|
if (task_context_alloc(&edf_pdata->ctx) < 0)
|
||||||
trace_edf_sch_error("schedule_edf_task_init() error: init "
|
goto error;
|
||||||
"context failed");
|
if (task_context_init(edf_pdata->ctx, &schedule_edf_task_run,
|
||||||
rfree(edf_pdata);
|
task, data, task->core) < 0)
|
||||||
edf_sch_set_pdata(task, NULL);
|
goto error;
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flush for slave core */
|
/* flush for slave core */
|
||||||
if (cpu_is_slave(task->core))
|
if (cpu_is_slave(task->core))
|
||||||
dcache_writeback_invalidate_region(edf_pdata,
|
dcache_writeback_invalidate_region(edf_pdata,
|
||||||
sizeof(*edf_pdata));
|
sizeof(*edf_pdata));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
trace_edf_sch_error("schedule_edf_task_init() error: init "
|
||||||
|
"context failed");
|
||||||
|
if (edf_pdata->ctx)
|
||||||
|
task_context_free(edf_pdata->ctx);
|
||||||
|
rfree(edf_pdata);
|
||||||
|
edf_sch_set_pdata(task, NULL);
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void schedule_edf_task_running(void *data, struct task *task)
|
static void schedule_edf_task_running(void *data, struct task *task)
|
||||||
|
@ -241,7 +247,8 @@ static void schedule_edf_task_free(void *data, struct task *task)
|
||||||
|
|
||||||
task->state = SOF_TASK_STATE_FREE;
|
task->state = SOF_TASK_STATE_FREE;
|
||||||
|
|
||||||
task_context_free(task);
|
task_context_free(edf_pdata->ctx);
|
||||||
|
edf_pdata->ctx = NULL;
|
||||||
rfree(edf_pdata);
|
rfree(edf_pdata);
|
||||||
edf_sch_set_pdata(task, NULL);
|
edf_sch_set_pdata(task, NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue