From ea5c2b62caec8a2acd5298777b825b799e2b9c15 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Thu, 27 Oct 2011 18:42:53 +0200 Subject: Fix checksum calculation both in romstage and ramstage. The earlier fix for CMOS checksums only fixed the function rtc_set_checksum, which would fix the checksum, but then coreboot would no longer honor the settings because it assumed the checksum is wrong after this. This change fixes the remaining functions. Change-Id: I3f52d074df29fc29ae1d940b3dcec3aa2cfc96a5 Signed-off-by: Stefan Reinauer Reviewed-on: http://review.coreboot.org/342 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- src/pc80/mc146818rtc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/pc80/mc146818rtc.c') diff --git a/src/pc80/mc146818rtc.c b/src/pc80/mc146818rtc.c index 034957acf5..99d670de42 100644 --- a/src/pc80/mc146818rtc.c +++ b/src/pc80/mc146818rtc.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -80,12 +81,11 @@ static int rtc_checksum_valid(int range_start, int range_end, int cks_loc) { int i; - unsigned sum, old_sum; + u16 sum, old_sum; sum = 0; for(i = range_start; i <= range_end; i++) { sum += cmos_read(i); } - sum = (~sum)&0x0ffff; old_sum = ((cmos_read(cks_loc)<<8) | cmos_read(cks_loc+1))&0x0ffff; return sum == old_sum; } @@ -93,7 +93,7 @@ static int rtc_checksum_valid(int range_start, int range_end, int cks_loc) static void rtc_set_checksum(int range_start, int range_end, int cks_loc) { int i; - unsigned sum; + u16 sum; sum = 0; for(i = range_start; i <= range_end; i++) { sum += cmos_read(i); -- cgit v1.2.3