summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2010-08-17 10:14:50 +0000
committerPatrick Georgi <patrick.georgi@coresystems.de>2010-08-17 10:14:50 +0000
commit59a1b7f7f1a847e20b58dbf426ba00b6b1fc8344 (patch)
tree004e8c078bc9c77c6da45f6db088d728cbdbd7b1
parent835674b9298b19315ae1ed70c2fc9d82a7f3535b (diff)
downloadcoreboot-59a1b7f7f1a847e20b58dbf426ba00b6b1fc8344.tar.xz
libpayload: Add function to fix CMOS checksum.
Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Myles Watson <mylesgw@gmail.com> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5711 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r--payloads/libpayload/drivers/options.c17
-rw-r--r--payloads/libpayload/include/libpayload.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/payloads/libpayload/drivers/options.c b/payloads/libpayload/drivers/options.c
index 5117300427..1c692f46e0 100644
--- a/payloads/libpayload/drivers/options.c
+++ b/payloads/libpayload/drivers/options.c
@@ -48,6 +48,23 @@ static int options_checksum_valid(void)
return (checksum_old == checksum);
}
+void fix_options_checksum(void)
+{
+ int i;
+ int range_start = lib_sysinfo.cmos_range_start / 8;
+ int range_end = lib_sysinfo.cmos_range_end / 8;
+ int checksum_location = lib_sysinfo.cmos_checksum_location / 8;
+ u16 checksum = 0;
+
+ for(i = range_start; i <= range_end; i++) {
+ checksum += nvram_read(i);
+ }
+ checksum = (~checksum)&0xffff;
+
+ nvram_write((checksum >> 8), checksum_location);
+ nvram_write((checksum & 0xff), checksum_location + 1);
+}
+
static int get_cmos_value(u32 bitnum, u32 len, void *valptr)
{
u8 *value = (u8 *)valptr;
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index f3da228933..43e138fd7d 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -194,6 +194,7 @@ void video_console_set_cursor(unsigned int cursorx, unsigned int cursory);
/** @} */
/* drivers/option.c */
+void fix_options_checksum(void);
int get_option(void *dest, char *name);
/**