Use convenience function to checksum
[coreboot.git] / payloads / coreinfo / coreboot_module.c
index e5615b332231aa89c3743a14a4201401ebc11246..7289366f8b5ded61902e9be7fc93cb70a14afb58 100644 (file)
  * 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
 
 #define MAX_MEMORY_COUNT 5
 
@@ -66,7 +68,7 @@ int coreboot_module_redraw(WINDOW *win)
 
        if (cb_info.serial.tag != 0x0) {
                mvwprintw(win, row++, 1, "Serial Port I/O base: 0x%x",
-                         cb_info.serial.ioport);
+                         cb_info.serial.baseaddr);
        }
 
        if (cb_info.console.tag != 0x0) {
@@ -110,9 +112,9 @@ int coreboot_module_redraw(WINDOW *win)
                }
 
                wprintw(win, "%16.16llx - %16.16llx",
-                       UNPACK_CB64(cb_info.range[i].start),
-                       UNPACK_CB64(cb_info.range[i].start) +
-                       UNPACK_CB64(cb_info.range[i].size) - 1);
+                       cb_unpack64(cb_info.range[i].start),
+                       cb_unpack64(cb_info.range[i].start) +
+                       cb_unpack64(cb_info.range[i].size) - 1);
        }
 
        return 0;
@@ -187,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;
 
@@ -201,6 +203,9 @@ static int parse_header(void *addr, int len)
                struct cb_record *rec = (struct cb_record *)ptr;
 
                switch (rec->tag) {
+               case CB_TAG_FORWARD:
+                       return parse_header((void *)(unsigned long)((struct cb_forward *)rec)->forward, 1);
+                       break;
                case CB_TAG_MEMORY:
                        parse_memory(ptr);
                        break;
@@ -252,3 +257,10 @@ struct coreinfo_module coreboot_module = {
        .init = coreboot_module_init,
        .redraw = coreboot_module_redraw,
 };
+
+#else
+
+struct coreinfo_module coreboot_module = {
+};
+
+#endif