All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabien Chouteau <chouteau@adacore.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: qemu-devel@nongnu.org, atar4qemu@gmail.com, avi@redhat.com
Subject: Re: [Qemu-devel] [PATCH V2] GRLIB UART: Add RX channel
Date: Mon, 30 Jan 2012 10:22:56 +0100	[thread overview]
Message-ID: <4F266170.8020802@adacore.com> (raw)
In-Reply-To: <CAAu8pHtNxK0U8C9shY753VJ7vjrEK5zPcBqDcW1W5uRyG4eqEQ@mail.gmail.com>

On 28/01/2012 13:20, Blue Swirl wrote:
> On Thu, Jan 26, 2012 at 17:03, Fabien Chouteau <chouteau@adacore.com> wrote:
>> This patch implements the RX channel of GRLIB UART with a FIFO to
>> improve data rate.
>>
>> Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
>> ---
>>  hw/grlib_apbuart.c |  106 +++++++++++++++++++++++++++++++++++++++++++--------
>>  trace-events       |    1 +
>>  2 files changed, 90 insertions(+), 17 deletions(-)
>>
>> diff --git a/hw/grlib_apbuart.c b/hw/grlib_apbuart.c
>> index f8a64e1..51406c6 100644
>> --- a/hw/grlib_apbuart.c
>> +++ b/hw/grlib_apbuart.c
>> @@ -24,7 +24,6 @@
>>
>>  #include "sysbus.h"
>>  #include "qemu-char.h"
>> -#include "ptimer.h"
>>
>>  #include "trace.h"
>>
>> @@ -66,6 +65,8 @@
>>  #define SCALER_OFFSET     0x0C  /* not supported */
>>  #define FIFO_DEBUG_OFFSET 0x10  /* not supported */
>>
>> +#define FIFO_LENGTH 1024
>> +
>>  typedef struct UART {
>>     SysBusDevice busdev;
>>     MemoryRegion iomem;
>> @@ -77,21 +78,67 @@ typedef struct UART {
>>     uint32_t receive;
>>     uint32_t status;
>>     uint32_t control;
>> +
>> +    /* FIFO */
>> +    char buffer[FIFO_LENGTH];
>> +    int  len;
>> +    int  current;
>>  } UART;
>>
>> +static int uart_data_to_read(UART *uart)
>> +{
>> +    return uart->current < uart->len;
>> +}
>> +
>> +static char uart_pop(UART *uart)
>> +{
>> +    char ret;
>> +
>> +    if (uart->len == 0) {
>> +        uart->status &= ~UART_DATA_READY;
>> +        return 0;
>> +    }
>> +
>> +    ret = uart->buffer[uart->current++];
>> +
>> +    if (uart->current >= uart->len) {
>> +        /* Flush */
>> +        uart->len     = 0;
>> +        uart->current = 0;
>> +    }
>> +
>> +    if (!uart_data_to_read(uart)) {
>> +        uart->status &= ~UART_DATA_READY;
>> +    }
>> +
>> +    return ret;
>> +}
>> +
>> +static void uart_add_to_fifo(UART          *uart,
>> +                             const uint8_t *buffer,
>> +                             int            length)
>> +{
>> +    if (uart->len + length > FIFO_LENGTH) {
>> +        abort();
> 
> A guest could trigger this abort(), which is not OK. I think you can
> just return.
> 

This will abort if Qemu sends more bytes than the number requested in
grlib_apbuart_can_receive, so this would be a failure from Qemu not the
guest.

Regards,

-- 
Fabien Chouteau

  reply	other threads:[~2012-01-30  9:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-26 17:03 [Qemu-devel] [PATCH V2] GRLIB UART: Add RX channel Fabien Chouteau
2012-01-28 12:20 ` Blue Swirl
2012-01-30  9:22   ` Fabien Chouteau [this message]
2012-01-30 19:28     ` Blue Swirl
  -- strict thread matches above, loose matches on Subject: below --
2012-01-26 14:54 Fabien Chouteau
2012-01-26 14:12 Fabien Chouteau

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=4F266170.8020802@adacore.com \
    --to=chouteau@adacore.com \
    --cc=atar4qemu@gmail.com \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.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.