summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2021-04-05 17:30:51 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2021-04-05 17:30:51 +0200
commit34ffcb1893ee724d17671b7c388394fb646821bd (patch)
tree3c4b656ad2b76619aa021e4ef16ac893e7bc2e16
parentf040677be3c0eec63a5bd013a092ac5182790a50 (diff)
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 <kern/printf.h> (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.
-rw-r--r--i386/i386at/rtc.c17
1 files changed, 16 insertions, 1 deletions
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 <sys/types.h>
#include <sys/time.h>
#include <kern/mach_clock.h>
+#include <kern/printf.h>
#include <i386/machspl.h>
#include <i386/pio.h>
#include <i386at/rtc.h>
@@ -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);