Port-luna68k archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
diffs for luna68k todr and timecounter
Attached are the diffs. Pretty straight-forward. Luna didn't appear to
be using a good counter, so the only timecounter you get is clockinterrupt.
Please either test, or just give me approval to commit. :-)
- Garrett
--
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
http://www.tadpolecomputer.com/
Phone: 951 325-2134 Fax: 951 325-2191
Index: sys/arch/luna68k/dev/timekeeper.c
===================================================================
RCS file: /cvsroot/src/sys/arch/luna68k/dev/timekeeper.c,v
retrieving revision 1.3
diff -d -p -u -r1.3 timekeeper.c
--- sys/arch/luna68k/dev/timekeeper.c 12 Mar 2006 22:55:19 -0000 1.3
+++ sys/arch/luna68k/dev/timekeeper.c 13 Sep 2006 20:27:21 -0000
@@ -48,7 +48,6 @@ __KERNEL_RCSID(0, "$NetBSD: timekeeper.c
#include <machine/cpu.h>
#include <dev/clock_subr.h>
-#include <luna68k/luna68k/clockvar.h>
#include <luna68k/dev/timekeeper.h>
#include <machine/autoconf.h>
@@ -59,6 +58,7 @@ struct timekeeper_softc {
void *sc_clock, *sc_nvram;
int sc_nvramsize;
u_int8_t sc_image[2040];
+ struct todr_chip_handle sc_todr;
};
static int clock_match __P((struct device *, struct cfdata *, void *));
@@ -68,18 +68,10 @@ CFATTACH_DECL(clock, sizeof (struct time
clock_match, clock_attach, NULL, NULL);
extern struct cfdriver clock_cd;
-static void mkclock_get __P((struct device *, time_t, struct clock_ymdhms *));
-static void mkclock_set __P((struct device *, struct clock_ymdhms *));
-static void dsclock_get __P((struct device *, time_t, struct clock_ymdhms *));
-static void dsclock_set __P((struct device *, struct clock_ymdhms *));
-
-static struct clockfns mkclock_clockfns = {
- NULL /* never used */, mkclock_get, mkclock_set,
-};
-
-static struct clockfns dsclock_clockfns = {
- NULL /* never used */, dsclock_get, dsclock_set,
-};
+static int mkclock_get __P((todr_chip_handle_t, struct clock_ymdhms *));
+static int mkclock_set __P((todr_chip_handle_t, struct clock_ymdhms *));
+static int dsclock_get __P((todr_chip_handle_t, struct clock_ymdhms *));
+static int dsclock_set __P((todr_chip_handle_t, struct clock_ymdhms *));
static int
clock_match(parent, match, aux)
@@ -101,7 +93,6 @@ clock_attach(parent, self, aux)
{
struct timekeeper_softc *sc = (void *)self;
struct mainbus_attach_args *ma = aux;
- struct clockfns *clockwork;
switch (machtype) {
default:
@@ -109,31 +100,32 @@ clock_attach(parent, self, aux)
sc->sc_clock = (void *)(ma->ma_addr + 2040);
sc->sc_nvram = (void *)ma->ma_addr;
sc->sc_nvramsize = 2040;
- clockwork = &mkclock_clockfns;
+ sc->sc_todr.todr_gettime_ymdhms = mkclock_get;
+ sc->sc_todr.todr_settime_ymdhms = mkclock_set;
+ sc->sc_todr.cookie = sc;
printf(": mk48t02\n");
break;
case LUNA_II: /* Dallas DS1287A */
sc->sc_clock = (void *)ma->ma_addr;
sc->sc_nvram = (void *)(ma->ma_addr + 50);
sc->sc_nvramsize = 50;
- clockwork = &dsclock_clockfns;
+ sc->sc_todr.todr_gettime_ymdhms = dsclock_get;
+ sc->sc_todr.todr_settime_ymdhms = dsclock_set;
+ sc->sc_todr.cookie = sc;
printf(": ds1287a\n");
break;
}
- clockattach(&sc->sc_dev, clockwork);
+ todr_attach(&sc->sc_todr);
memcpy(sc->sc_image, sc->sc_nvram, sc->sc_nvramsize);
}
/*
* Get the time of day, based on the clock's value and/or the base value.
*/
-static void
-mkclock_get(dev, base, dt)
- struct device *dev;
- time_t base;
- struct clock_ymdhms *dt;
+static int
+mkclock_get(todr_chip_handle_t tch, struct clock_ymdhms *dt)
{
- struct timekeeper_softc *sc = (void *)dev;
+ struct timekeeper_softc *sc = (void *)tch->cookie;
volatile u_int8_t *chiptime = (void *)sc->sc_clock;
int s;
@@ -148,22 +140,16 @@ mkclock_get(dev, base, dt)
dt->dt_year = FROMBCD(chiptime[MK_YEAR]) + YEAR0;
chiptime[MK_CSR] &= ~MK_CSR_READ; /* time wears on */
splx(s);
-#ifdef TIMEKEEPER_DEBUG
- printf("get %d/%d/%d %d:%d:%d\n",
- dt->dt_year, dt->dt_mon, dt->dt_day,
- dt->dt_hour, dt->dt_min, dt->dt_sec);
-#endif
+ return 0;
}
/*
* Reset the TODR based on the time value.
*/
-static void
-mkclock_set(dev, dt)
- struct device *dev;
- struct clock_ymdhms *dt;
+static int
+mkclock_set(todr_chip_handle_t tch, struct clock_ymdhms *dt)
{
- struct timekeeper_softc *sc = (void *)dev;
+ struct timekeeper_softc *sc = (void *)tch->cookie;
volatile u_int8_t *chiptime = (void *)sc->sc_clock;
volatile u_int8_t *stamp = (u_int8_t *)sc->sc_nvram + 0x10;
int s;
@@ -179,25 +165,18 @@ mkclock_set(dev, dt)
chiptime[MK_YEAR] = TOBCD(dt->dt_year - YEAR0);
chiptime[MK_CSR] &= ~MK_CSR_WRITE; /* load them up */
splx(s);
-#ifdef TIMEKEEPER_DEBUG
- printf("set %d/%d/%d %d:%d:%d\n",
- dt->dt_year, dt->dt_mon, dt->dt_day,
- dt->dt_hour, dt->dt_min, dt->dt_sec);
-#endif
stamp[0] = 'R'; stamp[1] = 'T'; stamp[2] = 'C'; stamp[3] = '\0';
+ return 0;
}
/*
* Get the time of day, based on the clock's value and/or the base value.
*/
-static void
-dsclock_get(dev, base, dt)
- struct device *dev;
- time_t base;
- struct clock_ymdhms *dt;
+static int
+dsclock_get(todr_chip_handle_t tch, struct clock_ymdhms *dt)
{
- struct timekeeper_softc *sc = (void *)dev;
+ struct timekeeper_softc *sc = (void *)tch->cookie;
volatile u_int8_t *chiptime = (void *)sc->sc_clock;
int s;
@@ -213,17 +192,16 @@ dsclock_get(dev, base, dt)
dt->dt_mon = chiptime[MC_MONTH];
dt->dt_year = chiptime[MC_YEAR] + YEAR0;
splx(s);
+ return 0;
}
/*
* Reset the TODR based on the time value.
*/
-static void
-dsclock_set(dev, dt)
- struct device *dev;
- struct clock_ymdhms *dt;
+static int
+dsclock_set(todr_chip_handle_t tch, struct clock_ymdhms *dt)
{
- struct timekeeper_softc *sc = (void *)dev;
+ struct timekeeper_softc *sc = (void *)tch->cookie;
volatile u_int8_t *chiptime = (void *)sc->sc_clock;
int s;
@@ -238,4 +216,5 @@ dsclock_set(dev, dt)
chiptime[MC_YEAR] = dt->dt_year - YEAR0;
chiptime[MC_REGB] &= ~MC_REGB_SET; /* load them up */
splx(s);
+ return 0;
}
Index: sys/arch/luna68k/include/types.h
===================================================================
RCS file: /cvsroot/src/sys/arch/luna68k/include/types.h,v
retrieving revision 1.2
diff -d -p -u -r1.2 types.h
--- sys/arch/luna68k/include/types.h 28 Feb 2002 03:17:33 -0000 1.2
+++ sys/arch/luna68k/include/types.h 13 Sep 2006 20:27:21 -0000
@@ -5,4 +5,7 @@
#include <m68k/types.h>
+#define __HAVE_TIMECOUNTER
+#define __HAVE_GENERIC_TODR
+
#endif
Index: sys/arch/luna68k/luna68k/clock.c
===================================================================
RCS file: /cvsroot/src/sys/arch/luna68k/luna68k/clock.c,v
retrieving revision 1.4
diff -d -p -u -r1.4 clock.c
--- sys/arch/luna68k/luna68k/clock.c 11 Dec 2005 12:17:52 -0000 1.4
+++ sys/arch/luna68k/luna68k/clock.c 13 Sep 2006 20:27:21 -0000
@@ -88,28 +88,6 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.
#include <machine/cpu.h>
#include <dev/clock_subr.h>
-#include <luna68k/luna68k/clockvar.h>
-
-#define CLOCK_LEVEL 5
-#include <luna68k/luna68k/isr.h>
-
-static struct device *clockdev;
-static struct clockfns *clockfns;
-static int clockinitted;
-
-void
-clockattach(dev, fns)
- struct device *dev;
- struct clockfns *fns;
-{
- /*
- * Just bookkeeping.
- */
- if (clockfns != NULL)
- panic("clockattach: multiple clocks");
- clockdev = dev;
- clockfns = fns;
-}
/*
* Machine-dependent clock routines.
@@ -117,11 +95,6 @@ clockattach(dev, fns)
* 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.
*/
int clock_enable; /* XXX to be removed XXX */
@@ -135,21 +108,11 @@ cpu_initclocks()
{
int s;
- if (clockfns == NULL)
- panic("cpu_initclocks: no clock attached");
-
if (machtype == LUNA_I)
hz = 60; /* LUNA-I is clocked at 60Hz, not 100Hz */
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 started.
*/
@@ -175,80 +138,3 @@ setstatclockrate(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(base)
- time_t base;
-{
- struct clock_ymdhms dt;
- time_t deltat;
- int badbase;
-
- if (base < 5*SECYR) {
- printf("WARNING: preposterous time in file system");
- /* read the system clock anyway */
- base = 6*SECYR + 186*SECDAY + SECDAY/2;
- badbase = 1;
- } else
- badbase = 0;
-
- (*clockfns->cf_get)(clockdev, base, &dt);
- clockinitted = 1;
- /* simple sanity checks */
- if (dt.dt_year < 1970 || dt.dt_mon < 1 || dt.dt_mon > 12
- || dt.dt_day < 1 || dt.dt_day > 31
- || dt.dt_hour > 23 || dt.dt_min > 59 || dt.dt_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");
- resettodr();
- }
- goto bad;
- }
- /* now have days since Jan 1, 1970; the rest is easy... */
- time.tv_sec = clock_ymdhms_to_secs(&dt);
-
- 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 %d days",
- time.tv_sec < base ? "lost" : "gained",
- (int) (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()
-{
- struct clock_ymdhms dt;
-
- if (!clockinitted)
- return;
- clock_secs_to_ymdhms(time.tv_sec, &dt);
- (*clockfns->cf_set)(clockdev, &dt);
-}
Index: sys/arch/luna68k/luna68k/clockvar.h
===================================================================
RCS file: sys/arch/luna68k/luna68k/clockvar.h
diff -N sys/arch/luna68k/luna68k/clockvar.h
--- sys/arch/luna68k/luna68k/clockvar.h 5 Jan 2000 08:49:02 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-/* $NetBSD: clockvar.h,v 1.1 2000/01/05 08:49:02 nisimura Exp $ */
-
-/*-
- * Copyright (c) 2000 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Tohru Nishimura.
- *
- * 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 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.
- */
-
-struct clock_ymdhms;
-
-/*
- * clockfns structure:
- *
- * function switch used by chip-independent clock code, to access
- * chip-dependent routines.
- */
-struct clockfns {
- void (*cf_init) __P((struct device *));
- void (*cf_get) __P((struct device *, time_t, struct clock_ymdhms *));
- void (*cf_set) __P((struct device *, struct clock_ymdhms *));
-};
-
-void clockattach __P((struct device *, struct clockfns *));
Index: sys/arch/luna68k/luna68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/luna68k/luna68k/machdep.c,v
retrieving revision 1.45
diff -d -p -u -r1.45 machdep.c
--- sys/arch/luna68k/luna68k/machdep.c 4 Aug 2006 02:26:49 -0000 1.45
+++ sys/arch/luna68k/luna68k/machdep.c 13 Sep 2006 20:27:21 -0000
@@ -804,37 +804,6 @@ cpu_exec_aout_makecmds(l, epp)
return error;
}
-/*
- * Return the best possible estimate of the time in the timeval
- * to which tvp points. Unfortunately, we can't read the hardware
registers.
- * We guarantee that the time will be greater than the value obtained by a
- * previous call.
- */
-void
-microtime(tvp)
- register struct timeval *tvp;
-{
- int s = splclock();
- static struct timeval lasttime;
-
- *tvp = time;
-#ifdef notdef
- tvp->tv_usec += clkread();
- while (tvp->tv_usec >= 1000000) {
- tvp->tv_sec++;
- tvp->tv_usec -= 1000000;
- }
-#endif
- 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);
-}
-
#if 1
struct consdev *cn_tab = &syscons;
Home |
Main Index |
Thread Index |
Old Index