Date: Mon, 2 May 2016 16:14:55 +0000 (UTC) From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= <royger@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298928 - in head/sys: isa x86/isa Message-ID: <201605021614.u42GEtuj052305@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: royger Date: Mon May 2 16:14:55 2016 New Revision: 298928 URL: https://svnweb.freebsd.org/changeset/base/298928 Log: atrtc: export function to set RTC This is going to be used by the Xen clock on Dom0 in order to set the RTC of the host. The current logic in atrtc_settime is moved to atrtc_set and the unused device_t parameter is removed from the atrtc_set function call so it can be safely used by other callers. Sponsored by: Citrix Systems R&D Reviewed by: kib, jhb Differential revision: https://reviews.freebsd.org/D6067 Modified: head/sys/isa/rtc.h head/sys/x86/isa/atrtc.c Modified: head/sys/isa/rtc.h ============================================================================== --- head/sys/isa/rtc.h Mon May 2 16:13:55 2016 (r298927) +++ head/sys/isa/rtc.h Mon May 2 16:14:55 2016 (r298928) @@ -117,6 +117,7 @@ extern int atrtcclock_disable; int rtcin(int reg); void atrtc_restore(void); void writertc(int reg, u_char val); +void atrtc_set(struct timespec *ts); #endif #endif /* _I386_ISA_RTC_H_ */ Modified: head/sys/x86/isa/atrtc.c ============================================================================== --- head/sys/x86/isa/atrtc.c Mon May 2 16:13:55 2016 (r298927) +++ head/sys/x86/isa/atrtc.c Mon May 2 16:14:55 2016 (r298928) @@ -151,6 +151,33 @@ atrtc_restore(void) rtcin(RTC_INTR); } +void +atrtc_set(struct timespec *ts) +{ + struct clocktime ct; + + clock_ts_to_ct(ts, &ct); + + /* Disable RTC updates and interrupts. */ + writertc(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR); + + writertc(RTC_SEC, bin2bcd(ct.sec)); /* Write back Seconds */ + writertc(RTC_MIN, bin2bcd(ct.min)); /* Write back Minutes */ + writertc(RTC_HRS, bin2bcd(ct.hour)); /* Write back Hours */ + + writertc(RTC_WDAY, ct.dow + 1); /* Write back Weekday */ + writertc(RTC_DAY, bin2bcd(ct.day)); /* Write back Day */ + writertc(RTC_MONTH, bin2bcd(ct.mon)); /* Write back Month */ + writertc(RTC_YEAR, bin2bcd(ct.year % 100)); /* Write back Year */ +#ifdef USE_RTC_CENTURY + writertc(RTC_CENTURY, bin2bcd(ct.year / 100)); /* ... and Century */ +#endif + + /* Re-enable RTC updates and interrupts. */ + writertc(RTC_STATUSB, rtc_statusb); + rtcin(RTC_INTR); +} + /********************************************************************** * RTC driver for subr_rtc */ @@ -297,28 +324,8 @@ atrtc_resume(device_t dev) static int atrtc_settime(device_t dev __unused, struct timespec *ts) { - struct clocktime ct; - - clock_ts_to_ct(ts, &ct); - - /* Disable RTC updates and interrupts. */ - writertc(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR); - - writertc(RTC_SEC, bin2bcd(ct.sec)); /* Write back Seconds */ - writertc(RTC_MIN, bin2bcd(ct.min)); /* Write back Minutes */ - writertc(RTC_HRS, bin2bcd(ct.hour)); /* Write back Hours */ - writertc(RTC_WDAY, ct.dow + 1); /* Write back Weekday */ - writertc(RTC_DAY, bin2bcd(ct.day)); /* Write back Day */ - writertc(RTC_MONTH, bin2bcd(ct.mon)); /* Write back Month */ - writertc(RTC_YEAR, bin2bcd(ct.year % 100)); /* Write back Year */ -#ifdef USE_RTC_CENTURY - writertc(RTC_CENTURY, bin2bcd(ct.year / 100)); /* ... and Century */ -#endif - - /* Reenable RTC updates and interrupts. */ - writertc(RTC_STATUSB, rtc_statusb); - rtcin(RTC_INTR); + atrtc_set(ts); return (0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605021614.u42GEtuj052305>