Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 May 1996 19:17:58 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@freefall.freebsd.org, current@freebsd.org
Subject:   Re: cvs commit:  src/sys/i386/include clock.h src/sys/i386/isa clock.c src/sys/i386/i386 machdep.c
Message-ID:  <199605010917.TAA18171@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
This change is supposed to make timekeeping more accurate when no
external clocks are available.  The RTC is probably more accurate
than the i8254 clock so it is used as a reference.  The nominal
frequencies can be overridden using sysctl if desired.

Please test it with the temporary options enabled:

# If booted with -v, loop at boot time repeating the calibration and
# printing the results until a key is hit.
option	CLK_CALIBRATION_LOOP

# Use the result of the calibration of the i8254 clock relative to the
# RTC instead of the default of 1193182.  This option will probably be
# the default unless the default is set using the TIMER_FREQ option.
option	CLK_USE_I8254_CALIBRATION

# Use the result of the calibration of the i586 clock relative to the
# RTC instead of the result of a sloppier calibration of the i586 clock
# relative to the i8254 clock.  This option will probably go away.
option	CLK_USE_I586_CALIBRATION

Before trying these, you can look for the results of the calibrations
in the boot messages and set them using sysctl.  The sysctl variables
are named machdep.i8254_freq and machdep.i586_freq.

Bruce

>bde         96/05/01 01:39:04

>  Modified:    sys/i386/i386  machdep.c
>               sys/i386/include  clock.h
>               sys/i386/isa  clock.c
>  Log:
>  Added calibration the i8254 and the i586 clocks agains the RTC at boot
>  time.  The results are currently ignored unless certain temporary options
>  are used.
>  
>  Added sysctls to support reading and writing the clock frequency variables
>  (not the frequencies themselves).  Writing is supposed to atomically
>  adjust all related variables.
>  
>  machdep.c:
>  Fixed spelling of a function name in a comment so that I can log this
>  message which should have been with the previous commit.
>  
>  Initialize `cpu_class' earlier so that it can be used in startrtclock()
>  instead of in calibrate_cyclecounter() (which no longer exists).
>  
>  Removed range checking of `cpu'.  It is always initialized to CPU_XXX
>  so it is less likely to be out of bounds than most variables.
>  
>  clock.h:
>  Removed I586_CYCLECTR().  Use rdtsc() instead.
>  
>  clock.c:
>  TIMER_FREQ is now a variable timer_freq that defaults to the old value of
>  TIMER_FREQ.  #define'ing TIMER_FREQ should still work and may be the best
>  way of setting the frequency.
>  
>  Calibration involves counting cycles while watching the RTC for one second.
>  This gives values correct to within (a few ppm) + (the innaccuracy of the
>  RTC) on my systems.
>  
>  Revision  Changes    Path
>  1.186     +2 -2      src/sys/i386/i386/machdep.c
>  1.13      +4 -9      src/sys/i386/include/clock.h
>  1.58      +249 -43   src/sys/i386/isa/clock.c




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605010917.TAA18171>