From 34ffcb1893ee724d17671b7c388394fb646821bd Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 5 Apr 2021 17:30:51 +0200 Subject: rtc: Add read/write messages We are still having issues with bogus dates. This adds prints at boot and time set, to make sure what we actually read and write. * i386/i386at/rtc.c: Include (readtodc): Warning about reaching CENTURY_START. Print the time read from RTC. (writetodc): Record in RTC remainder of division of year by 100 rather than subtracting 1900. Print the time written to RTC. --- i386/i386at/rtc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/i386/i386at/rtc.c b/i386/i386at/rtc.c index 4187cbf5..51373751 100644 --- a/i386/i386at/rtc.c +++ b/i386/i386at/rtc.c @@ -49,6 +49,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include #include #include @@ -171,6 +172,12 @@ readtodc(uint64_t *tp) yr+CENTURY_START-CENTURY_START%100+100 : yr+CENTURY_START-CENTURY_START%100; + if (yr >= CENTURY_START+90) { + printf("FIXME: we are approaching %u, update CENTURY_START\n", CENTURY_START); + } + + printf("RTC time is %04u-%02u-%02u %02u:%02u:%02u\n", yr, mon, dom, hr, min, sec); + n = sec + 60 * min + 3600 * hr; n += (dom - 1) * 3600 * 24; @@ -219,7 +226,7 @@ writetodc(void) for (j = 1970, i = yeartoday(j); n >= i; j++, i = yeartoday(j)) n -= i; - rtclk.rtc_yr = dectohexdec(j - 1900); + rtclk.rtc_yr = dectohexdec(j % 100); if (i == 366) month[1] = 29; @@ -230,6 +237,14 @@ writetodc(void) rtclk.rtc_dom = dectohexdec(++n); + printf("Setting RTC time to %02u-%02u-%02u %02u:%02u:%02u\n", + hexdectodec(rtclk.rtc_yr), + hexdectodec(rtclk.rtc_mon), + hexdectodec(rtclk.rtc_dom), + hexdectodec(rtclk.rtc_hr), + hexdectodec(rtclk.rtc_min), + hexdectodec(rtclk.rtc_sec)); + ospl = splclock(); rtcput(&rtclk); splx(ospl); -- cgit v1.2.3