diff options
author | iwasaki <iwasaki@FreeBSD.org> | 1999-10-30 14:56:01 +0000 |
---|---|---|
committer | iwasaki <iwasaki@FreeBSD.org> | 1999-10-30 14:56:01 +0000 |
commit | 945a25b48913c2f1a8b8f0aadcb902c3189ed927 (patch) | |
tree | 44779f7a28dcd79760060b54d492be07d1a097e2 /sys/amd64/isa | |
parent | 437d3feb752ab5ec3128771f54f8a684bf186e02 (diff) | |
download | FreeBSD-src-945a25b48913c2f1a8b8f0aadcb902c3189ed927.zip FreeBSD-src-945a25b48913c2f1a8b8f0aadcb902c3189ed927.tar.gz |
i8254_restore is called from apm_default_resume() to reload
the countdown register.
this should not be necessary but there are broken laptops that
do not restore the countdown register on resume.
when it happnes, it messes up the hardclock interval and system clock,
which leads to the infamous "calcru: negative time" problem.
Submitted by: kjc, iwasaki
Reviewed by: Steve O'Hara-Smith <steveo@eircom.net> and committers.
Obtained from: PAO3
Diffstat (limited to 'sys/amd64/isa')
-rw-r--r-- | sys/amd64/isa/clock.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index c659741..4d393b0 100644 --- a/sys/amd64/isa/clock.c +++ b/sys/amd64/isa/clock.c @@ -691,6 +691,28 @@ set_timer_freq(u_int freq, int intr_freq) } /* + * i8254_restore is called from apm_default_resume() to reload + * the countdown register. + * this should not be necessary but there are broken laptops that + * do not restore the countdown register on resume. + * when it happnes, it messes up the hardclock interval and system clock, + * which leads to the infamous "calcru: negative time" problem. + */ +void +i8254_restore(void) +{ + u_long ef; + + ef = read_eflags(); + disable_intr(); + outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); + outb(TIMER_CNTR0, timer0_max_count & 0xff); + outb(TIMER_CNTR0, timer0_max_count >> 8); + CLOCK_UNLOCK(); + write_eflags(ef); +} + +/* * Initialize 8254 timer 0 early so that it can be used in DELAY(). * XXX initialization of other timers is unintentionally left blank. */ |