diff --git a/sys/pc98/cbus/clock.c b/sys/pc98/cbus/clock.c index 8706a99db0c5..15705726cefa 100644 --- a/sys/pc98/cbus/clock.c +++ b/sys/pc98/cbus/clock.c @@ -262,13 +262,6 @@ DELAY(int n) if (state == 1) 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 @@ -511,10 +504,15 @@ timer_restore(void) i8254_restore(); /* restore timer_freq and hz */ } -/* - * 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() { @@ -526,7 +524,6 @@ startrtclock() else timer_freq = 2457600L; /* 2.4576 MHz */ - set_timer_freq(timer_freq, hz); freq = calibrate_clocks(); #ifdef CLK_CALIBRATION_LOOP if (bootverbose) { diff --git a/sys/pc98/cbus/pcrtc.c b/sys/pc98/cbus/pcrtc.c index 8706a99db0c5..15705726cefa 100644 --- a/sys/pc98/cbus/pcrtc.c +++ b/sys/pc98/cbus/pcrtc.c @@ -262,13 +262,6 @@ DELAY(int n) if (state == 1) 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 @@ -511,10 +504,15 @@ timer_restore(void) i8254_restore(); /* restore timer_freq and hz */ } -/* - * 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() { @@ -526,7 +524,6 @@ startrtclock() else timer_freq = 2457600L; /* 2.4576 MHz */ - set_timer_freq(timer_freq, hz); freq = calibrate_clocks(); #ifdef CLK_CALIBRATION_LOOP if (bootverbose) { diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index 06661e21b499..d35cbd8307a6 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -1971,7 +1971,6 @@ init386(first) * under witness. */ mutex_init(); - mtx_init(&clock_lock, "clk", NULL, MTX_SPIN); mtx_init(&icu_lock, "icu", NULL, MTX_SPIN | MTX_NOWITNESS); /* make ldt memory segments */ @@ -2032,6 +2031,12 @@ init386(first) r_idt.rd_base = (int) idt; lidt(&r_idt); + /* + * Initialize the i8254 before the console so that console + * initialization can use DELAY(). + */ + i8254_init(); + /* * Initialize the console before we print anything out. */