diff options
| author | KATO Takenori <kato@FreeBSD.org> | 1998-02-13 09:32:17 +0000 |
|---|---|---|
| committer | KATO Takenori <kato@FreeBSD.org> | 1998-02-13 09:32:17 +0000 |
| commit | a7378a5844612b770e8c2786705abd8a17656c91 (patch) | |
| tree | be9f4f3b56f111b8ff48c8e2356659d4a85fbd1f | |
| parent | b0fc6ff1dd5b9174a0afcd9a10be8ec511856c73 (diff) | |
Notes
| -rw-r--r-- | sys/pc98/cbus/clock.c | 67 | ||||
| -rw-r--r-- | sys/pc98/cbus/pcrtc.c | 67 | ||||
| -rw-r--r-- | sys/pc98/pc98/clock.c | 67 |
3 files changed, 99 insertions, 102 deletions
diff --git a/sys/pc98/cbus/clock.c b/sys/pc98/cbus/clock.c index 05cba07d2e5c..aacdf0af31e8 100644 --- a/sys/pc98/cbus/clock.c +++ b/sys/pc98/cbus/clock.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.40 1998/01/28 12:25:06 kato Exp $ + * $Id: clock.c,v 1.41 1998/02/09 15:05:42 kato Exp $ */ /* @@ -209,9 +209,9 @@ clkintr(struct clockframe frame) case ACQUIRED: if ((timer0_prescaler_count += timer0_max_count) >= hardclock_max_count) { + timer0_prescaler_count -= hardclock_max_count; hardclock(&frame); setdelayed(); - timer0_prescaler_count -= hardclock_max_count; } break; @@ -233,50 +233,41 @@ clkintr(struct clockframe frame) case RELEASE_PENDING: if ((timer0_prescaler_count += timer0_max_count) >= hardclock_max_count) { - hardclock(&frame); - setdelayed(); - timer0_max_count = hardclock_max_count; - timer0_overflow_threshold = - timer0_max_count - TIMER0_LATCH_COUNT; - 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); - enable_intr(); + timer0_prescaler_count -= hardclock_max_count; /* * See microtime.s for this magic. */ #ifdef PC98 #ifndef AUTO_CLOCK #ifndef PC98_8M - time.tv_usec += (6667 * - (timer0_prescaler_count - hardclock_max_count)) - >> 14; + time.tv_usec += (6667 * timer0_prescaler_count) >> 14; #else /* PC98_8M */ - time.tv_usec += (16411 * - (timer0_prescaler_count - hardclock_max_count)) - >> 15; + time.tv_usec += (16411 * timer0_prescaler_count) >> 15; #endif /* PC98_8M */ #else /* AUTO_CLOCK */ if (pc98_machine_type & M_8M) { /* PC98_8M */ - time.tv_usec += (16411 * - (timer0_prescaler_count - - hardclock_max_count)) >> 15; + time.tv_usec += (16411 * timer0_prescaler_count) >> 15; } else { - time.tv_usec += (6667 * - (timer0_prescaler_count - - hardclock_max_count)) >> 14; + time.tv_usec += (6667 * timer0_prescaler_count) >> 14; } #endif /* AUTO_CLOCK */ #else /* IBM-PC */ - time.tv_usec += (27465 * - (timer0_prescaler_count - hardclock_max_count)) - >> 15; -#endif /* PC98 */ + time.tv_usec += (27465 * timer0_prescaler_count) >> 15; +#endif if (time.tv_usec >= 1000000) time.tv_usec -= 1000000; + hardclock(&frame); + setdelayed(); + timer0_max_count = hardclock_max_count; + timer0_overflow_threshold = + timer0_max_count - TIMER0_LATCH_COUNT; + 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); + enable_intr(); timer0_prescaler_count = 0; timer_func = hardclock; timer0_state = RELEASED; @@ -639,8 +630,11 @@ rtcin(reg) static __inline void writertc(u_char reg, u_char val) { + inb(0x84); outb(IO_RTC, reg); + inb(0x84); outb(IO_RTC + 1, val); + inb(0x84); /* XXX work around wrong order in rtcin() */ } static __inline int @@ -767,15 +761,20 @@ static void set_timer_freq(u_int freq, int intr_freq) { u_long ef; + int new_timer0_max_count; ef = read_eflags(); disable_intr(); timer_freq = freq; - timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq); - timer0_overflow_threshold = timer0_max_count - TIMER0_LATCH_COUNT; - outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); - outb(TIMER_CNTR0, timer0_max_count & 0xff); - outb(TIMER_CNTR0, timer0_max_count >> 8); + new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq); + if (new_timer0_max_count != timer0_max_count) { + timer0_max_count = new_timer0_max_count; + timer0_overflow_threshold = timer0_max_count - + TIMER0_LATCH_COUNT; + 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); } diff --git a/sys/pc98/cbus/pcrtc.c b/sys/pc98/cbus/pcrtc.c index 05cba07d2e5c..aacdf0af31e8 100644 --- a/sys/pc98/cbus/pcrtc.c +++ b/sys/pc98/cbus/pcrtc.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.40 1998/01/28 12:25:06 kato Exp $ + * $Id: clock.c,v 1.41 1998/02/09 15:05:42 kato Exp $ */ /* @@ -209,9 +209,9 @@ clkintr(struct clockframe frame) case ACQUIRED: if ((timer0_prescaler_count += timer0_max_count) >= hardclock_max_count) { + timer0_prescaler_count -= hardclock_max_count; hardclock(&frame); setdelayed(); - timer0_prescaler_count -= hardclock_max_count; } break; @@ -233,50 +233,41 @@ clkintr(struct clockframe frame) case RELEASE_PENDING: if ((timer0_prescaler_count += timer0_max_count) >= hardclock_max_count) { - hardclock(&frame); - setdelayed(); - timer0_max_count = hardclock_max_count; - timer0_overflow_threshold = - timer0_max_count - TIMER0_LATCH_COUNT; - 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); - enable_intr(); + timer0_prescaler_count -= hardclock_max_count; /* * See microtime.s for this magic. */ #ifdef PC98 #ifndef AUTO_CLOCK #ifndef PC98_8M - time.tv_usec += (6667 * - (timer0_prescaler_count - hardclock_max_count)) - >> 14; + time.tv_usec += (6667 * timer0_prescaler_count) >> 14; #else /* PC98_8M */ - time.tv_usec += (16411 * - (timer0_prescaler_count - hardclock_max_count)) - >> 15; + time.tv_usec += (16411 * timer0_prescaler_count) >> 15; #endif /* PC98_8M */ #else /* AUTO_CLOCK */ if (pc98_machine_type & M_8M) { /* PC98_8M */ - time.tv_usec += (16411 * - (timer0_prescaler_count - - hardclock_max_count)) >> 15; + time.tv_usec += (16411 * timer0_prescaler_count) >> 15; } else { - time.tv_usec += (6667 * - (timer0_prescaler_count - - hardclock_max_count)) >> 14; + time.tv_usec += (6667 * timer0_prescaler_count) >> 14; } #endif /* AUTO_CLOCK */ #else /* IBM-PC */ - time.tv_usec += (27465 * - (timer0_prescaler_count - hardclock_max_count)) - >> 15; -#endif /* PC98 */ + time.tv_usec += (27465 * timer0_prescaler_count) >> 15; +#endif if (time.tv_usec >= 1000000) time.tv_usec -= 1000000; + hardclock(&frame); + setdelayed(); + timer0_max_count = hardclock_max_count; + timer0_overflow_threshold = + timer0_max_count - TIMER0_LATCH_COUNT; + 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); + enable_intr(); timer0_prescaler_count = 0; timer_func = hardclock; timer0_state = RELEASED; @@ -639,8 +630,11 @@ rtcin(reg) static __inline void writertc(u_char reg, u_char val) { + inb(0x84); outb(IO_RTC, reg); + inb(0x84); outb(IO_RTC + 1, val); + inb(0x84); /* XXX work around wrong order in rtcin() */ } static __inline int @@ -767,15 +761,20 @@ static void set_timer_freq(u_int freq, int intr_freq) { u_long ef; + int new_timer0_max_count; ef = read_eflags(); disable_intr(); timer_freq = freq; - timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq); - timer0_overflow_threshold = timer0_max_count - TIMER0_LATCH_COUNT; - outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); - outb(TIMER_CNTR0, timer0_max_count & 0xff); - outb(TIMER_CNTR0, timer0_max_count >> 8); + new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq); + if (new_timer0_max_count != timer0_max_count) { + timer0_max_count = new_timer0_max_count; + timer0_overflow_threshold = timer0_max_count - + TIMER0_LATCH_COUNT; + 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); } diff --git a/sys/pc98/pc98/clock.c b/sys/pc98/pc98/clock.c index 05cba07d2e5c..aacdf0af31e8 100644 --- a/sys/pc98/pc98/clock.c +++ b/sys/pc98/pc98/clock.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.40 1998/01/28 12:25:06 kato Exp $ + * $Id: clock.c,v 1.41 1998/02/09 15:05:42 kato Exp $ */ /* @@ -209,9 +209,9 @@ clkintr(struct clockframe frame) case ACQUIRED: if ((timer0_prescaler_count += timer0_max_count) >= hardclock_max_count) { + timer0_prescaler_count -= hardclock_max_count; hardclock(&frame); setdelayed(); - timer0_prescaler_count -= hardclock_max_count; } break; @@ -233,50 +233,41 @@ clkintr(struct clockframe frame) case RELEASE_PENDING: if ((timer0_prescaler_count += timer0_max_count) >= hardclock_max_count) { - hardclock(&frame); - setdelayed(); - timer0_max_count = hardclock_max_count; - timer0_overflow_threshold = - timer0_max_count - TIMER0_LATCH_COUNT; - 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); - enable_intr(); + timer0_prescaler_count -= hardclock_max_count; /* * See microtime.s for this magic. */ #ifdef PC98 #ifndef AUTO_CLOCK #ifndef PC98_8M - time.tv_usec += (6667 * - (timer0_prescaler_count - hardclock_max_count)) - >> 14; + time.tv_usec += (6667 * timer0_prescaler_count) >> 14; #else /* PC98_8M */ - time.tv_usec += (16411 * - (timer0_prescaler_count - hardclock_max_count)) - >> 15; + time.tv_usec += (16411 * timer0_prescaler_count) >> 15; #endif /* PC98_8M */ #else /* AUTO_CLOCK */ if (pc98_machine_type & M_8M) { /* PC98_8M */ - time.tv_usec += (16411 * - (timer0_prescaler_count - - hardclock_max_count)) >> 15; + time.tv_usec += (16411 * timer0_prescaler_count) >> 15; } else { - time.tv_usec += (6667 * - (timer0_prescaler_count - - hardclock_max_count)) >> 14; + time.tv_usec += (6667 * timer0_prescaler_count) >> 14; } #endif /* AUTO_CLOCK */ #else /* IBM-PC */ - time.tv_usec += (27465 * - (timer0_prescaler_count - hardclock_max_count)) - >> 15; -#endif /* PC98 */ + time.tv_usec += (27465 * timer0_prescaler_count) >> 15; +#endif if (time.tv_usec >= 1000000) time.tv_usec -= 1000000; + hardclock(&frame); + setdelayed(); + timer0_max_count = hardclock_max_count; + timer0_overflow_threshold = + timer0_max_count - TIMER0_LATCH_COUNT; + 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); + enable_intr(); timer0_prescaler_count = 0; timer_func = hardclock; timer0_state = RELEASED; @@ -639,8 +630,11 @@ rtcin(reg) static __inline void writertc(u_char reg, u_char val) { + inb(0x84); outb(IO_RTC, reg); + inb(0x84); outb(IO_RTC + 1, val); + inb(0x84); /* XXX work around wrong order in rtcin() */ } static __inline int @@ -767,15 +761,20 @@ static void set_timer_freq(u_int freq, int intr_freq) { u_long ef; + int new_timer0_max_count; ef = read_eflags(); disable_intr(); timer_freq = freq; - timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq); - timer0_overflow_threshold = timer0_max_count - TIMER0_LATCH_COUNT; - outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); - outb(TIMER_CNTR0, timer0_max_count & 0xff); - outb(TIMER_CNTR0, timer0_max_count >> 8); + new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq); + if (new_timer0_max_count != timer0_max_count) { + timer0_max_count = new_timer0_max_count; + timer0_overflow_threshold = timer0_max_count - + TIMER0_LATCH_COUNT; + 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); } |
