Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_rtc.c
Show First 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | settime_task_func(void *arg, int pending) | ||||
struct timespec ts; | struct timespec ts; | ||||
struct rtc_instance *rtc; | struct rtc_instance *rtc; | ||||
rtc = arg; | rtc = arg; | ||||
if (!(rtc->flags & CLOCKF_SETTIME_NO_TS)) { | if (!(rtc->flags & CLOCKF_SETTIME_NO_TS)) { | ||||
getnanotime(&ts); | getnanotime(&ts); | ||||
if (!(rtc->flags & CLOCKF_SETTIME_NO_ADJ)) { | if (!(rtc->flags & CLOCKF_SETTIME_NO_ADJ)) { | ||||
ts.tv_sec -= utc_offset(); | ts.tv_sec -= utc_offset(); | ||||
timespecadd(&ts, &rtc->resadj); | timespecadd(&ts, &rtc->resadj, &ts); | ||||
} | } | ||||
} else { | } else { | ||||
ts.tv_sec = 0; | ts.tv_sec = 0; | ||||
ts.tv_nsec = 0; | ts.tv_nsec = 0; | ||||
} | } | ||||
CLOCK_SETTIME(rtc->clockdev, &ts); | CLOCK_SETTIME(rtc->clockdev, &ts); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | read_clocks(struct timespec *ts, bool debug_read) | ||||
LIST_FOREACH(rtc, &rtc_list, rtc_entries) { | LIST_FOREACH(rtc, &rtc_list, rtc_entries) { | ||||
if ((error = CLOCK_GETTIME(rtc->clockdev, ts)) != 0) | if ((error = CLOCK_GETTIME(rtc->clockdev, ts)) != 0) | ||||
continue; | continue; | ||||
if (ts->tv_sec < 0 || ts->tv_nsec < 0) { | if (ts->tv_sec < 0 || ts->tv_nsec < 0) { | ||||
error = EINVAL; | error = EINVAL; | ||||
continue; | continue; | ||||
} | } | ||||
if (!(rtc->flags & CLOCKF_GETTIME_NO_ADJ)) { | if (!(rtc->flags & CLOCKF_GETTIME_NO_ADJ)) { | ||||
timespecadd(ts, &rtc->resadj); | timespecadd(ts, &rtc->resadj, ts); | ||||
ts->tv_sec += utc_offset(); | ts->tv_sec += utc_offset(); | ||||
} | } | ||||
if (!debug_read) { | if (!debug_read) { | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(rtc->clockdev, | device_printf(rtc->clockdev, | ||||
"providing initial system time\n"); | "providing initial system time\n"); | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |