[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 44/49] semihosting: Use console_in_gf for SYS_READC
From: |
Richard Henderson |
Subject: |
[PATCH v3 44/49] semihosting: Use console_in_gf for SYS_READC |
Date: |
Fri, 20 May 2022 17:03:55 -0700 |
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
semihosting/arm-compat-semi.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index 20d97290ff..9230c69ff2 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -290,6 +290,22 @@ common_semi_flen_fstat_cb(CPUState *cs, uint64_t ret, int
err)
common_semi_cb(cs, ret, err);
}
+static void
+common_semi_readc_cb(CPUState *cs, uint64_t ret, int err)
+{
+ if (!err) {
+ CPUArchState *env G_GNUC_UNUSED = cs->env_ptr;
+ uint8_t ch;
+
+ if (get_user_u8(ch, common_semi_stack_bottom(cs) - 1)) {
+ ret = -1, err = EFAULT;
+ } else {
+ ret = ch;
+ }
+ }
+ common_semi_cb(cs, ret, err);
+}
+
#define SHFB_MAGIC_0 0x53
#define SHFB_MAGIC_1 0x48
#define SHFB_MAGIC_2 0x46
@@ -415,15 +431,8 @@ void do_common_semihosting(CPUState *cs)
break;
case TARGET_SYS_READC:
- {
- uint8_t ch;
- int ret = qemu_semihosting_console_read(cs, &ch, 1);
- if (ret == 1) {
- common_semi_cb(cs, ch, 0);
- } else {
- common_semi_cb(cs, -1, EIO);
- }
- }
+ semihost_sys_read_gf(cs, common_semi_readc_cb, &console_in_gf,
+ common_semi_stack_bottom(cs) - 1, 1);
break;
case TARGET_SYS_ISERROR:
--
2.34.1
- [PATCH v3 20/49] semihosting: Split out common_semi_has_synccache, (continued)
- [PATCH v3 20/49] semihosting: Split out common_semi_has_synccache, Richard Henderson, 2022/05/20
- [PATCH v3 19/49] semihosting: Split common_semi_flen_buf per target, Richard Henderson, 2022/05/20
- [PATCH v3 27/49] semihosting: Bound length for semihost_sys_{read, write}, Richard Henderson, 2022/05/20
- [PATCH v3 33/49] semihosting: Split out semihost_sys_system, Richard Henderson, 2022/05/20
- [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 <=
- [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, 2022/05/20
- [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