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 * $Id: clock.c,v 1.117 1998/03/16 10:06:58 phk Exp $ |
38 */ 39 40/* 41 * Routines to handle clock hardware. 42 */ 43 44/* 45 * inittodr, settodr and support routines written --- 186 unchanged lines hidden (view full) --- 232 timer_func = new_function; 233 timer0_state = ACQUIRED; 234 break; 235 236 case RELEASE_PENDING: 237 if ((timer0_prescaler_count += timer0_max_count) 238 >= hardclock_max_count) { 239 timer0_prescaler_count -= hardclock_max_count; |
240#ifdef FIXME |
241 /* |
242 * XXX: This magic doesn't work, but It shouldn't be 243 * needed now anyway since we will not be able to 244 * aquire the i8254 if it is used for timecounting. 245 */ 246 /* |
247 * See microtime.s for this magic. 248 */ 249 time.tv_usec += (27465 * timer0_prescaler_count) >> 15; 250 if (time.tv_usec >= 1000000) 251 time.tv_usec -= 1000000; |
252#endif |
253 hardclock(&frame); 254 setdelayed(); 255 timer0_max_count = hardclock_max_count; 256 disable_intr(); 257 outb(TIMER_MODE, 258 TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); 259 outb(TIMER_CNTR0, timer0_max_count & 0xff); 260 outb(TIMER_CNTR0, timer0_max_count >> 8); --- 585 unchanged lines hidden (view full) --- 846 readrtc(RTC_HRS)) * 60 + 847 readrtc(RTC_MIN)) * 60 + 848 readrtc(RTC_SEC)); 849 /* sec now contains the number of seconds, since Jan 1 1970, 850 in the local time zone */ 851 852 sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0); 853 |
854 y = time_second - sec; |
855 if (y <= -2 || y >= 2) { 856 /* badly off, adjust it */ 857 s = splclock(); 858 ts.tv_sec = sec; 859 ts.tv_nsec = 0; 860 set_timecounter(&ts); 861 splx(s); 862 } --- 12 unchanged lines hidden (view full) --- 875{ 876 unsigned long tm; 877 int y, m, s; 878 879 if (disable_rtc_set) 880 return; 881 882 s = splclock(); |
883 tm = time_second; |
884 splx(s); 885 886 /* Disable RTC updates and interrupts. */ 887 writertc(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR); 888 889 /* Calculate local time to put in RTC */ 890 891 tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0); --- 284 unchanged lines hidden --- |