summaryrefslogtreecommitdiff
path: root/common/stdio.c
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2022-09-24 13:58:49 -0400
committerTom Rini <[email protected]>2022-09-24 13:58:49 -0400
commit81da5042e514bfd27516d3530dde4d62a6708ca4 (patch)
tree75203cc106a2c1c340024fdb562be7c9b6d0e4e2 /common/stdio.c
parent694e9008674c2008b9ccdc25a9bb3ac078e20911 (diff)
parentefc3f9526f9cfcd8614668c03b9c66b209782c41 (diff)
Merge branch '2022-09-24-add-console-flush' into next
To quote the author: On certain places it is required to flush output print buffers to ensure that text strings were sent to console or serial devices. For example when printing message that U-Boot is going to boot kernel or when U-Boot is going to change baudrate of terminal device. Some console devices, like UART, have putc/puts functions which just put characters into HW transmit queue and do not wait until all data are transmitted. Doing some sensitive operations (like changing baudrate or starting kernel which resets UART HW) cause that U-Boot messages are lost. Therefore introduce a new flush() function, implement it for all serial devices via pending(false) callback and use this new flush() function on sensitive places after which output device may go into reset state. This change fixes printing of U-Boot messages: "## Starting application at ..." "## Switch baudrate to ..." In addition, take a patch from Heinrich to rename some EFI test functions in order to not conflict with this series.
Diffstat (limited to 'common/stdio.c')
-rw-r--r--common/stdio.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/common/stdio.c b/common/stdio.c
index 92161a0df87..13083842cbd 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -87,6 +87,13 @@ static void stdio_serial_puts(struct stdio_dev *dev, const char *s)
serial_puts(s);
}
+#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
+static void stdio_serial_flush(struct stdio_dev *dev)
+{
+ serial_flush();
+}
+#endif
+
static int stdio_serial_getc(struct stdio_dev *dev)
{
return serial_getc();
@@ -112,6 +119,7 @@ static void drv_system_init (void)
dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT;
dev.putc = stdio_serial_putc;
dev.puts = stdio_serial_puts;
+ STDIO_DEV_ASSIGN_FLUSH(&dev, stdio_serial_flush);
dev.getc = stdio_serial_getc;
dev.tstc = stdio_serial_tstc;
stdio_register (&dev);