summaryrefslogtreecommitdiffstats
path: root/sys/amd64/isa/clock.c
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2004-07-11 18:07:55 +0000
committermarcel <marcel@FreeBSD.org>2004-07-11 18:07:55 +0000
commit62f362bd8ff68238bbf44b8e713e7e82cbf477ac (patch)
treef8f2af5ca240d954467b956425418b9b4e4d3d17 /sys/amd64/isa/clock.c
parent841342b02b5a2d0e4efa2bb43e4234424bf4c70a (diff)
downloadFreeBSD-src-62f362bd8ff68238bbf44b8e713e7e82cbf477ac.zip
FreeBSD-src-62f362bd8ff68238bbf44b8e713e7e82cbf477ac.tar.gz
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...
Diffstat (limited to 'sys/amd64/isa/clock.c')
-rw-r--r--sys/amd64/isa/clock.c35
1 files changed, 23 insertions, 12 deletions
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 <sys/systm.h>
#include <sys/bus.h>
#include <sys/lock.h>
-#include <sys/mutex.h>
#include <sys/kdb.h>
+#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/time.h>
#include <sys/timetc.h>
@@ -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);
OpenPOWER on IntegriCloud