summaryrefslogtreecommitdiffstats
path: root/linux-user
diff options
context:
space:
mode:
authorRichard Henderson2022-05-01 21:31:08 +0200
committerRichard Henderson2022-06-28 01:05:52 +0200
commite7fb6f320548c1b0c25d291466a0249ee80d91b6 (patch)
tree418c8dc3bae7cc3dfcb21b749ed5fcd5a9f60fe5 /linux-user
parentsemihosting: Pass CPUState to qemu_semihosting_console_inc (diff)
downloadqemu-e7fb6f320548c1b0c25d291466a0249ee80d91b6.tar.gz
qemu-e7fb6f320548c1b0c25d291466a0249ee80d91b6.tar.xz
qemu-e7fb6f320548c1b0c25d291466a0249ee80d91b6.zip
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.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/linux-user/semihost.c b/linux-user/semihost.c
index f14c6ae21d..2029fb674c 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;
}