diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-06-04 11:45:19 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-06-11 02:57:45 +0000 |
commit | 0a7f37d720ef8e2a0c6541054e9c01161ba0afb0 (patch) | |
tree | 09136f946239518b8c0429776b29c97829741f98 /board/zinger/runtime.c | |
parent | c75e78cd50a6e7ab2fba293199ebf97bcf66ed13 (diff) | |
download | chrome-ec-0a7f37d720ef8e2a0c6541054e9c01161ba0afb0.tar.gz |
core: add task_wait_event_mask() function to other cores
Add task_wait_event_mask() function to core/cortex-m0, core/host
and board/zinger/runtime in order to delay a task until a specific
event occurs.
BUG=none
BRANCH=smaug
TEST=make -j buildall
Change-Id: Ic89487fcae5352eec53b745179c7f0d5893ad3e0
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276744
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board/zinger/runtime.c')
-rw-r--r-- | board/zinger/runtime.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/board/zinger/runtime.c b/board/zinger/runtime.c index f2b40cbfd9..8631eea74e 100644 --- a/board/zinger/runtime.c +++ b/board/zinger/runtime.c @@ -216,6 +216,25 @@ uint32_t task_wait_event(int timeout_us) return evt; } +uint32_t task_wait_event_mask(uint32_t event_mask, int timeout_us) +{ + uint32_t evt = 0; + + /* Add the timer event to the mask so we can indicate a timeout */ + event_mask |= TASK_EVENT_TIMER; + + /* Wait until an event matching event_mask */ + do { + evt |= task_wait_event(timeout_us); + } while (!(evt & event_mask)); + + /* Restore any pending events not in the event_mask */ + if (evt & ~event_mask) + task_set_event(0, evt & ~event_mask, 0); + + return evt & event_mask; +} + void __keep cpu_reset(void) { /* Disable interrupts */ |