summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-01-15 00:10:25 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-01-15 00:10:25 +0000
commit39d33b60c503129bb65722ea76ed9220cbd0dfe4 (patch)
treec9aa7103bc158a53b4e73407589dc105208a186d /sys/arch
parentc3c14af105691d6310872766d76fd7a5657ee994 (diff)
Do not put HZ in the kernel configuration file anymore, and let the kernel
decide by itself: Quadra-style machines with A/UX style interrupts and clock at level 6 will use 100Hz now, while other machines will remain at 60Hz.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/mac68k/conf/GENERIC3
-rw-r--r--sys/arch/mac68k/conf/RAMDISK3
-rw-r--r--sys/arch/mac68k/mac68k/clock.c52
-rw-r--r--sys/arch/mac68k/mac68k/clockreg.h58
4 files changed, 45 insertions, 71 deletions
diff --git a/sys/arch/mac68k/conf/GENERIC b/sys/arch/mac68k/conf/GENERIC
index e3be16927c1..00b37025e68 100644
--- a/sys/arch/mac68k/conf/GENERIC
+++ b/sys/arch/mac68k/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.45 2006/01/13 19:36:41 miod Exp $
+# $OpenBSD: GENERIC,v 1.46 2006/01/15 00:10:22 miod Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -14,7 +14,6 @@ include "../../../conf/GENERIC"
maxusers 32 # estimated number of users
# Mac-specific options
-option HZ=60 # Macs like 60Hz
option M68040
option M68030
option M68020 # Must have 68851 PMMU
diff --git a/sys/arch/mac68k/conf/RAMDISK b/sys/arch/mac68k/conf/RAMDISK
index baf08b67f5e..fa9b42d18f5 100644
--- a/sys/arch/mac68k/conf/RAMDISK
+++ b/sys/arch/mac68k/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.21 2006/01/13 19:36:41 miod Exp $
+# $OpenBSD: RAMDISK,v 1.22 2006/01/15 00:10:22 miod Exp $
#
# RAMDISK - bsd.rd configuration file (non-SBC version)
@@ -27,7 +27,6 @@ pseudo-device bpfilter 1 # packet filter
option DDB
# Mac-specific options
-option HZ=60 # Macs like 60Hz
option M68040
option M68030
option M68020 # Must have 68851 PMMU
diff --git a/sys/arch/mac68k/mac68k/clock.c b/sys/arch/mac68k/mac68k/clock.c
index 686852d7b23..07ba4a2128a 100644
--- a/sys/arch/mac68k/mac68k/clock.c
+++ b/sys/arch/mac68k/mac68k/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.20 2006/01/09 22:59:35 miod Exp $ */
+/* $OpenBSD: clock.c,v 1.21 2006/01/15 00:10:24 miod Exp $ */
/* $NetBSD: clock.c,v 1.39 1999/11/05 19:14:56 scottr Exp $ */
/*
@@ -89,7 +89,6 @@
#include <machine/cpu.h>
#include <mac68k/mac68k/pram.h>
-#include <mac68k/mac68k/clockreg.h>
#include <machine/viareg.h>
#include <dev/clock_subr.h>
@@ -100,6 +99,9 @@ int clock_debug = 0;
int rtclock_intr(void *);
+u_int clk_interval;
+u_int8_t clk_inth, clk_intl;
+
#define DIFF19041970 2082844800
/*
@@ -116,19 +118,51 @@ int rtclock_intr(void *);
void
startrtclock()
{
+#ifndef HZ
+ /*
+ * By default, if HZ is not specified, use 60 Hz, unless we are
+ * using A/UX style interrupts. We then need to readjust values
+ * based on a 100Hz value in param.c.
+ */
+ if (mac68k_machine.aux_interrupts == 0) {
+#define HZ_60 60
+ hz = HZ_60;
+ tick = 1000000 / HZ_60;
+ tickadj = 240000 / (60 * HZ_60);/* can adjust 240ms in 60s */
+ }
+#endif
+
+ /*
+ * Calculate clocks needed to hit hz ticks/sec.
+ *
+ * The VIA clock speed is 1.2766us, so the timer value needed is:
+ *
+ * 1 1,000,000us 1
+ * CLK_INTERVAL = -------- * ----------- * ------
+ e 1.2766us 1s hz
+ *
+ * While it may be tempting to simplify the following further,
+ * we can run into integer overflow problems.
+ * Also note: do *not* define HZ to be less than 12; overflow
+ * will occur, yielding invalid results.
+ */
+ clk_interval = ((100000000UL / hz) * 100) / 12766;
+ clk_inth = ((clk_interval >> 8) & 0xff);
+ clk_intl = (clk_interval & 0xff);
+
/* be certain clock interrupts are off */
via_reg(VIA1, vIER) = V1IF_T1;
/* set timer latch */
via_reg(VIA1, vACR) |= ACR_T1LATCH;
- /* set VIA timer 1 latch to 60 Hz (100 Hz) */
- via_reg(VIA1, vT1L) = CLK_INTL;
- via_reg(VIA1, vT1LH) = CLK_INTH;
+ /* set VIA timer 1 latch to ``hz'' Hz */
+ via_reg(VIA1, vT1L) = clk_intl;
+ via_reg(VIA1, vT1LH) = clk_inth;
- /* set VIA timer 1 counter started for 60(100) Hz */
- via_reg(VIA1, vT1C) = CLK_INTL;
- via_reg(VIA1, vT1CH) = CLK_INTH;
+ /* set VIA timer 1 counter started for ``hz'' Hz */
+ via_reg(VIA1, vT1C) = clk_intl;
+ via_reg(VIA1, vT1CH) = clk_inth;
}
void
@@ -173,7 +207,7 @@ clkread()
high = high2;
/* return count left in timer / 1.27 */
- return ((CLK_INTERVAL - (high << 8) - low) * 10000 / CLK_RATE);
+ return ((clk_interval - (high << 8) - low) * 10000 / CLK_RATE);
}
static u_long ugmt_2_pramt(u_long);
diff --git a/sys/arch/mac68k/mac68k/clockreg.h b/sys/arch/mac68k/mac68k/clockreg.h
deleted file mode 100644
index 6c6186c850c..00000000000
--- a/sys/arch/mac68k/mac68k/clockreg.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* $OpenBSD: clockreg.h,v 1.7 2006/01/09 22:59:35 miod Exp $ */
-/* $NetBSD: clockreg.h,v 1.5 1996/04/01 05:16:52 scottr Exp $ */
-
-/*-
- * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
- * Michael L. Finch, Bradley A. Grantham, and
- * Lawrence A. Kesteloot
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the Alice Group.
- * 4. The names of the Alice Group or any of its members may not be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-/*
- * Clock defines and things.
- * MacII clock characteristics used.
- */
-
-/*
- * Calculate clocks needed to hit HZ ticks/sec.
- *
- * The VIA clock speed is 1.2766us, so the timer value needed is:
- *
- * 1 1,000,000us 1
- * CLK_INTERVAL = -------- * ----------- * ------
- * 1.2766us 1s HZ
- *
- * While it may be tempting to simplify the following further, we can run
- * into integer overflow problems. Also note: do *not* define HZ to be
- * less than 12; overflow will occur, yielding invalid results.
- */
-#define CLK_INTERVAL ((int)((((100000000L / HZ) * 100) / 12766)))
-
-#define CLK_INTH ((CLK_INTERVAL >> 8) & 0xff) /* high byte */
-#define CLK_INTL (CLK_INTERVAL & 0xff) /* low byte */