From: Christophe LYON <christophe.lyon@st.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] ARM/system mode/stdin
Date: Mon, 14 Jun 2010 15:03:25 +0200 [thread overview]
Message-ID: <4C16289D.8040708@st.com> (raw)
Hello,
I am trying to use qemu-system-arm (0.12.3) to execute an ARM bare
machine program (not a Linux kernel), and I have some trouble when the
program in question tries to read from stdin.
The program does use ARM semihosting to communicate with the host.
Here is the sample code:
======================
#include <stdio.h>
int main() {
int i, j;
char tab[81];
printf("enter a number\n");
scanf("%d", &i);
printf("enter a string (max: 80 char)\n");
scanf("%80s", tab);
printf("enter a number\n");
scanf("%d", &j);
printf("You entered:\n%d\n%s\n%d\n", i, tab, j);
return 0;
}
=======================
(compiled with arm-none-eabi-gcc -O0 -mcpu=cortex-a9)
To execute it, I use:
$ qemu-system-arm -semihosting -cpu cortex-a9 -nographic -kernel ./input.exe
In this case, it does not wait for me to type something:
enter a number
enter a string (max: 80 char)
enter a number
You entered:
134217720
1
Now, if
$ cat data
4 hello 5
$ qemu-system-arm -semihosting -cpu cortex-a9 -nographic -kernel
./input.exe < data
enter a number
enter a string (max: 80 char)
enter a number
You entered:
134217720
ello
5
as you can see, the first 3 chars of 'data' have been changed/swallowed.
If I remove
fcntl(0, F_SETFL, O_NONBLOCK);
from term_init() (qemu-char.c), then I get expected behaviour when I
don't redirect stdin, but this has no effect on the latter case.
What should I do/patch to achieve the behaviour I'd like?
Thanks!
Christophe.
next reply other threads:[~2010-06-14 13:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-14 13:03 Christophe LYON [this message]
2010-06-16 14:49 ` [Qemu-devel] ARM/system mode/stdin Christophe LYON
2010-06-18 16:52 ` Paul Brook
2010-06-21 8:34 ` Christophe LYON
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C16289D.8040708@st.com \
--to=christophe.lyon@st.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.