summaryrefslogtreecommitdiff
path: root/core/nds32/task.c
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2015-07-01 09:31:26 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-07-13 18:43:56 +0000
commitfbc84dc56566f31d897b420232088ba341810ea2 (patch)
treee3e9bf5cf66e28ceb55d3ff27a845d2553a80735 /core/nds32/task.c
parent41b538d4c6df5311fbf76495c187a4781938ae49 (diff)
downloadchrome-ec-fbc84dc56566f31d897b420232088ba341810ea2.tar.gz
hooks: Move HOOK_INIT to after task switching.
This commit changes the way in which tasks are started. Instead of having all tasks marked as ready to run upon initialization, only the hooks task is marked as ready to run. HOOK_INITs are now run at the beginning of the hooks task. After the HOOK_INITs, the hooks task calls back to enable the rest of the tasks, reschedules, and proceeds as usual. This also allows the removal of checks for task_start_called(). BUG=chrome-os-partner:27226 BRANCH=None TEST=Built and flash EC image for samus and verified that EC boot was successful as well as AP boot. Additionally, verified that charging, keyboard, tap-for-battery were all still functional. TEST=make -j buildall tests Change-Id: Iea53670222c803c2985e9c86c96974386888a4fe Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/283657 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'core/nds32/task.c')
-rw-r--r--core/nds32/task.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/core/nds32/task.c b/core/nds32/task.c
index 269513092b..baf87ffbf3 100644
--- a/core/nds32/task.c
+++ b/core/nds32/task.c
@@ -139,9 +139,11 @@ int need_resched;
/*
* Bitmap of all tasks ready to be run.
*
- * Currently all tasks are enabled at startup.
+ * Start off with only the hooks task marked as ready such that all the modules
+ * can do their init within a task switching context. The hooks task will then
+ * make a call to enable all tasks.
*/
-static uint32_t tasks_ready = (1<<TASK_ID_COUNT) - 1;
+static uint32_t tasks_ready = (1 << TASK_ID_HOOKS);
static int start_called; /* Has task swapping started */
@@ -306,6 +308,14 @@ static void set_int_priority(uint32_t val)
asm volatile ("mtsr %0, $INT_PRI" : : "r"(val));
}
+void task_enable_all_tasks(void)
+{
+ /* Mark all tasks are ready to run. */
+ tasks_ready = (1 << TASK_ID_COUNT) - 1;
+ /* Reschedule the highest priority task. */
+ __schedule(0, 0, 0);
+}
+
void task_enable_irq(int irq)
{
int cpu_int = chip_enable_irq(irq);