libpayload: Remove bitfield use from EHCI data structures
[coreboot.git] / payloads / coreinfo / coreboot_module.c
index 906833eab3a7c4e0435df56cf6cd92e5415eb33f..77a4bb2d8b65200ae2c13548e6b5e8b4c18064d2 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
 
@@ -47,30 +49,30 @@ int coreboot_module_redraw(WINDOW *win)
        print_module_title(win, "Coreboot Tables");
 
        if (tables_good) {
-               mvwprintw(win, row++, 2, "No Coreboot tables were found");
+               mvwprintw(win, row++, 1, "No Coreboot tables were found");
                return 0;
        }
 
-       mvwprintw(win, row++, 2, "Vendor: %s", cb_info.vendor);
-       mvwprintw(win, row++, 2, "Part: %s", cb_info.part);
+       mvwprintw(win, row++, 1, "Vendor: %s", cb_info.vendor);
+       mvwprintw(win, row++, 1, "Part: %s", cb_info.part);
 
-       mvwprintw(win, row++, 2, "Version: %s%s",
+       mvwprintw(win, row++, 1, "Version: %s%s",
                  cb_info.strings[CB_TAG_VERSION - 0x4],
                  cb_info.strings[CB_TAG_EXTRA_VERSION - 0x4]);
 
-       mvwprintw(win, row++, 2, "Built: %s (%s@%s.%s)",
+       mvwprintw(win, row++, 1, "Built: %s (%s@%s.%s)",
                  cb_info.strings[CB_TAG_BUILD - 0x4],
                  cb_info.strings[CB_TAG_COMPILE_BY - 0x04],
                  cb_info.strings[CB_TAG_COMPILE_HOST - 0x04],
                  cb_info.strings[CB_TAG_COMPILE_DOMAIN - 0x04]);
 
        if (cb_info.serial.tag != 0x0) {
-               mvwprintw(win, row++, 2, "Serial Port I/O base: 0x%x",
-                         cb_info.serial.ioport);
+               mvwprintw(win, row++, 1, "Serial Port I/O base: 0x%x",
+                         cb_info.serial.baseaddr);
        }
 
        if (cb_info.console.tag != 0x0) {
-               mvwprintw(win, row++, 2, "Default Output Console: ");
+               mvwprintw(win, row++, 1, "Default Output Console: ");
 
                switch (cb_info.console.type) {
                case CB_TAG_CONSOLE_SERIAL8250:
@@ -95,31 +97,32 @@ int coreboot_module_redraw(WINDOW *win)
        }
 
        row++;
-       mvwprintw(win, row++, 2, "-- Memory Map --");
+       mvwprintw(win, row++, 1, "-- Memory Map --");
 
        for (i = 0; i < cb_info.mem_count; i++) {
                switch (cb_info.range[i].type) {
                case CB_MEM_RAM:
-                       mvwprintw(win, row++, 4, "     RAM: ");
+                       mvwprintw(win, row++, 3, "     RAM: ");
                        break;
                case CB_MEM_RESERVED:
-                       mvwprintw(win, row++, 4, "Reserved: ");
+                       mvwprintw(win, row++, 3, "Reserved: ");
                        break;
                case CB_MEM_TABLE:
-                       mvwprintw(win, row++, 4, "   Table: ");
+                       mvwprintw(win, row++, 3, "   Table: ");
                }
 
                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;
 }
 
 static void parse_memory(unsigned char *ptr)
 {
        struct cb_memory *mem = (struct cb_memory *)ptr;
-
        int max = (MEM_RANGE_COUNT(mem) > MAX_MEMORY_COUNT)
            ? MAX_MEMORY_COUNT : MEM_RANGE_COUNT(mem);
        int i;
@@ -139,8 +142,8 @@ static void parse_mainboard(unsigned char *ptr)
 {
        struct cb_mainboard *mb = (struct cb_mainboard *)ptr;
 
-       strncpy(cb_info.vendor, MB_VENDOR_STRING(mb), 31);
-       strncpy(cb_info.part, MB_PART_STRING(mb), 31);
+       strncpy(cb_info.vendor, cb_mb_vendor_part(mb), sizeof(cb_info.vendor) - 1);
+       strncpy(cb_info.part, cb_mb_part_string(mb), sizeof(cb_info.part) - 1);
 }
 
 static void parse_strings(unsigned char *ptr)
@@ -148,7 +151,7 @@ static void parse_strings(unsigned char *ptr)
        struct cb_string *string = (struct cb_string *)ptr;
        int index = string->tag - CB_TAG_VERSION;
 
-       strncpy(cb_info.strings[index], string->string, 63);
+       strncpy(cb_info.strings[index], (const char *)string->string, 63);
        cb_info.strings[index][63] = 0;
 }
 
@@ -173,7 +176,7 @@ static int parse_header(void *addr, int len)
        for (i = 0; i < len; i += 16, ptr += 16) {
                header = (struct cb_header *)ptr;
 
-               if (!strncmp(header->signature, "LBIO", 4))
+               if (!strncmp((const char *)header->signature, "LBIO", 4))
                        break;
        }
 
@@ -186,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;
 
@@ -200,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;
@@ -234,7 +240,7 @@ static int parse_header(void *addr, int len)
        return 1;
 }
 
-int coreboot_module_init(void)
+static int coreboot_module_init(void)
 {
        int ret = parse_header((void *)0x00000, 0x1000);
 
@@ -251,3 +257,10 @@ struct coreinfo_module coreboot_module = {
        .init = coreboot_module_init,
        .redraw = coreboot_module_redraw,
 };
+
+#else
+
+struct coreinfo_module coreboot_module = {
+};
+
+#endif