All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 1/6] display_options: Refactor to allow obtaining the banner
@ 2017-06-16  3:37 Simon Glass
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 2/6] Allow displaying the U-Boot banner on a video display Simon Glass
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Simon Glass @ 2017-06-16  3:37 UTC (permalink / raw)
  To: u-boot

Move the display options code into a separate function so that the U-Boot
banner can be obtained from other code. Adjust the 'version' command to
use it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3: None
Changes in v2:
- Update the code to be more testable
- Avoid a warning on spring, etc.

 cmd/version.c             |  4 +++-
 include/display_options.h | 19 +++++++++++++++++++
 lib/display_options.c     | 36 +++++++++++++++++++++++++++++++-----
 3 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/cmd/version.c b/cmd/version.c
index 1be0667f09..15aab5dc18 100644
--- a/cmd/version.c
+++ b/cmd/version.c
@@ -17,7 +17,9 @@ const char __weak version_string[] = U_BOOT_VERSION_STRING;
 
 static int do_version(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	printf("\n%s\n", version_string);
+	char buf[DISPLAY_OPTIONS_BANNER_LENGTH];
+
+	printf(display_options_get_banner(false, buf, sizeof(buf)));
 #ifdef CC_VERSION_STRING
 	puts(CC_VERSION_STRING "\n");
 #endif
diff --git a/include/display_options.h b/include/display_options.h
index ac44c459b3..ad707a344c 100644
--- a/include/display_options.h
+++ b/include/display_options.h
@@ -56,4 +56,23 @@ int print_buffer(ulong addr, const void *data, uint width, uint count,
  */
 int display_options(void);
 
+/* Suggested length of the buffer to pass to display_options_get_banner() */
+#define DISPLAY_OPTIONS_BANNER_LENGTH	200
+
+/**
+ * display_options_get_banner() - Get the U-Boot banner as a string
+ *
+ * This returns the U-Boot banner string
+ *
+ * @newlines: true to include two newlines at the start
+ * @buf: place to put string
+ * @size: Size of buf (string is truncated to fit)
+ * @return buf
+ */
+char *display_options_get_banner(bool newlines, char *buf, int size);
+
+/** This function is used for testing only */
+char *display_options_get_banner_priv(bool newlines, const char *build_tag,
+				      char *buf, int size);
+
 #endif
diff --git a/lib/display_options.c b/lib/display_options.c
index 29343fc00e..4ea27ca99d 100644
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -13,13 +13,39 @@
 #include <linux/ctype.h>
 #include <asm/io.h>
 
-int display_options (void)
+char *display_options_get_banner_priv(bool newlines, const char *build_tag,
+				      char *buf, int size)
 {
-#if defined(BUILD_TAG)
-	printf ("\n\n%s, Build: %s\n\n", version_string, BUILD_TAG);
-#else
-	printf ("\n\n%s\n\n", version_string);
+	int len;
+
+	len = snprintf(buf, size, "%s%s", newlines ? "\n\n" : "",
+		       version_string);
+	if (build_tag && len < size)
+		len += snprintf(buf + len, size - len, ", Build: %s",
+				build_tag);
+	if (len > size - 3)
+		len = size - 3;
+	strcpy(buf + len, "\n\n");
+
+	return buf;
+}
+
+#ifndef BUILD_TAG
+#define BUILD_TAG NULL
 #endif
+
+char *display_options_get_banner(bool newlines, char *buf, int size)
+{
+	return display_options_get_banner_priv(newlines, BUILD_TAG, buf, size);
+}
+
+int display_options(void)
+{
+	char buf[DISPLAY_OPTIONS_BANNER_LENGTH];
+
+	display_options_get_banner(true, buf, sizeof(buf));
+	printf("%s", buf);
+
 	return 0;
 }
 
-- 
2.13.1.518.g3df882009-goog

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 2/6] Allow displaying the U-Boot banner on a video display
  2017-06-16  3:37 [U-Boot] [PATCH v3 1/6] display_options: Refactor to allow obtaining the banner Simon Glass
@ 2017-06-16  3:37 ` Simon Glass
  2017-06-16  5:07   ` Bin Meng
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 3/6] test: Add a test for snprintf() and the banner/version Simon Glass
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Simon Glass @ 2017-06-16  3:37 UTC (permalink / raw)
  To: u-boot

At present the U-Boot banner is only displayed on the serial console. If
this is not visible to the user, the banner does not show. Some devices
have a video display which can usefully display this information.

Add a banner which is printed after relocation only on non-serial devices
if CONFIG_DISPLAY_BOARDINFO_LATE is defined.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3: None
Changes in v2:
- Reword function comment for console_announce_r() slighty

 common/board_r.c  |  1 +
 common/console.c  | 17 +++++++++++++----
 include/console.h | 12 ++++++++++++
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index adc1f1937e..8d9f0a3c5e 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -832,6 +832,7 @@ static init_fnc_t init_sequence_r[] = {
 #endif
 	console_init_r,		/* fully init console as a device */
 #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
+	console_announce_r,
 	show_board_info,
 #endif
 #ifdef CONFIG_ARCH_MISC_INIT
diff --git a/common/console.c b/common/console.c
index 1232808df5..60e7a94a56 100644
--- a/common/console.c
+++ b/common/console.c
@@ -202,7 +202,6 @@ static void console_putc(int file, const char c)
 	}
 }
 
-#if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
 static void console_puts_noserial(int file, const char *s)
 {
 	int i;
@@ -214,7 +213,6 @@ static void console_puts_noserial(int file, const char *s)
 			dev->puts(dev, s);
 	}
 }
-#endif
 
 static void console_puts(int file, const char *s)
 {
@@ -248,13 +246,11 @@ static inline void console_putc(int file, const char c)
 	stdio_devices[file]->putc(stdio_devices[file], c);
 }
 
-#if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
 static inline void console_puts_noserial(int file, const char *s)
 {
 	if (strcmp(stdio_devices[file]->name, "serial") != 0)
 		stdio_devices[file]->puts(stdio_devices[file], s);
 }
-#endif
 
 static inline void console_puts(int file, const char *s)
 {
@@ -699,6 +695,19 @@ static void console_update_silent(void)
 #endif
 }
 
+int console_announce_r(void)
+{
+#if !CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
+	char buf[DISPLAY_OPTIONS_BANNER_LENGTH];
+
+	display_options_get_banner(false, buf, sizeof(buf));
+
+	console_puts_noserial(stdout, buf);
+#endif
+
+	return 0;
+}
+
 /* Called before relocation - use serial functions */
 int console_init_f(void)
 {
diff --git a/include/console.h b/include/console.h
index 3d37f6a53b..cea29ed6dc 100644
--- a/include/console.h
+++ b/include/console.h
@@ -42,6 +42,18 @@ void console_record_reset(void);
  */
 void console_record_reset_enable(void);
 
+/**
+ * console_announce_r() - print a U-Boot console on non-serial consoles
+ *
+ * When U-Boot starts up with a display it generally does not announce itself
+ * on the display. The banner is instead emitted on the UART before relocation.
+ * This function prints a banner on devices which (we assume) did not receive
+ * it before relocation.
+ *
+ * @return 0 (meaning no errors)
+ */
+int console_announce_r(void);
+
 /*
  * CONSOLE multiplexing.
  */
-- 
2.13.1.518.g3df882009-goog

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 3/6] test: Add a test for snprintf() and the banner/version
  2017-06-16  3:37 [U-Boot] [PATCH v3 1/6] display_options: Refactor to allow obtaining the banner Simon Glass
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 2/6] Allow displaying the U-Boot banner on a video display Simon Glass
@ 2017-06-16  3:37 ` Simon Glass
  2017-06-16  5:07   ` Bin Meng
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 4/6] console: Use map_sysmem() for the pre-relocation console Simon Glass
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Simon Glass @ 2017-06-16  3:37 UTC (permalink / raw)
  To: u-boot

Add a simple test to make sure that these functions obey the buffer size
passed into them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3: None
Changes in v2:
- Fix buffer overflow problem when there is not enough space for the build tag
- Add test to check for buffer overflow problems

 test/Makefile   |  1 +
 test/print_ut.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 test/print_ut.c

diff --git a/test/Makefile b/test/Makefile
index 0f5de57399..6305afb211 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -8,4 +8,5 @@ obj-$(CONFIG_UNIT_TEST) += cmd_ut.o
 obj-$(CONFIG_UNIT_TEST) += ut.o
 obj-$(CONFIG_SANDBOX) += command_ut.o
 obj-$(CONFIG_SANDBOX) += compression.o
+obj-$(CONFIG_SANDBOX) += print_ut.o
 obj-$(CONFIG_UT_TIME) += time_ut.o
diff --git a/test/print_ut.c b/test/print_ut.c
new file mode 100644
index 0000000000..baad289972
--- /dev/null
+++ b/test/print_ut.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2012, The Chromium Authors
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#define DEBUG
+
+#include <common.h>
+#include <display_options.h>
+#include <version.h>
+
+#define FAKE_BUILD_TAG	"jenkins-u-boot-denx_uboot_dm-master-build-aarch64" \
+			"and a lot more text to come"
+
+static int do_ut_print(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char *const argv[])
+{
+	char big_str[400];
+	int big_str_len;
+	char str[10], *s;
+	int len;
+
+	printf("%s: Testing print\n", __func__);
+
+	snprintf(str, sizeof(str), "testing");
+	assert(!strcmp("testing", str));
+
+	snprintf(str, sizeof(str), "testing but too long");
+	assert(!strcmp("testing b", str));
+
+	snprintf(str, 1, "testing none");
+	assert(!strcmp("", str));
+
+	*str = 'x';
+	snprintf(str, 0, "testing none");
+	assert(*str == 'x');
+
+	/* Test the banner function */
+	s = display_options_get_banner(true, str, sizeof(str));
+	assert(s == str);
+	assert(!strcmp("\n\nU-Boo\n\n", s));
+
+	s = display_options_get_banner(true, str, 1);
+	assert(s == str);
+	assert(!strcmp("", s));
+
+	s = display_options_get_banner(true, str, 2);
+	assert(s == str);
+	assert(!strcmp("\n", s));
+
+	s = display_options_get_banner(false, str, sizeof(str));
+	assert(s == str);
+	assert(!strcmp("U-Boot \n\n", s));
+
+	/* Give it enough space for some of the version */
+	big_str_len = strlen(version_string) - 5;
+	s = display_options_get_banner_priv(false, FAKE_BUILD_TAG, big_str,
+					    big_str_len);
+	assert(s == big_str);
+	assert(!strncmp(version_string, s, big_str_len - 3));
+	assert(!strcmp("\n\n", s + big_str_len - 3));
+
+	/* Give it enough space for the version and some of the build tag */
+	big_str_len = strlen(version_string) + 9 + 20;
+	s = display_options_get_banner_priv(false, FAKE_BUILD_TAG, big_str,
+					    big_str_len);
+	assert(s == big_str);
+	len = strlen(version_string);
+	assert(!strncmp(version_string, s, len));
+	assert(!strncmp(", Build: ", s + len, 9));
+	assert(!strncmp(FAKE_BUILD_TAG, s + 9 + len, 12));
+	assert(!strcmp("\n\n", s + big_str_len - 3));
+
+	printf("%s: Everything went swimmingly\n", __func__);
+	return 0;
+}
+
+U_BOOT_CMD(
+	ut_print,	1,	1,	do_ut_print,
+	"Very basic test of printf(), etc.",
+	""
+);
-- 
2.13.1.518.g3df882009-goog

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 4/6] console: Use map_sysmem() for the pre-relocation console
  2017-06-16  3:37 [U-Boot] [PATCH v3 1/6] display_options: Refactor to allow obtaining the banner Simon Glass
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 2/6] Allow displaying the U-Boot banner on a video display Simon Glass
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 3/6] test: Add a test for snprintf() and the banner/version Simon Glass
@ 2017-06-16  3:37 ` Simon Glass
  2017-06-16  5:07   ` Bin Meng
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 5/6] sandbox: Enable more console options Simon Glass
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Simon Glass @ 2017-06-16  3:37 UTC (permalink / raw)
  To: u-boot

At present this feature casts the address to a pointer. Use the
map_sysmem() function so that it will work correctly on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3:
- Add new patch to use map_sysmem() for the pre-relocation console

Changes in v2: None

 common/console.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/common/console.c b/common/console.c
index 60e7a94a56..762d5f291c 100644
--- a/common/console.c
+++ b/common/console.c
@@ -11,6 +11,7 @@
 #include <stdarg.h>
 #include <iomux.h>
 #include <malloc.h>
+#include <mapmem.h>
 #include <os.h>
 #include <serial.h>
 #include <stdio_dev.h>
@@ -416,9 +417,13 @@ int tstc(void)
 
 static void pre_console_putc(const char c)
 {
-	char *buffer = (char *)CONFIG_PRE_CON_BUF_ADDR;
+	char *buffer;
+
+	buffer = map_sysmem(CONFIG_PRE_CON_BUF_ADDR, CONFIG_PRE_CON_BUF_SZ);
 
 	buffer[CIRC_BUF_IDX(gd->precon_buf_idx++)] = c;
+
+	unmap_sysmem(buffer);
 }
 
 static void pre_console_puts(const char *s)
@@ -430,14 +435,16 @@ static void pre_console_puts(const char *s)
 static void print_pre_console_buffer(int flushpoint)
 {
 	unsigned long in = 0, out = 0;
-	char *buf_in = (char *)CONFIG_PRE_CON_BUF_ADDR;
 	char buf_out[CONFIG_PRE_CON_BUF_SZ + 1];
+	char *buf_in;
 
+	buf_in = map_sysmem(CONFIG_PRE_CON_BUF_ADDR, CONFIG_PRE_CON_BUF_SZ);
 	if (gd->precon_buf_idx > CONFIG_PRE_CON_BUF_SZ)
 		in = gd->precon_buf_idx - CONFIG_PRE_CON_BUF_SZ;
 
 	while (in < gd->precon_buf_idx)
 		buf_out[out++] = buf_in[CIRC_BUF_IDX(in++)];
+	unmap_sysmem(buf_in);
 
 	buf_out[out] = 0;
 
-- 
2.13.1.518.g3df882009-goog

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 5/6] sandbox: Enable more console options
  2017-06-16  3:37 [U-Boot] [PATCH v3 1/6] display_options: Refactor to allow obtaining the banner Simon Glass
                   ` (2 preceding siblings ...)
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 4/6] console: Use map_sysmem() for the pre-relocation console Simon Glass
@ 2017-06-16  3:37 ` Simon Glass
  2017-06-16  5:08   ` Bin Meng
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 6/6] sandbox: Drop special case console code for sandbox Simon Glass
  2017-06-16  5:07 ` [U-Boot] [PATCH v3 1/6] display_options: Refactor to allow obtaining the banner Bin Meng
  5 siblings, 1 reply; 17+ messages in thread
From: Simon Glass @ 2017-06-16  3:37 UTC (permalink / raw)
  To: u-boot

Enable the pre-console buffer, displaying the model and post-relocation
console announce on sandbox. Also add a model name to the device tree.
This allows testing of these features.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3:
- Add new patch to enable more console options on sandbox

Changes in v2: None

 arch/sandbox/dts/sandbox.dts | 1 +
 common/Kconfig               | 2 +-
 configs/sandbox_defconfig    | 2 ++
 include/configs/sandbox.h    | 1 +
 4 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 40f423da25..0aba6c9a6d 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -5,6 +5,7 @@
 / {
 	#address-cells = <1>;
 	#size-cells = <1>;
+	model = "sandbox";
 
 	aliases {
 		eth5 = "/eth at 90000000";
diff --git a/common/Kconfig b/common/Kconfig
index c49199bb1a..4853863470 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -472,7 +472,7 @@ config DISPLAY_CPUINFO
 
 config DISPLAY_BOARDINFO
 	bool "Display information about the board during start up"
-	default y if ARM || M68K || MIPS || PPC || XTENSA
+	default y if ARM || M68K || MIPS || PPC || SANDBOX || XTENSA
 	help
 	  Display information about the board that U-Boot is running on
 	  when U-Boot starts up. The board function checkboard() is called
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 6a6e7741d8..7a1b9ef052 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -14,6 +14,8 @@ CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
 CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 CONFIG_SILENT_CONSOLE=y
+CONFIG_PRE_CONSOLE_BUFFER=y
+CONFIG_PRE_CON_BUF_ADDR=0
 CONFIG_CMD_CPU=y
 CONFIG_CMD_LICENSE=y
 CONFIG_CMD_BOOTZ=y
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 9276cf9734..1e8404cbdf 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -41,6 +41,7 @@
 
 #define CONFIG_SYS_LONGHELP			/* #undef to save memory */
 #define CONFIG_SYS_CBSIZE		1024	/* Console I/O Buffer Size */
+#define CONFIG_DISPLAY_BOARDINFO_LATE
 
 /* Print Buffer Size */
 #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
-- 
2.13.1.518.g3df882009-goog

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 6/6] sandbox: Drop special case console code for sandbox
  2017-06-16  3:37 [U-Boot] [PATCH v3 1/6] display_options: Refactor to allow obtaining the banner Simon Glass
                   ` (3 preceding siblings ...)
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 5/6] sandbox: Enable more console options Simon Glass
@ 2017-06-16  3:37 ` Simon Glass
  2017-06-16  5:08   ` Bin Meng
  2017-06-16  5:07 ` [U-Boot] [PATCH v3 1/6] display_options: Refactor to allow obtaining the banner Bin Meng
  5 siblings, 1 reply; 17+ messages in thread
From: Simon Glass @ 2017-06-16  3:37 UTC (permalink / raw)
  To: u-boot

At present sandbox has a special case where it directly calls os_putc()
when it does not have a console yet.

Now that we have the pre-console buffer enabled we can drop this. Any
early characters will be buffered and output later.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3:
- Add new patch to drop special case console code for sandbox

Changes in v2: None

 common/console.c | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/common/console.c b/common/console.c
index 762d5f291c..c6156f33bb 100644
--- a/common/console.c
+++ b/common/console.c
@@ -465,13 +465,6 @@ static inline void print_pre_console_buffer(int flushpoint) {}
 
 void putc(const char c)
 {
-#ifdef CONFIG_SANDBOX
-	/* sandbox can send characters to stdout before it has a console */
-	if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
-		os_putc(c);
-		return;
-	}
-#endif
 #ifdef CONFIG_DEBUG_UART
 	/* if we don't have a console yet, use the debug UART */
 	if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
@@ -508,12 +501,6 @@ void putc(const char c)
 
 void puts(const char *s)
 {
-#ifdef CONFIG_SANDBOX
-	if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
-		os_puts(s);
-		return;
-	}
-#endif
 #ifdef CONFIG_DEBUG_UART
 	if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
 		while (*s) {
-- 
2.13.1.518.g3df882009-goog

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 1/6] display_options: Refactor to allow obtaining the banner
  2017-06-16  3:37 [U-Boot] [PATCH v3 1/6] display_options: Refactor to allow obtaining the banner Simon Glass
                   ` (4 preceding siblings ...)
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 6/6] sandbox: Drop special case console code for sandbox Simon Glass
@ 2017-06-16  5:07 ` Bin Meng
  5 siblings, 0 replies; 17+ messages in thread
From: Bin Meng @ 2017-06-16  5:07 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 16, 2017 at 11:37 AM, Simon Glass <sjg@chromium.org> wrote:
> Move the display options code into a separate function so that the U-Boot
> banner can be obtained from other code. Adjust the 'version' command to
> use it.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3: None
> Changes in v2:
> - Update the code to be more testable
> - Avoid a warning on spring, etc.
>
>  cmd/version.c             |  4 +++-
>  include/display_options.h | 19 +++++++++++++++++++
>  lib/display_options.c     | 36 +++++++++++++++++++++++++++++++-----
>  3 files changed, 53 insertions(+), 6 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>

One nits below.

> diff --git a/cmd/version.c b/cmd/version.c
> index 1be0667f09..15aab5dc18 100644
> --- a/cmd/version.c
> +++ b/cmd/version.c
> @@ -17,7 +17,9 @@ const char __weak version_string[] = U_BOOT_VERSION_STRING;
>
>  static int do_version(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  {
> -       printf("\n%s\n", version_string);
> +       char buf[DISPLAY_OPTIONS_BANNER_LENGTH];
> +
> +       printf(display_options_get_banner(false, buf, sizeof(buf)));
>  #ifdef CC_VERSION_STRING
>         puts(CC_VERSION_STRING "\n");
>  #endif
> diff --git a/include/display_options.h b/include/display_options.h
> index ac44c459b3..ad707a344c 100644
> --- a/include/display_options.h
> +++ b/include/display_options.h
> @@ -56,4 +56,23 @@ int print_buffer(ulong addr, const void *data, uint width, uint count,
>   */
>  int display_options(void);
>
> +/* Suggested length of the buffer to pass to display_options_get_banner() */
> +#define DISPLAY_OPTIONS_BANNER_LENGTH  200
> +
> +/**
> + * display_options_get_banner() - Get the U-Boot banner as a string
> + *
> + * This returns the U-Boot banner string
> + *
> + * @newlines: true to include two newlines at the start
> + * @buf: place to put string
> + * @size: Size of buf (string is truncated to fit)
> + * @return buf
> + */
> +char *display_options_get_banner(bool newlines, char *buf, int size);
> +
> +/** This function is used for testing only */

nits: /*

> +char *display_options_get_banner_priv(bool newlines, const char *build_tag,
> +                                     char *buf, int size);
> +
>  #endif

[snip]

Regards,
Bin

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 2/6] Allow displaying the U-Boot banner on a video display
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 2/6] Allow displaying the U-Boot banner on a video display Simon Glass
@ 2017-06-16  5:07   ` Bin Meng
  2017-07-06 14:52     ` sjg at google.com
  0 siblings, 1 reply; 17+ messages in thread
From: Bin Meng @ 2017-06-16  5:07 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 16, 2017 at 11:37 AM, Simon Glass <sjg@chromium.org> wrote:
> At present the U-Boot banner is only displayed on the serial console. If
> this is not visible to the user, the banner does not show. Some devices
> have a video display which can usefully display this information.
>
> Add a banner which is printed after relocation only on non-serial devices
> if CONFIG_DISPLAY_BOARDINFO_LATE is defined.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3: None
> Changes in v2:
> - Reword function comment for console_announce_r() slighty
>
>  common/board_r.c  |  1 +
>  common/console.c  | 17 +++++++++++++----
>  include/console.h | 12 ++++++++++++
>  3 files changed, 26 insertions(+), 4 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 3/6] test: Add a test for snprintf() and the banner/version
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 3/6] test: Add a test for snprintf() and the banner/version Simon Glass
@ 2017-06-16  5:07   ` Bin Meng
  2017-07-06 14:52     ` sjg at google.com
  0 siblings, 1 reply; 17+ messages in thread
From: Bin Meng @ 2017-06-16  5:07 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 16, 2017 at 11:37 AM, Simon Glass <sjg@chromium.org> wrote:
> Add a simple test to make sure that these functions obey the buffer size
> passed into them.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3: None
> Changes in v2:
> - Fix buffer overflow problem when there is not enough space for the build tag
> - Add test to check for buffer overflow problems
>
>  test/Makefile   |  1 +
>  test/print_ut.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 84 insertions(+)
>  create mode 100644 test/print_ut.c
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 4/6] console: Use map_sysmem() for the pre-relocation console
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 4/6] console: Use map_sysmem() for the pre-relocation console Simon Glass
@ 2017-06-16  5:07   ` Bin Meng
  2017-07-06 14:52     ` sjg at google.com
  0 siblings, 1 reply; 17+ messages in thread
From: Bin Meng @ 2017-06-16  5:07 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 16, 2017 at 11:37 AM, Simon Glass <sjg@chromium.org> wrote:
> At present this feature casts the address to a pointer. Use the
> map_sysmem() function so that it will work correctly on sandbox.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3:
> - Add new patch to use map_sysmem() for the pre-relocation console
>
> Changes in v2: None
>
>  common/console.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 5/6] sandbox: Enable more console options
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 5/6] sandbox: Enable more console options Simon Glass
@ 2017-06-16  5:08   ` Bin Meng
  2017-07-06 14:51     ` sjg at google.com
  0 siblings, 1 reply; 17+ messages in thread
From: Bin Meng @ 2017-06-16  5:08 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 16, 2017 at 11:37 AM, Simon Glass <sjg@chromium.org> wrote:
> Enable the pre-console buffer, displaying the model and post-relocation
> console announce on sandbox. Also add a model name to the device tree.
> This allows testing of these features.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3:
> - Add new patch to enable more console options on sandbox
>
> Changes in v2: None
>
>  arch/sandbox/dts/sandbox.dts | 1 +
>  common/Kconfig               | 2 +-
>  configs/sandbox_defconfig    | 2 ++
>  include/configs/sandbox.h    | 1 +
>  4 files changed, 5 insertions(+), 1 deletion(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 6/6] sandbox: Drop special case console code for sandbox
  2017-06-16  3:37 ` [U-Boot] [PATCH v3 6/6] sandbox: Drop special case console code for sandbox Simon Glass
@ 2017-06-16  5:08   ` Bin Meng
  2017-07-06 14:51     ` sjg at google.com
  0 siblings, 1 reply; 17+ messages in thread
From: Bin Meng @ 2017-06-16  5:08 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 16, 2017 at 11:37 AM, Simon Glass <sjg@chromium.org> wrote:
> At present sandbox has a special case where it directly calls os_putc()
> when it does not have a console yet.
>
> Now that we have the pre-console buffer enabled we can drop this. Any
> early characters will be buffered and output later.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3:
> - Add new patch to drop special case console code for sandbox
>
> Changes in v2: None
>
>  common/console.c | 13 -------------
>  1 file changed, 13 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 5/6] sandbox: Enable more console options
  2017-06-16  5:08   ` Bin Meng
@ 2017-07-06 14:51     ` sjg at google.com
  0 siblings, 0 replies; 17+ messages in thread
From: sjg at google.com @ 2017-07-06 14:51 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 16, 2017 at 11:37 AM, Simon Glass <sjg@chromium.org> wrote:
> Enable the pre-console buffer, displaying the model and post-relocation
> console announce on sandbox. Also add a model name to the device tree.
> This allows testing of these features.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3:
> - Add new patch to enable more console options on sandbox
>
> Changes in v2: None
>
>  arch/sandbox/dts/sandbox.dts | 1 +
>  common/Kconfig               | 2 +-
>  configs/sandbox_defconfig    | 2 ++
>  include/configs/sandbox.h    | 1 +
>  4 files changed, 5 insertions(+), 1 deletion(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 6/6] sandbox: Drop special case console code for sandbox
  2017-06-16  5:08   ` Bin Meng
@ 2017-07-06 14:51     ` sjg at google.com
  0 siblings, 0 replies; 17+ messages in thread
From: sjg at google.com @ 2017-07-06 14:51 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 16, 2017 at 11:37 AM, Simon Glass <sjg@chromium.org> wrote:
> At present sandbox has a special case where it directly calls os_putc()
> when it does not have a console yet.
>
> Now that we have the pre-console buffer enabled we can drop this. Any
> early characters will be buffered and output later.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3:
> - Add new patch to drop special case console code for sandbox
>
> Changes in v2: None
>
>  common/console.c | 13 -------------
>  1 file changed, 13 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 4/6] console: Use map_sysmem() for the pre-relocation console
  2017-06-16  5:07   ` Bin Meng
@ 2017-07-06 14:52     ` sjg at google.com
  0 siblings, 0 replies; 17+ messages in thread
From: sjg at google.com @ 2017-07-06 14:52 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 16, 2017 at 11:37 AM, Simon Glass <sjg@chromium.org> wrote:
> At present this feature casts the address to a pointer. Use the
> map_sysmem() function so that it will work correctly on sandbox.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3:
> - Add new patch to use map_sysmem() for the pre-relocation console
>
> Changes in v2: None
>
>  common/console.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 3/6] test: Add a test for snprintf() and the banner/version
  2017-06-16  5:07   ` Bin Meng
@ 2017-07-06 14:52     ` sjg at google.com
  0 siblings, 0 replies; 17+ messages in thread
From: sjg at google.com @ 2017-07-06 14:52 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 16, 2017 at 11:37 AM, Simon Glass <sjg@chromium.org> wrote:
> Add a simple test to make sure that these functions obey the buffer size
> passed into them.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3: None
> Changes in v2:
> - Fix buffer overflow problem when there is not enough space for the build tag
> - Add test to check for buffer overflow problems
>
>  test/Makefile   |  1 +
>  test/print_ut.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 84 insertions(+)
>  create mode 100644 test/print_ut.c
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH v3 2/6] Allow displaying the U-Boot banner on a video display
  2017-06-16  5:07   ` Bin Meng
@ 2017-07-06 14:52     ` sjg at google.com
  0 siblings, 0 replies; 17+ messages in thread
From: sjg at google.com @ 2017-07-06 14:52 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 16, 2017 at 11:37 AM, Simon Glass <sjg@chromium.org> wrote:
> At present the U-Boot banner is only displayed on the serial console. If
> this is not visible to the user, the banner does not show. Some devices
> have a video display which can usefully display this information.
>
> Add a banner which is printed after relocation only on non-serial devices
> if CONFIG_DISPLAY_BOARDINFO_LATE is defined.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3: None
> Changes in v2:
> - Reword function comment for console_announce_r() slighty
>
>  common/board_r.c  |  1 +
>  common/console.c  | 17 +++++++++++++----
>  include/console.h | 12 ++++++++++++
>  3 files changed, 26 insertions(+), 4 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-07-06 14:52 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-16  3:37 [U-Boot] [PATCH v3 1/6] display_options: Refactor to allow obtaining the banner Simon Glass
2017-06-16  3:37 ` [U-Boot] [PATCH v3 2/6] Allow displaying the U-Boot banner on a video display Simon Glass
2017-06-16  5:07   ` Bin Meng
2017-07-06 14:52     ` sjg at google.com
2017-06-16  3:37 ` [U-Boot] [PATCH v3 3/6] test: Add a test for snprintf() and the banner/version Simon Glass
2017-06-16  5:07   ` Bin Meng
2017-07-06 14:52     ` sjg at google.com
2017-06-16  3:37 ` [U-Boot] [PATCH v3 4/6] console: Use map_sysmem() for the pre-relocation console Simon Glass
2017-06-16  5:07   ` Bin Meng
2017-07-06 14:52     ` sjg at google.com
2017-06-16  3:37 ` [U-Boot] [PATCH v3 5/6] sandbox: Enable more console options Simon Glass
2017-06-16  5:08   ` Bin Meng
2017-07-06 14:51     ` sjg at google.com
2017-06-16  3:37 ` [U-Boot] [PATCH v3 6/6] sandbox: Drop special case console code for sandbox Simon Glass
2017-06-16  5:08   ` Bin Meng
2017-07-06 14:51     ` sjg at google.com
2017-06-16  5:07 ` [U-Boot] [PATCH v3 1/6] display_options: Refactor to allow obtaining the banner Bin Meng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.