* [Qemu-devel] ARM/system mode/stdin
@ 2010-06-14 13:03 Christophe LYON
2010-06-16 14:49 ` Christophe LYON
2010-06-18 16:52 ` Paul Brook
0 siblings, 2 replies; 4+ messages in thread
From: Christophe LYON @ 2010-06-14 13:03 UTC (permalink / raw)
To: qemu-devel
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] ARM/system mode/stdin
2010-06-14 13:03 [Qemu-devel] ARM/system mode/stdin Christophe LYON
@ 2010-06-16 14:49 ` Christophe LYON
2010-06-18 16:52 ` Paul Brook
1 sibling, 0 replies; 4+ messages in thread
From: Christophe LYON @ 2010-06-16 14:49 UTC (permalink / raw)
To: qemu-devel
Hi all,
After more investigation, I am wondering whether there is a conflict
between 2 entities reading for stdin:
- one is initialized by qemu_chr_open_stdio() (in qemu-char.c)
- the 2nd one is the handling of SYS_READ in arm-semi.c
After some debug/tracing, I have noticed that a few chars a swallowed
from stdin by calls to stdio_read() because the stdin FD is monitored by
the select() call in main_loop_wait().
This seems to be in conflict with the ARM semihosting support for
SYS_READ which also tries to read FD 0.
If I remove the call to
qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr);
in qemu_chr_open_stdio() then my sample test works, but I wonder what I
might have broken?
Thanks and best regards,
Christophe.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] ARM/system mode/stdin
2010-06-14 13:03 [Qemu-devel] ARM/system mode/stdin Christophe LYON
2010-06-16 14:49 ` Christophe LYON
@ 2010-06-18 16:52 ` Paul Brook
2010-06-21 8:34 ` Christophe LYON
1 sibling, 1 reply; 4+ messages in thread
From: Paul Brook @ 2010-06-18 16:52 UTC (permalink / raw)
To: qemu-devel; +Cc: Christophe LYON
> $ qemu-system-arm -semihosting -cpu cortex-a9 -nographic -kernel
> ./input.exe
-nographic implies -monitor stdio -serial stdio. Don't do that if you want to
access stdio via semihosting.
Paul
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] ARM/system mode/stdin
2010-06-18 16:52 ` Paul Brook
@ 2010-06-21 8:34 ` Christophe LYON
0 siblings, 0 replies; 4+ messages in thread
From: Christophe LYON @ 2010-06-21 8:34 UTC (permalink / raw)
To: Paul Brook; +Cc: qemu-devel
On 18.06.2010 18:52, Paul Brook wrote:
>> $ qemu-system-arm -semihosting -cpu cortex-a9 -nographic -kernel
>> ./input.exe
>
> -nographic implies -monitor stdio -serial stdio. Don't do that if you want to
> access stdio via semihosting.
>
Indeed, using either
-monitor null -serial none -nographic
or
-monitor vc -serial vc -nographic -kernel
achieves what I want. (probably other values too, not sure which is optimal)
Thanks!
Christophe.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-06-21 8:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-14 13:03 [Qemu-devel] ARM/system mode/stdin Christophe LYON
2010-06-16 14:49 ` Christophe LYON
2010-06-18 16:52 ` Paul Brook
2010-06-21 8:34 ` Christophe LYON
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.