2007-09-17 01:08:06 +04:00
|
|
|
/*
|
2007-06-03 15:13:39 +04:00
|
|
|
* ColdFire UART emulation.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2007 CodeSourcery.
|
|
|
|
*
|
2011-06-26 06:21:35 +04:00
|
|
|
* This code is licensed under the GPL
|
2007-06-03 15:13:39 +04:00
|
|
|
*/
|
2019-05-23 17:35:07 +03:00
|
|
|
|
2016-01-26 21:17:30 +03:00
|
|
|
#include "qemu/osdep.h"
|
2019-08-12 08:23:42 +03:00
|
|
|
#include "hw/irq.h"
|
2017-01-28 09:56:22 +03:00
|
|
|
#include "hw/sysbus.h"
|
2019-05-23 17:35:07 +03:00
|
|
|
#include "qemu/module.h"
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:31:58 +03:00
|
|
|
#include "qapi/error.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/m68k/mcf.h"
|
2019-08-12 08:23:51 +03:00
|
|
|
#include "hw/qdev-properties.h"
|
2020-12-12 01:05:12 +03:00
|
|
|
#include "hw/qdev-properties-system.h"
|
2017-01-26 17:26:44 +03:00
|
|
|
#include "chardev/char-fe.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2007-06-03 15:13:39 +04:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct mcf_uart_state {
|
2017-01-28 09:56:22 +03:00
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
2011-11-24 17:31:13 +04:00
|
|
|
MemoryRegion iomem;
|
2007-06-03 15:13:39 +04:00
|
|
|
uint8_t mr[2];
|
|
|
|
uint8_t sr;
|
|
|
|
uint8_t isr;
|
|
|
|
uint8_t imr;
|
|
|
|
uint8_t bg1;
|
|
|
|
uint8_t bg2;
|
|
|
|
uint8_t fifo[4];
|
|
|
|
uint8_t tb;
|
|
|
|
int current_mr;
|
|
|
|
int fifo_len;
|
|
|
|
int tx_enabled;
|
|
|
|
int rx_enabled;
|
|
|
|
qemu_irq irq;
|
2016-10-22 12:52:52 +03:00
|
|
|
CharBackend chr;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2007-06-03 15:13:39 +04:00
|
|
|
|
2017-01-28 09:56:22 +03:00
|
|
|
#define TYPE_MCF_UART "mcf-uart"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(mcf_uart_state, MCF_UART)
|
2017-01-28 09:56:22 +03:00
|
|
|
|
2007-06-03 15:13:39 +04:00
|
|
|
/* UART Status Register bits. */
|
|
|
|
#define MCF_UART_RxRDY 0x01
|
|
|
|
#define MCF_UART_FFULL 0x02
|
|
|
|
#define MCF_UART_TxRDY 0x04
|
|
|
|
#define MCF_UART_TxEMP 0x08
|
|
|
|
#define MCF_UART_OE 0x10
|
|
|
|
#define MCF_UART_PE 0x20
|
|
|
|
#define MCF_UART_FE 0x40
|
|
|
|
#define MCF_UART_RB 0x80
|
|
|
|
|
|
|
|
/* Interrupt flags. */
|
|
|
|
#define MCF_UART_TxINT 0x01
|
|
|
|
#define MCF_UART_RxINT 0x02
|
|
|
|
#define MCF_UART_DBINT 0x04
|
|
|
|
#define MCF_UART_COSINT 0x80
|
|
|
|
|
|
|
|
/* UMR1 flags. */
|
|
|
|
#define MCF_UART_BC0 0x01
|
|
|
|
#define MCF_UART_BC1 0x02
|
|
|
|
#define MCF_UART_PT 0x04
|
|
|
|
#define MCF_UART_PM0 0x08
|
|
|
|
#define MCF_UART_PM1 0x10
|
|
|
|
#define MCF_UART_ERR 0x20
|
|
|
|
#define MCF_UART_RxIRQ 0x40
|
|
|
|
#define MCF_UART_RxRTS 0x80
|
|
|
|
|
|
|
|
static void mcf_uart_update(mcf_uart_state *s)
|
|
|
|
{
|
|
|
|
s->isr &= ~(MCF_UART_TxINT | MCF_UART_RxINT);
|
|
|
|
if (s->sr & MCF_UART_TxRDY)
|
|
|
|
s->isr |= MCF_UART_TxINT;
|
|
|
|
if ((s->sr & ((s->mr[0] & MCF_UART_RxIRQ)
|
|
|
|
? MCF_UART_FFULL : MCF_UART_RxRDY)) != 0)
|
|
|
|
s->isr |= MCF_UART_RxINT;
|
|
|
|
|
|
|
|
qemu_set_irq(s->irq, (s->isr & s->imr) != 0);
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
uint64_t mcf_uart_read(void *opaque, hwaddr addr,
|
2011-11-24 17:31:13 +04:00
|
|
|
unsigned size)
|
2007-06-03 15:13:39 +04:00
|
|
|
{
|
|
|
|
mcf_uart_state *s = (mcf_uart_state *)opaque;
|
|
|
|
switch (addr & 0x3f) {
|
|
|
|
case 0x00:
|
|
|
|
return s->mr[s->current_mr];
|
|
|
|
case 0x04:
|
|
|
|
return s->sr;
|
|
|
|
case 0x0c:
|
|
|
|
{
|
|
|
|
uint8_t val;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (s->fifo_len == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
val = s->fifo[0];
|
|
|
|
s->fifo_len--;
|
|
|
|
for (i = 0; i < s->fifo_len; i++)
|
|
|
|
s->fifo[i] = s->fifo[i + 1];
|
|
|
|
s->sr &= ~MCF_UART_FFULL;
|
|
|
|
if (s->fifo_len == 0)
|
|
|
|
s->sr &= ~MCF_UART_RxRDY;
|
|
|
|
mcf_uart_update(s);
|
2016-10-22 12:52:55 +03:00
|
|
|
qemu_chr_fe_accept_input(&s->chr);
|
2007-06-03 15:13:39 +04:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
case 0x10:
|
|
|
|
/* TODO: Implement IPCR. */
|
|
|
|
return 0;
|
|
|
|
case 0x14:
|
|
|
|
return s->isr;
|
|
|
|
case 0x18:
|
|
|
|
return s->bg1;
|
|
|
|
case 0x1c:
|
|
|
|
return s->bg2;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update TxRDY flag and set data if present and enabled. */
|
|
|
|
static void mcf_uart_do_tx(mcf_uart_state *s)
|
|
|
|
{
|
|
|
|
if (s->tx_enabled && (s->sr & MCF_UART_TxEMP) == 0) {
|
2016-10-22 12:52:59 +03:00
|
|
|
/* 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);
|
2007-06-03 15:13:39 +04:00
|
|
|
s->sr |= MCF_UART_TxEMP;
|
|
|
|
}
|
|
|
|
if (s->tx_enabled) {
|
|
|
|
s->sr |= MCF_UART_TxRDY;
|
|
|
|
} else {
|
|
|
|
s->sr &= ~MCF_UART_TxRDY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mcf_do_command(mcf_uart_state *s, uint8_t cmd)
|
|
|
|
{
|
|
|
|
/* Misc command. */
|
2015-06-24 14:55:51 +03:00
|
|
|
switch ((cmd >> 4) & 7) {
|
2007-06-03 15:13:39 +04:00
|
|
|
case 0: /* No-op. */
|
|
|
|
break;
|
|
|
|
case 1: /* Reset mode register pointer. */
|
|
|
|
s->current_mr = 0;
|
|
|
|
break;
|
|
|
|
case 2: /* Reset receiver. */
|
|
|
|
s->rx_enabled = 0;
|
|
|
|
s->fifo_len = 0;
|
|
|
|
s->sr &= ~(MCF_UART_RxRDY | MCF_UART_FFULL);
|
|
|
|
break;
|
|
|
|
case 3: /* Reset transmitter. */
|
|
|
|
s->tx_enabled = 0;
|
|
|
|
s->sr |= MCF_UART_TxEMP;
|
|
|
|
s->sr &= ~MCF_UART_TxRDY;
|
|
|
|
break;
|
|
|
|
case 4: /* Reset error status. */
|
|
|
|
break;
|
|
|
|
case 5: /* Reset break-change interrupt. */
|
|
|
|
s->isr &= ~MCF_UART_DBINT;
|
|
|
|
break;
|
|
|
|
case 6: /* Start break. */
|
|
|
|
case 7: /* Stop break. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Transmitter command. */
|
|
|
|
switch ((cmd >> 2) & 3) {
|
|
|
|
case 0: /* No-op. */
|
|
|
|
break;
|
|
|
|
case 1: /* Enable. */
|
|
|
|
s->tx_enabled = 1;
|
|
|
|
mcf_uart_do_tx(s);
|
|
|
|
break;
|
|
|
|
case 2: /* Disable. */
|
|
|
|
s->tx_enabled = 0;
|
|
|
|
mcf_uart_do_tx(s);
|
|
|
|
break;
|
|
|
|
case 3: /* Reserved. */
|
|
|
|
fprintf(stderr, "mcf_uart: Bad TX command\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Receiver command. */
|
|
|
|
switch (cmd & 3) {
|
|
|
|
case 0: /* No-op. */
|
|
|
|
break;
|
|
|
|
case 1: /* Enable. */
|
|
|
|
s->rx_enabled = 1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
s->rx_enabled = 0;
|
|
|
|
break;
|
|
|
|
case 3: /* Reserved. */
|
|
|
|
fprintf(stderr, "mcf_uart: Bad RX command\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
void mcf_uart_write(void *opaque, hwaddr addr,
|
2011-11-24 17:31:13 +04:00
|
|
|
uint64_t val, unsigned size)
|
2007-06-03 15:13:39 +04:00
|
|
|
{
|
|
|
|
mcf_uart_state *s = (mcf_uart_state *)opaque;
|
|
|
|
switch (addr & 0x3f) {
|
|
|
|
case 0x00:
|
|
|
|
s->mr[s->current_mr] = val;
|
|
|
|
s->current_mr = 1;
|
|
|
|
break;
|
|
|
|
case 0x04:
|
|
|
|
/* CSR is ignored. */
|
|
|
|
break;
|
|
|
|
case 0x08: /* Command Register. */
|
|
|
|
mcf_do_command(s, val);
|
|
|
|
break;
|
|
|
|
case 0x0c: /* Transmit Buffer. */
|
|
|
|
s->sr &= ~MCF_UART_TxEMP;
|
|
|
|
s->tb = val;
|
|
|
|
mcf_uart_do_tx(s);
|
|
|
|
break;
|
|
|
|
case 0x10:
|
|
|
|
/* ACR is ignored. */
|
|
|
|
break;
|
|
|
|
case 0x14:
|
|
|
|
s->imr = val;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mcf_uart_update(s);
|
|
|
|
}
|
|
|
|
|
2017-01-28 09:56:22 +03:00
|
|
|
static void mcf_uart_reset(DeviceState *dev)
|
2007-06-03 15:13:39 +04:00
|
|
|
{
|
2017-01-28 09:56:22 +03:00
|
|
|
mcf_uart_state *s = MCF_UART(dev);
|
|
|
|
|
2007-06-03 15:13:39 +04:00
|
|
|
s->fifo_len = 0;
|
|
|
|
s->mr[0] = 0;
|
|
|
|
s->mr[1] = 0;
|
|
|
|
s->sr = MCF_UART_TxEMP;
|
|
|
|
s->tx_enabled = 0;
|
|
|
|
s->rx_enabled = 0;
|
|
|
|
s->isr = 0;
|
|
|
|
s->imr = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mcf_uart_push_byte(mcf_uart_state *s, uint8_t data)
|
|
|
|
{
|
|
|
|
/* Break events overwrite the last byte if the fifo is full. */
|
|
|
|
if (s->fifo_len == 4)
|
|
|
|
s->fifo_len--;
|
|
|
|
|
|
|
|
s->fifo[s->fifo_len] = data;
|
|
|
|
s->fifo_len++;
|
|
|
|
s->sr |= MCF_UART_RxRDY;
|
|
|
|
if (s->fifo_len == 4)
|
|
|
|
s->sr |= MCF_UART_FFULL;
|
|
|
|
|
|
|
|
mcf_uart_update(s);
|
|
|
|
}
|
|
|
|
|
chardev: Use QEMUChrEvent enum in IOEventHandler typedef
The Chardev events are listed in the QEMUChrEvent enum.
By using the enum in the IOEventHandler typedef we:
- make the IOEventHandler type more explicit (this handler
process out-of-band information, while the IOReadHandler
is in-band),
- help static code analyzers.
This patch was produced with the following spatch script:
@match@
expression backend, opaque, context, set_open;
identifier fd_can_read, fd_read, fd_event, be_change;
@@
qemu_chr_fe_set_handlers(backend, fd_can_read, fd_read, fd_event,
be_change, opaque, context, set_open);
@depends on match@
identifier opaque, event;
identifier match.fd_event;
@@
static
-void fd_event(void *opaque, int event)
+void fd_event(void *opaque, QEMUChrEvent event)
{
...
}
Then the typedef was modified manually in
include/chardev/char-fe.h.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Corey Minyard <cminyard@mvista.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20191218172009.8868-15-philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-12-18 20:20:09 +03:00
|
|
|
static void mcf_uart_event(void *opaque, QEMUChrEvent event)
|
2007-06-03 15:13:39 +04:00
|
|
|
{
|
|
|
|
mcf_uart_state *s = (mcf_uart_state *)opaque;
|
|
|
|
|
|
|
|
switch (event) {
|
|
|
|
case CHR_EVENT_BREAK:
|
|
|
|
s->isr |= MCF_UART_DBINT;
|
|
|
|
mcf_uart_push_byte(s, 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mcf_uart_can_receive(void *opaque)
|
|
|
|
{
|
|
|
|
mcf_uart_state *s = (mcf_uart_state *)opaque;
|
|
|
|
|
|
|
|
return s->rx_enabled && (s->sr & MCF_UART_FFULL) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mcf_uart_receive(void *opaque, const uint8_t *buf, int size)
|
|
|
|
{
|
|
|
|
mcf_uart_state *s = (mcf_uart_state *)opaque;
|
|
|
|
|
|
|
|
mcf_uart_push_byte(s, buf[0]);
|
|
|
|
}
|
|
|
|
|
2011-11-24 17:31:13 +04:00
|
|
|
static const MemoryRegionOps mcf_uart_ops = {
|
|
|
|
.read = mcf_uart_read,
|
|
|
|
.write = mcf_uart_write,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
2007-06-03 15:13:39 +04:00
|
|
|
};
|
|
|
|
|
2017-01-28 09:56:22 +03:00
|
|
|
static void mcf_uart_instance_init(Object *obj)
|
|
|
|
{
|
|
|
|
SysBusDevice *dev = SYS_BUS_DEVICE(obj);
|
|
|
|
mcf_uart_state *s = MCF_UART(dev);
|
|
|
|
|
|
|
|
memory_region_init_io(&s->iomem, obj, &mcf_uart_ops, s, "uart", 0x40);
|
|
|
|
sysbus_init_mmio(dev, &s->iomem);
|
|
|
|
|
|
|
|
sysbus_init_irq(dev, &s->irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mcf_uart_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
|
|
|
mcf_uart_state *s = MCF_UART(dev);
|
|
|
|
|
|
|
|
qemu_chr_fe_set_handlers(&s->chr, mcf_uart_can_receive, mcf_uart_receive,
|
2017-07-06 15:08:49 +03:00
|
|
|
mcf_uart_event, NULL, s, NULL, true);
|
2017-01-28 09:56:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static Property mcf_uart_properties[] = {
|
|
|
|
DEFINE_PROP_CHR("chardev", mcf_uart_state, chr),
|
|
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
|
|
};
|
|
|
|
|
|
|
|
static void mcf_uart_class_init(ObjectClass *oc, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
|
|
|
|
|
|
|
dc->realize = mcf_uart_realize;
|
2024-09-13 17:31:44 +03:00
|
|
|
device_class_set_legacy_reset(dc, mcf_uart_reset);
|
2020-01-10 18:30:32 +03:00
|
|
|
device_class_set_props(dc, mcf_uart_properties);
|
2017-01-28 09:56:22 +03:00
|
|
|
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const TypeInfo mcf_uart_info = {
|
|
|
|
.name = TYPE_MCF_UART,
|
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(mcf_uart_state),
|
|
|
|
.instance_init = mcf_uart_instance_init,
|
|
|
|
.class_init = mcf_uart_class_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void mcf_uart_register(void)
|
|
|
|
{
|
|
|
|
type_register_static(&mcf_uart_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
type_init(mcf_uart_register)
|
|
|
|
|
2023-10-19 13:49:29 +03:00
|
|
|
DeviceState *mcf_uart_create(qemu_irq irq, Chardev *chrdrv)
|
2017-01-28 09:56:22 +03:00
|
|
|
{
|
2023-10-19 13:49:29 +03:00
|
|
|
DeviceState *dev;
|
2017-01-28 09:56:22 +03:00
|
|
|
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:31:58 +03:00
|
|
|
dev = qdev_new(TYPE_MCF_UART);
|
2017-01-28 09:56:22 +03:00
|
|
|
if (chrdrv) {
|
|
|
|
qdev_prop_set_chr(dev, "chardev", chrdrv);
|
|
|
|
}
|
sysbus: Convert to sysbus_realize() etc. with Coccinelle
Convert from qdev_realize(), qdev_realize_and_unref() with null @bus
argument to sysbus_realize(), sysbus_realize_and_unref().
Coccinelle script:
@@
expression dev, errp;
@@
- qdev_realize(DEVICE(dev), NULL, errp);
+ sysbus_realize(SYS_BUS_DEVICE(dev), errp);
@@
expression sysbus_dev, dev, errp;
@@
+ sysbus_dev = SYS_BUS_DEVICE(dev);
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
- sysbus_dev = SYS_BUS_DEVICE(dev);
@@
expression sysbus_dev, dev, errp;
expression expr;
@@
sysbus_dev = SYS_BUS_DEVICE(dev);
... when != dev = expr;
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(DEVICE(dev), NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
Whitespace changes minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-46-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
|
2017-01-28 09:56:22 +03:00
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq);
|
|
|
|
|
|
|
|
return dev;
|
|
|
|
}
|
|
|
|
|
2023-10-19 13:49:29 +03:00
|
|
|
DeviceState *mcf_uart_create_mmap(hwaddr base, qemu_irq irq, Chardev *chrdrv)
|
2007-06-03 15:13:39 +04:00
|
|
|
{
|
2023-10-19 13:49:29 +03:00
|
|
|
DeviceState *dev;
|
2007-06-03 15:13:39 +04:00
|
|
|
|
2023-10-19 13:49:29 +03:00
|
|
|
dev = mcf_uart_create(irq, chrdrv);
|
2017-01-28 09:56:22 +03:00
|
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
|
2023-10-19 13:49:29 +03:00
|
|
|
|
|
|
|
return dev;
|
2007-06-03 15:13:39 +04:00
|
|
|
}
|