Deleted Added
sdiff udiff text old ( 55420 ) new ( 58377 )
full compact
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz and Don Ahn.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)clock.c 7.2 (Berkeley) 5/12/91
37 * $FreeBSD: head/sys/isa/atrtc.c 58377 2000-03-20 14:09:06Z phk $
38 */
39
40/*
41 * Routines to handle clock hardware.
42 */
43
44/*
45 * inittodr, settodr and support routines written
46 * by Christoph Robitschko <chmr@edvz.tu-graz.ac.at>
47 *
48 * reintroduced and updated by Chris Stenton <chris@gnome.co.uk> 8/10/94
49 */
50
51#include "opt_clock.h"
52#include "apm.h"
53
54#include <sys/param.h>
55#include <sys/systm.h>
56#include <sys/time.h>
57#include <sys/timetc.h>
58#include <sys/kernel.h>
59#ifndef SMP
60#include <sys/lock.h>
61#endif
62#include <sys/sysctl.h>
63#include <sys/cons.h>
64
65#include <machine/clock.h>

--- 701 unchanged lines hidden (view full) ---

767 printf(
768 "%d Hz differs from default of %d Hz by more than 1%%\n",
769 freq, timer_freq);
770 tsc_freq = 0;
771 }
772
773 set_timer_freq(timer_freq, hz);
774 i8254_timecounter.tc_frequency = timer_freq;
775 tc_init(&i8254_timecounter);
776
777#ifndef CLK_USE_TSC_CALIBRATION
778 if (tsc_freq != 0) {
779 if (bootverbose)
780 printf(
781"CLK_USE_TSC_CALIBRATION not specified - using old calibration method\n");
782 tsc_freq = 0;
783 }

--- 33 unchanged lines hidden (view full) ---

817 * We don't know at this point whether APM is going to be used
818 * or not, nor when it might be activated. Play it safe.
819 */
820 return;
821#endif /* NAPM > 0 */
822
823 if (tsc_present && tsc_freq != 0 && !tsc_is_broken) {
824 tsc_timecounter.tc_frequency = tsc_freq;
825 tc_init(&tsc_timecounter);
826 }
827
828#endif /* !defined(SMP) */
829}
830
831/*
832 * Initialize the time of day register, based on the time base which is, e.g.
833 * from a filesystem.

--- 6 unchanged lines hidden (view full) ---

840 int year, month;
841 int y, m, s;
842 struct timespec ts;
843
844 if (base) {
845 s = splclock();
846 ts.tv_sec = base;
847 ts.tv_nsec = 0;
848 tc_setclock(&ts);
849 splx(s);
850 }
851
852 /* Look if we have a RTC present and the time is valid */
853 if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
854 goto wrong_time;
855
856 /* wait for time update to complete */

--- 34 unchanged lines hidden (view full) ---

891
892 sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
893
894 y = time_second - sec;
895 if (y <= -2 || y >= 2) {
896 /* badly off, adjust it */
897 ts.tv_sec = sec;
898 ts.tv_nsec = 0;
899 tc_setclock(&ts);
900 }
901 splx(s);
902 return;
903
904wrong_time:
905 printf("Invalid time in real time clock.\n");
906 printf("Check and reset the date immediately!\n");
907}

--- 245 unchanged lines hidden (view full) ---

1153 */
1154 freq = timer_freq;
1155 error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
1156 if (error == 0 && req->newptr != NULL) {
1157 if (timer0_state != RELEASED)
1158 return (EBUSY); /* too much trouble to handle */
1159 set_timer_freq(freq, hz);
1160 i8254_timecounter.tc_frequency = freq;
1161 tc_update(&i8254_timecounter);
1162 }
1163 return (error);
1164}
1165
1166SYSCTL_PROC(_machdep, OID_AUTO, i8254_freq, CTLTYPE_INT | CTLFLAG_RW,
1167 0, sizeof(u_int), sysctl_machdep_i8254_freq, "I", "");
1168
1169static int

--- 4 unchanged lines hidden (view full) ---

1174
1175 if (tsc_timecounter.tc_frequency == 0)
1176 return (EOPNOTSUPP);
1177 freq = tsc_freq;
1178 error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
1179 if (error == 0 && req->newptr != NULL) {
1180 tsc_freq = freq;
1181 tsc_timecounter.tc_frequency = tsc_freq;
1182 tc_update(&tsc_timecounter);
1183 }
1184 return (error);
1185}
1186
1187SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
1188 0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
1189
1190static unsigned

--- 41 unchanged lines hidden ---