aboutsummaryrefslogtreecommitdiff
path: root/semihosting
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-05-01 17:42:43 -0700
committerRichard Henderson <richard.henderson@linaro.org>2022-06-28 04:37:18 +0530
commit1577eec0fca6fd67bdc0727d10de4bdc3f8afa95 (patch)
tree9e10446e7f9026ca32d16bf2576b545271a8ac2d /semihosting
parente4a4aaa51b4c71914a6f30ca504ab78e8f695aee (diff)
downloadqemu-1577eec0fca6fd67bdc0727d10de4bdc3f8afa95.zip
qemu-1577eec0fca6fd67bdc0727d10de4bdc3f8afa95.tar.gz
qemu-1577eec0fca6fd67bdc0727d10de4bdc3f8afa95.tar.bz2
semihosting: Use console_in_gf for SYS_READC
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'semihosting')
-rw-r--r--semihosting/arm-compat-semi.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index fdb143a..9d4d6d2 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -302,6 +302,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
@@ -428,15 +444,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: