hw/arm: virt uart fix

commit f0d1d2c115
("hw/char: QOM'ify pl011 model") break qemu-system-arm virt machine
if option '-machine secure=on' is provided.

The function create_uart is called twice. So make CharDriverState pointer
a parameter to create_uart instead of hardcoded.

Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org>
Message-id: 1465353045-26323-1-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:
xiaoqiang zhao 2016-06-08 10:30:45 +08:00 committed by Peter Maydell
parent b66e10e4c9
commit 9bbbf6497a

View File

@ -525,7 +525,7 @@ static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic, int type, bool secure)
} }
static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic, int uart, static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic, int uart,
MemoryRegion *mem) MemoryRegion *mem, CharDriverState *chr)
{ {
char *nodename; char *nodename;
hwaddr base = vbi->memmap[uart].base; hwaddr base = vbi->memmap[uart].base;
@ -536,7 +536,7 @@ static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic, int uart,
DeviceState *dev = qdev_create(NULL, "pl011"); DeviceState *dev = qdev_create(NULL, "pl011");
SysBusDevice *s = SYS_BUS_DEVICE(dev); SysBusDevice *s = SYS_BUS_DEVICE(dev);
qdev_prop_set_chr(dev, "chardev", serial_hds[0]); qdev_prop_set_chr(dev, "chardev", chr);
qdev_init_nofail(dev); qdev_init_nofail(dev);
memory_region_add_subregion(mem, base, memory_region_add_subregion(mem, base,
sysbus_mmio_get_region(s, 0)); sysbus_mmio_get_region(s, 0));
@ -1259,11 +1259,11 @@ static void machvirt_init(MachineState *machine)
create_gic(vbi, pic, gic_version, vms->secure); create_gic(vbi, pic, gic_version, vms->secure);
create_uart(vbi, pic, VIRT_UART, sysmem); create_uart(vbi, pic, VIRT_UART, sysmem, serial_hds[0]);
if (vms->secure) { if (vms->secure) {
create_secure_ram(vbi, secure_sysmem); create_secure_ram(vbi, secure_sysmem);
create_uart(vbi, pic, VIRT_SECURE_UART, secure_sysmem); create_uart(vbi, pic, VIRT_SECURE_UART, secure_sysmem, serial_hds[1]);
} }
create_rtc(vbi, pic); create_rtc(vbi, pic);