summaryrefslogtreecommitdiff
path: root/core/riscv-rv32i/task.c
diff options
context:
space:
mode:
authorYilun Lin <yllin@google.com>2019-08-08 10:57:02 +0800
committerCommit Bot <commit-bot@chromium.org>2019-08-22 08:48:56 +0000
commit60c1f84d024395fac90f144ad5a027f56b5ff3d0 (patch)
tree8bd5268caf5d30cc17e1961c3e9b1a46ee401db3 /core/riscv-rv32i/task.c
parent50ca8d5e647b7002650eda35dbc829c42f978bb6 (diff)
downloadchrome-ec-60c1f84d024395fac90f144ad5a027f56b5ff3d0.tar.gz
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
Diffstat (limited to 'core/riscv-rv32i/task.c')
-rw-r--r--core/riscv-rv32i/task.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/riscv-rv32i/task.c b/core/riscv-rv32i/task.c
index b7ed17a211..f5053a8329 100644
--- a/core/riscv-rv32i/task.c
+++ b/core/riscv-rv32i/task.c
@@ -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();