diff options
author | marcel <marcel@FreeBSD.org> | 2004-07-11 17:50:59 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2004-07-11 17:50:59 +0000 |
commit | 841342b02b5a2d0e4efa2bb43e4234424bf4c70a (patch) | |
tree | 09e5bc0592e19b2a5f04a7cc195382cc6863c4f9 /sys | |
parent | e0b2a5b339c89dccabc683c04970ca9e8c870ac0 (diff) | |
download | FreeBSD-src-841342b02b5a2d0e4efa2bb43e4234424bf4c70a.zip FreeBSD-src-841342b02b5a2d0e4efa2bb43e4234424bf4c70a.tar.gz |
Partially revert previous commit. Calling getit() unconditionally fixed
a problem that could also be fixed differently without reverting previous
attempts to fix DELAY while the debugger is active (rev 1.204). The bug
was that the i8254 implements a countdown timer, while for (k)db_active
a countup timer was implemented. This resulted in premature termination
and consequently the breakage of DELAY. The fix (relative to rev 1.211)
is to implement a countdown timer for the kdb_active case. As such the
ability to step clock initialization is preserved and DELAY does what is
expected of it.
Blushed: bde :-)
Submitted by: bde
Diffstat (limited to 'sys')
-rw-r--r-- | sys/i386/isa/clock.c | 33 | ||||
-rw-r--r-- | sys/isa/atrtc.c | 33 |
2 files changed, 44 insertions, 22 deletions
diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c index d474259..1c82ffa 100644 --- a/sys/i386/isa/clock.c +++ b/sys/i386/isa/clock.c @@ -401,10 +401,7 @@ getit(void) { int high, low; -#ifdef KDB - if (!kdb_active) -#endif - mtx_lock_spin(&clock_lock); + mtx_lock_spin(&clock_lock); /* Select timer0 and latch counter value. */ outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH); @@ -412,11 +409,7 @@ getit(void) low = inb(TIMER_CNTR0); high = inb(TIMER_CNTR0); -#ifdef KDB - if (!kdb_active) -#endif - mtx_unlock_spin(&clock_lock); - + mtx_unlock_spin(&clock_lock); return ((high << 8) | low); } @@ -457,8 +450,18 @@ DELAY(int n) * takes about 1.5 usec for each of the i/o's in getit(). The loop * takes about 6 usec on a 486/33 and 13 usec on a 386/20. The * multiplications and divisions to scale the count take a while). + * + * However, if ddb is active then use a fake counter since reading + * the i8254 counter involves acquiring a lock. ddb must not do + * locking for many reasons, but it calls here for at least atkbd + * input. */ - prev_tick = getit(); +#ifdef KDB + if (kdb_active) + prev_tick = 1; + else +#endif + prev_tick = getit(); n -= 0; /* XXX actually guess no initial overhead */ /* * Calculate (n * (timer_freq / 1e6)) without using floating point @@ -485,7 +488,15 @@ DELAY(int n) / 1000000; while (ticks_left > 0) { - tick = getit(); +#ifdef KDB + if (kdb_active) { + inb(0x84); + tick = prev_tick - 1; + if (tick <= 0) + tick = timer0_max_count; + } else +#endif + tick = getit(); #ifdef DELAYDEBUG ++getit_calls; #endif diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c index d474259..1c82ffa 100644 --- a/sys/isa/atrtc.c +++ b/sys/isa/atrtc.c @@ -401,10 +401,7 @@ getit(void) { int high, low; -#ifdef KDB - if (!kdb_active) -#endif - mtx_lock_spin(&clock_lock); + mtx_lock_spin(&clock_lock); /* Select timer0 and latch counter value. */ outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH); @@ -412,11 +409,7 @@ getit(void) low = inb(TIMER_CNTR0); high = inb(TIMER_CNTR0); -#ifdef KDB - if (!kdb_active) -#endif - mtx_unlock_spin(&clock_lock); - + mtx_unlock_spin(&clock_lock); return ((high << 8) | low); } @@ -457,8 +450,18 @@ DELAY(int n) * takes about 1.5 usec for each of the i/o's in getit(). The loop * takes about 6 usec on a 486/33 and 13 usec on a 386/20. The * multiplications and divisions to scale the count take a while). + * + * However, if ddb is active then use a fake counter since reading + * the i8254 counter involves acquiring a lock. ddb must not do + * locking for many reasons, but it calls here for at least atkbd + * input. */ - prev_tick = getit(); +#ifdef KDB + if (kdb_active) + prev_tick = 1; + else +#endif + prev_tick = getit(); n -= 0; /* XXX actually guess no initial overhead */ /* * Calculate (n * (timer_freq / 1e6)) without using floating point @@ -485,7 +488,15 @@ DELAY(int n) / 1000000; while (ticks_left > 0) { - tick = getit(); +#ifdef KDB + if (kdb_active) { + inb(0x84); + tick = prev_tick - 1; + if (tick <= 0) + tick = timer0_max_count; + } else +#endif + tick = getit(); #ifdef DELAYDEBUG ++getit_calls; #endif |