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; }
/****************************************************************
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