From: Jan Kiszka <[email protected]>

Unix tools like awk expect Unix ordering and that is different from what
we generate so far. Issue the CR first, and then the LF.

Reported-by: Michael Hinton <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
---
 inmates/lib/printk.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/inmates/lib/printk.c b/inmates/lib/printk.c
index 29cbc3f6..45af2730 100644
--- a/inmates/lib/printk.c
+++ b/inmates/lib/printk.c
@@ -3,7 +3,7 @@
  *
  * Copyright (c) ARM Limited, 2014
  * Copyright (c) OTH Regensburg, 2018
- * Copyright (c) Siemens AG, 2013-2019
+ * Copyright (c) Siemens AG, 2013-2020
  *
  * Authors:
  *  Jean-Philippe Brucker <[email protected]>
@@ -49,29 +49,34 @@
 static struct uart_chip *chip;
 static bool virtual_console;

+static void console_write_char(char c)
+{
+       if (chip) {
+               while (chip->is_busy(chip))
+                       cpu_relax();
+               chip->write(chip, c);
+       }
+
+       if (virtual_console)
+               jailhouse_call_arg1(JAILHOUSE_HC_DEBUG_CONSOLE_PUTC, c);
+}
+
 static void console_write(const char *msg)
 {
-       char c = 0;
+       char c;

        if (!chip && !virtual_console)
                return;

        while (1) {
-               if (c == '\n')
-                       c = '\r';
-               else
-                       c = *msg++;
+               c = *msg++;
                if (!c)
                        break;

-               if (chip) {
-                       while (chip->is_busy(chip))
-                               cpu_relax();
-                       chip->write(chip, c);
-               }
+               if (c == '\n')
+                       console_write_char('\r');

-               if (virtual_console)
-                       jailhouse_call_arg1(JAILHOUSE_HC_DEBUG_CONSOLE_PUTC, c);
+               console_write_char(c);
        }
 }

--
2.16.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/096ee03151b45c8ff0ead2da1cd605be74fbceb8.1581770164.git.jan.kiszka%40web.de.

Reply via email to