summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-05-29 09:24:12 -0700
committerRong Chang <rongchang@chromium.org>2012-06-07 23:14:08 -0700
commit959f895f652b867c48934c32326f03b7a188461b (patch)
tree4e4f16792eb7129718c7116665924d75575852d0
parent219078633e587e720b8b06a5912449053cec7d9e (diff)
downloadchrome-ec-959f895f652b867c48934c32326f03b7a188461b.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 Reviewed-on: https://gerrit.chromium.org/gerrit/24848 Reviewed-by: Rong Chang <rongchang@chromium.org> Tested-by: Rong Chang <rongchang@chromium.org>
-rw-r--r--core/cortex-m/task.c9
-rw-r--r--core/cortex-m/timer.c7
-rw-r--r--include/task.h16
3 files changed, 26 insertions, 6 deletions
diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c
index 3041f431c8..16027a2b28 100644
--- a/core/cortex-m/task.c
+++ b/core/cortex-m/task.c
@@ -133,6 +133,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)
{
@@ -215,6 +217,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)
{
@@ -581,6 +589,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 2ea927d4be..64cf8c89df 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);
diff --git a/include/task.h b/include/task.h
index 660195460e..075ed43698 100644
--- a/include/task.h
+++ b/include/task.h
@@ -99,22 +99,26 @@ void task_start_irq_handler(void *excep_return);
* last call of the interrupt handler. */
void task_resched_if_needed(void *excep_return);
-/* Initializes tasks and interrupt controller. */
+/* Initialize tasks and interrupt controller. */
int task_pre_init(void);
-/* Starts task scheduling. Does not normally return. */
+/* Start task scheduling. Does not normally return. */
int task_start(void);
-/* Enables an interrupt. */
+/* Return non-zero if task_start() has been called and task scheduling has
+ * started. */
+int task_start_called(void);
+
+/* Enable an interrupt. */
void task_enable_irq(int irq);
-/* Disables an interrupt. */
+/* Disable an interrupt. */
void task_disable_irq(int irq);
-/* Software-triggers an interrupt. */
+/* Software-trigger an interrupt. */
void task_trigger_irq(int irq);
-/* Clears a pending interrupt.
+/* Clear a pending interrupt.
*
* Note that most interrupts can be removed from the pending state simply by
* handling whatever caused the interrupt in the first place. This only needs