From 62f362bd8ff68238bbf44b8e713e7e82cbf477ac Mon Sep 17 00:00:00 2001 From: marcel Date: Sun, 11 Jul 2004 18:07:55 +0000 Subject: MFi386: rev 1.213 -- fix DELAY while the debugger is active. This also fixes the (runtime) breakage introduced in the previous commit that was the result of a botched merge. This hasn't even been compile-tested... --- sys/amd64/isa/clock.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'sys/amd64') diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index c311a2a..c2632e8 100644 --- a/sys/amd64/isa/clock.c +++ b/sys/amd64/isa/clock.c @@ -53,8 +53,8 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include +#include #include #include #include @@ -293,8 +293,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 go + * 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 @@ -321,7 +331,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 @@ -366,17 +384,10 @@ sysbeep(int pitch, int period) splx(x); return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */ } -#ifdef KDB - if (!kdb_active) -#endif - mtx_lock_spin(&clock_lock); + mtx_lock_spin(&clock_lock); outb(TIMER_CNTR2, pitch); outb(TIMER_CNTR2, (pitch>>8)); -#ifdef KDB - if (!kdb_active) -#endif - mtx_unlock_spin(&clock_lock); - + mtx_unlock_spin(&clock_lock); if (!beeping) { /* enable counter2 output to speaker */ outb(IO_PPI, inb(IO_PPI) | 3); -- cgit v1.1