summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/cortex-m/task.c13
-rw-r--r--core/cortex-m0/task.c13
-rw-r--r--core/minute-ia/task.c13
-rw-r--r--core/nds32/task.c13
-rw-r--r--core/riscv-rv32i/task.c13
-rw-r--r--include/task.h12
6 files changed, 77 insertions, 0 deletions
diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c
index 83d53105aa..b9f9738e67 100644
--- a/core/cortex-m/task.c
+++ b/core/cortex-m/task.c
@@ -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);
diff --git a/core/cortex-m0/task.c b/core/cortex-m0/task.c
index 1a198827db..d9f0e85c40 100644
--- a/core/cortex-m0/task.c
+++ b/core/cortex-m0/task.c
@@ -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;
diff --git a/core/minute-ia/task.c b/core/minute-ia/task.c
index 8cd42186f2..5675d32992 100644
--- a/core/minute-ia/task.c
+++ b/core/minute-ia/task.c
@@ -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);
diff --git a/core/nds32/task.c b/core/nds32/task.c
index 66d922504d..389b20ba38 100644
--- a/core/nds32/task.c
+++ b/core/nds32/task.c
@@ -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();
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();
diff --git a/include/task.h b/include/task.h
index 529545bdf6..897ba79f34 100644
--- a/include/task.h
+++ b/include/task.h
@@ -229,6 +229,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.
*/
void task_enable_irq(int irq);