Subject: Re: localtime & timezone adjustment?
To: None <port-macppc@netbsd.org>
From: John Valdes <valdes@uchicago.edu>
List: port-macppc
Date: 02/02/2001 20:02:07
On Sun, Jan 21, 2001 at 08:44:33PM -0600, Bob Nestor wrote:
> John Valdes wrote:
>
> >Does NetBSD/macppc have any way to compensate for the fact the Mac
> >(normally) stores local time in the hardware clock?
>
> Other ports have a similar problem. Setting RTC_OFFSET would solve the
> problem, but it seems that it's not writeable via sysctl.
Hmmm, I tried setting "options RTC_OFFSET=360" in the kernel config
file, but it didn't seem to have any effect. Well, "sysctl
kern.rtc_offset" now reports 360 rather than 0, but the system clock
was unaffected. A quick grep of /usr/src/arch/macppc/macppc/clock.c
didn't find any reference to rtc_offset, so it looks like this option
is ignored in the macppc port. This was easy to patch though (see
below). Actually, checking now, I see there are a couple of PR's on
this already...
> On the i386
> port I got around this by using the instructions in the INSTALL document
> for changing the address for some PCI devices. Basically you boot up the
> system and get it to drop into the debugger. Then you modify the
> RTC_OFFSET value and write it back out. Thereafter the NetBSD system
> applies the RTC_OFFSET to the hardware clock and all is well -- until
> Daylight Savings Time. ;)
I think I'll just compile two kernels; one for Standard Time, and one
for DST... :)
John
--------------------------------------------------------------------
--- /usr/src/sys/arch/macppc/macppc/clock.c.FCS Wed Nov 1 10:01:50 2000
+++ /usr/src/sys/arch/macppc/macppc/clock.c Fri Feb 2 13:02:17 2001
@@ -80,7 +80,7 @@
return;
}
clockinitted = 1;
- time.tv_sec = rtc_time - DIFF19041970;
+ time.tv_sec = rtc_time - DIFF19041970 + rtc_offset * 60;
deltat = time.tv_sec - base;
if (deltat < 0)
@@ -104,7 +104,7 @@
u_int rtc_time;
if (clockinitted) {
- rtc_time = time.tv_sec + DIFF19041970;
+ rtc_time = time.tv_sec + DIFF19041970 - rtc_offset * 60;
adb_set_date_time(rtc_time);
}
#endif