diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2022-05-01 12:42:37 -0700 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2022-06-28 04:35:52 +0530 |
commit | cd66f20f614bb492e4e5be11e4b65d58b4a046ca (patch) | |
tree | 52b91ede9cb6138a2629ee1d826af4a8ac2b3814 | |
parent | fb08790b35174a98301ecbac4d5234d0cbfebea0 (diff) |
semihosting: Create qemu_semihosting_console_write
Will replace qemu_semihosting_console_{outs,outc},
but we need more plumbing first.
Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
-rw-r--r-- | include/semihosting/console.h | 12 | ||||
-rw-r--r-- | linux-user/semihost.c | 5 | ||||
-rw-r--r-- | semihosting/console.c | 9 |
3 files changed, 26 insertions, 0 deletions
diff --git a/include/semihosting/console.h b/include/semihosting/console.h index 39dbf1b062..6994f23c82 100644 --- a/include/semihosting/console.h +++ b/include/semihosting/console.h @@ -55,6 +55,18 @@ void qemu_semihosting_console_outc(CPUArchState *env, target_ulong c); int qemu_semihosting_console_read(CPUState *cs, void *buf, int len); /** + * qemu_semihosting_console_write: + * @buf: host buffer + * @len: buffer size + * + * Write len bytes from buf to the debug console. + * + * Returns: number of bytes written -- this should only ever be short + * on some sort of i/o error. + */ +int qemu_semihosting_console_write(void *buf, int len); + +/** * qemu_semihosting_log_out: * @s: pointer to string * @len: length of string diff --git a/linux-user/semihost.c b/linux-user/semihost.c index 2029fb674c..871edf993a 100644 --- a/linux-user/semihost.c +++ b/linux-user/semihost.c @@ -76,3 +76,8 @@ int qemu_semihosting_console_read(CPUState *cs, void *buf, int len) return ret; } + +int qemu_semihosting_console_write(void *buf, int len) +{ + return fwrite(buf, 1, len, stderr); +} diff --git a/semihosting/console.c b/semihosting/console.c index 1d16a290c4..540aa0cd4b 100644 --- a/semihosting/console.c +++ b/semihosting/console.c @@ -169,6 +169,15 @@ int qemu_semihosting_console_read(CPUState *cs, void *buf, int len) return ret; } +int qemu_semihosting_console_write(void *buf, int len) +{ + if (console.chr) { + return qemu_chr_write_all(console.chr, (uint8_t *)buf, len); + } else { + return fwrite(buf, 1, len, stderr); + } +} + void qemu_semihosting_console_init(Chardev *chr) { console.chr = chr; |