summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2019-07-23 12:32:58 +0900
committerMasahiro Yamada <yamada.masahiro@socionext.com>2019-08-19 17:00:08 +0900
commitf51df47572fb9d5e6808a07ccf5a7e6a5170554d (patch)
tree2c61c17086157da32a44d457f65b610e8d77bab8 /drivers
parentd1b6013d8485094d948e6b6039b8d119a907ecf8 (diff)
console: add a flag to prepend '\r' in the multi-console framework
Currently, console drivers prepend '\r' to '\n' by themselves. This is common enough to be supported in the framework. Add a new flag, CONSOLE_FLAG_TRANSLATE_CRLF. A driver can set this flag to ask the framework to transform LF into CRLF instead of doing it by itself. Change-Id: I4f5c5887591bc0a8749a105abe62b6562eaf503b Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/console/multi_console.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/console/multi_console.c b/drivers/console/multi_console.c
index d9eba7f0..215f4951 100644
--- a/drivers/console/multi_console.c
+++ b/drivers/console/multi_console.c
@@ -70,6 +70,20 @@ void console_set_scope(console_t *console, unsigned int scope)
console->flags = (console->flags & ~CONSOLE_FLAG_SCOPE_MASK) | scope;
}
+static int do_putc(int c, console_t *console)
+{
+ int ret;
+
+ if ((c == '\n') &&
+ ((console->flags & CONSOLE_FLAG_TRANSLATE_CRLF) != 0)) {
+ ret = console->putc('\r', console);
+ if (ret < 0)
+ return ret;
+ }
+
+ return console->putc(c, console);
+}
+
int console_putc(int c)
{
int err = ERROR_NO_VALID_CONSOLE;
@@ -77,7 +91,7 @@ int console_putc(int c)
for (console = console_list; console != NULL; console = console->next)
if ((console->flags & console_state) && console->putc) {
- int ret = console->putc(c, console);
+ int ret = do_putc(c, console);
if ((err == ERROR_NO_VALID_CONSOLE) || (ret < err))
err = ret;
}