[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 42/74] semihosting: Use console_in_gf for SYS_READC
From: |
Richard Henderson |
Subject: |
[PATCH v2 42/74] semihosting: Use console_in_gf for SYS_READC |
Date: |
Tue, 3 May 2022 12:48:11 -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 d60f7ed6a4..34d635006d 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -293,6 +293,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
@@ -418,15 +434,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 v2 34/74] gdbstub: Widen gdb_syscall_complete_cb return value, (continued)
- [PATCH v2 34/74] gdbstub: Widen gdb_syscall_complete_cb return value, Richard Henderson, 2022/05/03
- [PATCH v2 32/74] semihosting: Create semihost_sys_{stat,fstat}, Richard Henderson, 2022/05/03
- [PATCH v2 33/74] semihosting: Create semihost_sys_gettimeofday, Richard Henderson, 2022/05/03
- [PATCH v2 35/74] semihosting: Fix docs comment for qemu_semihosting_console_inc, Richard Henderson, 2022/05/03
- [PATCH v2 38/74] semihosting: Cleanup chardev init, Richard Henderson, 2022/05/03
- [PATCH v2 37/74] semihosting: Expand qemu_semihosting_console_inc to read, Richard Henderson, 2022/05/03
- [PATCH v2 36/74] semihosting: Pass CPUState to qemu_semihosting_console_inc, Richard Henderson, 2022/05/03
- [PATCH v2 39/74] semihosting: Create qemu_semihosting_console_write, Richard Henderson, 2022/05/03
- [PATCH v2 40/74] semihosting: Add GuestFDConsole, Richard Henderson, 2022/05/03
- [PATCH v2 41/74] semihosting: Create qemu_semihosting_guestfd_init, Richard Henderson, 2022/05/03
- [PATCH v2 42/74] semihosting: Use console_in_gf for SYS_READC,
Richard Henderson <=
- [PATCH v2 46/74] semihosting: Remove qemu_semihosting_console_outs, Richard Henderson, 2022/05/03
- [PATCH v2 43/74] semihosting: Use console_out_gf for SYS_WRITEC, Richard Henderson, 2022/05/03
- [PATCH v2 44/74] semihosting: Remove qemu_semihosting_console_outc, Richard Henderson, 2022/05/03
- [PATCH v2 47/74] semihosting: Create semihost_sys_poll_one, Richard Henderson, 2022/05/03
- [PATCH v2 45/74] semihosting: Use console_out_gf for SYS_WRITE0, Richard Henderson, 2022/05/03
- [PATCH v2 48/74] target/m68k: Eliminate m68k_semi_is_fseek, Richard Henderson, 2022/05/03
- [PATCH v2 55/74] target/mips: Add UHI errno values, Richard Henderson, 2022/05/03
- [PATCH v2 49/74] target/m68k: Make semihosting system only, Richard Henderson, 2022/05/03
- [PATCH v2 52/74] target/nios2: Move nios2-semi.c to nios2_softmmu_ss, Richard Henderson, 2022/05/03
- [PATCH v2 50/74] target/m68k: Use semihosting/syscalls.h, Richard Henderson, 2022/05/03