diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2000-01-24 16:02:05 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2000-01-24 16:02:05 +0000 |
commit | 0bc9a23a8da2ec668b97493c68a333c6e9f04c26 (patch) | |
tree | eaa06ed76b563fc9dcd7175878caa07b7fe5e1c4 /sys/arch/amiga/dev | |
parent | 6cac601084a8fff27c3019d896171c0e1dc0f940 (diff) |
Amiga HW clock code was not Y2K compliant.
Fix (from netbsd).
Diffstat (limited to 'sys/arch/amiga/dev')
-rw-r--r-- | sys/arch/amiga/dev/a2kbbc.c | 9 | ||||
-rw-r--r-- | sys/arch/amiga/dev/a34kbbc.c | 14 | ||||
-rw-r--r-- | sys/arch/amiga/dev/rtc.h | 5 |
3 files changed, 21 insertions, 7 deletions
diff --git a/sys/arch/amiga/dev/a2kbbc.c b/sys/arch/amiga/dev/a2kbbc.c index 16081b80221..a8968db91b5 100644 --- a/sys/arch/amiga/dev/a2kbbc.c +++ b/sys/arch/amiga/dev/a2kbbc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a2kbbc.c,v 1.1 1997/09/18 13:39:41 niklas Exp $ */ +/* $OpenBSD: a2kbbc.c,v 1.2 2000/01/24 16:02:04 espie Exp $ */ /* $NetBSD: a2kbbc.c,v 1.3 1997/07/23 10:19:44 is Exp $ */ /* @@ -175,6 +175,9 @@ a2gettod() rt->control1 &= ~A2CONTROL1_HOLD; dt.dt_year += CLOCK_BASE_YEAR; + /* Ancient year: must be >=2000 */ + if (dt.dt_year < STARTOFTIME) + dt.dt_year += 100; if ((dt.dt_hour > 23) || (dt.dt_day > 31) || @@ -203,7 +206,6 @@ a2settod(secs) return (0); clock_secs_to_ymdhms(secs, &dt); - dt.dt_year -= CLOCK_BASE_YEAR; /* * hold clock @@ -235,7 +237,8 @@ a2settod(secs) rt->day2 = dt.dt_day % 10; rt->month1 = dt.dt_mon / 10; rt->month2 = dt.dt_mon % 10; - rt->year1 = dt.dt_year / 10; + /* Store two digit year */ + rt->year1 = (dt.dt_year / 10) % 10; rt->year2 = dt.dt_year % 10; rt->weekday = dt.dt_wday; diff --git a/sys/arch/amiga/dev/a34kbbc.c b/sys/arch/amiga/dev/a34kbbc.c index 3f4cc8af7db..80e6f392346 100644 --- a/sys/arch/amiga/dev/a34kbbc.c +++ b/sys/arch/amiga/dev/a34kbbc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a34kbbc.c,v 1.1 1997/09/18 13:39:42 niklas Exp $ */ +/* $OpenBSD: a34kbbc.c,v 1.2 2000/01/24 16:02:04 espie Exp $ */ /* $NetBSD: a34kbbc.c,v 1.1 1997/07/19 00:01:42 is Exp $ */ /* @@ -138,6 +138,10 @@ a3gettod() /* let it run again.. */ rt->control1 = A3CONTROL1_FREE_CLOCK; + /* year too low: must be >= 2000 */ + if (dt.dt_year < STARTOFTIME) + dt.dt_year += 100; + if ((dt.dt_hour > 23) || (dt.dt_wday > 6) || (dt.dt_day > 31) || @@ -166,7 +170,6 @@ a3settod(secs) return (0); clock_secs_to_ymdhms(secs, &dt); - dt.dt_year -= CLOCK_BASE_YEAR; rt->control1 = A3CONTROL1_HOLD_CLOCK; rt->second1 = dt.dt_sec / 10; @@ -180,9 +183,14 @@ a3settod(secs) rt->day2 = dt.dt_day % 10; rt->month1 = dt.dt_mon / 10; rt->month2 = dt.dt_mon % 10; - rt->year1 = dt.dt_year / 10; + /* Store two digit year */ + rt->year1 = (dt.dt_year / 10) % 10; rt->year2 = dt.dt_year % 10; rt->control1 = A3CONTROL1_FREE_CLOCK; + rt->control1 = A3CONTROL1_HOLD_CLOCK | 1; /* mode 1 registers */ + rt->leapyear = dt.dt_year; /* XXX implicit % 4 */ + rt->control1 = A3CONTROL1_FREE_CLOCK; /* implied mode 1 */ + return (1); } diff --git a/sys/arch/amiga/dev/rtc.h b/sys/arch/amiga/dev/rtc.h index 53f33209c90..842e77e2acb 100644 --- a/sys/arch/amiga/dev/rtc.h +++ b/sys/arch/amiga/dev/rtc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rtc.h,v 1.3 1997/09/18 13:39:59 niklas Exp $ */ +/* $OpenBSD: rtc.h,v 1.4 2000/01/24 16:02:04 espie Exp $ */ /* $NetBSD: rtc.h,v 1.5 1997/07/17 23:29:28 is Exp $ */ /* @@ -93,6 +93,9 @@ struct rtclock3000 { #define A3CONTROL1_HOLD_CLOCK 0 #define A3CONTROL1_FREE_CLOCK 9 +/* mode1 registers we use */ +#define leapyear year2 + #define A3BBC_SET_REG 0xe0 #define A3BBC_WRITE_REG 0xc2 #define A3BBC_READ_REG 0xc3 |