mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-09 16:28:02 -06:00
hw/char: QOM'ify digic-uart model
* drop qemu_char_get_next_serial and use chardev prop * change affected board code to use the new way Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com> Message-id: 1465028065-5855-4-git-send-email-zxq_yx_007@163.com Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
4be12ea09a
commit
746c3b3eba
2 changed files with 8 additions and 4 deletions
|
@ -23,6 +23,7 @@
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "hw/arm/digic.h"
|
#include "hw/arm/digic.h"
|
||||||
|
#include "sysemu/sysemu.h"
|
||||||
|
|
||||||
#define DIGIC4_TIMER_BASE(n) (0xc0210000 + (n) * 0x100)
|
#define DIGIC4_TIMER_BASE(n) (0xc0210000 + (n) * 0x100)
|
||||||
|
|
||||||
|
@ -84,6 +85,7 @@ static void digic_realize(DeviceState *dev, Error **errp)
|
||||||
sysbus_mmio_map(sbd, 0, DIGIC4_TIMER_BASE(i));
|
sysbus_mmio_map(sbd, 0, DIGIC4_TIMER_BASE(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qdev_prop_set_chr(DEVICE(&s->uart), "chardev", serial_hds[0]);
|
||||||
object_property_set_bool(OBJECT(&s->uart), true, "realized", &err);
|
object_property_set_bool(OBJECT(&s->uart), true, "realized", &err);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
error_propagate(errp, err);
|
error_propagate(errp, err);
|
||||||
|
|
|
@ -145,8 +145,6 @@ static void digic_uart_realize(DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
DigicUartState *s = DIGIC_UART(dev);
|
DigicUartState *s = DIGIC_UART(dev);
|
||||||
|
|
||||||
/* FIXME use a qdev chardev prop instead of qemu_char_get_next_serial() */
|
|
||||||
s->chr = qemu_char_get_next_serial();
|
|
||||||
if (s->chr) {
|
if (s->chr) {
|
||||||
qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s);
|
qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s);
|
||||||
}
|
}
|
||||||
|
@ -172,6 +170,11 @@ static const VMStateDescription vmstate_digic_uart = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static Property digic_uart_properties[] = {
|
||||||
|
DEFINE_PROP_CHR("chardev", DigicUartState, chr),
|
||||||
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
|
};
|
||||||
|
|
||||||
static void digic_uart_class_init(ObjectClass *klass, void *data)
|
static void digic_uart_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
@ -179,8 +182,7 @@ static void digic_uart_class_init(ObjectClass *klass, void *data)
|
||||||
dc->realize = digic_uart_realize;
|
dc->realize = digic_uart_realize;
|
||||||
dc->reset = digic_uart_reset;
|
dc->reset = digic_uart_reset;
|
||||||
dc->vmsd = &vmstate_digic_uart;
|
dc->vmsd = &vmstate_digic_uart;
|
||||||
/* Reason: realize() method uses qemu_char_get_next_serial() */
|
dc->props = digic_uart_properties;
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo digic_uart_info = {
|
static const TypeInfo digic_uart_info = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue