coreboot: add cbmem console support
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>
diff --git a/src/coreboot.c b/src/coreboot.c
index 6ad4cfc..c66e6e3 100644
--- a/src/coreboot.c
+++ b/src/coreboot.c
@@ -69,6 +69,21 @@
#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 @@
// 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 @@
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
diff --git a/src/output.c b/src/output.c
index d548766..fb2dd76 100644
--- a/src/output.c
+++ b/src/output.c
@@ -81,6 +81,8 @@
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);
diff --git a/src/util.h b/src/util.h
index 996c29a..8bde0b2 100644
--- a/src/util.h
+++ b/src/util.h
@@ -327,6 +327,7 @@
// 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);