diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2022-05-01 12:31:08 -0700 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2022-06-28 04:35:52 +0530 |
commit | e7fb6f320548c1b0c25d291466a0249ee80d91b6 (patch) | |
tree | 418c8dc3bae7cc3dfcb21b749ed5fcd5a9f60fe5 /linux-user | |
parent | 3367d452b001e91547634756e32246610701df5c (diff) | |
download | qemu-e7fb6f320548c1b0c25d291466a0249ee80d91b6.zip qemu-e7fb6f320548c1b0c25d291466a0249ee80d91b6.tar.gz qemu-e7fb6f320548c1b0c25d291466a0249ee80d91b6.tar.bz2 |
semihosting: Expand qemu_semihosting_console_inc to read
Allow more than one character to be read at one time.
Will be used by m68k and nios2 semihosting for stdio.
Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/semihost.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/linux-user/semihost.c b/linux-user/semihost.c index f14c6ae2..2029fb6 100644 --- a/linux-user/semihost.c +++ b/linux-user/semihost.c @@ -56,21 +56,23 @@ void qemu_semihosting_console_outc(CPUArchState *env, target_ulong addr) * program is expecting more normal behaviour. This is slow but * nothing using semihosting console reading is expecting to be fast. */ -target_ulong qemu_semihosting_console_inc(CPUState *cs) +int qemu_semihosting_console_read(CPUState *cs, void *buf, int len) { - uint8_t c; + int ret; struct termios old_tio, new_tio; /* Disable line-buffering and echo */ tcgetattr(STDIN_FILENO, &old_tio); new_tio = old_tio; new_tio.c_lflag &= (~ICANON & ~ECHO); + new_tio.c_cc[VMIN] = 1; + new_tio.c_cc[VTIME] = 0; tcsetattr(STDIN_FILENO, TCSANOW, &new_tio); - c = getchar(); + ret = fread(buf, 1, len, stdin); /* restore config */ tcsetattr(STDIN_FILENO, TCSANOW, &old_tio); - return (target_ulong) c; + return ret; } |