diff options
author | grehan <grehan@FreeBSD.org> | 2003-01-08 12:17:44 +0000 |
---|---|---|
committer | grehan <grehan@FreeBSD.org> | 2003-01-08 12:17:44 +0000 |
commit | be4bc4017501a05921869f9121a54415301ea500 (patch) | |
tree | d654de58538e99fc065213e2921dc83f7daa95cf /sys/powerpc | |
parent | c1833e36de6b282f7fa0920e03e6d56c02c0a22b (diff) | |
download | FreeBSD-src-be4bc4017501a05921869f9121a54415301ea500.zip FreeBSD-src-be4bc4017501a05921869f9121a54415301ea500.tar.gz |
Fetch the initial time from the rtc OpenFirmware node. This is a short-term
measure until the rtc h/w driver is written, and it's a lot better
than having "jan 1 1970" on filesys times.
Approved by: benno
Diffstat (limited to 'sys/powerpc')
-rw-r--r-- | sys/powerpc/aim/clock.c | 21 | ||||
-rw-r--r-- | sys/powerpc/powerpc/clock.c | 21 |
2 files changed, 42 insertions, 0 deletions
diff --git a/sys/powerpc/aim/clock.c b/sys/powerpc/aim/clock.c index 5aa880f..d1f13e2 100644 --- a/sys/powerpc/aim/clock.c +++ b/sys/powerpc/aim/clock.c @@ -115,10 +115,31 @@ inittodr(time_t base) time_t deltat; u_int rtc_time; struct timespec ts; + phandle_t phandle; + ihandle_t ihandle; + char rtcpath[128]; + u_int rtcsecs; /* * If we can't read from RTC, use the fs time. */ + phandle = OF_finddevice("rtc"); + if (phandle != -1) { + OF_package_to_path(phandle, rtcpath, sizeof(rtcpath)); + ihandle = OF_open(rtcpath); + if (ihandle != -1) { + if (OF_call_method("read-rtc", ihandle, + 0, 1, &rtcsecs)) + printf("RTC call method error\n"); + else { + ts.tv_sec = rtcsecs - DIFF19041970; + ts.tv_nsec = 0; + tc_setclock(&ts); + return; + } + } + } + #if NADB > 0 if (adb_read_date_time(&rtc_time) < 0) #endif diff --git a/sys/powerpc/powerpc/clock.c b/sys/powerpc/powerpc/clock.c index 5aa880f..d1f13e2 100644 --- a/sys/powerpc/powerpc/clock.c +++ b/sys/powerpc/powerpc/clock.c @@ -115,10 +115,31 @@ inittodr(time_t base) time_t deltat; u_int rtc_time; struct timespec ts; + phandle_t phandle; + ihandle_t ihandle; + char rtcpath[128]; + u_int rtcsecs; /* * If we can't read from RTC, use the fs time. */ + phandle = OF_finddevice("rtc"); + if (phandle != -1) { + OF_package_to_path(phandle, rtcpath, sizeof(rtcpath)); + ihandle = OF_open(rtcpath); + if (ihandle != -1) { + if (OF_call_method("read-rtc", ihandle, + 0, 1, &rtcsecs)) + printf("RTC call method error\n"); + else { + ts.tv_sec = rtcsecs - DIFF19041970; + ts.tv_nsec = 0; + tc_setclock(&ts); + return; + } + } + } + #if NADB > 0 if (adb_read_date_time(&rtc_time) < 0) #endif |