[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 41/49] semihosting: Create qemu_semihosting_console_write
From: |
Richard Henderson |
Subject: |
[PATCH v3 41/49] semihosting: Create qemu_semihosting_console_write |
Date: |
Fri, 20 May 2022 17:03:52 -0700 |
Will replace qemu_semihosting_console_{outs,outc},
but we need more plumbing first.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/semihosting/console.h | 12 ++++++++++++
linux-user/semihost.c | 5 +++++
semihosting/console.c | 9 +++++++++
3 files changed, 26 insertions(+)
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
@@ -54,6 +54,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
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 4088192842..b6a342744d 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;
--
2.34.1
- [PATCH v3 36/49] gdbstub: Widen gdb_syscall_complete_cb return value, (continued)
- [PATCH v3 36/49] gdbstub: Widen gdb_syscall_complete_cb return value, Richard Henderson, 2022/05/20
- [PATCH v3 03/49] semihosting: Improve condition for config.c and console.c, Richard Henderson, 2022/05/20
- [PATCH v3 23/49] semihosting: Split out semihost_sys_open, Richard Henderson, 2022/05/20
- [PATCH v3 40/49] semihosting: Cleanup chardev init, Richard Henderson, 2022/05/20
- [PATCH v3 42/49] semihosting: Add GuestFDConsole, Richard Henderson, 2022/05/20
- [PATCH v3 43/49] semihosting: Create qemu_semihosting_guestfd_init, Richard Henderson, 2022/05/20
- [PATCH v3 44/49] semihosting: Use console_in_gf for SYS_READC, Richard Henderson, 2022/05/20
- [PATCH v3 46/49] semihosting: Remove qemu_semihosting_console_outc, Richard Henderson, 2022/05/20
- [PATCH v3 41/49] semihosting: Create qemu_semihosting_console_write,
Richard Henderson <=
- [PATCH v3 45/49] semihosting: Use console_out_gf for SYS_WRITEC, Richard Henderson, 2022/05/20
- [PATCH v3 47/49] semihosting: Use console_out_gf for SYS_WRITE0, Richard Henderson, 2022/05/20
- [PATCH v3 49/49] semihosting: Create semihost_sys_poll_one, Richard Henderson, 2022/05/20
- [PATCH v3 48/49] semihosting: Remove qemu_semihosting_console_outs, Richard Henderson, 2022/05/20