Changeset
src/fw/coreboot.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
Git apply log
Switched to a new branch '20170419223609.15116-1-jwerner@chromium.org'
Applying: coreboot: Adapt to upstream CBMEM console changes
To https://github.com/patchew-project/seabios
 * [new tag]         patchew/20170419223609.15116-1-jwerner@chromium.org -> patchew/20170419223609.15116-1-jwerner@chromium.org
[SeaBIOS] [PATCH] coreboot: Adapt to upstream CBMEM console changes
Posted by Julius Werner, 22 weeks ago
coreboot's CBMEM console format changed with
https://review.coreboot.org/#/c/18301. This patch adapts the SeaBIOS
implementation to support the new format. (SeaBIOS versions with this
patch will continue to work fine with older version of coreboot. SeaBIOS
versions without this patch may fail to log messages to the CBMEM
console if run with newer versions of coreboot, but should not
experience any more serious issues than that.)

Signed-off-by: Julius Werner <jwerner@chromium.org>
---
 src/fw/coreboot.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/fw/coreboot.c b/src/fw/coreboot.c
index 4957b80..7214f8a 100644
--- a/src/fw/coreboot.c
+++ b/src/fw/coreboot.c
@@ -80,10 +80,12 @@ struct cb_cbmem_ref {
 #define CB_TAG_CBMEM_CONSOLE 0x17
 
 struct cbmem_console {
-    u32 buffer_size;
-    u32 buffer_cursor;
-    u8  buffer_body[0];
+    u32 size;
+    u32 cursor;
+    u8  body[0];
 } PACKED;
+#define CBMC_CURSOR_MASK ((1 << 28) - 1)
+#define CBMC_OVERFLOW (1 << 31)
 static struct cbmem_console *cbcon = NULL;
 
 static u16
@@ -220,9 +222,16 @@ void coreboot_debug_putc(char c)
         return;
     if (!cbcon)
         return;
-    u32 cursor = cbcon->buffer_cursor++;
-    if (cursor < cbcon->buffer_size)
-        cbcon->buffer_body[cursor] = c;
+    u32 cursor = cbcon->cursor & CBMC_CURSOR_MASK;
+    u32 flags = cbcon->cursor & ~CBMC_CURSOR_MASK;
+    if (cursor >= cbcon->size)
+        return;	// Old coreboot version with legacy overflow mechanism.
+    cbcon->body[cursor++] = c;
+    if (cursor >= cbcon->size) {
+        cursor = 0;
+        flags |= CBMC_OVERFLOW;
+    }
+    cbcon->cursor = flags | cursor;
 }
 
 /****************************************************************
-- 
2.12.2.816.g2cccc81164-goog


_______________________________________________
SeaBIOS mailing list
SeaBIOS@seabios.org
https://mail.coreboot.org/mailman/listinfo/seabios
Re: [SeaBIOS] [PATCH] coreboot: Adapt to upstream CBMEM console changes
Posted by Kevin O'Connor, 21 weeks ago
On Wed, Apr 19, 2017 at 03:36:09PM -0700, Julius Werner wrote:
> coreboot's CBMEM console format changed with
> https://review.coreboot.org/#/c/18301. This patch adapts the SeaBIOS
> implementation to support the new format. (SeaBIOS versions with this
> patch will continue to work fine with older version of coreboot. SeaBIOS
> versions without this patch may fail to log messages to the CBMEM
> console if run with newer versions of coreboot, but should not
> experience any more serious issues than that.)

Thanks.  I committed this patch.

-Kevin

_______________________________________________
SeaBIOS mailing list
SeaBIOS@seabios.org
https://mail.coreboot.org/mailman/listinfo/seabios