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

login
register
mail settings
Submitter Simon Glass
Date Oct. 13, 2012, 4:48 a.m.
Message ID <1350103729-15913-4-git-send-email-sjg@chromium.org>
Download mbox | patch
Permalink /patch/191279/
State Accepted, archived
Delegated to: Simon Glass
Headers show

Comments

Simon Glass - Oct. 13, 2012, 4:48 a.m.
From: Vadim Bendebury <vbendeb@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@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
---
 drivers/misc/cbmem_console.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

Patch

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);