atrtc.c (82555) | atrtc.c (82971) |
---|---|
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 82555 2001-08-30 09:17:03Z msmith $ | 37 * $FreeBSD: head/sys/isa/atrtc.c 82971 2001-09-04 16:02:06Z iwasaki $ |
38 */ 39 40/* 41 * Routines to handle clock hardware. 42 */ 43 44/* 45 * inittodr, settodr and support routines written --- 654 unchanged lines hidden (view full) --- 700/* 701 * i8254_restore is called from apm_default_resume() to reload 702 * the countdown register. 703 * this should not be necessary but there are broken laptops that 704 * do not restore the countdown register on resume. 705 * when it happnes, it messes up the hardclock interval and system clock, 706 * which leads to the infamous "calcru: negative time" problem. 707 */ | 38 */ 39 40/* 41 * Routines to handle clock hardware. 42 */ 43 44/* 45 * inittodr, settodr and support routines written --- 654 unchanged lines hidden (view full) --- 700/* 701 * i8254_restore is called from apm_default_resume() to reload 702 * the countdown register. 703 * this should not be necessary but there are broken laptops that 704 * do not restore the countdown register on resume. 705 * when it happnes, it messes up the hardclock interval and system clock, 706 * which leads to the infamous "calcru: negative time" problem. 707 */ |
708void | 708static void |
709i8254_restore(void) 710{ 711 712 mtx_lock_spin(&clock_lock); 713 outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); 714 outb(TIMER_CNTR0, timer0_max_count & 0xff); 715 outb(TIMER_CNTR0, timer0_max_count >> 8); 716 mtx_unlock_spin(&clock_lock); 717} 718 | 709i8254_restore(void) 710{ 711 712 mtx_lock_spin(&clock_lock); 713 outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); 714 outb(TIMER_CNTR0, timer0_max_count & 0xff); 715 outb(TIMER_CNTR0, timer0_max_count >> 8); 716 mtx_unlock_spin(&clock_lock); 717} 718 |
719static void 720rtc_restore(void) 721{ 722 723 /* Reenable RTC updates and interrupts. */ 724 /* XXX locking is needed for RTC access? */ 725 writertc(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR); 726 writertc(RTC_STATUSB, rtc_statusb); 727} 728 |
|
719/* | 729/* |
730 * Restore all the timers atomically. 731 */ 732void 733timer_restore(void) 734{ 735 736 i8254_restore(); /* restore timer_freq and hz */ 737 rtc_restore(); /* reenable RTC interrupts */ 738} 739 740/* |
|
720 * Initialize 8254 timer 0 early so that it can be used in DELAY(). 721 * XXX initialization of other timers is unintentionally left blank. 722 */ 723void 724startrtclock() 725{ 726 u_int delta, freq; 727 --- 555 unchanged lines hidden --- | 741 * Initialize 8254 timer 0 early so that it can be used in DELAY(). 742 * XXX initialization of other timers is unintentionally left blank. 743 */ 744void 745startrtclock() 746{ 747 u_int delta, freq; 748 --- 555 unchanged lines hidden --- |