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 <reinauer@google.com> Reviewed-on: http://review.coreboot.org/342 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
This commit is contained in:
parent
113c349720
commit
ea5c2b62ca
|
@ -1,3 +1,4 @@
|
||||||
|
#include <stdint.h>
|
||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <pc80/mc146818rtc.h>
|
#include <pc80/mc146818rtc.h>
|
||||||
#include <boot/coreboot_tables.h>
|
#include <boot/coreboot_tables.h>
|
||||||
|
@ -80,12 +81,11 @@
|
||||||
static int rtc_checksum_valid(int range_start, int range_end, int cks_loc)
|
static int rtc_checksum_valid(int range_start, int range_end, int cks_loc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned sum, old_sum;
|
u16 sum, old_sum;
|
||||||
sum = 0;
|
sum = 0;
|
||||||
for(i = range_start; i <= range_end; i++) {
|
for(i = range_start; i <= range_end; i++) {
|
||||||
sum += cmos_read(i);
|
sum += cmos_read(i);
|
||||||
}
|
}
|
||||||
sum = (~sum)&0x0ffff;
|
|
||||||
old_sum = ((cmos_read(cks_loc)<<8) | cmos_read(cks_loc+1))&0x0ffff;
|
old_sum = ((cmos_read(cks_loc)<<8) | cmos_read(cks_loc+1))&0x0ffff;
|
||||||
return sum == old_sum;
|
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)
|
static void rtc_set_checksum(int range_start, int range_end, int cks_loc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned sum;
|
u16 sum;
|
||||||
sum = 0;
|
sum = 0;
|
||||||
for(i = range_start; i <= range_end; i++) {
|
for(i = range_start; i <= range_end; i++) {
|
||||||
sum += cmos_read(i);
|
sum += cmos_read(i);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <stdint.h>
|
||||||
#include <pc80/mc146818rtc.h>
|
#include <pc80/mc146818rtc.h>
|
||||||
#include <fallback.h>
|
#include <fallback.h>
|
||||||
#if CONFIG_USE_OPTION_TABLE
|
#if CONFIG_USE_OPTION_TABLE
|
||||||
|
@ -23,13 +24,12 @@ static int cmos_chksum_valid(void)
|
||||||
{
|
{
|
||||||
#if CONFIG_USE_OPTION_TABLE
|
#if CONFIG_USE_OPTION_TABLE
|
||||||
unsigned char addr;
|
unsigned char addr;
|
||||||
unsigned long sum, old_sum;
|
u16 sum, old_sum;
|
||||||
sum = 0;
|
sum = 0;
|
||||||
/* Comput the cmos checksum */
|
/* Compute the cmos checksum */
|
||||||
for(addr = LB_CKS_RANGE_START; addr <= LB_CKS_RANGE_END; addr++) {
|
for(addr = LB_CKS_RANGE_START; addr <= LB_CKS_RANGE_END; addr++) {
|
||||||
sum += cmos_read(addr);
|
sum += cmos_read(addr);
|
||||||
}
|
}
|
||||||
sum = (sum & 0xffff) ^ 0xffff;
|
|
||||||
|
|
||||||
/* Read the stored checksum */
|
/* Read the stored checksum */
|
||||||
old_sum = cmos_read(LB_CKS_LOC) << 8;
|
old_sum = cmos_read(LB_CKS_LOC) << 8;
|
||||||
|
|
Loading…
Reference in New Issue