Vadim Bendebury has uploaded this change for review. ( https://review.coreboot.org/23100
Change subject: libpayload: add a function to dump cbmem console buffer to UART ......................................................................
libpayload: add a function to dump cbmem console buffer to UART
This function could be handy if someone stops the payload at a CLI prompt or if a vboot device falls into recovery.
BRANCH=none BUG=none TEST=with accompanying changes in depthcharge printed cbmem console buffer to the UART console.
Change-Id: I3a2d7b1dd6566ae2c42323c77408c7112e0e1974 Signed-off-by: Vadim Bendebury vbendeb@chromium.org --- M payloads/libpayload/drivers/cbmem_console.c M payloads/libpayload/include/libpayload.h 2 files changed, 20 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/00/23100/1
diff --git a/payloads/libpayload/drivers/cbmem_console.c b/payloads/libpayload/drivers/cbmem_console.c index 9435e1c..09043d4 100644 --- a/payloads/libpayload/drivers/cbmem_console.c +++ b/payloads/libpayload/drivers/cbmem_console.c @@ -75,3 +75,22 @@
do_write(buffer, count); } + +static void dump_buffer_to_uart(const uint8_t *buffer, size_t size) +{ + size_t i; + + for (i = 0; i < size; i++) + serial_putchar(*buffer++); +} + +void cbmem_console_dump_buffer_to_uart(void) +{ + uint32_t cursor = cbmem_console_p->cursor & CURSOR_MASK; + + if (cbmem_console_p->cursor & OVERFLOW) + dump_buffer_to_uart(cbmem_console_p->body + cursor, + cbmem_console_p->size - cursor); + + dump_buffer_to_uart(cbmem_console_p->body, cursor); +} diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h index 83658d1..86e3e1b 100644 --- a/payloads/libpayload/include/libpayload.h +++ b/payloads/libpayload/include/libpayload.h @@ -245,6 +245,7 @@ */ void cbmem_console_init(void); void cbmem_console_write(const void *buffer, size_t count); +void cbmem_console_dump_buffer_to_uart(void); /** @} */
/* drivers/option.c */