Subject: patch to src/sys/arch/pc532/pc532.clock.c
To: None <port-pc532@netbsd.org>
From: Phil Nelson <phil@cs.wwu.edu>
List: port-pc532
Date: 12/05/1994 11:15:58
I discovered a bug in the resettodr routine in clock.c that causes the
clock chip to appear to be not working. (i.e. on boot, the kernel
says -- Warning: no clock chip found. ) It sets the month to 13!
There were also a couple other bugs that needed fixing. They had to do
with dst, timezones and leap years.
Here is a patch that makes it work correctly.
--Phil
(p.s. this has not yet been checked in on sun-lamp. It will be done soon.)
*** clock.c.orig Mon Dec 5 11:10:56 1994
--- clock.c Mon Dec 5 11:10:55 1994
***************
*** 1,5 ****
! /* $NetBSD: clock.c,v 1.6.2.1 1994/10/19 19:07:14 cgd Exp $
! */
/*-
* Copyright (c) 1990 The Regents of the University of California.
--- 1,4 ----
! /* $NetBSD: clock.c,v 1.8 1994/10/26 08:24:52 cgd Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
***************
*** 59,66 ****
extern struct timezone tz;
/* Conversion data */
! static const short daymon[12] = {
! 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
};
/* Defines to make code more readable. */
--- 58,65 ----
extern struct timezone tz;
/* Conversion data */
! static const short daymon[13] = {
! 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
};
/* Defines to make code more readable. */
***************
*** 68,74 ****
#define FROMBCD(B) (((B)>>4) * 10 + ((B)&0xf))
#define TOBCD(D) ((((D)/10)<<4) + (D)%10)
! #define DAYMON(M,L) (daymon[(M)] + ((L) && (M) > 0))
#define SECDAY (24*60*60)
#define SECMON(M,L) (DAYMON(M,L)*SECDAY)
--- 67,73 ----
#define FROMBCD(B) (((B)>>4) * 10 + ((B)&0xf))
#define TOBCD(D) ((((D)/10)<<4) + (D)%10)
! #define DAYMON(M,L) (daymon[(M)] + ((L) && (M) > 1))
#define SECDAY (24*60*60)
#define SECMON(M,L) (DAYMON(M,L)*SECDAY)
***************
*** 146,151 ****
--- 145,154 ----
/* Check to see if it was really the rtc by checking for bad date info. */
if (sec > 59 || min > 59 || hour > 23 || dom > 31 || month > 12) {
printf("inittodr: No clock found\n");
+ #ifdef TEST
+ printf ("sec=%d, min=%d, hour=%d, dom=%d, month=%d\n",
+ sec, min, hour, dom, month);
+ #endif
have_rtc = 0;
time.tv_sec = base;
return;
***************
*** 203,211 ****
/* XXX apply 1-day tweak? */
/* apply local offset */
! sec -= tz.tz_minuteswest * 60;
if (tz.tz_dsttime)
! sec += 60 * 60;
year = 70;
for (;;) {
--- 206,214 ----
/* XXX apply 1-day tweak? */
/* apply local offset */
! t -= tz.tz_minuteswest * 60;
if (tz.tz_dsttime)
! t += 60 * 60;
year = 70;
for (;;) {