summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-05-29 09:24:12 -0700
committerRandall Spangler <rspangler@chromium.org>2012-05-29 09:38:58 -0700
commitef46903dea21dee8932b5413c1c0ae6cd3a4eb16 (patch)
treed8e1a7fe045d80d478b369f074275abee14e4fc0 /core
parentf2678998617771edbfb3574b66c4573d75e6dda7 (diff)
downloadchrome-ec-ef46903dea21dee8932b5413c1c0ae6cd3a4eb16.tar.gz
usleep() chains to udelay() if called before task_start()
...so I can use usleep() for eeprom delays in the CL coming next... Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:10200 TEST=if it boots, it worked Change-Id: I564578f24452a4ac39abe79ff28cfff4b665ad2f
Diffstat (limited to 'core')
-rw-r--r--core/cortex-m/task.c9
-rw-r--r--core/cortex-m/timer.c7
2 files changed, 16 insertions, 0 deletions
diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c
index aaaa776385..41b0b7e39a 100644
--- a/core/cortex-m/task.c
+++ b/core/cortex-m/task.c
@@ -129,6 +129,8 @@ static int need_resched_or_profiling = 0;
*/
static uint32_t tasks_ready = (1<<TASK_ID_COUNT) - 1;
+static int start_called; /* Has task swapping started */
+
static task_ *__get_current(void)
{
@@ -211,6 +213,12 @@ uint32_t *task_get_event_bitmap(task_id_t tskid)
}
+int task_start_called(void)
+{
+ return start_called;
+}
+
+
/* Scheduling system call */
void svc_handler(int desched, task_id_t resched)
{
@@ -597,6 +605,7 @@ int task_start(void)
#ifdef CONFIG_TASK_PROFILING
task_start_time = exc_end_time = get_time().val;
#endif
+ start_called = 1;
return __task_start(&need_resched_or_profiling);
}
diff --git a/core/cortex-m/timer.c b/core/cortex-m/timer.c
index 14e59c900f..994f9c1245 100644
--- a/core/cortex-m/timer.c
+++ b/core/cortex-m/timer.c
@@ -138,6 +138,13 @@ int timer_cancel(task_id_t tskid)
void usleep(unsigned us)
{
uint32_t evt = 0;
+
+ /* If task scheduling has not started, just delay */
+ if (!task_start_called()) {
+ udelay(us);
+ return;
+ }
+
ASSERT(us);
do {
evt |= task_wait_event(us);