On Wed, Aug 8, 2018 at 10:07 PM, Julia Suvorova <jus...@mail.ru> wrote: > +static uint64_t uart_read(void *opaque, hwaddr addr, unsigned int size) > +{ > + NRF51UARTState *s = NRF51_UART(opaque); > + uint64_t r; > + > + if (!s->enabled) { > + return 0; > + } > + > + switch (addr) { > + case A_UART_RXD: > + r = s->rx_fifo[s->rx_fifo_pos]; > + if (s->rx_started && s->rx_fifo_len) { > + qemu_chr_fe_accept_input(&s->chr);
Should this be called after popping a byte from the rx fifo? That way .can_receive() will return true again. > +static void nrf51_uart_realize(DeviceState *dev, Error **errp) > +{ > + NRF51UARTState *s = NRF51_UART(dev); > + > + qemu_chr_fe_set_handlers(&s->chr, uart_can_receive, uart_receive, > + uart_event, NULL, s, NULL, true); > +} unrealize() should set the handlers to NULL. That way the device can be removed without leaving callbacks registered.