Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Define the todr(9) interface.



details:   https://anonhg.NetBSD.org/src/rev/70a06c097f6d
branches:  trunk
changeset: 495299:70a06c097f6d
user:      pk <pk%NetBSD.org@localhost>
date:      Tue Jul 25 22:38:14 2000 +0000

description:
Define the todr(9) interface.

diffstat:

 sys/dev/clock_subr.h |  39 +++++++++++++++++++++++++++++++++++----
 1 files changed, 35 insertions(+), 4 deletions(-)

diffs (59 lines):

diff -r 41e236a9a2d7 -r 70a06c097f6d sys/dev/clock_subr.h
--- a/sys/dev/clock_subr.h      Tue Jul 25 22:33:02 2000 +0000
+++ b/sys/dev/clock_subr.h      Tue Jul 25 22:38:14 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock_subr.h,v 1.2 1997/03/15 18:11:17 is Exp $        */
+/*     $NetBSD: clock_subr.h,v 1.3 2000/07/25 22:38:14 pk Exp $        */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -49,8 +49,8 @@
        u_char dt_sec;
 };
 
-time_t clock_ymdhms_to_secs __P((struct clock_ymdhms *));
-void clock_secs_to_ymdhms __P((time_t, struct clock_ymdhms *));
+time_t clock_ymdhms_to_secs __P((struct clock_ymdhms *));
+void   clock_secs_to_ymdhms __P((time_t, struct clock_ymdhms *));
 
 /*
  * BCD to decimal and decimal to BCD.
@@ -59,6 +59,37 @@
 #define        TOBCD(x)        (((x) / 10 * 16) + ((x) % 10))
 
 /* Some handy constants. */
-#define SECDAY         86400L
+#define SECDAY         86400UL
 #define SECYR          (SECDAY * 365)
 
+
+/*
+ * Interface to time-of-day clock devices.
+ *
+ * todr_gettime: convert time-of-day clock into a `struct timeval'
+ * todr_settime: set time-of-day clock from a `struct timeval'
+ * todr_getcal: get current TOD clock calibration value in ppm
+ * todr_setcal: set calibration value in ppm in TOD clock
+ *
+ * (this is probably not so useful:)
+ * todr_setwen: provide a machine-dependent TOD clock write-enable callback
+ *             function which takes one boolean argument:
+ *                     1 to enable writes; 0 to disable writes.
+ */
+struct todr_chip_handle {
+       void    *cookie;        /* Device specific data */
+
+       int     (*todr_gettime)(struct todr_chip_handle *, struct timeval *);
+       int     (*todr_settime)(struct todr_chip_handle *, struct timeval *);
+       int     (*todr_getcal)(struct todr_chip_handle *, int *);
+       int     (*todr_setcal)(struct todr_chip_handle *, int);
+#if notyet
+       int     (*todr_setwen)(struct todr_chip_handle *, int (*)(int));
+#endif
+};
+typedef struct todr_chip_handle *todr_chip_handle_t;
+
+#define todr_gettime(ct, t)    ((*(ct)->todr_gettime)(ct, t))
+#define todr_settime(ct, t)    ((*(ct)->todr_settime)(ct, t))
+#define todr_getcal(ct, vp)    ((*(ct)->todr_gettime)(ct, vp))
+#define todr_setcal(ct, v)     ((*(ct)->todr_settime)(ct, v))



Home | Main Index | Thread Index | Old Index