From owner-freebsd-mobile Wed Oct 27 10:12:10 1999 Delivered-To: freebsd-mobile@freebsd.org Received: from tasogare.imasy.or.jp (tasogare.imasy.or.jp [202.227.24.5]) by hub.freebsd.org (Postfix) with ESMTP id 1A10814E01; Wed, 27 Oct 1999 10:12:01 -0700 (PDT) (envelope-from iwasaki@jp.FreeBSD.org) Received: from localhost (isdnb26.imasy.or.jp [202.227.24.154]) by tasogare.imasy.or.jp (8.9.3+3.2W/3.7W-tasogare/smtpfeed 1.01) with ESMTP id CAA28493; Thu, 28 Oct 1999 02:11:48 +0900 (JST) (envelope-from iwasaki@jp.FreeBSD.org) Message-Id: <199910271711.CAA28493@tasogare.imasy.or.jp> To: mike@smith.net.au Cc: iwasaki@jp.FreeBSD.org, steveo@iol.ie, freebsd-mobile@freebsd.org, cvs-committers@freebsd.org Subject: Re: FreeBSD on a Compaq 1690 In-Reply-To: Your message of "Wed, 27 Oct 1999 09:49:03 -0700" <199910271649.JAA03917@dingo.cdrom.com> References: <199910271649.JAA03917@dingo.cdrom.com> X-Mailer: Mew version 1.93 on Emacs 19.34 / Mule 2.3 (SUETSUMUHANA) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 28 Oct 1999 02:11:44 +0900 From: Mitsuru IWASAKI X-Dispatcher: imput version 980905(IM100) Lines: 84 Sender: owner-freebsd-mobile@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Hi, > > Linux people also are doing also reloading the countdown register of > > i8254 after suspend in the same way. It couldn't hurt, I think. > > > > #ifdef INIT_TIMER_AFTER_SUSPEND > > ... > > Don't make it conditional on yet another obscure define. It should be > the default behaviour. Sure, I think so too. My previous mail showed the equivalent code in linux kernel :-) The patch I'm going to commit is following. Index: sys/i386/apm/apm.c =================================================================== RCS file: /home/ncvs/src/sys/i386/apm/apm.c,v retrieving revision 1.77.2.13 diff -u -r1.77.2.13 apm.c --- apm.c 1999/10/13 22:06:46 1.77.2.13 +++ apm.c 1999/10/23 21:03:17 @@ -450,6 +450,7 @@ /* modified for adjkerntz */ pl = splsoftclock(); + i8254_restore(); /* restore timer_freq and hz */ inittodr(0); /* adjust time to RTC */ microtime(&resume_time); getmicrotime(&tmp_time); Index: sys/i386/include/clock.h =================================================================== RCS file: /home/ncvs/src/sys/i386/include/clock.h,v retrieving revision 1.34.2.2 diff -u -r1.34.2.2 clock.h --- clock.h 1999/08/29 16:06:23 1.34.2.2 +++ clock.h 1999/10/23 21:02:24 @@ -44,6 +44,7 @@ int release_timer1 __P((void)); #endif int sysbeep __P((int pitch, int period)); +void i8254_restore __P((void)); #endif /* KERNEL */ Index: sys/i386/isa/clock.c =================================================================== RCS file: /home/ncvs/src/sys/i386/isa/clock.c,v retrieving revision 1.129.2.4 diff -u -r1.129.2.4 clock.c --- clock.c 1999/08/29 16:07:14 1.129.2.4 +++ clock.c 1999/10/23 21:20:18 @@ -703,6 +703,28 @@ } /* + * 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. */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-mobile" in the body of the message