/* * Support for the RTC device. * * We don't want to use the rtc-cmos driver, because we don't want to support * alarms, as that would be indistinguishable from timer interrupts. * * Further, generic code is really, really tied to a 1900 epoch. This is * true in __get_rtc_time as well as the users of struct rtc_time e.g. * rtc_tm_to_time. Thankfully all of the other epochs in use are later * than 1900, and so it's easy to adjust.
*/
staticvoid __init
init_rtc_epoch(void)
{ int epoch, year, ctrl;
if (rtc_epoch != 0) { /* The epoch was specified on the command-line. */ return;
}
/* Detect the epoch in use on this computer. */
ctrl = CMOS_READ(RTC_CONTROL);
year = CMOS_READ(RTC_YEAR); if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
year = bcd2bin(year);
/* PC-like is standard; used for year >= 70 */
epoch = 1900; if (year < 20) {
epoch = 2000;
} elseif (year >= 20 && year < 48) { /* NT epoch */
epoch = 1980;
} elseif (year >= 48 && year < 70) { /* Digital UNIX epoch */
epoch = 1952;
}
rtc_epoch = epoch;
printk(KERN_INFO "Using epoch %d for rtc year %d\n", epoch, year);
}
staticint
alpha_rtc_read_time(struct device *dev, struct rtc_time *tm)
{ int ret = mc146818_get_time(tm, 10);
if (ret < 0) {
dev_err_ratelimited(dev, "unable to read current time\n"); return ret;
}
/* Adjust for non-default epochs. It's easier to depend on the generic __get_rtc_time and adjust the epoch here than create
a copy of __get_rtc_time with the edits we need. */ if (rtc_epoch != 1900) { int year = tm->tm_year; /* Undo the century adjustment made in __get_rtc_time. */ if (year >= 100)
year -= 100;
year += rtc_epoch - 1900; /* Redo the century adjustment with the epoch in place. */ if (year <= 69)
year += 100;
tm->tm_year = year;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.