task: Add task_enable_task() and task_disable_task()

Provide API to disable/enable tasks.
All the tasks are marked enabled after hook_task starts.
We need a way to control the tasks when it shouldn't run in some states.

BUG=b:136240895
TEST=Disable the tasks and see it won't be scheudled when task_wake().
BRANCH=None

Change-Id: I2662f3619b22ed28387fe3c783001ba2a745620c
Signed-off-by: Yilun Lin <yllin@google.com>
Signed-off-by: Yilun Lin <yllin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1753562
This commit is contained in:
Yilun Lin 2019-08-08 10:57:02 +08:00 committed by Commit Bot
parent 50ca8d5e64
commit 60c1f84d02
6 changed files with 77 additions and 0 deletions

View File

@ -493,6 +493,19 @@ void task_enable_all_tasks(void)
__schedule(0, 0);
}
void task_enable_task(task_id_t tskid)
{
atomic_or(&tasks_enabled, BIT(tskid));
}
void task_disable_task(task_id_t tskid)
{
atomic_clear(&tasks_enabled, BIT(tskid));
if (!in_interrupt_context() && tskid == task_get_current())
__schedule(0, 0);
}
void task_enable_irq(int irq)
{
CPU_NVIC_EN(irq / 32) = 1 << (irq % 32);

View File

@ -433,6 +433,19 @@ void task_enable_all_tasks(void)
__schedule(0, 0);
}
void task_enable_task(task_id_t tskid)
{
atomic_or(&tasks_enabled, BIT(tskid));
}
void task_disable_task(task_id_t tskid)
{
atomic_clear(&tasks_enabled, BIT(tskid));
if (!in_interrupt_context() && tskid == task_get_current())
__schedule(0, 0);
}
void task_enable_irq(int irq)
{
CPU_NVIC_EN(0) = 1 << irq;

View File

@ -406,6 +406,19 @@ void task_enable_all_tasks(void)
__schedule(0, 0);
}
void task_enable_task(task_id_t tskid)
{
atomic_or(&tasks_enabled, BIT(tskid));
}
void task_disable_task(task_id_t tskid)
{
atomic_clear(&tasks_enabled, BIT(tskid));
if (!in_interrupt_context() && tskid == task_get_current())
__schedule(0, 0);
}
void task_enable_irq(int irq)
{
unmask_interrupt(irq);

View File

@ -549,6 +549,19 @@ void task_enable_all_tasks(void)
__schedule(0, 0, 0);
}
void task_enable_task(task_id_t tskid)
{
atomic_or(&tasks_enabled, BIT(tskid));
}
void task_disable_task(task_id_t tskid)
{
atomic_clear(&tasks_enabled, BIT(tskid));
if (!in_interrupt_context() && tskid == task_get_current())
__schedule(0, 0, 0);
}
void __ram_code task_enable_irq(int irq)
{
uint32_t int_mask = get_int_mask();

View File

@ -489,6 +489,19 @@ void task_enable_all_tasks(void)
__schedule(0, 0, 0);
}
void task_enable_task(task_id_t tskid)
{
atomic_or(&tasks_enabled, BIT(tskid));
}
void task_disable_task(task_id_t tskid)
{
atomic_clear(&tasks_enabled, BIT(tskid));
if (!in_interrupt_context() && tskid == task_get_current())
__schedule(0, 0, 0);
}
void task_enable_irq(int irq)
{
uint32_t int_mask = get_int_mask();

View File

@ -228,6 +228,18 @@ void task_clear_fp_used(void);
*/
void task_enable_all_tasks(void);
/**
* Enable a task.
*/
void task_enable_task(task_id_t tskid);
/**
* Disable a task.
*
* If the task disable itself, this will cause an immediate reschedule.
*/
void task_disable_task(task_id_t tskid);
/**
* Enable an interrupt.
*/