Use convenience function to checksum
authorPhilip Prindeville <philipp@redfish-solutions.com>
Sat, 24 Dec 2011 00:22:05 +0000 (17:22 -0700)
committerPatrick Georgi <patrick@georgi-clan.de>
Sat, 24 Dec 2011 10:51:14 +0000 (11:51 +0100)
That coreboot uses the IP checksum is an artifact, not a deliberate
requirement to be compatible with the Internet Protocole suite. Use
a wrapper to abstract the computation of coreboot's checksum.

Change-Id: I6491b9ba5efb9ffe5cb12a6172653a6ac80a1370
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Reviewed-on: http://review.coreboot.org/497
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
payloads/coreinfo/coreboot_module.c
payloads/libpayload/include/coreboot_tables.h

index 5d13128e32c1ffc8e91fd48bfb3d1707771cc268..7289366f8b5ded61902e9be7fc93cb70a14afb58 100644 (file)
@@ -17,8 +17,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-#include <coreboot_tables.h>
 #include "coreinfo.h"
+#include <coreboot_tables.h>
 
 #ifdef CONFIG_MODULE_COREBOOT
 
@@ -189,10 +189,10 @@ static int parse_header(void *addr, int len)
 
        /* FIXME: Check the checksum. */
 
-       if (ipchksum((uint16_t *) header, sizeof(*header)))
+       if (cb_checksum(header, sizeof(*header)))
                return -1;
 
-       if (ipchksum((uint16_t *) (ptr + sizeof(*header)), header->table_bytes)
+       if (cb_checksum((ptr + sizeof(*header)), header->table_bytes)
            != header->table_checksum)
                return -1;
 
index 3b3b7d2299b00146b1838cb3dc8edaf05d9d3420..574469a6ed57085f9e3c6ddc808fb753e848edae 100644 (file)
@@ -223,6 +223,11 @@ static inline u64 cb_unpack64(struct cbuint64 val)
        return (((u64) val.hi) << 32) | val.lo;
 }
 
+static inline u16 cb_checksum(const void *ptr, unsigned len)
+{
+       return ipchksum(ptr, len);
+}
+
 /* Helpful macros */
 
 #define MEM_RANGE_COUNT(_rec) \