summaryrefslogtreecommitdiffstats
path: root/sys/i386/isa/clock.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/i386/isa/clock.c')
-rw-r--r--sys/i386/isa/clock.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c
index bc0bf61..29ddd39 100644
--- a/sys/i386/isa/clock.c
+++ b/sys/i386/isa/clock.c
@@ -106,11 +106,11 @@ int statclock_disable;
u_int timer_freq = TIMER_FREQ;
int timer0_max_count;
int timer0_real_max_count;
-struct mtx clock_lock;
#define RTC_LOCK mtx_lock_spin(&clock_lock)
#define RTC_UNLOCK mtx_unlock_spin(&clock_lock)
static int beeping = 0;
+static struct mtx clock_lock;
static struct intsrc *i8254_intsrc;
static u_int32_t i8254_lastcount;
static u_int32_t i8254_offset;
@@ -302,13 +302,6 @@ DELAY(int n)
printf("DELAY(%d)...", n);
#endif
/*
- * Guard against the timer being uninitialized if we are called
- * early for console i/o.
- */
- if (timer0_max_count == 0)
- set_timer_freq(timer_freq, hz);
-
- /*
* Read the counter first, so that the rest of the setup overhead is
* counted. Guess the initial overhead is 20 usec (on most systems it
* takes about 1.5 usec for each of the i/o's in getit(). The loop
@@ -605,10 +598,15 @@ timer_restore(void)
rtc_restore(); /* reenable RTC interrupts */
}
-/*
- * Initialize 8254 timer 0 early so that it can be used in DELAY().
- * XXX initialization of other timers is unintentionally left blank.
- */
+/* This is separate from startrtclock() so that it can be called early. */
+void
+i8254_init(void)
+{
+
+ mtx_init(&clock_lock, "clk", NULL, MTX_SPIN | MTX_NOPROFILE);
+ set_timer_freq(timer_freq, hz);
+}
+
void
startrtclock()
{
@@ -617,7 +615,6 @@ startrtclock()
writertc(RTC_STATUSA, rtc_statusa);
writertc(RTC_STATUSB, RTCSB_24HR);
- set_timer_freq(timer_freq, hz);
freq = calibrate_clocks();
#ifdef CLK_CALIBRATION_LOOP
if (bootverbose) {
OpenPOWER on IntegriCloud