summaryrefslogtreecommitdiff
path: root/sys/arch/i386/isa
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1996-09-09 04:02:45 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1996-09-09 04:02:45 +0000
commit7392d7a58d9a4d8d21ebd4e01aab4ed2b296a148 (patch)
tree2caff1ba227ee832ca2af98dd056418377b91fc6 /sys/arch/i386/isa
parent72838af0bafea3307643d28ad9e2d817ba272aa8 (diff)
Add seperate profiling/statistics clock running at 1024/128 Hz, using the
RTC in periodic interrupt mode
Diffstat (limited to 'sys/arch/i386/isa')
-rw-r--r--sys/arch/i386/isa/clock.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/sys/arch/i386/isa/clock.c b/sys/arch/i386/isa/clock.c
index d033bef12e1..ed748c2ab6f 100644
--- a/sys/arch/i386/isa/clock.c
+++ b/sys/arch/i386/isa/clock.c
@@ -112,7 +112,6 @@ int clockintr __P((void *));
int gettick __P((void));
void sysbeepstop __P((void *));
void sysbeep __P((int, int));
-void rtcinit __P((void));
int rtcget __P((mc_todregs *));
void rtcput __P((mc_todregs *));
static int yeartoday __P((int));
@@ -183,6 +182,21 @@ clockintr(arg)
}
int
+rtcintr(arg)
+ void *arg;
+{
+ struct clockframe *frame = arg; /* not strictly neccecary */
+ u_int stat;
+
+ stat = mc146818_read(NULL, MC_REGC);
+ if (stat & MC_REGC_PF) {
+ statclock(frame);
+ return -1;
+ }
+ return 0;
+}
+
+int
gettick()
{
u_char lo, hi;
@@ -331,17 +345,25 @@ void
calibrate_cyclecounter()
{
unsigned long long count, last_count;
+#ifdef NTP
+ extern long time_precision;
+#endif
__asm __volatile(".byte 0xf, 0x31" : "=A" (last_count));
delay(1000000);
__asm __volatile(".byte 0xf, 0x31" : "=A" (count));
pentium_mhz = ((count - last_count) + 500000) / 1000000;
+#ifdef NTP
+ time_precision = 1; /* XXX */
+#endif
}
#endif
void
cpu_initclocks()
{
+ stathz = 128;
+ profhz = 1024;
/*
* XXX If you're doing strange things with multiple clocks, you might
@@ -349,28 +371,17 @@ cpu_initclocks()
*/
(void)isa_intr_establish(NULL, 0, IST_PULSE, IPL_CLOCK, clockintr,
0, "clock");
-}
-
-void
-rtcinit()
-{
- static int first_rtcopen_ever = 1;
+ (void)isa_intr_establish(NULL, 8, IST_PULSE, IPL_CLOCK, rtcintr,
+ 0, "rtc");
- if (!first_rtcopen_ever)
- return;
- first_rtcopen_ever = 0;
-
- mc146818_write(NULL, MC_REGA, /* XXX softc */
- MC_BASE_32_KHz | MC_RATE_1024_Hz);
- mc146818_write(NULL, MC_REGB, MC_REGB_24HR); /* XXX softc */
+ mc146818_write(NULL, MC_REGA, MC_BASE_32_KHz | MC_RATE_128_Hz);
+ mc146818_write(NULL, MC_REGB, MC_REGB_24HR | MC_REGB_PIE);
}
int
rtcget(regs)
mc_todregs *regs;
{
-
- rtcinit();
if ((mc146818_read(NULL, MC_REGD) & MC_REGD_VRT) == 0) /* XXX softc */
return (-1);
MC146818_GETTOD(NULL, regs); /* XXX softc */
@@ -381,8 +392,6 @@ void
rtcput(regs)
mc_todregs *regs;
{
-
- rtcinit();
MC146818_PUTTOD(NULL, regs); /* XXX softc */
}
@@ -552,4 +561,8 @@ void
setstatclockrate(arg)
int arg;
{
+ if (arg == stathz)
+ mc146818_write(NULL, MC_REGA, MC_BASE_32_KHz | MC_RATE_128_Hz);
+ else
+ mc146818_write(NULL, MC_REGA, MC_BASE_32_KHz | MC_RATE_1024_Hz);
}