diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2010-05-23 12:40:40 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2010-05-23 12:40:40 -0400 |
commit | bb68591e7169f9acdfb9625073ceab5f367613f0 (patch) | |
tree | 7a514b1790f1a0941107b8c787a7ca9762470515 | |
parent | b5cc2ca5d06b4982139afd1205a0390944c60c7d (diff) | |
download | seabios-bb68591e7169f9acdfb9625073ceab5f367613f0.tar.gz |
Don't use RTC to time boot menu delay.
It appears real machines sometimes have a flaky RTC, so avoid using
the RTC irq during boot. Instead, use a delay based on the standard
timer irq.
This also optimizes CONFIG_THREAD_OPTIONROMS users as it is no longer
necessary to use preemption - the wait_irq() call handles task
switching natively.
-rw-r--r-- | src/clock.c | 4 | ||||
-rw-r--r-- | src/util.c | 25 | ||||
-rw-r--r-- | src/util.h | 1 |
3 files changed, 7 insertions, 23 deletions
diff --git a/src/clock.c b/src/clock.c index 062658c1..49ab901b 100644 --- a/src/clock.c +++ b/src/clock.c @@ -231,14 +231,18 @@ calc_future_timer_ticks(u32 count) { return (GET_BDA(timer_counter) + count + 1) % TICKS_PER_DAY; } + // Return the timer value that is 'msecs' time in the future. u32 calc_future_timer(u32 msecs) { + if (!msecs) + return GET_BDA(timer_counter); u32 kticks = DIV_ROUND_UP((u64)(msecs * PIT_TICK_RATE), PIT_TICK_INTERVAL); u32 ticks = DIV_ROUND_UP(kticks, 1000); return calc_future_timer_ticks(ticks); } + // Check if the given timer value has passed. int check_timer(u32 end) @@ -244,19 +244,6 @@ strtcpy(char *dest, const char *src, size_t len) * Keyboard calls ****************************************************************/ -// Wait for 'usec' microseconds using (with irqs enabled) using int 1586. -void -biosusleep(u32 usec) -{ - struct bregs br; - memset(&br, 0, sizeof(br)); - br.flags = F_IF; - br.ah = 0x86; - br.cx = usec >> 16; - br.dx = usec; - call16_int(0x15, &br); -} - // See if a keystroke is pending in the keyboard buffer. static int check_for_keystroke(void) @@ -265,9 +252,7 @@ check_for_keystroke(void) memset(&br, 0, sizeof(br)); br.flags = F_IF; br.ah = 1; - start_preempt(); call16_int(0x16, &br); - finish_preempt(); return !(br.flags & F_ZF); } @@ -278,9 +263,7 @@ get_raw_keystroke(void) struct bregs br; memset(&br, 0, sizeof(br)); br.flags = F_IF; - start_preempt(); call16_int(0x16, &br); - finish_preempt(); return br.ah; } @@ -288,14 +271,12 @@ get_raw_keystroke(void) int get_keystroke(int msec) { + u32 end = calc_future_timer(msec); for (;;) { if (check_for_keystroke()) return get_raw_keystroke(); - if (msec <= 0) + if (check_timer(end)) return -1; - start_preempt(); - biosusleep(50*1000); - finish_preempt(); - msec -= 50; + wait_irq(); } } @@ -193,7 +193,6 @@ void *memcpy(void *d1, const void *s1, size_t len); void iomemcpy(void *d, const void *s, u32 len); void *memmove(void *d, const void *s, size_t len); char *strtcpy(char *dest, const char *src, size_t len); -void biosusleep(u32 usec); int get_keystroke(int msec); // stacks.c |