diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2015-05-27 10:39:56 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-06-12 22:21:15 +0000 |
commit | 2af21940a3ead5d45cb703a3851868cc6e9b7fbe (patch) | |
tree | 3beb0214865008d35c449c9a57f836022fe0485d /core/nds32 | |
parent | 35fbc972e9dae2fb85cce6837868352ad39aa981 (diff) | |
download | chrome-ec-2af21940a3ead5d45cb703a3851868cc6e9b7fbe.tar.gz |
core: Assert if task_get_current() cannot return a valid task ID
If task_get_current() is called early during initialization when we have
not yet done a context switch, our current_task pointer is invalid. Add
an assert to detect this case and put it behind CONFIG_DEBUG_BRINGUP, a
new config that's intended to enable possibly-costly pre-production
debugging.
BUG=chrome-os-partner:40677
TEST=Manual on glados. Define CONFIG_DEBUG_BRINGUP, then call i2c_write from
board_init and verify the new assert fails. Remove the i2c_write and verify
the new assert passes.
BRANCH=None
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I6014ccf739dcc4c8f4f960be2b89f01e423b65b5
Reviewed-on: https://chromium-review.googlesource.com/273541
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'core/nds32')
-rw-r--r-- | core/nds32/task.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/core/nds32/task.c b/core/nds32/task.c index 1725f2b498..269513092b 100644 --- a/core/nds32/task.c +++ b/core/nds32/task.c @@ -171,6 +171,10 @@ inline int in_interrupt_context(void) task_id_t task_get_current(void) { +#ifdef CONFIG_DEBUG_BRINGUP + /* If we haven't done a context switch then our task ID isn't valid */ + ASSERT(current_task != (task_ *)scratchpad); +#endif return current_task - tasks; } |