mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
char: remaining switch to CharBackend in frontend
Similar to previous change, for the remaining CharDriverState front ends users. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20161022095318.17775-13-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
becdfa00cf
commit
32a6ebecd2
14 changed files with 211 additions and 164 deletions
|
@ -10,6 +10,7 @@
|
|||
#include "hw/m68k/mcf.h"
|
||||
#include "sysemu/char.h"
|
||||
#include "exec/address-spaces.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
typedef struct {
|
||||
MemoryRegion iomem;
|
||||
|
@ -26,7 +27,7 @@ typedef struct {
|
|||
int tx_enabled;
|
||||
int rx_enabled;
|
||||
qemu_irq irq;
|
||||
CharDriverState *chr;
|
||||
CharBackend chr;
|
||||
} mcf_uart_state;
|
||||
|
||||
/* UART Status Register bits. */
|
||||
|
@ -92,7 +93,7 @@ uint64_t mcf_uart_read(void *opaque, hwaddr addr,
|
|||
if (s->fifo_len == 0)
|
||||
s->sr &= ~MCF_UART_RxRDY;
|
||||
mcf_uart_update(s);
|
||||
qemu_chr_accept_input(s->chr);
|
||||
qemu_chr_accept_input(s->chr.chr);
|
||||
return val;
|
||||
}
|
||||
case 0x10:
|
||||
|
@ -113,10 +114,11 @@ uint64_t mcf_uart_read(void *opaque, hwaddr addr,
|
|||
static void mcf_uart_do_tx(mcf_uart_state *s)
|
||||
{
|
||||
if (s->tx_enabled && (s->sr & MCF_UART_TxEMP) == 0) {
|
||||
if (s->chr)
|
||||
if (s->chr.chr) {
|
||||
/* XXX this blocks entire thread. Rewrite to use
|
||||
* qemu_chr_fe_write and background I/O callbacks */
|
||||
qemu_chr_fe_write_all(s->chr, (unsigned char *)&s->tb, 1);
|
||||
qemu_chr_fe_write_all(s->chr.chr, (unsigned char *)&s->tb, 1);
|
||||
}
|
||||
s->sr |= MCF_UART_TxEMP;
|
||||
}
|
||||
if (s->tx_enabled) {
|
||||
|
@ -280,9 +282,9 @@ void *mcf_uart_init(qemu_irq irq, CharDriverState *chr)
|
|||
mcf_uart_state *s;
|
||||
|
||||
s = g_malloc0(sizeof(mcf_uart_state));
|
||||
s->chr = chr;
|
||||
s->irq = irq;
|
||||
if (chr) {
|
||||
qemu_chr_fe_init(&s->chr, chr, &error_abort);
|
||||
qemu_chr_fe_claim_no_fail(chr);
|
||||
qemu_chr_add_handlers(chr, mcf_uart_can_receive, mcf_uart_receive,
|
||||
mcf_uart_event, s);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue