Subject: Re: Realtime clock
To: None <blaz.zupan@uni-mb.si, amiga-dev@NetBSD.ORG>
From: Bernd Ernesti <erbe0011@FH-Karlsruhe.DE>
List: amiga-dev
Date: 11/10/1994 21:14:54
Blaz Zupan writes:

>Ok, here is a context diff from the original clock.c source
>(nothing special really). It works on my 2000, dunno about
>3000 or 4000. Check it out and report.

It doen't work on a A4000, but I look at this problem and make an
new diff for the original clock.c and now it works on my A4000.
Can someone test this on an a3000 ?

>(patch with `patch /sys/arch/amiga/dev/clock.c <THIS_FILE')


*** clock.c-orig	Thu Jun 16 14:28:45 1994
--- clock.c	Thu Nov 10 20:20:12 1994
***************
*** 701,707 ****
  a3gettod()
  {
  	struct rtclock3000 *rt;
! 	int i, year, month, day, hour, min, sec;
  	u_long tmp;
  
  	rt = clockaddr;
--- 701,707 ----
  a3gettod()
  {
  	struct rtclock3000 *rt;
! 	int i, year, month, day, wday, hour, min, sec;
  	u_long tmp;
  
  	rt = clockaddr;
***************
*** 713,718 ****
--- 713,719 ----
  	sec   = rt->second1 * 10 + rt->second2;
  	min   = rt->minute1 * 10 + rt->minute2;
  	hour  = rt->hour1   * 10 + rt->hour2;
+ 	wday  = rt->weekday;
  	day   = rt->day1    * 10 + rt->day2;
  	month = rt->month1  * 10 + rt->month2;
  	year  = rt->year1   * 10 + rt->year2   + 1900;
***************
*** 722,727 ****
--- 723,730 ----
  
  	if (range_test(hour, 0, 23))
  		return(0);
+ 	if (range_test(wday, 0, 6))
+ 		return(0);
  	if (range_test(day, 1, 31))
  		return(0);
  	if (range_test(month, 1, 12))
***************
*** 754,759 ****
--- 757,763 ----
  	u_char sec1, sec2;
  	u_char min1, min2;
  	u_char hour1, hour2;
+ /*	u_char wday; */
  	u_char day1, day2;
  	u_char mon1, mon2;
  	u_char year1, year2;
***************
*** 764,772 ****
  	 * there seem to be problems with the bitfield addressing
  	 * currently used..
  	 */
! return(0);
! #if not_yet
! 	if (rt)
  		return 0;
  
  	/* prepare values to be written to clock */
--- 768,775 ----
  	 * there seem to be problems with the bitfield addressing
  	 * currently used..
  	 */
! 
! 	if (! rt)
  		return 0;
  
  	/* prepare values to be written to clock */
***************
*** 807,829 ****
  	day1 = day / 10;
  	day2 = day % 10;
  
! 	rt->control1 = CONTROL1_HOLD_CLOCK;
  	rt->second1 = sec1;
  	rt->second2 = sec2;
  	rt->minute1 = min1;
  	rt->minute2 = min2;
  	rt->hour1   = hour1;
  	rt->hour2   = hour2;
  	rt->day1    = day1;
  	rt->day2    = day2;
  	rt->month1  = mon1;
  	rt->month2  = mon2;
  	rt->year1   = year1;
  	rt->year2   = year2;
! 	rt->control2 = CONTROL1_FREE_CLOCK;
  
  	return 1;
- #endif
  }
  
  long
--- 810,832 ----
  	day1 = day / 10;
  	day2 = day % 10;
  
! 	rt->control1 = A3CONTROL1_HOLD_CLOCK;
  	rt->second1 = sec1;
  	rt->second2 = sec2;
  	rt->minute1 = min1;
  	rt->minute2 = min2;
  	rt->hour1   = hour1;
  	rt->hour2   = hour2;
+ /*	rt->weekday = wday; */
  	rt->day1    = day1;
  	rt->day2    = day2;
  	rt->month1  = mon1;
  	rt->month2  = mon2;
  	rt->year1   = year1;
  	rt->year2   = year2;
! 	rt->control1 = A3CONTROL1_FREE_CLOCK;
  
  	return 1;
  }
  
  long
***************
*** 915,922 ****
  	 *
  	 * XXX Check out the above where we (hour1 & 3)
  	 */
- return(0);
- #if not_yet
  	if (! rt)
  		return 0;
  
--- 918,923 ----
***************
*** 961,967 ****
  	/* 
  	 * XXXX spin wait as with reading???
  	 */
! 	rt->control1 = A2CONTROL1_HOLD_CLOCK;
  	rt->second1 = sec1;
  	rt->second2 = sec2;
  	rt->minute1 = min1;
--- 962,968 ----
  	/* 
  	 * XXXX spin wait as with reading???
  	 */
! 	rt->control1 |= A2CONTROL1_HOLD;
  	rt->second1 = sec1;
  	rt->second2 = sec2;
  	rt->minute1 = min1;
***************
*** 974,981 ****
  	rt->month2  = mon2;
  	rt->year1   = year1;
  	rt->year2   = year2;
! 	rt->control2 = CONTROL1_FREE_CLOCK;
  
    return 1;
- #endif
  }
--- 975,981 ----
  	rt->month2  = mon2;
  	rt->year1   = year1;
  	rt->year2   = year2;
! 	rt->control2 &= ~A2CONTROL1_HOLD;
  
    return 1;
  }