subr_rtc.c (b69f71eb29797c1a8175e6db41d45e6b2b08b2b5) subr_rtc.c (e5037a18a99371cfd20bfa65556fe0f816781695)
1/*-
2 * Copyright (c) 1988 University of Utah.
3 * Copyright (c) 1982, 1990, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department.

--- 44 unchanged lines hidden (view full) ---

53#include <sys/param.h>
54#include <sys/systm.h>
55#include <sys/kernel.h>
56#include <sys/bus.h>
57#include <sys/clock.h>
58#include <sys/sysctl.h>
59#include <sys/timetc.h>
60
1/*-
2 * Copyright (c) 1988 University of Utah.
3 * Copyright (c) 1982, 1990, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department.

--- 44 unchanged lines hidden (view full) ---

53#include <sys/param.h>
54#include <sys/systm.h>
55#include <sys/kernel.h>
56#include <sys/bus.h>
57#include <sys/clock.h>
58#include <sys/sysctl.h>
59#include <sys/timetc.h>
60
61/* XXX: for the CPU_* sysctl OID constants. */
62#include <machine/cpu.h>
63
64#include "clock_if.h"
65
66static device_t clock_dev = NULL;
67static long clock_res;
68
69void
70clock_register(device_t dev, long res) /* res has units of microseconds */
71{

--- 55 unchanged lines hidden (view full) ---

127 "will not be set accurately\n", error);
128 return;
129 }
130 if (error == EINVAL || ts.tv_sec < 0) {
131 printf("Invalid time in real time clock.\n");
132 printf("Check and reset the date immediately!\n");
133 }
134
61#include "clock_if.h"
62
63static device_t clock_dev = NULL;
64static long clock_res;
65
66void
67clock_register(device_t dev, long res) /* res has units of microseconds */
68{

--- 55 unchanged lines hidden (view full) ---

124 "will not be set accurately\n", error);
125 return;
126 }
127 if (error == EINVAL || ts.tv_sec < 0) {
128 printf("Invalid time in real time clock.\n");
129 printf("Check and reset the date immediately!\n");
130 }
131
135 ts.tv_sec += tz_minuteswest * 60 +
136 (wall_cmos_clock ? adjkerntz : 0);
132 ts.tv_sec += utc_offset();
137
138 if (timespeccmp(&ref, &ts, >)) {
139 diff = ref;
140 timespecsub(&ref, &ts);
141 } else {
142 diff = ts;
143 timespecsub(&diff, &ref);
144 }

--- 11 unchanged lines hidden (view full) ---

156{
157 struct timespec ts;
158 int error;
159
160 if (disable_rtc_set || clock_dev == NULL)
161 return;
162
163 getnanotime(&ts);
133
134 if (timespeccmp(&ref, &ts, >)) {
135 diff = ref;
136 timespecsub(&ref, &ts);
137 } else {
138 diff = ts;
139 timespecsub(&diff, &ref);
140 }

--- 11 unchanged lines hidden (view full) ---

152{
153 struct timespec ts;
154 int error;
155
156 if (disable_rtc_set || clock_dev == NULL)
157 return;
158
159 getnanotime(&ts);
164 ts.tv_sec -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
160 ts.tv_sec -= utc_offset();
165 if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0) {
166 printf("warning: clock_settime failed (%d), time-of-day clock "
167 "not adjusted to system time\n", error);
168 return;
169 }
170}
161 if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0) {
162 printf("warning: clock_settime failed (%d), time-of-day clock "
163 "not adjusted to system time\n", error);
164 return;
165 }
166}