[U-Boot] [PATCH 4/5] x86: Add console command to display CBMEM console buffer

Simon Glass sjg at chromium.org
Sat Oct 13 06:48:48 CEST 2012


From: Vadim Bendebury <vbendeb at chromium.org>

This command is useful to allow to observe messages generated by
coreboot and u-boot until present. In particular it is handy when
u-boot is instrumented to fall through into console mode on startup
errors.

Signed-off-by: Vadim Bendebury <vbendeb at chromium.org>
Signed-off-by: Simon Glass <sjg at chromium.org>
---
 drivers/misc/cbmem_console.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/misc/cbmem_console.c b/drivers/misc/cbmem_console.c
index 80a84fd..35c3cb1 100644
--- a/drivers/misc/cbmem_console.c
+++ b/drivers/misc/cbmem_console.c
@@ -31,10 +31,19 @@ struct cbmem_console {
 
 static struct cbmem_console *cbmem_console_p;
 
+/*
+ * Need to be able to avoid adding charactes to cbmem console buffer while its
+ * contents are being dumped.
+ */
+static int suppress_cbmem_console;
+
 void cbmemc_putc(char data)
 {
 	int cursor;
 
+	if (suppress_cbmem_console)
+		return;
+
 	cursor = cbmem_console_p->buffer_cursor++;
 	if (cursor < cbmem_console_p->buffer_size)
 		cbmem_console_p->buffer_body[cursor] = data;
@@ -65,3 +74,20 @@ int cbmemc_init(void)
 
 	return (rc == 0) ? 1 : rc;
 }
+
+static int
+do_cbc_dump(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	int cursor = 0;
+
+	suppress_cbmem_console = 1;
+
+	while (cursor < cbmem_console_p->buffer_cursor)
+		putc(cbmem_console_p->buffer_body[cursor++]);
+
+	suppress_cbmem_console = 0;
+	return 0;
+}
+
+U_BOOT_CMD(cbc_dump, 1, 1, do_cbc_dump,
+	   "dump CBMEM console buffer to serial port", NULL);
-- 
1.7.7.3



More information about the U-Boot mailing list