atrtc.c (55420) | atrtc.c (58377) |
---|---|
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 | 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 55420 2000-01-04 22:24:59Z tegge $ | 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> | 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> |
|
57#include <sys/kernel.h> 58#ifndef SMP 59#include <sys/lock.h> 60#endif 61#include <sys/sysctl.h> 62#include <sys/cons.h> 63 64#include <machine/clock.h> --- 701 unchanged lines hidden (view full) --- 766 printf( 767 "%d Hz differs from default of %d Hz by more than 1%%\n", 768 freq, timer_freq); 769 tsc_freq = 0; 770 } 771 772 set_timer_freq(timer_freq, hz); 773 i8254_timecounter.tc_frequency = timer_freq; | 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; |
774 init_timecounter(&i8254_timecounter); | 775 tc_init(&i8254_timecounter); |
775 776#ifndef CLK_USE_TSC_CALIBRATION 777 if (tsc_freq != 0) { 778 if (bootverbose) 779 printf( 780"CLK_USE_TSC_CALIBRATION not specified - using old calibration method\n"); 781 tsc_freq = 0; 782 } --- 33 unchanged lines hidden (view full) --- 816 * We don't know at this point whether APM is going to be used 817 * or not, nor when it might be activated. Play it safe. 818 */ 819 return; 820#endif /* NAPM > 0 */ 821 822 if (tsc_present && tsc_freq != 0 && !tsc_is_broken) { 823 tsc_timecounter.tc_frequency = tsc_freq; | 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; |
824 init_timecounter(&tsc_timecounter); | 825 tc_init(&tsc_timecounter); |
825 } 826 827#endif /* !defined(SMP) */ 828} 829 830/* 831 * Initialize the time of day register, based on the time base which is, e.g. 832 * from a filesystem. --- 6 unchanged lines hidden (view full) --- 839 int year, month; 840 int y, m, s; 841 struct timespec ts; 842 843 if (base) { 844 s = splclock(); 845 ts.tv_sec = base; 846 ts.tv_nsec = 0; | 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; |
847 set_timecounter(&ts); | 848 tc_setclock(&ts); |
848 splx(s); 849 } 850 851 /* Look if we have a RTC present and the time is valid */ 852 if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) 853 goto wrong_time; 854 855 /* wait for time update to complete */ --- 34 unchanged lines hidden (view full) --- 890 891 sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0); 892 893 y = time_second - sec; 894 if (y <= -2 || y >= 2) { 895 /* badly off, adjust it */ 896 ts.tv_sec = sec; 897 ts.tv_nsec = 0; | 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; |
898 set_timecounter(&ts); | 899 tc_setclock(&ts); |
899 } 900 splx(s); 901 return; 902 903wrong_time: 904 printf("Invalid time in real time clock.\n"); 905 printf("Check and reset the date immediately!\n"); 906} --- 245 unchanged lines hidden (view full) --- 1152 */ 1153 freq = timer_freq; 1154 error = sysctl_handle_int(oidp, &freq, sizeof(freq), req); 1155 if (error == 0 && req->newptr != NULL) { 1156 if (timer0_state != RELEASED) 1157 return (EBUSY); /* too much trouble to handle */ 1158 set_timer_freq(freq, hz); 1159 i8254_timecounter.tc_frequency = freq; | 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; |
1160 update_timecounter(&i8254_timecounter); | 1161 tc_update(&i8254_timecounter); |
1161 } 1162 return (error); 1163} 1164 1165SYSCTL_PROC(_machdep, OID_AUTO, i8254_freq, CTLTYPE_INT | CTLFLAG_RW, 1166 0, sizeof(u_int), sysctl_machdep_i8254_freq, "I", ""); 1167 1168static int --- 4 unchanged lines hidden (view full) --- 1173 1174 if (tsc_timecounter.tc_frequency == 0) 1175 return (EOPNOTSUPP); 1176 freq = tsc_freq; 1177 error = sysctl_handle_int(oidp, &freq, sizeof(freq), req); 1178 if (error == 0 && req->newptr != NULL) { 1179 tsc_freq = freq; 1180 tsc_timecounter.tc_frequency = tsc_freq; | 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; |
1181 update_timecounter(&tsc_timecounter); | 1182 tc_update(&tsc_timecounter); |
1182 } 1183 return (error); 1184} 1185 1186SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW, 1187 0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", ""); 1188 1189static unsigned --- 41 unchanged lines hidden --- | 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 --- |