summaryrefslogtreecommitdiffstats
path: root/c/src/lib
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1997-10-23 18:48:35 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1997-10-23 18:48:35 +0000
commitcfefaa6e9eadbecd3d1d2e03df34b962e8db5a79 (patch)
treec8a907e7176f49f9780ad2545fe3fc5630b63b83 /c/src/lib
parentRemoved GEN68360_INIT. (diff)
downloadrtems-cfefaa6e9eadbecd3d1d2e03df34b962e8db5a79.tar.bz2
Added TOD driver from Katsutoshi Shibuya.
Diffstat (limited to 'c/src/lib')
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/Makefile.in2
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/include/Makefile.in3
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/include/tod.h42
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/tod/Makefile.in54
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/tod/tod.c90
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/wrapup/Makefile.in2
6 files changed, 190 insertions, 3 deletions
diff --git a/c/src/lib/libbsp/m68k/mvme162/Makefile.in b/c/src/lib/libbsp/m68k/mvme162/Makefile.in
index 59024d5ca8..59c1021ebc 100644
--- a/c/src/lib/libbsp/m68k/mvme162/Makefile.in
+++ b/c/src/lib/libbsp/m68k/mvme162/Makefile.in
@@ -22,4 +22,4 @@ SRCS=README
# from the individual .rel files built in other directories
#
# XXXX add tools
-SUB_DIRS=include startup clock console consolex timer wrapup
+SUB_DIRS=include startup clock console consolex timer tod wrapup
diff --git a/c/src/lib/libbsp/m68k/mvme162/include/Makefile.in b/c/src/lib/libbsp/m68k/mvme162/include/Makefile.in
index 25f58d8d85..a74d3cf0f7 100644
--- a/c/src/lib/libbsp/m68k/mvme162/include/Makefile.in
+++ b/c/src/lib/libbsp/m68k/mvme162/include/Makefile.in
@@ -7,7 +7,8 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@
-H_FILES = $(srcdir)/bsp.h $(srcdir)/coverhd.h $(srcdir)/page_table.h
+H_FILES = $(srcdir)/bsp.h $(srcdir)/coverhd.h $(srcdir)/page_table.h \
+ $(srcdir)/tod.h
#
# Equate files are for including from assembly preprocessed by
diff --git a/c/src/lib/libbsp/m68k/mvme162/include/tod.h b/c/src/lib/libbsp/m68k/mvme162/include/tod.h
new file mode 100644
index 0000000000..4839e39df2
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/include/tod.h
@@ -0,0 +1,42 @@
+/*
+ * Real Time Clock (MK48T08) for RTEMS on MVME162
+ *
+ * Author:
+ * COPYRIGHT (C) 1997
+ * by Katsutoshi Shibuya - BU Denken Co.,Ltd. - Sapporo - JAPAN
+ * ALL RIGHTS RESERVED
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * This material is a part of the MVME162 Board Support Package
+ * for the RTEMS executive. Its licensing policies are those of the
+ * RTEMS above.
+ *
+ * $Id$
+ */
+
+
+#ifndef TOD_H
+#define TOD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void setRealTimeToRTEMS();
+/* Read real time from RTC and set it to RTEMS' clock manager */
+
+extern void setRealTimeFromRTEMS();
+/* Read time from RTEMS' clock manager and set it to RTC */
+
+extern int checkRealTime();
+/* Return the difference between RTC and RTEMS' clock manager time in minutes.
+ If the difference is greater than 1 day, this returns 9999. */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/c/src/lib/libbsp/m68k/mvme162/tod/Makefile.in b/c/src/lib/libbsp/m68k/mvme162/tod/Makefile.in
new file mode 100644
index 0000000000..cdc7e7d7a3
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/tod/Makefile.in
@@ -0,0 +1,54 @@
+#
+# $Id$
+#
+
+@SET_MAKE@
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH=@srcdir@
+
+PGM=${ARCH}/tod.rel
+
+# C source names, if any, go here -- minus the .c
+C_PIECES=tod
+C_FILES=$(C_PIECES:%=%.c)
+C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
+
+H_FILES=
+
+SRCS=$(C_FILES) $(H_FILES)
+OBJS=$(C_O_FILES)
+
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+DEFINES +=
+CPPFLAGS +=
+CFLAGS +=
+
+LD_PATHS +=
+LD_LIBS +=
+LDFLAGS +=
+
+#
+# Add your list of files to delete here. The config files
+# already know how to delete some stuff, so you may want
+# to just run 'make clean' first to see what gets missed.
+# 'make clobber' already includes 'make clean'
+#
+
+CLEAN_ADDITIONS +=
+CLOBBER_ADDITIONS +=
+
+${PGM}: ${SRCS} ${OBJS}
+ $(make-rel)
+
+all: ${ARCH} $(SRCS) $(PGM)
+
+# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
+install: all
diff --git a/c/src/lib/libbsp/m68k/mvme162/tod/tod.c b/c/src/lib/libbsp/m68k/mvme162/tod/tod.c
new file mode 100644
index 0000000000..67efadaf53
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/tod/tod.c
@@ -0,0 +1,90 @@
+/*
+ * Real Time Clock (MK48T08) for RTEMS on MVME162
+ *
+ * Author:
+ * COPYRIGHT (C) 1997
+ * by Katsutoshi Shibuya - BU Denken Co.,Ltd. - Sapporo - JAPAN
+ * ALL RIGHTS RESERVED
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * This material is a part of the MVME162 Board Support Package
+ * for the RTEMS executive. Its licensing policies are those of the
+ * RTEMS above.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <tod.h>
+
+#define tod ((volatile unsigned char *)0xfffc1ff8)
+
+static int getTod(int n, unsigned char mask)
+{
+ unsigned char x;
+
+ x = tod[n]&mask;
+ return (x>>4)*10+(x&0x0f);
+}
+
+static void setTod(int n, unsigned char d)
+{
+ tod[n] = ((d/10)<<4)+(d%10);
+}
+
+void setRealTimeToRTEMS()
+{
+ rtems_time_of_day t;
+
+ tod[0] |= 0x40; /* Stop read register */
+ t.year = 1900+getTod(7,0xff);
+ t.month = getTod(6,0x1f);
+ t.day = getTod(5,0x3f);
+ t.hour = getTod(3,0x3f);
+ t.minute = getTod(2,0x7f);
+ t.second = getTod(1,0x7f);
+ t.ticks = 0;
+ tod[0] &= 0x3f; /* Release read register */
+
+ rtems_clock_set(&t);
+}
+
+void setRealTimeFromRTEMS()
+{
+ rtems_time_of_day t;
+
+ rtems_clock_get(RTEMS_CLOCK_GET_TOD,&t);
+ t.year -= 1900;
+
+ tod[0] |= 0x80; /* Stop write register */
+ setTod(7,t.year);
+ setTod(6,t.month);
+ setTod(5,t.day);
+ setTod(4,1); /* I don't know which day of week is */
+ setTod(3,t.hour);
+ setTod(2,t.minute);
+ setTod(1,t.second);
+ tod[0] &= 0x3f; /* Write these parameters */
+}
+
+int checkRealTime()
+{
+ rtems_time_of_day t;
+ int d;
+
+ tod[0] |= 0x40; /* Stop read register */
+ rtems_clock_get(RTEMS_CLOCK_GET_TOD,&t);
+ if((t.year != 1900+getTod(7,0xff))
+ || (t.month != getTod(6,0x1f))
+ || (t.day != getTod(5,0x3f)))
+ d = 9999;
+ else
+ d = (t.hour-getTod(3,0x3f))*3600
+ + (t.minute-getTod(3,0x7f))*60
+ + (t.second - getTod(1,0x7f));
+ tod[1] &= 0x3f;
+ return d;
+}
diff --git a/c/src/lib/libbsp/m68k/mvme162/wrapup/Makefile.in b/c/src/lib/libbsp/m68k/mvme162/wrapup/Makefile.in
index c0838c5207..70d1a61381 100644
--- a/c/src/lib/libbsp/m68k/mvme162/wrapup/Makefile.in
+++ b/c/src/lib/libbsp/m68k/mvme162/wrapup/Makefile.in
@@ -7,7 +7,7 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@
-BSP_PIECES=startup clock console timer
+BSP_PIECES=startup clock console timer tod
CPU_PIECES=
GENERIC_PIECES=