Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/nathanw_sa]: src/sys/arch/algor Rewrite the interrupt handling code:
details: https://anonhg.NetBSD.org/src/rev/aa79422307d8
branches: nathanw_sa
changeset: 504724:aa79422307d8
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sun Jun 10 05:26:59 2001 +0000
description:
Rewrite the interrupt handling code:
- Compute the number of CPU pipeline cycles per second using the
mc146818.
- Use the COMPARE interrupt for the hardclock interrupt.
- Collapse all interrupt priorities into a single priority, and use
the CPU interrupt inputs to determine the interrupt source (local
device, PCI device, ISA device, etc.)
This allows us to have interrupt sharing.
diffstat:
sys/arch/algor/algor/autoconf.c | 83 ++++++++++
sys/arch/algor/algor/clock.c | 288 ++++++++++++++++++++++++++++++++++++++
sys/arch/algor/algor/clockvar.h | 66 ++++++++
sys/arch/algor/dev/mcclock.c | 137 ++++++++++++++++++
sys/arch/algor/include/autoconf.h | 55 +++++++
5 files changed, 629 insertions(+), 0 deletions(-)
diffs (truncated from 649 to 300 lines):
diff -r a97f7983e42d -r aa79422307d8 sys/arch/algor/algor/autoconf.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/algor/algor/autoconf.c Sun Jun 10 05:26:59 2001 +0000
@@ -0,0 +1,83 @@
+/* $NetBSD: autoconf.c,v 1.2.8.2 2001/06/10 05:26:59 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * 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 NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+#include "opt_algor_p4032.h"
+#include "opt_algor_p5064.h"
+#include "opt_algor_p6032.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/reboot.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+#include <machine/autoconf.h>
+#include <machine/intr.h>
+
+struct device *booted_device;
+int booted_partition;
+
+void
+cpu_configure(void)
+{
+
+ intr_init();
+
+ (void) splhigh();
+ if (config_rootfound("mainbus", "mainbus") == 0)
+ panic("no mainbus found");
+ (void) spl0();
+}
+
+void
+cpu_rootconf(void)
+{
+
+ setroot(booted_device, booted_partition);
+}
+
+void
+device_register(struct device *dev, void *aux)
+{
+
+ /*
+ * We don't ever know the boot device. But that's because the
+ * firmware only loads from the network or the parallel port.
+ */
+}
diff -r a97f7983e42d -r aa79422307d8 sys/arch/algor/algor/clock.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/algor/algor/clock.c Sun Jun 10 05:26:59 2001 +0000
@@ -0,0 +1,288 @@
+/* $NetBSD: clock.c,v 1.2.8.2 2001/06/10 05:26:59 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department and Ralph Campbell.
+ *
+ * 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 University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
+ *
+ * from: Utah Hdr: clock.c 1.18 91/01/21
+ *
+ * @(#)clock.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
+
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.2.8.2 2001/06/10 05:26:59 thorpej Exp $");
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/sched.h>
+
+#include <machine/autoconf.h>
+
+#include <mips/locore.h>
+
+#include <dev/clock_subr.h>
+
+#include <algor/algor/clockvar.h>
+
+#define MINYEAR 1998 /* "today" */
+#define UNIX_YEAR_OFFSET 0
+
+struct device *clockdev;
+const struct clockfns *clockfns;
+int clockinitted;
+
+void
+clockattach(struct device *dev, const struct clockfns *fns)
+{
+
+ /*
+ * Just bookkeeping.
+ */
+
+ if (clockfns != NULL)
+ panic("clockattach: multiple clocks");
+ clockdev = dev;
+ clockfns = fns;
+}
+
+/*
+ * Machine-dependent clock routines.
+ *
+ * Startrtclock restarts the real-time clock, which provides
+ * hardclock interrupts to kern_clock.c.
+ *
+ * Inittodr initializes the time of day hardware which provides
+ * date functions. Its primary function is to use some file
+ * system information in case the hardare clock lost state.
+ *
+ * Resettodr restores the time of day hardware after a time change.
+ */
+
+/*
+ * Start the real-time and statistics clocks. Leave stathz 0 since there
+ * are no other timers available.
+ */
+void
+cpu_initclocks(void)
+{
+ u_int32_t cycles;
+
+ if (clockfns == NULL)
+ panic("cpu_initclocks: no clock attached");
+
+ cycles = mips3_cp0_count_read();
+ mips3_cp0_compare_write(cycles + cycles_per_hz);
+
+ tick = 1000000 / hz; /* number of microseconds between interrupts */
+ tickfix = 1000000 - (hz * tick);
+ if (tickfix) {
+ int ftp;
+
+ ftp = min(ffs(tickfix), ffs(hz));
+ tickfix >>= (ftp - 1);
+ tickfixinterval = hz >> (ftp - 1);
+ }
+
+ /*
+ * Get the clock (well, the TODR, anyway) started.
+ */
+ (*clockfns->cf_init)(clockdev);
+}
+
+/*
+ * We assume newhz is either stathz or profhz, and that neither will
+ * change after being set up above. Could recalculate intervals here
+ * but that would be a drag.
+ */
+void
+setstatclockrate(int newhz)
+{
+
+ /* nothing we can do */
+}
+
+/*
+ * Initialze the time of day register, based on the time base which is, e.g.
+ * from a filesystem. Base provides the time to within six months,
+ * and the time of year clock (if any) provides the rest.
+ */
+void
+inittodr(time_t base)
+{
+ struct clocktime ct;
+ int year;
+ struct clock_ymdhms dt;
+ time_t deltat;
+ int badbase;
+
+ if (base < (MINYEAR-1970)*SECYR) {
+ printf("WARNING: preposterous time in file system");
+ /* read the system clock anyway */
+ base = (MINYEAR-1970)*SECYR;
+ badbase = 1;
+ } else
+ badbase = 0;
+
+ (*clockfns->cf_get)(clockdev, base, &ct);
+#ifdef DEBUG
+ printf("readclock: %d/%d/%d/%d/%d/%d", ct.year, ct.mon, ct.day,
+ ct.hour, ct.min, ct.sec);
+#endif
+ clockinitted = 1;
+
+ year = 1900 + UNIX_YEAR_OFFSET + ct.year;
+ if (year < 1970)
+ year += 100;
+ /* simple sanity checks (2037 = time_t overflow) */
+ if (year < MINYEAR || year > 2037 ||
+ ct.mon < 1 || ct.mon > 12 || ct.day < 1 ||
+ ct.day > 31 || ct.hour > 23 || ct.min > 59 || ct.sec > 59) {
+ /*
+ * Believe the time in the file system for lack of
+ * anything better, resetting the TODR.
+ */
+ time.tv_sec = base;
+ if (!badbase) {
+ printf("WARNING: preposterous clock chip time\n");
+ resettodr();
+ }
+ goto bad;
+ }
+
+ dt.dt_year = year;
+ dt.dt_mon = ct.mon;
+ dt.dt_day = ct.day;
+ dt.dt_hour = ct.hour;
+ dt.dt_min = ct.min;
+ dt.dt_sec = ct.sec;
+ time.tv_sec = clock_ymdhms_to_secs(&dt);
+#ifdef DEBUG
+ printf("=>%ld (%d)\n", time.tv_sec, base);
+#endif
+
+ if (!badbase) {
+ /*
+ * See if we gained/lost two or more days;
+ * if so, assume something is amiss.
+ */
+ deltat = time.tv_sec - base;
+ if (deltat < 0)
+ deltat = -deltat;
+ if (deltat < 2 * SECDAY)
+ return;
+ printf("WARNING: clock %s %ld days",
Home |
Main Index |
Thread Index |
Old Index