aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/isa/clock.c
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2008-03-26 22:12:00 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2008-03-26 22:12:00 +0000
commitdad3b6c6fd41ae85474bda91ea5282c8cca3d8c5 (patch)
tree20d0b26b46164667259cfe3e02b7532d073ad9f7 /sys/amd64/isa/clock.c
parent1d73a9dc742ef7fdbe616a7ea23b2c623a1d2557 (diff)
Notes
Diffstat (limited to 'sys/amd64/isa/clock.c')
-rw-r--r--sys/amd64/isa/clock.c112
1 files changed, 0 insertions, 112 deletions
diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c
index 342fe18c5a78..5cc076ee1383 100644
--- a/sys/amd64/isa/clock.c
+++ b/sys/amd64/isa/clock.c
@@ -430,86 +430,6 @@ readrtc(int port)
return(bcd2bin(rtcin(port)));
}
-static u_int
-calibrate_clocks(void)
-{
- u_int count, prev_count, tot_count;
- int sec, start_sec, timeout;
-
- if (bootverbose)
- printf("Calibrating clock(s) ... ");
- if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
- goto fail;
- timeout = 100000000;
-
- /* Read the mc146818A seconds counter. */
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Wait for the mC146818A seconds counter to change. */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- if (sec != start_sec)
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Start keeping track of the i8254 counter. */
- prev_count = getit();
- if (prev_count == 0 || prev_count > i8254_max_count)
- goto fail;
- tot_count = 0;
-
- /*
- * Wait for the mc146818A seconds counter to change. Read the i8254
- * counter for each iteration since this is convenient and only
- * costs a few usec of inaccuracy. The timing of the final reads
- * of the counters almost matches the timing of the initial reads,
- * so the main cause of inaccuracy is the varying latency from
- * inside getit() or rtcin(RTC_STATUSA) to the beginning of the
- * rtcin(RTC_SEC) that returns a changed seconds count. The
- * maximum inaccuracy from this cause is < 10 usec on 486's.
- */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP))
- sec = rtcin(RTC_SEC);
- count = getit();
- if (count == 0 || count > i8254_max_count)
- goto fail;
- if (count > prev_count)
- tot_count += prev_count - (count - i8254_max_count);
- else
- tot_count += prev_count - count;
- prev_count = count;
- if (sec != start_sec)
- break;
- if (--timeout == 0)
- goto fail;
- }
-
- if (bootverbose) {
- printf("i8254 clock: %u Hz\n", tot_count);
- }
- return (tot_count);
-
-fail:
- if (bootverbose)
- printf("failed, using default i8254 clock of %u Hz\n",
- i8254_freq);
- return (i8254_freq);
-}
-
static void
set_i8254_freq(u_int freq, int intr_freq)
{
@@ -547,42 +467,10 @@ i8254_init(void)
void
startrtclock()
{
- u_int delta, freq;
writertc(RTC_STATUSA, rtc_statusa);
writertc(RTC_STATUSB, RTCSB_24HR);
- freq = calibrate_clocks();
-#ifdef CLK_CALIBRATION_LOOP
- if (bootverbose) {
- printf(
- "Press a key on the console to abort clock calibration\n");
- while (cncheckc() == -1)
- calibrate_clocks();
- }
-#endif
-
- /*
- * Use the calibrated i8254 frequency if it seems reasonable.
- * Otherwise use the default, and don't use the calibrated i586
- * frequency.
- */
- delta = freq > i8254_freq ? freq - i8254_freq : i8254_freq - freq;
- if (delta < i8254_freq / 100) {
-#ifndef CLK_USE_I8254_CALIBRATION
- if (bootverbose)
- printf(
-"CLK_USE_I8254_CALIBRATION not specified - using default frequency\n");
- freq = i8254_freq;
-#endif
- i8254_freq = freq;
- } else {
- if (bootverbose)
- printf(
- "%d Hz differs from default of %d Hz by more than 1%%\n",
- freq, i8254_freq);
- }
-
set_i8254_freq(i8254_freq, hz);
tc_init(&i8254_timecounter);