Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/nathanw_sa]: src/sys/arch/arc split clock_mc.c into interval timer drive...



details:   https://anonhg.NetBSD.org/src/rev/38b821479602
branches:  nathanw_sa
changeset: 504748:38b821479602
user:      soda <soda%NetBSD.org@localhost>
date:      Wed Jun 13 15:02:13 2001 +0000

description:
split clock_mc.c into interval timer driver (timer) and
real time clock driver (mcclock)

diffstat:

 sys/arch/arc/dev/mcclock.c            |  120 ++++++++++++++++++++++++++++++++++
 sys/arch/arc/dev/mcclockvar.h         |   52 ++++++++++++++
 sys/arch/arc/isa/mcclock_isavar.h     |   39 +++++++++++
 sys/arch/arc/isa/timer_isavar.h       |   39 +++++++++++
 sys/arch/arc/jazz/mcclock_jazziovar.h |   45 ++++++++++++
 sys/arch/arc/jazz/timer_jazziovar.h   |   45 ++++++++++++
 6 files changed, 340 insertions(+), 0 deletions(-)

diffs (truncated from 364 to 300 lines):

diff -r 6598df3122da -r 38b821479602 sys/arch/arc/dev/mcclock.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arc/dev/mcclock.c        Wed Jun 13 15:02:13 2001 +0000
@@ -0,0 +1,120 @@
+/* $NetBSD: mcclock.c,v 1.1.10.2 2001/06/13 15:02:13 soda Exp $        */
+/* NetBSD: mcclock.c,v 1.12 1999/01/15 23:29:55 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@localhost
+ *  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.1.10.2 2001/06/13 15:02:13 soda Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+
+#include <dev/ic/mc146818reg.h>
+
+#include <arc/arc/todclockvar.h>
+#include <arc/dev/mcclockvar.h>
+
+void mcclock_get __P((struct device *, time_t, struct todclocktime *));
+void mcclock_set __P((struct device *, struct todclocktime *));
+
+const struct todclockfns mcclock_todclockfns = {
+       mcclock_get, mcclock_set,
+};
+
+void
+mcclock_attach(sc, busfns, year_offset)
+       struct mcclock_softc *sc;
+       const struct mcclock_busfns *busfns;
+       int year_offset;
+{
+
+       printf(": mc146818 or compatible\n");
+
+       sc->sc_busfns = busfns;
+
+       todclockattach(&sc->sc_dev, &mcclock_todclockfns, year_offset);
+}
+
+/*
+ * Get the time of day, based on the clock's value and/or the base value.
+ */
+void
+mcclock_get(dev, base, ct)
+       struct device *dev;
+       time_t base;
+       struct todclocktime *ct;
+{
+       struct mcclock_softc *sc = (struct mcclock_softc *)dev;
+       mc_todregs regs;
+       int s;
+
+       s = splclock();
+       MC146818_GETTOD(sc, &regs)
+       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];
+}
+
+/*
+ * Reset the TODR based on the time value.
+ */
+void
+mcclock_set(dev, ct)
+       struct device *dev;
+       struct todclocktime *ct;
+{
+       struct mcclock_softc *sc = (struct mcclock_softc *)dev;
+       mc_todregs regs;
+       int s;
+
+       s = splclock();
+       MC146818_GETTOD(sc, &regs);
+       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;
+
+       s = splclock();
+       MC146818_PUTTOD(sc, &regs);
+       splx(s);
+}
diff -r 6598df3122da -r 38b821479602 sys/arch/arc/dev/mcclockvar.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arc/dev/mcclockvar.h     Wed Jun 13 15:02:13 2001 +0000
@@ -0,0 +1,52 @@
+/* $NetBSD: mcclockvar.h,v 1.1.10.2 2001/06/13 15:02:14 soda Exp $ */
+/* NetBSD: mcclockvar.h,v 1.4 1997/06/22 08:02:19 jonathan 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@localhost
+ *  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;
+
+       /* the followings may be used by bus-dependent frontend */
+       bus_space_tag_t sc_iot;
+       bus_space_handle_t sc_ioh;
+};
+
+struct mcclock_busfns {
+       u_int   (*mc_bf_read) __P((struct mcclock_softc *, u_int));
+       void    (*mc_bf_write) __P((struct mcclock_softc *, u_int, u_int));
+};
+
+#define        mc146818_read(dev, reg)                                         \
+           (*(sc)->sc_busfns->mc_bf_read)(sc, reg)
+#define        mc146818_write(sc, reg, datum)                                  \
+           (*(sc)->sc_busfns->mc_bf_write)(sc, reg, datum)
+
+void   mcclock_attach __P((struct mcclock_softc *,
+           const struct mcclock_busfns *, int));
diff -r 6598df3122da -r 38b821479602 sys/arch/arc/isa/mcclock_isavar.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arc/isa/mcclock_isavar.h Wed Jun 13 15:02:13 2001 +0000
@@ -0,0 +1,39 @@
+/*     $NetBSD: mcclock_isavar.h,v 1.1.10.2 2001/06/13 15:02:15 soda Exp $     */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by SODA Noriyuki.
+ *
+ * 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.
+ */
+
+extern int mcclock_isa_conf;
diff -r 6598df3122da -r 38b821479602 sys/arch/arc/isa/timer_isavar.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arc/isa/timer_isavar.h   Wed Jun 13 15:02:13 2001 +0000
@@ -0,0 +1,39 @@
+/*     $NetBSD: timer_isavar.h,v 1.1.10.2 2001/06/13 15:02:15 soda Exp $       */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by SODA Noriyuki.
+ *
+ * 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.
+ */
+
+extern int timer_isa_conf;
diff -r 6598df3122da -r 38b821479602 sys/arch/arc/jazz/mcclock_jazziovar.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arc/jazz/mcclock_jazziovar.h     Wed Jun 13 15:02:13 2001 +0000
@@ -0,0 +1,45 @@
+/*     $NetBSD: mcclock_jazziovar.h,v 1.1.10.2 2001/06/13 15:02:16 soda Exp $  */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by SODA Noriyuki.
+ *
+ * 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



Home | Main Index | Thread Index | Old Index