|
@@ -320,7 +320,7 @@ static uint64_t sh_serial_read(void *opaque, hwaddr offs,
|
|
|
|
|
|
static int sh_serial_can_receive(SHSerialState *s)
|
|
|
{
|
|
|
- return s->scr & (1 << 4);
|
|
|
+ return s->scr & (1 << 4) ? SH_RX_FIFO_LENGTH - s->rx_head : 0;
|
|
|
}
|
|
|
|
|
|
static void sh_serial_receive_break(SHSerialState *s)
|
|
@@ -353,22 +353,20 @@ static void sh_serial_receive1(void *opaque, const uint8_t *buf, int size)
|
|
|
if (s->feat & SH_SERIAL_FEAT_SCIF) {
|
|
|
int i;
|
|
|
for (i = 0; i < size; i++) {
|
|
|
- if (s->rx_cnt < SH_RX_FIFO_LENGTH) {
|
|
|
- s->rx_fifo[s->rx_head++] = buf[i];
|
|
|
- if (s->rx_head == SH_RX_FIFO_LENGTH) {
|
|
|
- s->rx_head = 0;
|
|
|
- }
|
|
|
- s->rx_cnt++;
|
|
|
- if (s->rx_cnt >= s->rtrg) {
|
|
|
- s->flags |= SH_SERIAL_FLAG_RDF;
|
|
|
- if (s->scr & (1 << 6) && s->rxi) {
|
|
|
- timer_del(&s->fifo_timeout_timer);
|
|
|
- qemu_set_irq(s->rxi, 1);
|
|
|
- }
|
|
|
- } else {
|
|
|
- timer_mod(&s->fifo_timeout_timer,
|
|
|
- qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 15 * s->etu);
|
|
|
+ s->rx_fifo[s->rx_head++] = buf[i];
|
|
|
+ if (s->rx_head == SH_RX_FIFO_LENGTH) {
|
|
|
+ s->rx_head = 0;
|
|
|
+ }
|
|
|
+ s->rx_cnt++;
|
|
|
+ if (s->rx_cnt >= s->rtrg) {
|
|
|
+ s->flags |= SH_SERIAL_FLAG_RDF;
|
|
|
+ if (s->scr & (1 << 6) && s->rxi) {
|
|
|
+ timer_del(&s->fifo_timeout_timer);
|
|
|
+ qemu_set_irq(s->rxi, 1);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ timer_mod(&s->fifo_timeout_timer,
|
|
|
+ qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 15 * s->etu);
|
|
|
}
|
|
|
}
|
|
|
} else {
|