]> xenbits.xensource.com Git - seabios.git/commitdiff
coreboot: add cbmem console support
authorGerd Hoffmann <kraxel@redhat.com>
Mon, 24 Jun 2013 09:24:57 +0000 (11:24 +0200)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 14 Jul 2013 18:31:16 +0000 (14:31 -0400)
Add support for logging to the coreboot cbmem console.
Limitation: only supported in 32bit mode.  Use 'cbmem -c'
to see the logs (coreboot and seabios) after bootup.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
src/coreboot.c
src/output.c
src/util.h

index 6ad4cfc98801e677a9a1d8f1c7af80873802f9f8..c66e6e317604fe0a23ebad29c36bffe3c4ebf60d 100644 (file)
@@ -69,6 +69,21 @@ struct cb_forward {
 
 #define CB_TAG_FORWARD 0x11
 
+struct cb_cbmem_ref {
+    u32 tag;
+    u32 size;
+    u64 cbmem_addr;
+};
+
+#define CB_TAG_CBMEM_CONSOLE 0x17
+
+struct cbmem_console {
+       u32 buffer_size;
+       u32 buffer_cursor;
+       u8  buffer_body[0];
+} PACKED;
+static struct cbmem_console *cbcon = NULL;
+
 static u16
 ipchksum(char *buf, int count)
 {
@@ -162,6 +177,13 @@ coreboot_preinit(void)
     // confuses grub.  So, override it.
     add_e820(0, 16*1024, E820_RAM);
 
+    struct cb_cbmem_ref *cbref = find_cb_subtable(cbh, CB_TAG_CBMEM_CONSOLE);
+    if (cbref) {
+        cbcon = (void*)(u32)cbref->cbmem_addr;
+        dprintf(1, "----- [ seabios log starts here ] -----\n");
+        dprintf(1, "Found coreboot cbmem console @ %llx\n", cbref->cbmem_addr);
+    }
+
     struct cb_mainboard *cbmb = find_cb_subtable(cbh, CB_TAG_MAINBOARD);
     if (cbmb) {
         CBvendor = &cbmb->strings[cbmb->vendor_idx];
@@ -182,6 +204,16 @@ fail:
     return;
 }
 
+void debug_cbmem(char c)
+{
+    if (!CONFIG_COREBOOT)
+        return;
+    if (!cbcon)
+        return;
+    if (cbcon->buffer_cursor == cbcon->buffer_size)
+        return;
+    cbcon->buffer_body[cbcon->buffer_cursor++] = c;
+}
 
 /****************************************************************
  * BIOS table copying
index d548766da77ca4219b2ed85badfcd8d2669eed3f..fb2dd76c9a57cfe12fb53e6de02084215f47721d 100644 (file)
@@ -81,6 +81,8 @@ putc_debug(struct putcinfo *action, char c)
     if (CONFIG_DEBUG_IO && runningOnQEMU())
         // Send character to debug port.
         outb(c, GET_GLOBAL(DebugOutputPort));
+    if (!MODESEGMENT)
+        debug_cbmem(c);
     if (c == '\n')
         debug_serial('\r');
     debug_serial(c);
index 996c29ab8a7026f9defd61dced45b102244dbdbd..8bde0b2e704c7c15642a74d602f7fc3781faa077 100644 (file)
@@ -327,6 +327,7 @@ int apic_id_is_present(u8 apic_id);
 // coreboot.c
 extern const char *CBvendor, *CBpart;
 struct cbfs_file;
+void debug_cbmem(char c);
 void cbfs_run_payload(struct cbfs_file *file);
 void coreboot_platform_setup(void);
 void cbfs_payload_setup(void);