Author: quozl Date: Thu Mar 28 00:57:22 2013 New Revision: 3631 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3631
Log: OLPC - avoid use of RTC undefined data, by detecting power loss and clearing the RTC count.
XO-1 and XO-1.5 (ds1385): clear all the RTC count registers, not only the date.
XO-1.75 and XO-4 (ds1338): force the century to 20 like on previous models, check and clear the oscillator stop flag, clear all the RTC count registers, separate the clearing of RTC SRAM from the clearing of RTC count, and fix a regression in r3608 where the wrong register offsets were used.
Modified: cpu/arm/olpc/rtc.fth dev/ds1385r.fth
Modified: cpu/arm/olpc/rtc.fth ============================================================================== --- cpu/arm/olpc/rtc.fth Tue Mar 26 07:26:33 2013 (r3630) +++ cpu/arm/olpc/rtc.fth Thu Mar 28 00:57:22 2013 (r3631) @@ -12,12 +12,20 @@
headerless
+: reinit + h# 20 h# 8 rtc! \ century + h# 13 h# 6 rtc! \ year + h# 1 h# 5 rtc! \ month + h# 1 h# 4 rtc! \ day of month + h# 2 h# 3 rtc! \ day of week, monday + h# 0 h# 2 rtc! \ hours + h# 0 h# 1 rtc! \ minutes + h# 0 h# 0 rtc! \ seconds + ." RTC cleared" cr +; + : ?clear h# 3f rtc@ h# 3e rtc@ bwjoin h# 55aa <> if - h# 20 h# 8 rtc! \ century - h# 13 h# 9 rtc! \ year - h# 1 h# 8 rtc! \ month - h# 1 h# 7 rtc! \ day h# 20 h# 10 do 0 i rtc! loop \ wipe cmos@ cmos! area h# 55aa wbsplit h# 3e rtc! h# 3f rtc! ." RTC SRAM cleared" cr @@ -44,6 +52,12 @@ drop true ( true ) then ( okay? )
+ \ check and clear the oscillator stop flag + 7 rtc@ h# 20 and if + reinit + 7 rtc@ h# 20 invert and 7 rtc! + then + \ manage legacy RTC CMOS usage ?clear
@@ -69,6 +83,7 @@ bcd-time&date >r >r >r >r >r >r bcd> r> bcd> r> bcd> r> bcd> r> bcd> r> bcd> r> bcd> ( s m h d m y c )
+ d# 20 max d# 100 * + \ Merge century with year ; : set-time ( s m h d m y -- )
Modified: dev/ds1385r.fth ============================================================================== --- dev/ds1385r.fth Tue Mar 26 07:26:33 2013 (r3630) +++ dev/ds1385r.fth Thu Mar 28 00:57:22 2013 (r3631) @@ -89,10 +89,14 @@ then ; : reinit - h# 20 h# 1a rtc! - h# 13 h# 9 rtc! - h# 1 h# 8 rtc! - h# 1 h# 7 rtc! + h# 20 h# 1a rtc! \ century + h# 13 h# 9 rtc! \ year + h# 1 h# 8 rtc! \ month + h# 1 h# 7 rtc! \ day of the month + h# 2 h# 6 rtc! \ day of week, monday + h# 0 h# 4 rtc! \ hours + h# 0 h# 2 rtc! \ minutes + h# 0 h# 0 rtc! \ seconds ." RTC cleared" cr ; true value first-open? @@ -137,13 +141,7 @@ bcd-time&date >r >r >r >r >r >r bcd> r> bcd> r> bcd> r> bcd> r> bcd> r> bcd> r> bcd> ( s m h d m y c )
- \ We allow the century byte to force the year to 20xx, but not to force - \ it to 19xx, because that would cause a problem when the century - \ rolls over. - dup d# 20 <> if - drop dup d# 94 < if d# 20 else d# 19 then - then - + d# 20 max d# 100 * + \ Merge century with year ; : set-time ( s m h d m y -- )
openfirmware@openfirmware.info