- add apm to the GENERIC kernel (disabled by default), and add some comments

regarding apm to LINT
- Disabled the statistics clock on machines which have an APM BIOS and
  have the options "APM_BROKEN_STATCLOCK" enabled (which is default
  in GENERIC now)
- move around some of the code in clock.c dealing with the rtc to make
  it more obvios the effects of disabling the statistics clock

Reviewed by:	bde
This commit is contained in:
Nate Williams 1996-04-22 19:40:28 +00:00
parent 003aaef883
commit e597b4972e
14 changed files with 171 additions and 34 deletions

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91 * from: @(#)clock.c 7.2 (Berkeley) 5/12/91
* $Id: clock.c,v 1.55 1996/04/05 03:36:31 ache Exp $ * $Id: clock.c,v 1.56 1996/04/05 18:56:10 ache Exp $
*/ */
/* /*
@ -103,6 +103,7 @@ long long i586_ctr_bias;
long long i586_last_tick; long long i586_last_tick;
unsigned long i586_avg_tick; unsigned long i586_avg_tick;
#endif #endif
int statclock_disable;
u_int stat_imask = SWI_CLOCK_MASK; u_int stat_imask = SWI_CLOCK_MASK;
int timer0_max_count; int timer0_max_count;
u_int timer0_overflow_threshold; u_int timer0_overflow_threshold;
@ -123,6 +124,7 @@ static u_int hardclock_max_count;
static void (*new_function) __P((struct clockframe *frame)); static void (*new_function) __P((struct clockframe *frame));
static u_int new_rate; static u_int new_rate;
static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF; static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
static u_char rtc_statusb = RTCSB_24HR | RTCSB_PINTR;
static char timer0_state = 0; static char timer0_state = 0;
static char timer2_state = 0; static char timer2_state = 0;
static void (*timer_func) __P((struct clockframe *frame)) = hardclock; static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
@ -559,7 +561,7 @@ resettodr()
writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */ writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
/* Reenable RTC updates and interrupts. */ /* Reenable RTC updates and interrupts. */
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR); writertc(RTC_STATUSB, rtc_statusb);
} }
/* /*
@ -570,8 +572,20 @@ cpu_initclocks()
{ {
int diag; int diag;
stathz = RTC_NOPROFRATE; if (statclock_disable) {
profhz = RTC_PROFRATE; /*
* The stat interrupt mask is different without the
* statistics clock. Also, don't set the interrupt
* flag which would normally cause the RTC to generate
* interrupts.
*/
stat_imask = HWI_MASK | SWI_MASK;
rtc_statusb = RTCSB_24HR;
} else {
/* Setting stathz to nonzero early helps avoid races. */
stathz = RTC_NOPROFRATE;
profhz = RTC_PROFRATE;
}
/* Finish initializing 8253 timer 0. */ /* Finish initializing 8253 timer 0. */
register_intr(/* irq */ 0, /* XXX id */ 0, /* flags */ 0, register_intr(/* irq */ 0, /* XXX id */ 0, /* flags */ 0,
@ -591,6 +605,10 @@ cpu_initclocks()
/* Initialize RTC. */ /* Initialize RTC. */
writertc(RTC_STATUSA, rtc_statusa); writertc(RTC_STATUSA, rtc_statusa);
writertc(RTC_STATUSB, RTCSB_24HR); writertc(RTC_STATUSB, RTCSB_24HR);
/* Don't bother enabling the statistics clock. */
if (statclock_disable)
return;
diag = rtcin(RTC_DIAG); diag = rtcin(RTC_DIAG);
if (diag != 0) if (diag != 0)
printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS); printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
@ -598,7 +616,7 @@ cpu_initclocks()
/* XXX */ (inthand2_t *)rtcintr, &stat_imask, /* XXX */ (inthand2_t *)rtcintr, &stat_imask,
/* unit */ 0); /* unit */ 0);
INTREN(IRQ8); INTREN(IRQ8);
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR); writertc(RTC_STATUSB, rtc_statusb);
} }
void void

View File

@ -1,7 +1,7 @@
# #
# GENERIC -- Generic machine with WD/AHx/NCR/BTx family disks # GENERIC -- Generic machine with WD/AHx/NCR/BTx family disks
# #
# $Id: GENERIC,v 1.65 1996/04/10 23:03:36 jkh Exp $ # $Id: GENERIC,v 1.66 1996/04/18 04:02:30 nate Exp $
# #
machine "i386" machine "i386"
@ -92,6 +92,12 @@ device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr
# Mandatory, don't remove # Mandatory, don't remove
device npx0 at isa? port "IO_NPX" irq 13 vector npxintr device npx0 at isa? port "IO_NPX" irq 13 vector npxintr
#
# Laptop support (see LINT for more options)
#
device apm0 at isa? disable # Advanced Power Management
options APM_BROKEN_STATCLOCK # Workaround some buggy APM BIOS
device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr
device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr
device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr

View File

@ -3,7 +3,7 @@
* Garrett Wollman, September 1994. * Garrett Wollman, September 1994.
* This file is in the public domain. * This file is in the public domain.
* *
* $Id: clock.h,v 1.10 1996/03/31 04:05:17 bde Exp $ * $Id: clock.h,v 1.11 1996/04/05 03:36:20 ache Exp $
*/ */
#ifndef _MACHINE_CLOCK_H_ #ifndef _MACHINE_CLOCK_H_
@ -54,6 +54,7 @@
*/ */
extern int adjkerntz; extern int adjkerntz;
extern int disable_rtc_set; extern int disable_rtc_set;
extern int statclock_disable;
extern int wall_cmos_clock; extern int wall_cmos_clock;
#if defined(I586_CPU) || defined(I686_CPU) #if defined(I586_CPU) || defined(I686_CPU)

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91 * from: @(#)clock.c 7.2 (Berkeley) 5/12/91
* $Id: clock.c,v 1.55 1996/04/05 03:36:31 ache Exp $ * $Id: clock.c,v 1.56 1996/04/05 18:56:10 ache Exp $
*/ */
/* /*
@ -103,6 +103,7 @@ long long i586_ctr_bias;
long long i586_last_tick; long long i586_last_tick;
unsigned long i586_avg_tick; unsigned long i586_avg_tick;
#endif #endif
int statclock_disable;
u_int stat_imask = SWI_CLOCK_MASK; u_int stat_imask = SWI_CLOCK_MASK;
int timer0_max_count; int timer0_max_count;
u_int timer0_overflow_threshold; u_int timer0_overflow_threshold;
@ -123,6 +124,7 @@ static u_int hardclock_max_count;
static void (*new_function) __P((struct clockframe *frame)); static void (*new_function) __P((struct clockframe *frame));
static u_int new_rate; static u_int new_rate;
static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF; static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
static u_char rtc_statusb = RTCSB_24HR | RTCSB_PINTR;
static char timer0_state = 0; static char timer0_state = 0;
static char timer2_state = 0; static char timer2_state = 0;
static void (*timer_func) __P((struct clockframe *frame)) = hardclock; static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
@ -559,7 +561,7 @@ resettodr()
writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */ writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
/* Reenable RTC updates and interrupts. */ /* Reenable RTC updates and interrupts. */
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR); writertc(RTC_STATUSB, rtc_statusb);
} }
/* /*
@ -570,8 +572,20 @@ cpu_initclocks()
{ {
int diag; int diag;
stathz = RTC_NOPROFRATE; if (statclock_disable) {
profhz = RTC_PROFRATE; /*
* The stat interrupt mask is different without the
* statistics clock. Also, don't set the interrupt
* flag which would normally cause the RTC to generate
* interrupts.
*/
stat_imask = HWI_MASK | SWI_MASK;
rtc_statusb = RTCSB_24HR;
} else {
/* Setting stathz to nonzero early helps avoid races. */
stathz = RTC_NOPROFRATE;
profhz = RTC_PROFRATE;
}
/* Finish initializing 8253 timer 0. */ /* Finish initializing 8253 timer 0. */
register_intr(/* irq */ 0, /* XXX id */ 0, /* flags */ 0, register_intr(/* irq */ 0, /* XXX id */ 0, /* flags */ 0,
@ -591,6 +605,10 @@ cpu_initclocks()
/* Initialize RTC. */ /* Initialize RTC. */
writertc(RTC_STATUSA, rtc_statusa); writertc(RTC_STATUSA, rtc_statusa);
writertc(RTC_STATUSB, RTCSB_24HR); writertc(RTC_STATUSB, RTCSB_24HR);
/* Don't bother enabling the statistics clock. */
if (statclock_disable)
return;
diag = rtcin(RTC_DIAG); diag = rtcin(RTC_DIAG);
if (diag != 0) if (diag != 0)
printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS); printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
@ -598,7 +616,7 @@ cpu_initclocks()
/* XXX */ (inthand2_t *)rtcintr, &stat_imask, /* XXX */ (inthand2_t *)rtcintr, &stat_imask,
/* unit */ 0); /* unit */ 0);
INTREN(IRQ8); INTREN(IRQ8);
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR); writertc(RTC_STATUSB, rtc_statusb);
} }
void void

View File

@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in # LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can. # as much of the source tree as it can.
# #
# $Id: LINT,v 1.248 1996/04/03 00:28:40 gpalmer Exp $ # $Id: LINT,v 1.249 1996/04/11 06:19:44 scrappy Exp $
# #
# NB: You probably don't want to try running a kernel built from this # NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from # file. Instead, you should start from GENERIC, and add options from
@ -739,6 +739,14 @@ device pca0 at isa? port IO_TIMER1 tty
# tw: TW-523 power line interface for use with X-10 home control products # tw: TW-523 power line interface for use with X-10 home control products
# si: Specialix SI/XIO 4-32 port terminal multiplexor # si: Specialix SI/XIO 4-32 port terminal multiplexor
#
# Notes on APM
# Some APM implementations will not work with the `statistics clock'
# enabled, so it's disabled by default if the APM driver is enabled.
# However, this is not true for all laptops. Try removing the option
# APM_BROKEN_STATCLOCK and see if suspend/resume work
#
# #
# Notes on the spigot: # Notes on the spigot:
# The video spigot is at 0xad6. This port address can not be changed. # The video spigot is at 0xad6. This port address can not be changed.
@ -775,6 +783,7 @@ device ctx0 at isa? port 0x230 iomem 0xd0000
device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000 vector spigintr device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000 vector spigintr
device qcam0 at isa? port "IO_LPT3" tty device qcam0 at isa? port "IO_LPT3" tty
device apm0 at isa? device apm0 at isa?
options APM_BROKEN_STATCLOCK
device gp0 at isa? port 0x2c0 tty device gp0 at isa? port 0x2c0 tty
device gsc0 at isa? port "IO_GSC1" tty drq 3 device gsc0 at isa? port "IO_GSC1" tty drq 3
device joy0 at isa? port "IO_GAME" device joy0 at isa? port "IO_GAME"

View File

@ -14,7 +14,7 @@
* *
* Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) * Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
* *
* $Id: apm.c,v 1.37 1996/03/28 14:28:00 scrappy Exp $ * $Id: apm.c,v 1.38 1996/04/18 19:21:47 nate Exp $
*/ */
#include "apm.h" #include "apm.h"
@ -617,6 +617,9 @@ apmprobe(struct isa_device *dvp)
printf("apm: 32-bit connection error.\n"); printf("apm: 32-bit connection error.\n");
return 0; return 0;
} }
#ifdef APM_BROKEN_STATCLOCK
statclock_disable = 1;
#endif
return -1; return -1;
} }

View File

@ -14,7 +14,7 @@
* *
* Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) * Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
* *
* $Id: apm.c,v 1.37 1996/03/28 14:28:00 scrappy Exp $ * $Id: apm.c,v 1.38 1996/04/18 19:21:47 nate Exp $
*/ */
#include "apm.h" #include "apm.h"
@ -617,6 +617,9 @@ apmprobe(struct isa_device *dvp)
printf("apm: 32-bit connection error.\n"); printf("apm: 32-bit connection error.\n");
return 0; return 0;
} }
#ifdef APM_BROKEN_STATCLOCK
statclock_disable = 1;
#endif
return -1; return -1;
} }

View File

@ -1,7 +1,7 @@
# #
# GENERIC -- Generic machine with WD/AHx/NCR/BTx family disks # GENERIC -- Generic machine with WD/AHx/NCR/BTx family disks
# #
# $Id: GENERIC,v 1.65 1996/04/10 23:03:36 jkh Exp $ # $Id: GENERIC,v 1.66 1996/04/18 04:02:30 nate Exp $
# #
machine "i386" machine "i386"
@ -92,6 +92,12 @@ device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr
# Mandatory, don't remove # Mandatory, don't remove
device npx0 at isa? port "IO_NPX" irq 13 vector npxintr device npx0 at isa? port "IO_NPX" irq 13 vector npxintr
#
# Laptop support (see LINT for more options)
#
device apm0 at isa? disable # Advanced Power Management
options APM_BROKEN_STATCLOCK # Workaround some buggy APM BIOS
device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr
device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr
device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr

View File

@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in # LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can. # as much of the source tree as it can.
# #
# $Id: LINT,v 1.248 1996/04/03 00:28:40 gpalmer Exp $ # $Id: LINT,v 1.249 1996/04/11 06:19:44 scrappy Exp $
# #
# NB: You probably don't want to try running a kernel built from this # NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from # file. Instead, you should start from GENERIC, and add options from
@ -739,6 +739,14 @@ device pca0 at isa? port IO_TIMER1 tty
# tw: TW-523 power line interface for use with X-10 home control products # tw: TW-523 power line interface for use with X-10 home control products
# si: Specialix SI/XIO 4-32 port terminal multiplexor # si: Specialix SI/XIO 4-32 port terminal multiplexor
#
# Notes on APM
# Some APM implementations will not work with the `statistics clock'
# enabled, so it's disabled by default if the APM driver is enabled.
# However, this is not true for all laptops. Try removing the option
# APM_BROKEN_STATCLOCK and see if suspend/resume work
#
# #
# Notes on the spigot: # Notes on the spigot:
# The video spigot is at 0xad6. This port address can not be changed. # The video spigot is at 0xad6. This port address can not be changed.
@ -775,6 +783,7 @@ device ctx0 at isa? port 0x230 iomem 0xd0000
device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000 vector spigintr device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000 vector spigintr
device qcam0 at isa? port "IO_LPT3" tty device qcam0 at isa? port "IO_LPT3" tty
device apm0 at isa? device apm0 at isa?
options APM_BROKEN_STATCLOCK
device gp0 at isa? port 0x2c0 tty device gp0 at isa? port 0x2c0 tty
device gsc0 at isa? port "IO_GSC1" tty drq 3 device gsc0 at isa? port "IO_GSC1" tty drq 3
device joy0 at isa? port "IO_GAME" device joy0 at isa? port "IO_GAME"

View File

@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in # LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can. # as much of the source tree as it can.
# #
# $Id: LINT,v 1.248 1996/04/03 00:28:40 gpalmer Exp $ # $Id: LINT,v 1.249 1996/04/11 06:19:44 scrappy Exp $
# #
# NB: You probably don't want to try running a kernel built from this # NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from # file. Instead, you should start from GENERIC, and add options from
@ -739,6 +739,14 @@ device pca0 at isa? port IO_TIMER1 tty
# tw: TW-523 power line interface for use with X-10 home control products # tw: TW-523 power line interface for use with X-10 home control products
# si: Specialix SI/XIO 4-32 port terminal multiplexor # si: Specialix SI/XIO 4-32 port terminal multiplexor
#
# Notes on APM
# Some APM implementations will not work with the `statistics clock'
# enabled, so it's disabled by default if the APM driver is enabled.
# However, this is not true for all laptops. Try removing the option
# APM_BROKEN_STATCLOCK and see if suspend/resume work
#
# #
# Notes on the spigot: # Notes on the spigot:
# The video spigot is at 0xad6. This port address can not be changed. # The video spigot is at 0xad6. This port address can not be changed.
@ -775,6 +783,7 @@ device ctx0 at isa? port 0x230 iomem 0xd0000
device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000 vector spigintr device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000 vector spigintr
device qcam0 at isa? port "IO_LPT3" tty device qcam0 at isa? port "IO_LPT3" tty
device apm0 at isa? device apm0 at isa?
options APM_BROKEN_STATCLOCK
device gp0 at isa? port 0x2c0 tty device gp0 at isa? port 0x2c0 tty
device gsc0 at isa? port "IO_GSC1" tty drq 3 device gsc0 at isa? port "IO_GSC1" tty drq 3
device joy0 at isa? port "IO_GAME" device joy0 at isa? port "IO_GAME"

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91 * from: @(#)clock.c 7.2 (Berkeley) 5/12/91
* $Id: clock.c,v 1.55 1996/04/05 03:36:31 ache Exp $ * $Id: clock.c,v 1.56 1996/04/05 18:56:10 ache Exp $
*/ */
/* /*
@ -103,6 +103,7 @@ long long i586_ctr_bias;
long long i586_last_tick; long long i586_last_tick;
unsigned long i586_avg_tick; unsigned long i586_avg_tick;
#endif #endif
int statclock_disable;
u_int stat_imask = SWI_CLOCK_MASK; u_int stat_imask = SWI_CLOCK_MASK;
int timer0_max_count; int timer0_max_count;
u_int timer0_overflow_threshold; u_int timer0_overflow_threshold;
@ -123,6 +124,7 @@ static u_int hardclock_max_count;
static void (*new_function) __P((struct clockframe *frame)); static void (*new_function) __P((struct clockframe *frame));
static u_int new_rate; static u_int new_rate;
static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF; static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
static u_char rtc_statusb = RTCSB_24HR | RTCSB_PINTR;
static char timer0_state = 0; static char timer0_state = 0;
static char timer2_state = 0; static char timer2_state = 0;
static void (*timer_func) __P((struct clockframe *frame)) = hardclock; static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
@ -559,7 +561,7 @@ resettodr()
writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */ writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
/* Reenable RTC updates and interrupts. */ /* Reenable RTC updates and interrupts. */
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR); writertc(RTC_STATUSB, rtc_statusb);
} }
/* /*
@ -570,8 +572,20 @@ cpu_initclocks()
{ {
int diag; int diag;
stathz = RTC_NOPROFRATE; if (statclock_disable) {
profhz = RTC_PROFRATE; /*
* The stat interrupt mask is different without the
* statistics clock. Also, don't set the interrupt
* flag which would normally cause the RTC to generate
* interrupts.
*/
stat_imask = HWI_MASK | SWI_MASK;
rtc_statusb = RTCSB_24HR;
} else {
/* Setting stathz to nonzero early helps avoid races. */
stathz = RTC_NOPROFRATE;
profhz = RTC_PROFRATE;
}
/* Finish initializing 8253 timer 0. */ /* Finish initializing 8253 timer 0. */
register_intr(/* irq */ 0, /* XXX id */ 0, /* flags */ 0, register_intr(/* irq */ 0, /* XXX id */ 0, /* flags */ 0,
@ -591,6 +605,10 @@ cpu_initclocks()
/* Initialize RTC. */ /* Initialize RTC. */
writertc(RTC_STATUSA, rtc_statusa); writertc(RTC_STATUSA, rtc_statusa);
writertc(RTC_STATUSB, RTCSB_24HR); writertc(RTC_STATUSB, RTCSB_24HR);
/* Don't bother enabling the statistics clock. */
if (statclock_disable)
return;
diag = rtcin(RTC_DIAG); diag = rtcin(RTC_DIAG);
if (diag != 0) if (diag != 0)
printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS); printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
@ -598,7 +616,7 @@ cpu_initclocks()
/* XXX */ (inthand2_t *)rtcintr, &stat_imask, /* XXX */ (inthand2_t *)rtcintr, &stat_imask,
/* unit */ 0); /* unit */ 0);
INTREN(IRQ8); INTREN(IRQ8);
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR); writertc(RTC_STATUSB, rtc_statusb);
} }
void void

View File

@ -3,7 +3,7 @@
* Garrett Wollman, September 1994. * Garrett Wollman, September 1994.
* This file is in the public domain. * This file is in the public domain.
* *
* $Id: clock.h,v 1.10 1996/03/31 04:05:17 bde Exp $ * $Id: clock.h,v 1.11 1996/04/05 03:36:20 ache Exp $
*/ */
#ifndef _MACHINE_CLOCK_H_ #ifndef _MACHINE_CLOCK_H_
@ -54,6 +54,7 @@
*/ */
extern int adjkerntz; extern int adjkerntz;
extern int disable_rtc_set; extern int disable_rtc_set;
extern int statclock_disable;
extern int wall_cmos_clock; extern int wall_cmos_clock;
#if defined(I586_CPU) || defined(I686_CPU) #if defined(I586_CPU) || defined(I686_CPU)

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91 * from: @(#)clock.c 7.2 (Berkeley) 5/12/91
* $Id: clock.c,v 1.55 1996/04/05 03:36:31 ache Exp $ * $Id: clock.c,v 1.56 1996/04/05 18:56:10 ache Exp $
*/ */
/* /*
@ -103,6 +103,7 @@ long long i586_ctr_bias;
long long i586_last_tick; long long i586_last_tick;
unsigned long i586_avg_tick; unsigned long i586_avg_tick;
#endif #endif
int statclock_disable;
u_int stat_imask = SWI_CLOCK_MASK; u_int stat_imask = SWI_CLOCK_MASK;
int timer0_max_count; int timer0_max_count;
u_int timer0_overflow_threshold; u_int timer0_overflow_threshold;
@ -123,6 +124,7 @@ static u_int hardclock_max_count;
static void (*new_function) __P((struct clockframe *frame)); static void (*new_function) __P((struct clockframe *frame));
static u_int new_rate; static u_int new_rate;
static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF; static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
static u_char rtc_statusb = RTCSB_24HR | RTCSB_PINTR;
static char timer0_state = 0; static char timer0_state = 0;
static char timer2_state = 0; static char timer2_state = 0;
static void (*timer_func) __P((struct clockframe *frame)) = hardclock; static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
@ -559,7 +561,7 @@ resettodr()
writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */ writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
/* Reenable RTC updates and interrupts. */ /* Reenable RTC updates and interrupts. */
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR); writertc(RTC_STATUSB, rtc_statusb);
} }
/* /*
@ -570,8 +572,20 @@ cpu_initclocks()
{ {
int diag; int diag;
stathz = RTC_NOPROFRATE; if (statclock_disable) {
profhz = RTC_PROFRATE; /*
* The stat interrupt mask is different without the
* statistics clock. Also, don't set the interrupt
* flag which would normally cause the RTC to generate
* interrupts.
*/
stat_imask = HWI_MASK | SWI_MASK;
rtc_statusb = RTCSB_24HR;
} else {
/* Setting stathz to nonzero early helps avoid races. */
stathz = RTC_NOPROFRATE;
profhz = RTC_PROFRATE;
}
/* Finish initializing 8253 timer 0. */ /* Finish initializing 8253 timer 0. */
register_intr(/* irq */ 0, /* XXX id */ 0, /* flags */ 0, register_intr(/* irq */ 0, /* XXX id */ 0, /* flags */ 0,
@ -591,6 +605,10 @@ cpu_initclocks()
/* Initialize RTC. */ /* Initialize RTC. */
writertc(RTC_STATUSA, rtc_statusa); writertc(RTC_STATUSA, rtc_statusa);
writertc(RTC_STATUSB, RTCSB_24HR); writertc(RTC_STATUSB, RTCSB_24HR);
/* Don't bother enabling the statistics clock. */
if (statclock_disable)
return;
diag = rtcin(RTC_DIAG); diag = rtcin(RTC_DIAG);
if (diag != 0) if (diag != 0)
printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS); printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
@ -598,7 +616,7 @@ cpu_initclocks()
/* XXX */ (inthand2_t *)rtcintr, &stat_imask, /* XXX */ (inthand2_t *)rtcintr, &stat_imask,
/* unit */ 0); /* unit */ 0);
INTREN(IRQ8); INTREN(IRQ8);
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR); writertc(RTC_STATUSB, rtc_statusb);
} }
void void

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91 * from: @(#)clock.c 7.2 (Berkeley) 5/12/91
* $Id: clock.c,v 1.55 1996/04/05 03:36:31 ache Exp $ * $Id: clock.c,v 1.56 1996/04/05 18:56:10 ache Exp $
*/ */
/* /*
@ -103,6 +103,7 @@ long long i586_ctr_bias;
long long i586_last_tick; long long i586_last_tick;
unsigned long i586_avg_tick; unsigned long i586_avg_tick;
#endif #endif
int statclock_disable;
u_int stat_imask = SWI_CLOCK_MASK; u_int stat_imask = SWI_CLOCK_MASK;
int timer0_max_count; int timer0_max_count;
u_int timer0_overflow_threshold; u_int timer0_overflow_threshold;
@ -123,6 +124,7 @@ static u_int hardclock_max_count;
static void (*new_function) __P((struct clockframe *frame)); static void (*new_function) __P((struct clockframe *frame));
static u_int new_rate; static u_int new_rate;
static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF; static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
static u_char rtc_statusb = RTCSB_24HR | RTCSB_PINTR;
static char timer0_state = 0; static char timer0_state = 0;
static char timer2_state = 0; static char timer2_state = 0;
static void (*timer_func) __P((struct clockframe *frame)) = hardclock; static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
@ -559,7 +561,7 @@ resettodr()
writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */ writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
/* Reenable RTC updates and interrupts. */ /* Reenable RTC updates and interrupts. */
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR); writertc(RTC_STATUSB, rtc_statusb);
} }
/* /*
@ -570,8 +572,20 @@ cpu_initclocks()
{ {
int diag; int diag;
stathz = RTC_NOPROFRATE; if (statclock_disable) {
profhz = RTC_PROFRATE; /*
* The stat interrupt mask is different without the
* statistics clock. Also, don't set the interrupt
* flag which would normally cause the RTC to generate
* interrupts.
*/
stat_imask = HWI_MASK | SWI_MASK;
rtc_statusb = RTCSB_24HR;
} else {
/* Setting stathz to nonzero early helps avoid races. */
stathz = RTC_NOPROFRATE;
profhz = RTC_PROFRATE;
}
/* Finish initializing 8253 timer 0. */ /* Finish initializing 8253 timer 0. */
register_intr(/* irq */ 0, /* XXX id */ 0, /* flags */ 0, register_intr(/* irq */ 0, /* XXX id */ 0, /* flags */ 0,
@ -591,6 +605,10 @@ cpu_initclocks()
/* Initialize RTC. */ /* Initialize RTC. */
writertc(RTC_STATUSA, rtc_statusa); writertc(RTC_STATUSA, rtc_statusa);
writertc(RTC_STATUSB, RTCSB_24HR); writertc(RTC_STATUSB, RTCSB_24HR);
/* Don't bother enabling the statistics clock. */
if (statclock_disable)
return;
diag = rtcin(RTC_DIAG); diag = rtcin(RTC_DIAG);
if (diag != 0) if (diag != 0)
printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS); printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
@ -598,7 +616,7 @@ cpu_initclocks()
/* XXX */ (inthand2_t *)rtcintr, &stat_imask, /* XXX */ (inthand2_t *)rtcintr, &stat_imask,
/* unit */ 0); /* unit */ 0);
INTREN(IRQ8); INTREN(IRQ8);
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR); writertc(RTC_STATUSB, rtc_statusb);
} }
void void