Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sys/arch/arm32/dev Pullup 1.11 [abs]:



details:   https://anonhg.NetBSD.org/src/rev/6d68dd40b454
branches:  netbsd-1-5
changeset: 490114:6d68dd40b454
user:      tv <tv%NetBSD.org@localhost>
date:      Fri Nov 03 18:41:04 2000 +0000

description:
Pullup 1.11 [abs]:
Recalculate  NVRAM checksum when updating the NVRAM. Avoids 'reboot'
and 'halt' corruptring the NVRAM contents under RISC OS 4.
Taken from patch by Dave Daniels for PR/8759

diffstat:

 sys/arch/arm32/dev/rtc.c |  20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diffs (51 lines):

diff -r d78e725c2d07 -r 6d68dd40b454 sys/arch/arm32/dev/rtc.c
--- a/sys/arch/arm32/dev/rtc.c  Fri Nov 03 18:40:53 2000 +0000
+++ b/sys/arch/arm32/dev/rtc.c  Fri Nov 03 18:41:04 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtc.c,v 1.10 1998/04/19 03:55:44 mark Exp $    */
+/*     $NetBSD: rtc.c,v 1.10.24.1 2000/11/03 18:41:04 tv Exp $ */
 
 /*
  * Copyright (c) 1994-1996 Mark Brinicombe.
@@ -41,6 +41,7 @@
  * Routines to read and write the RTC and CMOS RAM
  *
  * Created      : 13/10/94
+ * Updated     : 15/07/2000    DD
  */
 
 #include <sys/param.h>
@@ -107,6 +108,7 @@
        int value;
 {
        u_char buff[2];
+       int oldvalue, oldsum;
 
 /*
  * This commented code dates from when I was translating CMOS address
@@ -125,9 +127,25 @@
        buff[0] = location;
        buff[1] = value;
 
+/* Read the old CMOS location value and old checksum */
+       oldvalue = cmos_read(location);
+       if (oldvalue<0)
+               return(-1);
+       oldsum = cmos_read(RTC_ADDR_CHECKSUM);
+       if (oldsum<0)
+               return(-1);
+               
        if (iic_control(RTC_Write, buff, 2))
                return(-1);
 
+/* Now update the checksum. This code only modifies the value. It does */
+/* not recalculate it */
+
+       buff[0] = RTC_ADDR_CHECKSUM;
+       buff[1] = oldsum - oldvalue + value;
+       if (iic_control(RTC_Write, buff, 2))
+               return(-1);
+       
        return(0);
 }
 



Home | Main Index | Thread Index | Old Index