qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Guest application reading from pl011 without device dri


From: Jiahuan Zhang
Subject: Re: [Qemu-devel] Guest application reading from pl011 without device driver
Date: Tue, 21 Mar 2017 19:11:47 +0100

2017年3月21日 18:55,"Peter Maydell" <address@hidden>写道:

On 21 March 2017 at 17:48, Jiahuan Zhang <address@hidden> wrote:
> The guest program is as follows.
>
> While (*UART_FR & PL011_RXFE); //wait until fifo not empty
> for (i=0;i <16;i++){
>    data [i] = (unsigned char) *UART_DR; //read from the data register.
> }

This is buggy. You must check RXFE every time, because
RXFE will be cleared as soon as even a single byte is
in the FIFO. It does not mean "FIFO full", it just
means "FIFO not empty".


Yes, here I need to make sure there are real data in the fifo, or data [i]
will get null.
Do you mean that I also need to make sure fifo is not full before reading?
For example, by while(*UART_FR & RXFF); ?

What do you mean "RXFE will be cleared"?
Here RXFE is
#define PL011_RXFE   0x10

By the way, at the beginning of the guest program, I set the line control
register s->lcr = 0x70 for pl011_can_recieve.

(You should also check that you're correctly using
'volatile' or some other mechanism for ensuring that
the C compiler does not decide that it can collapse
away accesses to hardware registers because it thinks
they're just memory and won't change value.)

> But what I met is that, when the receiving data is small,
> no data is knocking the door of the fifo by ReadFile (),
> then pl011_read can starts.
> When the data is large, after the fifo is full, there are still
> data requesting to get into the fifo. Then the device is busy
> with pl011_can_receive.

Are you saying that QEMU is looping round indefinitely calling
pl011_can_receive() and never running the guest at all?


Yes, exactly when fifo is full, s->count = 16. pl011_can_recieve keeps
returning 0.
The guest program is blocked.

That would be a QEMU bug, but it seems unlikely or we'd have
noticed it before.

What chardev backend are you connecting to the pl011 to
feed data to it?


I am using a windows named pipe to get the data from a window host program,
which uses ReadFile () in char_win.c


thanks
-- PMM


reply via email to

[Prev in Thread] Current Thread [Next in Thread]