If clock_ct_to_ts fails to convert time time from the real time clock,
print a one line error message. Add some comments on not being able to trust the day of week field (I'll act on these comments in a follow up commit). Approved by: re MFC after: 3 weeks
This commit is contained in:
parent
9f42d6219f
commit
e8276674f3
@ -686,8 +686,7 @@ inittodr(time_t base)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
wrong_time:
|
wrong_time:
|
||||||
printf("Invalid time in real time clock.\n");
|
printf("Invalid time in clock: check and reset the date!\n");
|
||||||
printf("Check and reset the date immediately!\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -679,8 +679,7 @@ inittodr(time_t base)
|
|||||||
|
|
||||||
/* Look if we have a RTC present and the time is valid */
|
/* Look if we have a RTC present and the time is valid */
|
||||||
if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) {
|
if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) {
|
||||||
printf("Invalid time in real time clock.\n");
|
printf("Invalid time in clock: check and reset the date!\n");
|
||||||
printf("Check and reset the date immediately!\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,7 +703,11 @@ inittodr(time_t base)
|
|||||||
#else
|
#else
|
||||||
ct.year += 2000;
|
ct.year += 2000;
|
||||||
#endif
|
#endif
|
||||||
clock_ct_to_ts(&ct, &ts);
|
/* Should we set dow = -1 because some clocks don't set it correctly? */
|
||||||
|
if (clock_ct_to_ts(&ct, &ts)) {
|
||||||
|
printf("Invalid time in clock: check and reset the date!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
ts.tv_sec += utc_offset();
|
ts.tv_sec += utc_offset();
|
||||||
tc_setclock(&ts);
|
tc_setclock(&ts);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,8 @@ inittodr(time_t base)
|
|||||||
ct.mon = tm.tm_mon;
|
ct.mon = tm.tm_mon;
|
||||||
ct.year = tm.tm_year;
|
ct.year = tm.tm_year;
|
||||||
ct.dow = -1;
|
ct.dow = -1;
|
||||||
clock_ct_to_ts(&ct, &ts);
|
if (clock_ct_to_ts(&ct, &ts))
|
||||||
|
printf("Invalid time in clock: check and reset the date!\n");
|
||||||
ts.tv_sec += utc_offset();
|
ts.tv_sec += utc_offset();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -679,8 +679,7 @@ inittodr(time_t base)
|
|||||||
|
|
||||||
/* Look if we have a RTC present and the time is valid */
|
/* Look if we have a RTC present and the time is valid */
|
||||||
if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) {
|
if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) {
|
||||||
printf("Invalid time in real time clock.\n");
|
printf("Invalid time in clock: check and reset the date!\n");
|
||||||
printf("Check and reset the date immediately!\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,7 +703,11 @@ inittodr(time_t base)
|
|||||||
#else
|
#else
|
||||||
ct.year += 2000;
|
ct.year += 2000;
|
||||||
#endif
|
#endif
|
||||||
clock_ct_to_ts(&ct, &ts);
|
/* Should we set dow = -1 because some clocks don't set it correctly? */
|
||||||
|
if (clock_ct_to_ts(&ct, &ts)) {
|
||||||
|
printf("Invalid time in clock: check and reset the date!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
ts.tv_sec += utc_offset();
|
ts.tv_sec += utc_offset();
|
||||||
tc_setclock(&ts);
|
tc_setclock(&ts);
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ clock_ct_to_ts(struct clocktime *ct, struct timespec *ts)
|
|||||||
days += days_in_month(year, i);
|
days += days_in_month(year, i);
|
||||||
days += (ct->day - 1);
|
days += (ct->day - 1);
|
||||||
|
|
||||||
/* Another sanity check. */
|
/* XXX Dow sanity check. Dow is not used, so should we check it? */
|
||||||
if (ct->dow != -1 && ct->dow != day_of_week(days))
|
if (ct->dow != -1 && ct->dow != day_of_week(days))
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
|
||||||
|
@ -638,7 +638,11 @@ inittodr(time_t base)
|
|||||||
ct.year = bcd2bin(rtc_inb() & 0xff) + 1900; /* year */
|
ct.year = bcd2bin(rtc_inb() & 0xff) + 1900; /* year */
|
||||||
if (ct.year < 1995)
|
if (ct.year < 1995)
|
||||||
ct.year += 100;
|
ct.year += 100;
|
||||||
clock_ct_to_ts(&ct, &ts);
|
/* Should we set dow = -1 because some clocks don't set it correctly? */
|
||||||
|
if (clock_ct_to_ts(&ct, &ts)) {
|
||||||
|
printf("Invalid time in clock: check and reset the date!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
ts.tv_sec += utc_offset();
|
ts.tv_sec += utc_offset();
|
||||||
tc_setclock(&ts);
|
tc_setclock(&ts);
|
||||||
}
|
}
|
||||||
|
@ -638,7 +638,11 @@ inittodr(time_t base)
|
|||||||
ct.year = bcd2bin(rtc_inb() & 0xff) + 1900; /* year */
|
ct.year = bcd2bin(rtc_inb() & 0xff) + 1900; /* year */
|
||||||
if (ct.year < 1995)
|
if (ct.year < 1995)
|
||||||
ct.year += 100;
|
ct.year += 100;
|
||||||
clock_ct_to_ts(&ct, &ts);
|
/* Should we set dow = -1 because some clocks don't set it correctly? */
|
||||||
|
if (clock_ct_to_ts(&ct, &ts)) {
|
||||||
|
printf("Invalid time in clock: check and reset the date!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
ts.tv_sec += utc_offset();
|
ts.tv_sec += utc_offset();
|
||||||
tc_setclock(&ts);
|
tc_setclock(&ts);
|
||||||
}
|
}
|
||||||
|
@ -170,9 +170,11 @@ eeprom_attach(device_t dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bootverbose) {
|
if (bootverbose) {
|
||||||
mk48txx_gettime(dev, &ts);
|
if (mk48txx_gettime(dev, &ts) != 0)
|
||||||
device_printf(dev, "current time: %ld.%09ld\n", (long)ts.tv_sec,
|
device_printf(dev, "invalid time");
|
||||||
ts.tv_nsec);
|
else
|
||||||
|
device_printf(dev, "current time: %ld.%09ld\n",
|
||||||
|
(long)ts.tv_sec, ts.tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -208,9 +208,11 @@ rtc_attach(device_t dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bootverbose) {
|
if (bootverbose) {
|
||||||
mc146818_gettime(dev, &ts);
|
if (mc146818_gettime(dev, &ts) != 0)
|
||||||
device_printf(dev, "current time: %ld.%09ld\n", (long)ts.tv_sec,
|
device_printf(dev, "invalid time");
|
||||||
ts.tv_nsec);
|
else
|
||||||
|
device_printf(dev, "current time: %ld.%09ld\n",
|
||||||
|
(long)ts.tv_sec, ts.tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
Loading…
Reference in New Issue
Block a user