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
This commit is contained in:
Randall Spangler
2012-05-29 09:24:12 -07:00
parent f267899861
commit ef46903dea
3 changed files with 26 additions and 6 deletions

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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