--- Net2/arch/i386/isa/clock.c 2018/04/24 18:11:58 1.1.1.2 +++ Net2/arch/i386/isa/clock.c 2018/04/24 18:19:59 1.1.1.3 @@ -33,20 +33,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)clock.c 7.2 (Berkeley) 5/12/91 - * - * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE - * -------------------- ----- ---------------------- - * CURRENT PATCH LEVEL: 3 00082 - * -------------------- ----- ---------------------- - * - * 14 Aug 92 Arne Henrik Juul Added code in the kernel to - * allow for DST in the BIOS. - * 17 Jan 93 Bruce Evans Fixed leap year and second - * calculations - * 01 Feb 93 Julian Elischer Added code to for the cpu - * speed independent spinwait() - * function, (used by scsi and others) + * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 + * clock.c,v 1.11 1993/07/06 06:06:28 deraadt Exp */ /* @@ -62,10 +50,15 @@ #include "i386/isa/rtc.h" #include "i386/isa/timerreg.h" +void spinwait __P((int)); + +/* XXX all timezone stuff should be moved out of the kernel */ +#if 1 #define DAYST 119 #define DAYEN 303 -#define XTALSPEED 1193182 +#endif +void startrtclock() { int s; @@ -73,8 +66,10 @@ startrtclock() { to find the cpu speed */ /* initialize 8253 clock */ outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT); - outb (IO_TIMER1, XTALSPEED/hz); - outb (IO_TIMER1, (XTALSPEED/hz)/256); + + /* Correct rounding will buy us a better precision in timekeeping */ + outb (IO_TIMER1, TIMER_DIV(hz)%256); + outb (IO_TIMER1, TIMER_DIV(hz)/256); /* initialize brain-dead battery powered clock */ outb (IO_RTC, RTC_STATUSA); @@ -110,11 +105,10 @@ findcpuspeed() /* Formula for delaycount is : * (loopcount * timer clock speed)/ (counter ticks * 1000) */ - delaycount = (FIRST_GUESS * (XTALSPEED/1000)) / (0xffff-remainder); + delaycount = (FIRST_GUESS * TIMER_DIV(1000)) / (0xffff-remainder); } - /* convert 2 digit BCD number */ bcd(i) int i; @@ -192,6 +186,7 @@ inittodr(base) sec += bcd(rtcin(RTC_MIN)) * 60; /* minutes */ sec += bcd(rtcin(RTC_SEC)); /* seconds */ +#ifdef DAYST /* XXX off by one? Need to calculate DST on SUNDAY */ /* Perhaps we should have the RTC hold GMT time to save */ /* us the bother of converting. */ @@ -199,6 +194,7 @@ inittodr(base) if ((yd >= DAYST) && ( yd <= DAYEN)) { sec -= 60*60; } +#endif sec += tz.tz_minuteswest * 60; time.tv_sec = sec; @@ -233,6 +229,7 @@ test_inittodr(base) /* * Restart the clock. */ +void resettodr() { } @@ -240,24 +237,20 @@ resettodr() /* * Wire clock interrupt in. */ -#define V(s) __CONCAT(V, s) -extern V(clk)(); +#define VEC(s) __CONCAT(X, s) +extern VEC(clk)(); +void enablertclock() { + setidt(ICU_OFFSET+0, &VEC(clk), SDT_SYS386IGT, SEL_KPL); INTREN(IRQ0); - setidt(ICU_OFFSET+0, &V(clk), SDT_SYS386IGT, SEL_KPL); - splnone(); } - - - +/* + * Delay for some number of milliseconds. + */ +void spinwait(millisecs) -int millisecs; /* number of milliseconds to delay */ + int millisecs; { - int i, j; - - for (i=0;i