summaryrefslogtreecommitdiff
path: root/include/task.h
diff options
context:
space:
mode:
authorLouis Collard <louiscollard@chromium.org>2018-09-17 20:56:17 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-01-26 03:38:59 -0800
commit9cb1b936e76809cb68419c3ff3612e17fec81e9c (patch)
tree573291dd3069ef9ff2150d362dba1374fc36c7af /include/task.h
parent0c0fbbe3275b0c069cf50e71603b797633f7b0a9 (diff)
downloadchrome-ec-9cb1b936e76809cb68419c3ff3612e17fec81e9c.tar.gz
ec: Add a task_reset function.
This adds a generic task_reset function that can reset any task that declares it supports being reset. Tasks that support reset must call task_reset_cleanup() on startup, and be prepared to perform any cleanup / re-initialisation necessary. The task can control when it can be reset using task_enable_resets() and task_disable_resets(). A task can request another task be reset at any point; if the reset cannot happen immediately, it will be queued and will happen at the earliest point allowed by the task to be reset. Task resets can be blocking or non-blocking, as specified by the requestor. BUG=b:73771117 BRANCH=none TEST=manual testing on local device Change-Id: I972184381b005c342374fa16c4dce2ac83e89854 Signed-off-by: Louis Collard <louiscollard@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1230394 Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'include/task.h')
-rw-r--r--include/task.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/include/task.h b/include/task.h
index f0b680386b..08acec1714 100644
--- a/include/task.h
+++ b/include/task.h
@@ -39,6 +39,8 @@
#define TASK_EVENT_DMA_TC (1 << 26)
/* ADC interrupt handler event */
#define TASK_EVENT_ADC_DONE (1 << 27)
+/* task_reset() that was requested has been completed */
+#define TASK_EVENT_RESET_DONE (1 << 28)
/* task_wake() called on task */
#define TASK_EVENT_WAKE (1 << 29)
/* Mutex unlocking */
@@ -234,6 +236,55 @@ void task_disable_irq(int irq);
*/
void task_trigger_irq(int irq);
+/*
+ * A task that supports resets may call this to indicate that it may be reset
+ * at any point between this call and the next call to task_disable_resets().
+ *
+ * Calling this function will trigger any resets that were requested while
+ * resets were disabled.
+ *
+ * It is not expected for this to be called if resets are already enabled.
+ */
+void task_enable_resets(void);
+
+/*
+ * A task that supports resets may call this to indicate that it may not be
+ * reset until the next call to task_enable_resets(). Any calls to task_reset()
+ * during this time will cause a reset request to be queued, and executed
+ * the next time task_enable_resets() is called.
+ *
+ * Must not be called if resets are already disabled.
+ */
+void task_disable_resets(void);
+
+/*
+ * If the current task was reset, completes the reset operation.
+ *
+ * Returns a non-zero value if the task was reset; tasks with state outside
+ * of the stack should perform any necessary cleanup immediately after calling
+ * this function.
+ *
+ * Tasks that support reset must call this function once at startup before
+ * doing anything else.
+ *
+ * Must only be called once at task startup.
+ */
+int task_reset_cleanup(void);
+
+/*
+ * Resets the specified task, which must not be the current task,
+ * to initial state.
+ *
+ * Returns EC_SUCCESS, or EC_ERROR_INVAL if the specified task does
+ * not support resets.
+ *
+ * If wait is true, blocks until the task has been reset. Otherwise,
+ * returns immediately - in this case the task reset may be delayed until
+ * that task can be safely reset. The duration of this delay depends on the
+ * task implementation.
+ */
+int task_reset(task_id_t id, int wait);
+
/**
* Clear a pending interrupt.
*