pcrtc.c (55456) | pcrtc.c (58477) |
---|---|
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/pc98/cbus/pcrtc.c 55456 2000-01-05 12:35:03Z kato $ | 37 * $FreeBSD: head/sys/pc98/cbus/pcrtc.c 58477 2000-03-23 08:55:45Z kato $ |
38 */ 39 40/* 41 * Routines to handle clock hardware. 42 */ 43 44/* 45 * inittodr, settodr and support routines written --- 7 unchanged lines hidden (view full) --- 53 */ 54 55#include "opt_clock.h" 56#include "apm.h" 57 58#include <sys/param.h> 59#include <sys/systm.h> 60#include <sys/time.h> | 38 */ 39 40/* 41 * Routines to handle clock hardware. 42 */ 43 44/* 45 * inittodr, settodr and support routines written --- 7 unchanged lines hidden (view full) --- 53 */ 54 55#include "opt_clock.h" 56#include "apm.h" 57 58#include <sys/param.h> 59#include <sys/systm.h> 60#include <sys/time.h> |
61#include <sys/timetc.h> |
|
61#include <sys/kernel.h> 62#ifndef SMP 63#include <sys/lock.h> 64#endif 65#include <sys/sysctl.h> 66#include <sys/cons.h> 67 68#include <machine/clock.h> --- 889 unchanged lines hidden (view full) --- 958 printf( 959 "%d Hz differs from default of %d Hz by more than 1%%\n", 960 freq, timer_freq); 961 tsc_freq = 0; 962 } 963 964 set_timer_freq(timer_freq, hz); 965 i8254_timecounter.tc_frequency = timer_freq; | 62#include <sys/kernel.h> 63#ifndef SMP 64#include <sys/lock.h> 65#endif 66#include <sys/sysctl.h> 67#include <sys/cons.h> 68 69#include <machine/clock.h> --- 889 unchanged lines hidden (view full) --- 959 printf( 960 "%d Hz differs from default of %d Hz by more than 1%%\n", 961 freq, timer_freq); 962 tsc_freq = 0; 963 } 964 965 set_timer_freq(timer_freq, hz); 966 i8254_timecounter.tc_frequency = timer_freq; |
966 init_timecounter(&i8254_timecounter); | 967 tc_init(&i8254_timecounter); |
967 968#ifndef CLK_USE_TSC_CALIBRATION 969 if (tsc_freq != 0) { 970 if (bootverbose) 971 printf( 972"CLK_USE_TSC_CALIBRATION not specified - using old calibration method\n"); 973 tsc_freq = 0; 974 } --- 33 unchanged lines hidden (view full) --- 1008 * We don't know at this point whether APM is going to be used 1009 * or not, nor when it might be activated. Play it safe. 1010 */ 1011 return; 1012#endif /* NAPM > 0 */ 1013 1014 if (tsc_present && tsc_freq != 0 && !tsc_is_broken) { 1015 tsc_timecounter.tc_frequency = tsc_freq; | 968 969#ifndef CLK_USE_TSC_CALIBRATION 970 if (tsc_freq != 0) { 971 if (bootverbose) 972 printf( 973"CLK_USE_TSC_CALIBRATION not specified - using old calibration method\n"); 974 tsc_freq = 0; 975 } --- 33 unchanged lines hidden (view full) --- 1009 * We don't know at this point whether APM is going to be used 1010 * or not, nor when it might be activated. Play it safe. 1011 */ 1012 return; 1013#endif /* NAPM > 0 */ 1014 1015 if (tsc_present && tsc_freq != 0 && !tsc_is_broken) { 1016 tsc_timecounter.tc_frequency = tsc_freq; |
1016 init_timecounter(&tsc_timecounter); | 1017 tc_init(&tsc_timecounter); |
1017 } 1018 1019#endif /* !defined(SMP) */ 1020} 1021 1022#ifdef PC98 1023static void 1024rtc_serialcombit(int i) --- 71 unchanged lines hidden (view full) --- 1096#ifdef PC98 1097 int second, min, hour; 1098#endif 1099 1100 if (base) { 1101 s = splclock(); 1102 ts.tv_sec = base; 1103 ts.tv_nsec = 0; | 1018 } 1019 1020#endif /* !defined(SMP) */ 1021} 1022 1023#ifdef PC98 1024static void 1025rtc_serialcombit(int i) --- 71 unchanged lines hidden (view full) --- 1097#ifdef PC98 1098 int second, min, hour; 1099#endif 1100 1101 if (base) { 1102 s = splclock(); 1103 ts.tv_sec = base; 1104 ts.tv_nsec = 0; |
1104 set_timecounter(&ts); | 1105 tc_setclock(&ts); |
1105 splx(s); 1106 } 1107 1108#ifdef PC98 1109 rtc_serialcom(0x03); /* Time Read */ 1110 rtc_serialcom(0x01); /* Register shift command. */ 1111 DELAY(20); 1112 --- 65 unchanged lines hidden (view full) --- 1178 1179 sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0); 1180 1181 y = time_second - sec; 1182 if (y <= -2 || y >= 2) { 1183 /* badly off, adjust it */ 1184 ts.tv_sec = sec; 1185 ts.tv_nsec = 0; | 1106 splx(s); 1107 } 1108 1109#ifdef PC98 1110 rtc_serialcom(0x03); /* Time Read */ 1111 rtc_serialcom(0x01); /* Register shift command. */ 1112 DELAY(20); 1113 --- 65 unchanged lines hidden (view full) --- 1179 1180 sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0); 1181 1182 y = time_second - sec; 1183 if (y <= -2 || y >= 2) { 1184 /* badly off, adjust it */ 1185 ts.tv_sec = sec; 1186 ts.tv_nsec = 0; |
1186 set_timecounter(&ts); | 1187 tc_setclock(&ts); |
1187 } 1188 splx(s); 1189 return; 1190 1191wrong_time: 1192 printf("Invalid time in real time clock.\n"); 1193 printf("Check and reset the date immediately!\n"); 1194} --- 299 unchanged lines hidden (view full) --- 1494 */ 1495 freq = timer_freq; 1496 error = sysctl_handle_int(oidp, &freq, sizeof(freq), req); 1497 if (error == 0 && req->newptr != NULL) { 1498 if (timer0_state != RELEASED) 1499 return (EBUSY); /* too much trouble to handle */ 1500 set_timer_freq(freq, hz); 1501 i8254_timecounter.tc_frequency = freq; | 1188 } 1189 splx(s); 1190 return; 1191 1192wrong_time: 1193 printf("Invalid time in real time clock.\n"); 1194 printf("Check and reset the date immediately!\n"); 1195} --- 299 unchanged lines hidden (view full) --- 1495 */ 1496 freq = timer_freq; 1497 error = sysctl_handle_int(oidp, &freq, sizeof(freq), req); 1498 if (error == 0 && req->newptr != NULL) { 1499 if (timer0_state != RELEASED) 1500 return (EBUSY); /* too much trouble to handle */ 1501 set_timer_freq(freq, hz); 1502 i8254_timecounter.tc_frequency = freq; |
1502 update_timecounter(&i8254_timecounter); | 1503 tc_update(&i8254_timecounter); |
1503 } 1504 return (error); 1505} 1506 1507SYSCTL_PROC(_machdep, OID_AUTO, i8254_freq, CTLTYPE_INT | CTLFLAG_RW, 1508 0, sizeof(u_int), sysctl_machdep_i8254_freq, "I", ""); 1509 1510static int --- 4 unchanged lines hidden (view full) --- 1515 1516 if (tsc_timecounter.tc_frequency == 0) 1517 return (EOPNOTSUPP); 1518 freq = tsc_freq; 1519 error = sysctl_handle_int(oidp, &freq, sizeof(freq), req); 1520 if (error == 0 && req->newptr != NULL) { 1521 tsc_freq = freq; 1522 tsc_timecounter.tc_frequency = tsc_freq; | 1504 } 1505 return (error); 1506} 1507 1508SYSCTL_PROC(_machdep, OID_AUTO, i8254_freq, CTLTYPE_INT | CTLFLAG_RW, 1509 0, sizeof(u_int), sysctl_machdep_i8254_freq, "I", ""); 1510 1511static int --- 4 unchanged lines hidden (view full) --- 1516 1517 if (tsc_timecounter.tc_frequency == 0) 1518 return (EOPNOTSUPP); 1519 freq = tsc_freq; 1520 error = sysctl_handle_int(oidp, &freq, sizeof(freq), req); 1521 if (error == 0 && req->newptr != NULL) { 1522 tsc_freq = freq; 1523 tsc_timecounter.tc_frequency = tsc_freq; |
1523 update_timecounter(&tsc_timecounter); | 1524 tc_update(&tsc_timecounter); |
1524 } 1525 return (error); 1526} 1527 1528SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW, 1529 0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", ""); 1530 1531static unsigned --- 41 unchanged lines hidden --- | 1525 } 1526 return (error); 1527} 1528 1529SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW, 1530 0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", ""); 1531 1532static unsigned --- 41 unchanged lines hidden --- |