Add timestamp table pointer to the coreboot table.
[coreboot.git] / src / arch / x86 / boot / coreboot_table.c
index dea030b60ac56b8d25cac6d707c8a9f6af01a032..53ff3d36d43f94763568909357dfe90199113dce 100644 (file)
@@ -29,7 +29,9 @@
 #include <version.h>
 #include <device/device.h>
 #include <stdlib.h>
-#if (CONFIG_USE_OPTION_TABLE == 1)
+#include <cbfs.h>
+#include <cbmem.h>
+#if CONFIG_USE_OPTION_TABLE
 #include <option_table.h>
 #endif
 
@@ -111,14 +113,32 @@ static struct lb_serial *lb_serial(struct lb_header *header)
        serial = (struct lb_serial *)rec;
        serial->tag = LB_TAG_SERIAL;
        serial->size = sizeof(*serial);
-       serial->ioport = CONFIG_TTYS0_BASE;
+       serial->type = LB_SERIAL_TYPE_IO_MAPPED;
+       serial->baseaddr = CONFIG_TTYS0_BASE;
        serial->baud = CONFIG_TTYS0_BAUD;
        return serial;
+#elif CONFIG_CONSOLE_SERIAL8250MEM
+       if (uartmem_getbaseaddr()) {
+               struct lb_record *rec;
+               struct lb_serial *serial;
+               rec = lb_new_record(header);
+               serial = (struct lb_serial *)rec;
+               serial->tag = LB_TAG_SERIAL;
+               serial->size = sizeof(*serial);
+               serial->type = LB_SERIAL_TYPE_MEMORY_MAPPED;
+               serial->baseaddr = uartmem_getbaseaddr();
+               serial->baud = CONFIG_TTYS0_BAUD;
+               return serial;
+       } else {
+               return NULL;
+       }
 #else
-       return header;
+       return NULL;
 #endif
 }
 
+#if CONFIG_CONSOLE_SERIAL8250 || CONFIG_CONSOLE_SERIAL8250MEM || \
+    CONFIG_CONSOLE_LOGBUF || CONFIG_USBDEBUG
 static void add_console(struct lb_header *header, u16 consoletype)
 {
        struct lb_console *console;
@@ -128,12 +148,16 @@ static void add_console(struct lb_header *header, u16 consoletype)
        console->size = sizeof(*console);
        console->type = consoletype;
 }
+#endif
 
 static void lb_console(struct lb_header *header)
 {
 #if CONFIG_CONSOLE_SERIAL8250
        add_console(header, LB_TAG_CONSOLE_SERIAL8250);
 #endif
+#if CONFIG_CONSOLE_SERIAL8250MEM
+       add_console(header, LB_TAG_CONSOLE_SERIAL8250MEM);
+#endif
 #if CONFIG_CONSOLE_LOGBUF
        add_console(header, LB_TAG_CONSOLE_LOGBUF);
 #endif
@@ -144,7 +168,7 @@ static void lb_console(struct lb_header *header)
 
 static void lb_framebuffer(struct lb_header *header)
 {
-#if defined(CONFIG_BOOTSPLASH) && CONFIG_BOOTSPLASH && CONFIG_COREBOOT_KEEP_FRAMEBUFFER
+#if CONFIG_FRAMEBUFFER_KEEP_VESA_MODE
        void fill_lb_framebuffer(struct lb_framebuffer *framebuffer);
 
        struct lb_framebuffer *framebuffer;
@@ -155,6 +179,23 @@ static void lb_framebuffer(struct lb_header *header)
 #endif
 }
 
+#if CONFIG_COLLECT_TIMESTAMPS
+static void lb_tsamp(struct lb_header *header)
+{
+       struct lb_tstamp *tstamp;
+       void *tstamp_table = cbmem_find(CBMEM_ID_TIMESTAMP);
+
+       if (!tstamp_table)
+               return;
+
+       tstamp = (struct lb_tstamp *)lb_new_record(header);
+       tstamp->tag = LB_TAG_TIMESTAMPS;
+       tstamp->size = sizeof(*tstamp);
+       tstamp->tstamp_tab = tstamp_table;
+
+}
+#endif
+
 static struct lb_mainboard *lb_mainboard(struct lb_header *header)
 {
        struct lb_record *rec;
@@ -179,7 +220,7 @@ static struct lb_mainboard *lb_mainboard(struct lb_header *header)
        return mainboard;
 }
 
-#if (CONFIG_USE_OPTION_TABLE == 1)
+#if CONFIG_USE_OPTION_TABLE
 static struct cmos_checksum *lb_cmos_checksum(struct lb_header *header)
 {
        struct lb_record *rec;
@@ -301,9 +342,10 @@ static unsigned long lb_table_fini(struct lb_header *head, int fixup)
        head->table_checksum = compute_ip_checksum(first_rec, head->table_bytes);
        head->header_checksum = 0;
        head->header_checksum = compute_ip_checksum(head, sizeof(*head));
-       printk(BIOS_DEBUG, "Wrote coreboot table at: %p - %p  checksum %x\n",
-               head, rec, head->table_checksum);
-       return (unsigned long)rec;
+       printk(BIOS_DEBUG,
+              "Wrote coreboot table at: %p, 0x%x bytes, checksum %x\n",
+              head, head->table_bytes, head->table_checksum);
+       return (unsigned long)rec + rec->size;
 }
 
 static void lb_cleanup_memory_ranges(struct lb_memory *mem)
@@ -493,10 +535,6 @@ static void add_lb_reserved(struct lb_memory *mem)
                lb_add_rsvd_range, mem);
 }
 
-#if CONFIG_WRITE_HIGH_TABLES == 1
-extern uint64_t high_tables_base, high_tables_size;
-#endif
-
 unsigned long write_coreboot_table(
        unsigned long low_table_start, unsigned long low_table_end,
        unsigned long rom_table_start, unsigned long rom_table_end)
@@ -504,7 +542,7 @@ unsigned long write_coreboot_table(
        struct lb_header *head;
        struct lb_memory *mem;
 
-#if CONFIG_WRITE_HIGH_TABLES == 1
+#if CONFIG_WRITE_HIGH_TABLES
        printk(BIOS_DEBUG, "Writing high table forward entry at 0x%08lx\n",
                        low_table_end);
        head = lb_table_init(low_table_end);
@@ -540,13 +578,13 @@ unsigned long write_coreboot_table(
        rom_table_end &= ~0xffff;
        printk(BIOS_DEBUG, "0x%08lx \n", rom_table_end);
 
-#if (CONFIG_USE_OPTION_TABLE == 1)
+#if CONFIG_USE_OPTION_TABLE
        {
-               struct cmos_option_table option_table = cbfs_find_file("cmos_layout.bin", 0x1aa);
+               struct cmos_option_table *option_table = cbfs_find_file("cmos_layout.bin", 0x1aa);
                if (option_table) {
                        struct lb_record *rec_dest = lb_new_record(head);
                        /* Copy the option config table, it's already a lb_record... */
-                       memcpy(rec_dest,  &option_table, option_table.size);
+                       memcpy(rec_dest,  option_table, option_table->size);
                        /* Create cmos checksum entry in coreboot table */
                        lb_cmos_checksum(head);
                } else {
@@ -565,7 +603,7 @@ unsigned long write_coreboot_table(
        lb_add_memory_range(mem, LB_MEM_TABLE,
                rom_table_start, rom_table_end-rom_table_start);
 
-#if CONFIG_WRITE_HIGH_TABLES == 1
+#if CONFIG_WRITE_HIGH_TABLES
        printk(BIOS_DEBUG, "Adding high table area\n");
        // should this be LB_MEM_ACPI?
        lb_add_memory_range(mem, LB_MEM_TABLE,
@@ -575,7 +613,7 @@ unsigned long write_coreboot_table(
        /* Add reserved regions */
        add_lb_reserved(mem);
 
-#if (CONFIG_HAVE_MAINBOARD_RESOURCES == 1)
+#if CONFIG_HAVE_MAINBOARD_RESOURCES
        add_mainboard_resources(mem);
 #endif
 
@@ -599,6 +637,9 @@ unsigned long write_coreboot_table(
        /* Record our framebuffer */
        lb_framebuffer(head);
 
+#if CONFIG_COLLECT_TIMESTAMPS
+       lb_tsamp(head);
+#endif
        /* Remember where my valid memory ranges are */
        return lb_table_fini(head, 1);