Oops, pc98 is independent of i386 for clock.c and machdep.c but not

for clock.h, so changing th i386 clock.h broke it.  MFi386 (not tested):

Cleaned up declaration and initialization of clock_lock.  It is only
used by clock code, so don't export it to the world for machdep.c to
initialize.  There is a minor problem initializing it before it is
used, since although clock initialization is split up so that parts
of it can be done early, the first part was never done early enough
to actually work.  Split it up a bit more and do the first part as
late as possible to document the necessary order.  The functions that
implement the split are still bogusly exported.

Cleaned up initialization of the i8254 clock hardware using the new
split.  Actually initialize it early enough, and don't work around it
not being initialized in DELAY() when DELAY() is called early for
initialization of some console drivers.

This unfortunately moves a little more code before the early debugger
breakpoint so that it is harder to debug.  The ordering of console and
related initialization is delicate because we want to do as little as
possible before the breakpoint, but must initialize a console.
This commit is contained in:
bde 2007-01-23 08:48:26 +00:00
parent 474b917526
commit 3f550f19b8
3 changed files with 24 additions and 25 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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.
*/