atrtc.c (170802) | atrtc.c (171553) |
---|---|
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 --- 19 unchanged lines hidden (view full) --- 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 33 */ 34 35#include <sys/cdefs.h> | 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 --- 19 unchanged lines hidden (view full) --- 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 33 */ 34 35#include <sys/cdefs.h> |
36__FBSDID("$FreeBSD: head/sys/isa/atrtc.c 170802 2007-06-15 22:58:14Z peter $"); | 36__FBSDID("$FreeBSD: head/sys/isa/atrtc.c 171553 2007-07-23 09:42:32Z dwmalone $"); |
37 38/* 39 * Routines to handle clock hardware. 40 */ 41 42/* 43 * inittodr, settodr and support routines written 44 * by Christoph Robitschko <chmr@edvz.tu-graz.ac.at> --- 629 unchanged lines hidden (view full) --- 674 ts.tv_sec = base; 675 ts.tv_nsec = 0; 676 tc_setclock(&ts); 677 splx(s); 678 } 679 680 /* Look if we have a RTC present and the time is valid */ 681 if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) { | 37 38/* 39 * Routines to handle clock hardware. 40 */ 41 42/* 43 * inittodr, settodr and support routines written 44 * by Christoph Robitschko <chmr@edvz.tu-graz.ac.at> --- 629 unchanged lines hidden (view full) --- 674 ts.tv_sec = base; 675 ts.tv_nsec = 0; 676 tc_setclock(&ts); 677 splx(s); 678 } 679 680 /* Look if we have a RTC present and the time is valid */ 681 if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) { |
682 printf("Invalid time in real time clock.\n"); 683 printf("Check and reset the date immediately!\n"); | 682 printf("Invalid time in clock: check and reset the date!\n"); |
684 return; 685 } 686 687 /* wait for time update to complete */ 688 /* If RTCSA_TUP is zero, we have at least 244us before next update */ 689 s = splhigh(); 690 while (rtcin(RTC_STATUSA) & RTCSA_TUP) { 691 splx(s); --- 7 unchanged lines hidden (view full) --- 699 ct.dow = readrtc(RTC_WDAY) - 1; 700 ct.mon = readrtc(RTC_MONTH); 701 ct.year = readrtc(RTC_YEAR); 702#ifdef USE_RTC_CENTURY 703 ct.year += readrtc(RTC_CENTURY) * 100; 704#else 705 ct.year += 2000; 706#endif | 683 return; 684 } 685 686 /* wait for time update to complete */ 687 /* If RTCSA_TUP is zero, we have at least 244us before next update */ 688 s = splhigh(); 689 while (rtcin(RTC_STATUSA) & RTCSA_TUP) { 690 splx(s); --- 7 unchanged lines hidden (view full) --- 698 ct.dow = readrtc(RTC_WDAY) - 1; 699 ct.mon = readrtc(RTC_MONTH); 700 ct.year = readrtc(RTC_YEAR); 701#ifdef USE_RTC_CENTURY 702 ct.year += readrtc(RTC_CENTURY) * 100; 703#else 704 ct.year += 2000; 705#endif |
707 clock_ct_to_ts(&ct, &ts); | 706 /* Should we set dow = -1 because some clocks don't set it correctly? */ 707 if (clock_ct_to_ts(&ct, &ts)) { 708 printf("Invalid time in clock: check and reset the date!\n"); 709 return; 710 } |
708 ts.tv_sec += utc_offset(); 709 tc_setclock(&ts); 710} 711 712/* 713 * Write system time back to RTC 714 */ 715void --- 317 unchanged lines hidden --- | 711 ts.tv_sec += utc_offset(); 712 tc_setclock(&ts); 713} 714 715/* 716 * Write system time back to RTC 717 */ 718void --- 317 unchanged lines hidden --- |