aboutsummaryrefslogtreecommitdiff
path: root/hw/semihosting/console.c
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2019-05-14 15:30:14 +0100
committerAlex Bennée <alex.bennee@linaro.org>2019-05-28 10:28:50 +0100
commit4e7f9032cf9bba8558b0fd5ab6a1366d6d7b8ee0 (patch)
treeb260754fa6471caa695fe9e6ac47a454fc5ccb43 /hw/semihosting/console.c
parenta331c6d774123fd3fdb916e58539920727dd2cbd (diff)
semihosting: enable chardev backed output for console
It will be useful for a number of use-cases to be able to re-direct output to a file like we do with serial output. This does the wiring to allow us to treat then semihosting console like just another character output device. Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Diffstat (limited to 'hw/semihosting/console.c')
-rw-r--r--hw/semihosting/console.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/hw/semihosting/console.c b/hw/semihosting/console.c
index 01826bd687..466ea6dade 100644
--- a/hw/semihosting/console.c
+++ b/hw/semihosting/console.c
@@ -17,13 +17,20 @@
#include "qemu/osdep.h"
#include "cpu.h"
+#include "hw/semihosting/semihost.h"
#include "hw/semihosting/console.h"
#include "exec/gdbstub.h"
#include "qemu/log.h"
+#include "chardev/char.h"
int qemu_semihosting_log_out(const char *s, int len)
{
- return write(STDERR_FILENO, s, len);
+ Chardev *chardev = semihosting_get_chardev();
+ if (chardev) {
+ return qemu_chr_write_all(chardev, (uint8_t *) s, len);
+ } else {
+ return write(STDERR_FILENO, s, len);
+ }
}
/*