Update algor clock handling. This includes using the common mc146818
support code, using the common MIPS 3 cp0 based interrupt code, adding time counters, and using the generic TODR code. Unfortunately, due to lack of hardware, I don't know for sure that any of this works, though the same code in evbmips works. Commiting anyway, ok'd by simon@.
This commit is contained in:
parent
c2be3dff63
commit
c119401402
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: algor_p4032_intr.c,v 1.11 2006/04/15 16:13:24 simonb Exp $ */
|
||||
/* $NetBSD: algor_p4032_intr.c,v 1.12 2006/09/05 01:33:24 gdamore Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -45,7 +45,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: algor_p4032_intr.c,v 1.11 2006/04/15 16:13:24 simonb Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: algor_p4032_intr.c,v 1.12 2006/09/05 01:33:24 gdamore Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
|
||||
|
@ -67,8 +67,6 @@ __KERNEL_RCSID(0, "$NetBSD: algor_p4032_intr.c,v 1.11 2006/04/15 16:13:24 simonb
|
|||
#include <algor/algor/algor_p4032reg.h>
|
||||
#include <algor/algor/algor_p4032var.h>
|
||||
|
||||
#include <algor/algor/clockvar.h>
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: algor_p5064_intr.c,v 1.14 2006/04/15 16:13:24 simonb Exp $ */
|
||||
/* $NetBSD: algor_p5064_intr.c,v 1.15 2006/09/05 01:33:24 gdamore Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -45,7 +45,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: algor_p5064_intr.c,v 1.14 2006/04/15 16:13:24 simonb Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: algor_p5064_intr.c,v 1.15 2006/09/05 01:33:24 gdamore Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
|
||||
|
@ -67,8 +67,6 @@ __KERNEL_RCSID(0, "$NetBSD: algor_p5064_intr.c,v 1.14 2006/04/15 16:13:24 simonb
|
|||
#include <algor/algor/algor_p5064reg.h>
|
||||
#include <algor/algor/algor_p5064var.h>
|
||||
|
||||
#include <algor/algor/clockvar.h>
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pciidereg.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: algor_p6032_intr.c,v 1.8 2006/04/15 16:13:24 simonb Exp $ */
|
||||
/* $NetBSD: algor_p6032_intr.c,v 1.9 2006/09/05 01:33:24 gdamore Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -44,7 +44,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: algor_p6032_intr.c,v 1.8 2006/04/15 16:13:24 simonb Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: algor_p6032_intr.c,v 1.9 2006/09/05 01:33:24 gdamore Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
|
||||
|
@ -66,8 +66,6 @@ __KERNEL_RCSID(0, "$NetBSD: algor_p6032_intr.c,v 1.8 2006/04/15 16:13:24 simonb
|
|||
#include <algor/algor/algor_p6032reg.h>
|
||||
#include <algor/algor/algor_p6032var.h>
|
||||
|
||||
#include <algor/algor/clockvar.h>
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
|
||||
|
|
|
@ -1,322 +0,0 @@
|
|||
/* $NetBSD: clock.c,v 1.4 2005/12/11 12:16:08 christos Exp $ */
|
||||
|
||||
/*
|
||||
* 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. 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
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
*
|
||||
* 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.4 2005/12/11 12:16:08 christos 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",
|
||||
time.tv_sec < base ? "lost" : "gained",
|
||||
(long)deltat / SECDAY);
|
||||
}
|
||||
bad:
|
||||
printf(" -- CHECK AND RESET THE DATE!\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset the TODR based on the time value; used when the TODR
|
||||
* has a preposterous value and also when the time is reset
|
||||
* by the stime system call. Also called when the TODR goes past
|
||||
* TODRZERO + 100*(SECYEAR+2*SECDAY) (e.g. on Jan 2 just after midnight)
|
||||
* to wrap the TODR around.
|
||||
*/
|
||||
void
|
||||
resettodr(void)
|
||||
{
|
||||
struct clock_ymdhms dt;
|
||||
struct clocktime ct;
|
||||
|
||||
if (!clockinitted)
|
||||
return;
|
||||
|
||||
clock_secs_to_ymdhms(time.tv_sec, &dt);
|
||||
|
||||
/* rt clock wants 2 digits */
|
||||
ct.year = (dt.dt_year - UNIX_YEAR_OFFSET) % 100;
|
||||
ct.mon = dt.dt_mon;
|
||||
ct.day = dt.dt_day;
|
||||
ct.hour = dt.dt_hour;
|
||||
ct.min = dt.dt_min;
|
||||
ct.sec = dt.dt_sec;
|
||||
ct.dow = dt.dt_wday;
|
||||
#ifdef DEBUG
|
||||
printf("setclock: %d/%d/%d/%d/%d/%d\n", ct.year, ct.mon, ct.day,
|
||||
ct.hour, ct.min, ct.sec);
|
||||
#endif
|
||||
|
||||
(*clockfns->cf_set)(clockdev, &ct);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the best possible estimate of the time in the timeval to
|
||||
* which tvp points. We guarantee that the time will be greater than
|
||||
* the value obtained by a previous call.
|
||||
*/
|
||||
void
|
||||
microtime(struct timeval *tvp)
|
||||
{
|
||||
int s = splclock();
|
||||
static struct timeval lasttime;
|
||||
|
||||
*tvp = time;
|
||||
|
||||
if (tvp->tv_usec >= 1000000) {
|
||||
tvp->tv_usec -= 1000000;
|
||||
tvp->tv_sec++;
|
||||
}
|
||||
|
||||
if (tvp->tv_sec == lasttime.tv_sec &&
|
||||
tvp->tv_usec <= lasttime.tv_usec &&
|
||||
(tvp->tv_usec = lasttime.tv_usec + 1) >= 1000000) {
|
||||
tvp->tv_sec++;
|
||||
tvp->tv_usec -= 1000000;
|
||||
}
|
||||
lasttime = *tvp;
|
||||
splx(s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait "n" microseconds.
|
||||
* XXX Should be calibrated with the cycle counter.
|
||||
*/
|
||||
void
|
||||
delay(int n)
|
||||
{
|
||||
|
||||
DELAY(n);
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
/* $NetBSD: clockvar.h,v 1.4 2005/12/11 12:16:08 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definitions for CPU-independent clock handling for the alpha and pmax.
|
||||
*/
|
||||
|
||||
/*
|
||||
* clocktime structure:
|
||||
*
|
||||
* structure passed to TOY clocks when setting them. broken out this
|
||||
* way, so that the time_t -> field conversion can be shared.
|
||||
*/
|
||||
struct clocktime {
|
||||
int year; /* year - 1900 */
|
||||
int mon; /* month (1 - 12) */
|
||||
int day; /* day (1 - 31) */
|
||||
int hour; /* hour (0 - 23) */
|
||||
int min; /* minute (0 - 59) */
|
||||
int sec; /* second (0 - 59) */
|
||||
int dow; /* day of week (0 - 6; 0 = Sunday) */
|
||||
};
|
||||
|
||||
/*
|
||||
* clockfns structure:
|
||||
*
|
||||
* function switch used by chip-independent clock code, to access
|
||||
* chip-dependent routines.
|
||||
*/
|
||||
struct clockfns {
|
||||
void (*cf_init)(struct device *);
|
||||
void (*cf_get)(struct device *, time_t, struct clocktime *);
|
||||
void (*cf_set)(struct device *, struct clocktime *);
|
||||
};
|
||||
|
||||
extern struct device *clockdev;
|
||||
extern const struct clockfns *clockfns;
|
||||
|
||||
void clockattach(struct device *, const struct clockfns *);
|
||||
int clockintr(void *);
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: interrupt.c,v 1.8 2006/04/15 16:13:24 simonb Exp $ */
|
||||
/* $NetBSD: interrupt.c,v 1.9 2006/09/05 01:33:24 gdamore Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.8 2006/04/15 16:13:24 simonb Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.9 2006/09/05 01:33:24 gdamore Exp $");
|
||||
|
||||
#include "opt_algor_p4032.h"
|
||||
#include "opt_algor_p5064.h"
|
||||
|
@ -51,6 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.8 2006/04/15 16:13:24 simonb Exp $")
|
|||
#include <machine/autoconf.h>
|
||||
#include <machine/intr.h>
|
||||
#include <machine/locore.h>
|
||||
#include <mips/mips3_clock.h>
|
||||
|
||||
#ifdef ALGOR_P4032
|
||||
#include <algor/algor/algor_p4032var.h>
|
||||
|
@ -126,9 +127,6 @@ const u_int32_t ipl_si_to_sr[_IPL_NSOFT] = {
|
|||
MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */
|
||||
};
|
||||
|
||||
struct evcnt mips_int5_evcnt =
|
||||
EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "mips", "int 5 (clock)");
|
||||
|
||||
void
|
||||
intr_init(void)
|
||||
{
|
||||
|
@ -147,19 +145,11 @@ intr_init(void)
|
|||
void
|
||||
cpu_intr(u_int32_t status, u_int32_t cause, u_int32_t pc, u_int32_t ipending)
|
||||
{
|
||||
struct clockframe cf;
|
||||
|
||||
uvmexp.intrs++;
|
||||
|
||||
if (ipending & MIPS_INT_MASK_5) {
|
||||
u_int32_t cycles = mips3_cp0_count_read();
|
||||
mips3_cp0_compare_write(cycles + cycles_per_hz);
|
||||
|
||||
cf.pc = pc;
|
||||
cf.sr = status;
|
||||
hardclock(&cf);
|
||||
|
||||
mips_int5_evcnt.ev_count++;
|
||||
mips3_clockintr(status, pc);
|
||||
|
||||
/* Re-enable clock interrupts. */
|
||||
cause &= ~MIPS_INT_MASK_5;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.algor,v 1.20 2006/04/15 16:13:24 simonb Exp $
|
||||
# $NetBSD: files.algor,v 1.21 2006/09/05 01:33:24 gdamore Exp $
|
||||
|
||||
# Algorithmics evaluation board specific configuration info.
|
||||
|
||||
|
@ -35,7 +35,6 @@ file arch/algor/algor/algor_p6032_intr.c algor_p6032
|
|||
|
||||
file arch/algor/algor/autoconf.c
|
||||
file arch/algor/algor/bus_dma.c
|
||||
file arch/algor/algor/clock.c
|
||||
file arch/algor/algor/disksubr.c
|
||||
file arch/algor/algor/interrupt.c
|
||||
file arch/algor/algor/led.c
|
||||
|
@ -43,6 +42,7 @@ file arch/algor/algor/machdep.c
|
|||
file arch/algor/algor/pmon.c
|
||||
|
||||
file arch/mips/mips/softintr.c
|
||||
file arch/mips/mips/mips3_clock.c
|
||||
|
||||
#
|
||||
# The autoconfiguration root.
|
||||
|
@ -55,8 +55,7 @@ device cpu
|
|||
attach cpu at mainbus
|
||||
file arch/algor/algor/cpu.c cpu
|
||||
|
||||
device mcclock
|
||||
file arch/algor/dev/mcclock.c mcclock
|
||||
device mcclock: mc146818
|
||||
|
||||
#
|
||||
# Machine-independent I2O drivers.
|
||||
|
|
|
@ -1,137 +0,0 @@
|
|||
/* $NetBSD: mcclock.c,v 1.2 2001/06/10 05:26:59 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 1.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 <machine/autoconf.h>
|
||||
|
||||
#include <dev/ic/mc146818reg.h>
|
||||
|
||||
#include <algor/algor/clockvar.h>
|
||||
#include <algor/dev/mcclockvar.h>
|
||||
|
||||
void mcclock_init(struct device *);
|
||||
void mcclock_get(struct device *, time_t, struct clocktime *);
|
||||
void mcclock_set(struct device *, struct clocktime *);
|
||||
|
||||
const struct clockfns mcclock_clockfns = {
|
||||
mcclock_init, mcclock_get, mcclock_set,
|
||||
};
|
||||
|
||||
#define mc146818_write(dev, reg, datum) \
|
||||
(*(dev)->sc_busfns->mc_bf_write)(dev, reg, datum)
|
||||
#define mc146818_read(dev, reg) \
|
||||
(*(dev)->sc_busfns->mc_bf_read)(dev, reg)
|
||||
|
||||
void
|
||||
mcclock_attach(struct mcclock_softc *sc, const struct mcclock_busfns *busfns)
|
||||
{
|
||||
|
||||
printf(": mc146818 or compatible\n");
|
||||
|
||||
sc->sc_busfns = busfns;
|
||||
|
||||
/*
|
||||
* Turn interrupts off, just in case. Need to leave the SQWE
|
||||
* set, because that's the DRAM refresh signal on Rev. B boards.
|
||||
*/
|
||||
mc146818_write(sc, MC_REGB, MC_REGB_SQWE | MC_REGB_BINARY |
|
||||
MC_REGB_24HR);
|
||||
|
||||
clockattach(&sc->sc_dev, &mcclock_clockfns);
|
||||
}
|
||||
|
||||
void
|
||||
mcclock_init(struct device *dev)
|
||||
{
|
||||
|
||||
/* We don't use the mcclock for the hardclock interrupt. */
|
||||
}
|
||||
|
||||
/*
|
||||
* Note the Algorithmics PMON firmware uses a different year base.
|
||||
*/
|
||||
#define ALGOR_YEAR_OFFSET 80
|
||||
|
||||
/*
|
||||
* Get the time of day, based on the clock's value and/or the base value.
|
||||
*/
|
||||
void
|
||||
mcclock_get(struct device *dev, time_t base, struct clocktime *ct)
|
||||
{
|
||||
struct mcclock_softc *sc = (struct mcclock_softc *)dev;
|
||||
mc_todregs regs;
|
||||
int s;
|
||||
|
||||
s = splclock();
|
||||
MC146818_GETTOD(sc, ®s)
|
||||
splx(s);
|
||||
|
||||
ct->sec = regs[MC_SEC];
|
||||
ct->min = regs[MC_MIN];
|
||||
ct->hour = regs[MC_HOUR];
|
||||
ct->dow = regs[MC_DOW];
|
||||
ct->day = regs[MC_DOM];
|
||||
ct->mon = regs[MC_MONTH];
|
||||
ct->year = regs[MC_YEAR] - ALGOR_YEAR_OFFSET;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset the TODR based on the time value.
|
||||
*/
|
||||
void
|
||||
mcclock_set(struct device *dev, struct clocktime *ct)
|
||||
{
|
||||
struct mcclock_softc *sc = (struct mcclock_softc *)dev;
|
||||
mc_todregs regs;
|
||||
int s;
|
||||
|
||||
s = splclock();
|
||||
MC146818_GETTOD(sc, ®s);
|
||||
splx(s);
|
||||
|
||||
regs[MC_SEC] = ct->sec;
|
||||
regs[MC_MIN] = ct->min;
|
||||
regs[MC_HOUR] = ct->hour;
|
||||
regs[MC_DOW] = ct->dow;
|
||||
regs[MC_DOM] = ct->day;
|
||||
regs[MC_MONTH] = ct->mon;
|
||||
regs[MC_YEAR] = ct->year + ALGOR_YEAR_OFFSET;
|
||||
|
||||
s = splclock();
|
||||
MC146818_PUTTOD(sc, ®s);
|
||||
splx(s);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mcclock_mainbus.c,v 1.5 2002/10/02 03:36:20 thorpej Exp $ */
|
||||
/* $NetBSD: mcclock_mainbus.c,v 1.6 2006/09/05 01:33:24 gdamore Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_mainbus.c,v 1.5 2002/10/02 03:36:20 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_mainbus.c,v 1.6 2006/09/05 01:33:24 gdamore Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
|
@ -39,30 +39,18 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_mainbus.c,v 1.5 2002/10/02 03:36:20 thorpej
|
|||
#include <machine/autoconf.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/clock_subr.h>
|
||||
#include <dev/ic/mc146818reg.h>
|
||||
|
||||
#include <algor/algor/clockvar.h>
|
||||
#include <algor/dev/mcclockvar.h>
|
||||
|
||||
struct mcclock_mainbus_softc {
|
||||
struct mcclock_softc sc_mcclock;
|
||||
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_ioh;
|
||||
};
|
||||
#include <dev/ic/mc146818var.h>
|
||||
|
||||
int mcclock_mainbus_match(struct device *, struct cfdata *, void *);
|
||||
void mcclock_mainbus_attach(struct device *, struct device *, void *);
|
||||
|
||||
CFATTACH_DECL(mcclock_mainbus, sizeof(struct mcclock_mainbus_softc),
|
||||
CFATTACH_DECL(mcclock_mainbus, sizeof(struct mc146818_softc),
|
||||
mcclock_mainbus_match, mcclock_mainbus_attach, NULL, NULL);
|
||||
|
||||
void mcclock_mainbus_write(struct mcclock_softc *, u_int, u_int);
|
||||
u_int mcclock_mainbus_read(struct mcclock_softc *, u_int);
|
||||
|
||||
const struct mcclock_busfns mcclock_mainbus_busfns = {
|
||||
mcclock_mainbus_write, mcclock_mainbus_read,
|
||||
};
|
||||
void mcclock_mainbus_write(struct mc146818_softc *, u_int, u_int);
|
||||
u_int mcclock_mainbus_read(struct mc146818_softc *, u_int);
|
||||
|
||||
int
|
||||
mcclock_mainbus_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
|
@ -79,32 +67,46 @@ void
|
|||
mcclock_mainbus_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct mainbus_attach_args *ma = aux;
|
||||
struct mcclock_mainbus_softc *sc = (void *)self;
|
||||
struct mc146818_softc *sc = (struct mc146818_softc *)self;
|
||||
|
||||
sc->sc_iot = ma->ma_st;
|
||||
if (bus_space_map(sc->sc_iot, ma->ma_addr, 2, 0, &sc->sc_ioh))
|
||||
sc->sc_bst = ma->ma_st;
|
||||
if (bus_space_map(sc->sc_bst, ma->ma_addr, 2, 0, &sc->sc_bsh))
|
||||
panic("mcclock_mainbus_attach: couldn't map clock I/O space");
|
||||
|
||||
mcclock_attach(&sc->sc_mcclock, &mcclock_mainbus_busfns);
|
||||
/*
|
||||
* Turn interrupts off, just in case. Need to leave the SQWE
|
||||
* set, because that's the DRAM refresh signal on Rev. B boards.
|
||||
*/
|
||||
mcclock_mainbus_write(sc, MC_REGB, MC_REGB_SQWE | MC_REGB_BINARY |
|
||||
MC_REGB_24HR);
|
||||
|
||||
sc->sc_mcread = mcclock_mainbus_read;
|
||||
sc->sc_mcwrite = mcclock_mainbus_write;
|
||||
sc->sc_getcent = NULL;
|
||||
sc->sc_setcent = NULL;
|
||||
sc->sc_flag = 0;
|
||||
|
||||
/* Algor uses year 1980 as offset */
|
||||
sc->sc_year0 = 80;
|
||||
|
||||
mc146818_attach(sc);
|
||||
}
|
||||
|
||||
void
|
||||
mcclock_mainbus_write(struct mcclock_softc *mcsc, u_int reg, u_int datum)
|
||||
mcclock_mainbus_write(struct mc146818_softc *sc, u_int reg, u_int datum)
|
||||
{
|
||||
struct mcclock_mainbus_softc *sc = (void *)mcsc;
|
||||
bus_space_tag_t iot = sc->sc_iot;
|
||||
bus_space_handle_t ioh = sc->sc_ioh;
|
||||
bus_space_tag_t iot = sc->sc_bst;
|
||||
bus_space_handle_t ioh = sc->sc_bsh;
|
||||
|
||||
bus_space_write_1(iot, ioh, 0, reg);
|
||||
bus_space_write_1(iot, ioh, 1, datum);
|
||||
}
|
||||
|
||||
u_int
|
||||
mcclock_mainbus_read(struct mcclock_softc *mcsc, u_int reg)
|
||||
mcclock_mainbus_read(struct mc146818_softc *sc, u_int reg)
|
||||
{
|
||||
struct mcclock_mainbus_softc *sc = (void *)mcsc;
|
||||
bus_space_tag_t iot = sc->sc_iot;
|
||||
bus_space_handle_t ioh = sc->sc_ioh;
|
||||
bus_space_tag_t iot = sc->sc_bst;
|
||||
bus_space_handle_t ioh = sc->sc_bsh;
|
||||
|
||||
bus_space_write_1(iot, ioh, 0, reg);
|
||||
return bus_space_read_1(iot, ioh, 1);
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
/* $NetBSD: mcclockvar.h,v 1.1 2001/05/28 16:22:16 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
struct mcclock_softc {
|
||||
struct device sc_dev;
|
||||
const struct mcclock_busfns *sc_busfns;
|
||||
};
|
||||
|
||||
struct mcclock_busfns {
|
||||
void (*mc_bf_write)(struct mcclock_softc *, u_int, u_int);
|
||||
u_int (*mc_bf_read)(struct mcclock_softc *, u_int);
|
||||
};
|
||||
|
||||
void mcclock_attach(struct mcclock_softc *, const struct mcclock_busfns *);
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: param.h,v 1.6 2005/12/11 12:16:08 christos Exp $ */
|
||||
/* $NetBSD: param.h,v 1.7 2006/09/05 01:33:24 gdamore Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -131,9 +131,8 @@
|
|||
#ifdef _KERNEL
|
||||
#ifndef _LOCORE
|
||||
|
||||
void delay __P((int n));
|
||||
extern int cpuspeed;
|
||||
#define DELAY(n) { int N = cpuspeed * (n); while (--N > 0); }
|
||||
void delay(int n);
|
||||
#define DELAY delay
|
||||
|
||||
#include <machine/intr.h>
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/* $NetBSD: types.h,v 1.1 2001/05/28 16:22:20 thorpej Exp $ */
|
||||
/* $NetBSD: types.h,v 1.2 2006/09/05 01:33:24 gdamore Exp $ */
|
||||
|
||||
#include <mips/types.h>
|
||||
|
||||
#define __HAVE_DEVICE_REGISTER
|
||||
#define __HAVE_GENERIC_SOFT_INTERRUPTS
|
||||
#define __HAVE_TIMECOUNTER
|
||||
#define __HAVE_GENERIC_TODR
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mcclock_isa.c,v 1.7 2005/12/11 12:16:08 christos Exp $ */
|
||||
/* $NetBSD: mcclock_isa.c,v 1.8 2006/09/05 01:33:24 gdamore Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_isa.c,v 1.7 2005/12/11 12:16:08 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_isa.c,v 1.8 2006/09/05 01:33:24 gdamore Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
|
@ -38,34 +38,20 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_isa.c,v 1.7 2005/12/11 12:16:08 christos Exp
|
|||
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/clock_subr.h>
|
||||
#include <dev/ic/mc146818reg.h>
|
||||
|
||||
#include <algor/algor/clockvar.h>
|
||||
#include <algor/dev/mcclockvar.h>
|
||||
#include <dev/ic/mc146818var.h>
|
||||
|
||||
#include <dev/isa/isavar.h>
|
||||
|
||||
struct mcclock_isa_softc {
|
||||
struct mcclock_softc sc_mcclock;
|
||||
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_ioh;
|
||||
|
||||
void *sc_ih;
|
||||
};
|
||||
|
||||
int mcclock_isa_match(struct device *, struct cfdata *, void *);
|
||||
void mcclock_isa_attach(struct device *, struct device *, void *);
|
||||
|
||||
CFATTACH_DECL(mcclock_isa, sizeof(struct mcclock_isa_softc),
|
||||
CFATTACH_DECL(mcclock_isa, sizeof(struct mc146818_softc),
|
||||
mcclock_isa_match, mcclock_isa_attach, NULL, NULL);
|
||||
|
||||
void mcclock_isa_write(struct mcclock_softc *, u_int, u_int);
|
||||
u_int mcclock_isa_read(struct mcclock_softc *, u_int);
|
||||
|
||||
const struct mcclock_busfns mcclock_isa_busfns = {
|
||||
mcclock_isa_write, mcclock_isa_read,
|
||||
};
|
||||
void mcclock_isa_write(struct mc146818_softc *, u_int, u_int);
|
||||
u_int mcclock_isa_read(struct mc146818_softc *, u_int);
|
||||
|
||||
int
|
||||
mcclock_isa_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
|
@ -110,33 +96,47 @@ void
|
|||
mcclock_isa_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct isa_attach_args *ia = aux;
|
||||
struct mcclock_isa_softc *sc = (struct mcclock_isa_softc *)self;
|
||||
struct mc146818_softc *sc = (struct mc146818_softc *)self;
|
||||
|
||||
sc->sc_iot = ia->ia_iot;
|
||||
if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr,
|
||||
ia->ia_io[0].ir_size, 0, &sc->sc_ioh))
|
||||
sc->sc_bst = ia->ia_iot;
|
||||
if (bus_space_map(sc->sc_bst, ia->ia_io[0].ir_addr,
|
||||
ia->ia_io[0].ir_size, 0, &sc->sc_bsh))
|
||||
panic("mcclock_isa_attach: couldn't map clock I/O space");
|
||||
|
||||
mcclock_attach(&sc->sc_mcclock, &mcclock_isa_busfns);
|
||||
/*
|
||||
* Turn interrupts off, just in case. Need to leave the SQWE
|
||||
* set, because that's the DRAM refresh signal on Rev. B boards.
|
||||
*/
|
||||
mcclock_isa_write(sc, MC_REGB, MC_REGB_SQWE | MC_REGB_BINARY |
|
||||
MC_REGB_24HR);
|
||||
|
||||
sc->sc_mcread = mcclock_isa_read;
|
||||
sc->sc_mcwrite = mcclock_isa_write;
|
||||
sc->sc_getcent = NULL;
|
||||
sc->sc_setcent = NULL;
|
||||
sc->sc_flag = 0;
|
||||
|
||||
/* Algor uses year 1980 as offset */
|
||||
sc->sc_year0 = 80;
|
||||
|
||||
mc146818_attach(sc);
|
||||
}
|
||||
|
||||
void
|
||||
mcclock_isa_write(struct mcclock_softc *mcsc, u_int reg, u_int datum)
|
||||
mcclock_isa_write(struct mc146818_softc *sc, u_int reg, u_int datum)
|
||||
{
|
||||
struct mcclock_isa_softc *sc = (struct mcclock_isa_softc *)mcsc;
|
||||
bus_space_tag_t iot = sc->sc_iot;
|
||||
bus_space_handle_t ioh = sc->sc_ioh;
|
||||
bus_space_tag_t iot = sc->sc_bst;
|
||||
bus_space_handle_t ioh = sc->sc_bsh;
|
||||
|
||||
bus_space_write_1(iot, ioh, 0, reg);
|
||||
bus_space_write_1(iot, ioh, 1, datum);
|
||||
}
|
||||
|
||||
u_int
|
||||
mcclock_isa_read(struct mcclock_softc *mcsc, u_int reg)
|
||||
mcclock_isa_read(struct mc146818_softc *sc, u_int reg)
|
||||
{
|
||||
struct mcclock_isa_softc *sc = (struct mcclock_isa_softc *)mcsc;
|
||||
bus_space_tag_t iot = sc->sc_iot;
|
||||
bus_space_handle_t ioh = sc->sc_ioh;
|
||||
bus_space_tag_t iot = sc->sc_bst;
|
||||
bus_space_handle_t ioh = sc->sc_bsh;
|
||||
|
||||
bus_space_write_1(iot, ioh, 0, reg);
|
||||
return bus_space_read_1(iot, ioh, 1);
|
||||
|
|
Loading…
Reference in New Issue