Fix CMOS checksum calculation in libpayload.
[coreboot.git] / payloads / libpayload / drivers / options.c
index 1c692f46e0dd89eee06a30c8f24e9280efd83ea9..394c7920ec99fb4621cc92d479f58478b632ff0c 100644 (file)
@@ -41,7 +41,6 @@ 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));
 
@@ -59,7 +58,6 @@ void fix_options_checksum(void)
        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);
@@ -93,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);
 
@@ -118,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);
+}