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

2017-05-01 Thread Jiahuan Zhang
Hi, can somebody help to check this host (Windows 7) to guest (Linux 4.10) Windows named pipe data transfer? The method I implemented has while loops that makes qemu consume 100% CPU time. I cannot find any optimization to eliminate the loops. So sad! Anyone has time, please help. On 24 March

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

2017-03-24 Thread Jiahuan Zhang
Hi, now it is working with the following char-pipe_new.c. See the patch. Doing the "if fifo has space" polling only when there are data on the pipe, and next reading from pipe. The sub_thread does these three things, and the main thread only does writing to UART fifo when the subthread signalled

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

2017-03-24 Thread Jiahuan Zhang
Hi, here are the patch files for char-pipe.c, char-win.c, char-win.h On 23 March 2017 at 18:31, Paolo Bonzini wrote: > > > On 23/03/2017 18:28, Jiahuan Zhang wrote: > > Hi, the method doesn't work for pipe. It still causes the same issue. > > The only difference is that

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

2017-03-23 Thread Paolo Bonzini
On 23/03/2017 18:28, Jiahuan Zhang wrote: > Hi, the method doesn't work for pipe. It still causes the same issue. > The only difference is that the first byte in the UART fifo can be read > by the guest app. > So now my guest app can immediately read 17bytes when the host is > sending data

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

2017-03-23 Thread Jiahuan Zhang
Hi, the method doesn't work for pipe. It still causes the same issue. The only difference is that the first byte in the UART fifo can be read by the guest app. So now my guest app can immediately read 17bytes when the host is sending data continuously, then guest app is unable to read. Now there

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

2017-03-23 Thread Paolo Bonzini
On 23/03/2017 11:12, Jiahuan Zhang wrote: > > It's Windows that doesn't support it (the Windows function name is > WaitForSingleObject). > > > Hi, I have checked the Windows chardev implimentation in QEMU. > I learned from char-win-stdio.c to using thread and WaitForSingleObject > for

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

2017-03-23 Thread Jiahuan Zhang
On 22 March 2017 at 12:27, Paolo Bonzini wrote: > > > On 22/03/2017 11:28, Jiahuan Zhang wrote: > > > > A function that lets a process sleep until data is available on the > > socket. The solution is to rewrite Windows chardev handling in QEMU > to > > use

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

2017-03-22 Thread Paolo Bonzini
On 22/03/2017 12:07, Peter Maydell wrote: > That's not the end that's a problem. Here we know we have > data available from the Windows end to read, we just > can't feed it to the QEMU UART model yet because the > UART model is saying "my FIFO is full, try later". > We should be able to handle

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

2017-03-22 Thread Paolo Bonzini
On 22/03/2017 11:28, Jiahuan Zhang wrote: > > A function that lets a process sleep until data is available on the > socket. The solution is to rewrite Windows chardev handling in QEMU to > use threads or overlapped I/O. > > Yes, socket is working well. Will you add the "select" to

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

2017-03-22 Thread Peter Maydell
On 22 March 2017 at 08:40, Paolo Bonzini wrote: > >> > I am using a windows named pipe to get the data from a window >> > host program, which uses ReadFile () in char_win.c >> >> OK, bugs in the windows-specific char backend would be >> unsurprising. >> >> I'm not entirely

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

2017-03-22 Thread Jiahuan Zhang
On 22 March 2017 at 10:37, Paolo Bonzini wrote: > > > On 22/03/2017 09:48, Jiahuan Zhang wrote: > > > > > > On 22 March 2017 at 09:40, Paolo Bonzini > > wrote: > > > > > > > > I am using a windows named pipe to get the

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

2017-03-22 Thread Paolo Bonzini
On 22/03/2017 09:48, Jiahuan Zhang wrote: > > > On 22 March 2017 at 09:40, Paolo Bonzini > wrote: > > > > > I am using a windows named pipe to get the data from a window > > > host program, which uses ReadFile () in char_win.c >

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

2017-03-22 Thread Jiahuan Zhang
On 22 March 2017 at 09:40, Paolo Bonzini wrote: > > > > I am using a windows named pipe to get the data from a window > > > host program, which uses ReadFile () in char_win.c > > > > OK, bugs in the windows-specific char backend would be > > unsurprising. > > > > I'm not

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

2017-03-22 Thread Paolo Bonzini
> > I am using a windows named pipe to get the data from a window > > host program, which uses ReadFile () in char_win.c > > OK, bugs in the windows-specific char backend would be > unsurprising. > > I'm not entirely sure how the chardev layer works, but > at the pl011 end if we return 0 from

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

2017-03-21 Thread Jiahuan Zhang
Okay. Thank you very much. I'll take your advice and test. Let's see the chardev maintainers reply. Best, Huan 2017年3月21日 19:28,"Peter Maydell" 写道: > On 21 March 2017 at 18:11, Jiahuan Zhang wrote: > > What do you mean "RXFE will be cleared"?

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

2017-03-21 Thread Peter Maydell
On 21 March 2017 at 18:11, Jiahuan Zhang wrote: > What do you mean "RXFE will be cleared"? > Here RXFE is > #define PL011_RXFE 0x10 I mean that as soon as 1 byte of data is ready to read the RXFE bit will be cleared in the FR register. So you need: /* probably you

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

2017-03-21 Thread Jiahuan Zhang
2017年3月21日 18:55,"Peter Maydell" 写道: On 21 March 2017 at 17:48, Jiahuan Zhang 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)

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

2017-03-21 Thread Peter Maydell
On 21 March 2017 at 17:48, Jiahuan Zhang 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

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

2017-03-21 Thread Jiahuan Zhang
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. The

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

2017-03-21 Thread Peter Maydell
On 21 March 2017 at 16:59, Jiahuan Zhang wrote: > > > On 21 March 2017 at 17:50, Peter Maydell wrote: >> >> On 21 March 2017 at 16:47, Jiahuan Zhang wrote: >> > The actual situation is, pl011_can_receive is returning

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

2017-03-21 Thread Jiahuan Zhang
On 21 March 2017 at 17:59, Jiahuan Zhang wrote: > > > On 21 March 2017 at 17:50, Peter Maydell wrote: > >> On 21 March 2017 at 16:47, Jiahuan Zhang >> wrote: >> > The actual situation is, pl011_can_receive is

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

2017-03-21 Thread Jiahuan Zhang
On 21 March 2017 at 17:50, Peter Maydell wrote: > On 21 March 2017 at 16:47, Jiahuan Zhang wrote: > > The actual situation is, pl011_can_receive is returning false, the fifo > is > > full, pl011_read does't start. > > At this moment, only

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

2017-03-21 Thread Peter Maydell
On 21 March 2017 at 16:47, Jiahuan Zhang wrote: > The actual situation is, pl011_can_receive is returning false, the fifo is > full, pl011_read does't start. > At this moment, only pl011_can_recieve is keeping returning 0. OK, so the incoming data has filled up the

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

2017-03-21 Thread Jiahuan Zhang
many thanks for the rapid reply! On 21 March 2017 at 17:39, Peter Maydell wrote: > On 21 March 2017 at 16:32, Jiahuan Zhang wrote: > > I found the serial device is always trying to receive all the data when > > ReadFile() is running, then

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

2017-03-21 Thread Peter Maydell
On 21 March 2017 at 16:32, Jiahuan Zhang wrote: > I found the serial device is always trying to receive all the data when > ReadFile() is running, then start reading. Even if the fifo is full, the > _can_receive function still keeps polling if the data is larger than 16

[Qemu-devel] Guest application reading from pl011 without device driver

2017-03-21 Thread Jiahuan Zhang
Dear QEMU developers, I am trying to read streaming data from a serial device by pointing to the data register. The input data for the serial device is a string, whose length is larger than the receiving fifo (I am using pl011). Ths input is done by ReadFile() since my host is Win 7; Now the