diff options
author | bde <bde@FreeBSD.org> | 2007-01-23 08:01:20 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 2007-01-23 08:01:20 +0000 |
commit | b12ed0640c857dc93ba125eb06170e17027fd27a (patch) | |
tree | f0e1eb361836da7c3492fa9da1f26ee29d68baa6 /sys/amd64/isa/clock.c | |
parent | ae205e357394497283a47a0e9c42c058fb72bd32 (diff) | |
download | FreeBSD-src-b12ed0640c857dc93ba125eb06170e17027fd27a.zip FreeBSD-src-b12ed0640c857dc93ba125eb06170e17027fd27a.tar.gz |
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.
Diffstat (limited to 'sys/amd64/isa/clock.c')
-rw-r--r-- | sys/amd64/isa/clock.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index 0b1fc4d..e548b26 100644 --- a/sys/amd64/isa/clock.c +++ b/sys/amd64/isa/clock.c @@ -103,11 +103,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 const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; static struct intsrc *i8254_intsrc; static u_int32_t i8254_lastcount; @@ -295,13 +295,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 @@ -560,10 +553,15 @@ set_timer_freq(u_int freq, int intr_freq) mtx_unlock_spin(&clock_lock); } -/* - * 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); + set_timer_freq(timer_freq, hz); +} + void startrtclock() { @@ -572,7 +570,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) { |