X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=payloads%2Flibpayload%2Fdrivers%2Foptions.c;h=394c7920ec99fb4621cc92d479f58478b632ff0c;hb=d7ecfa7c152da59cf76b5dfd8ff4ef1313a74260;hp=51173004271d078aa541868bea97c028082bf25c;hpb=14e22779625de673569c7b950ecc2753fb915b31;p=coreboot.git diff --git a/payloads/libpayload/drivers/options.c b/payloads/libpayload/drivers/options.c index 511730042..394c7920e 100644 --- a/payloads/libpayload/drivers/options.c +++ b/payloads/libpayload/drivers/options.c @@ -41,13 +41,28 @@ static int options_checksum_valid(void) for(i = range_start; i <= range_end; i++) { checksum += nvram_read(i); } - checksum = (~checksum)&0xffff; checksum_old = ((nvram_read(checksum_location)<<8) | nvram_read(checksum_location+1)); 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); + } + + 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; @@ -76,9 +91,8 @@ static int get_cmos_value(u32 bitnum, u32 len, void *valptr) return 0; } -int get_option(void *dest, char *name) +int get_option_from(struct cb_cmos_option_table *option_table, void *dest, char *name) { - struct cb_cmos_option_table *option_table = phys_to_virt(lib_sysinfo.option_table); struct cb_cmos_entries *cmos_entry; int len = strnlen(name, CMOS_MAX_NAME_LENGTH); @@ -101,3 +115,9 @@ int get_option(void *dest, char *name) printf("ERROR: No such CMOS option (%s)\n", name); return 1; } + +int get_option(void *dest, char *name) +{ + struct cb_cmos_option_table *option_table = phys_to_virt(lib_sysinfo.option_table); + return get_option_from(option_table, dest, name); +}