diff options
author | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:08 +0100 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:08 +0100 |
commit | 0e058a8a6aab56565677dc3a7f994b0c8f191a48 (patch) | |
tree | b567e8f97339d6a9fa30ab89775a022bb6f209ff /hw | |
parent | 2d72c5727f8343a39862b8fca3b53a2bce26a7ca (diff) | |
download | qemu-0e058a8a6aab56565677dc3a7f994b0c8f191a48.zip qemu-0e058a8a6aab56565677dc3a7f994b0c8f191a48.tar.gz qemu-0e058a8a6aab56565677dc3a7f994b0c8f191a48.tar.bz2 |
Virtio-console conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/pc.c | 6 | ||||
-rw-r--r-- | hw/ppc440_bamboo.c | 6 | ||||
-rw-r--r-- | hw/virtio-console.c | 26 | ||||
-rw-r--r-- | hw/virtio-console.h | 3 |
4 files changed, 17 insertions, 24 deletions
@@ -33,7 +33,6 @@ #include "boards.h" #include "monitor.h" #include "fw_cfg.h" -#include "virtio-console.h" #include "hpet_emul.h" #include "watchdog.h" #include "smbios.h" @@ -1147,8 +1146,9 @@ static void pc_init1(ram_addr_t ram_size, /* Add virtio console devices */ if (pci_enabled) { for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) { - if (virtcon_hds[i]) - virtio_console_init(pci_bus, virtcon_hds[i]); + if (virtcon_hds[i]) { + pci_create_simple(pci_bus, -1, "virtio-console"); + } } } } diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index a58f6ea..606fc32 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -16,7 +16,6 @@ #include "net.h" #include "hw.h" #include "pci.h" -#include "virtio-console.h" #include "boards.h" #include "sysemu.h" #include "ppc440.h" @@ -118,8 +117,9 @@ static void bamboo_init(ram_addr_t ram_size, /* Add virtio console devices */ for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) { - if (virtcon_hds[i]) - virtio_console_init(pcibus, virtcon_hds[i]); + if (virtcon_hds[i]) { + pci_create_simple(pcibus, -1, "virtio-console"); + } } /* Register network interfaces. */ diff --git a/hw/virtio-console.c b/hw/virtio-console.c index c006d90..7f3efa0 100644 --- a/hw/virtio-console.c +++ b/hw/virtio-console.c @@ -123,35 +123,31 @@ static int virtio_console_load(QEMUFile *f, void *opaque, int version_id) return 0; } -void *virtio_console_init(PCIBus *bus, CharDriverState *chr) +static void virtio_console_init(PCIDevice *pci_dev) { VirtIOConsole *s; - PCIDevice *d; - - d = pci_register_device(bus, "virtio-console", sizeof(VirtIOConsole), - -1, NULL, NULL); - if (!d) - return NULL; - - s = (VirtIOConsole *)virtio_init_pci(d, "virtio-console", + s = (VirtIOConsole *)virtio_init_pci(pci_dev, "virtio-console", PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_CONSOLE, PCI_VENDOR_ID_REDHAT_QUMRANET, VIRTIO_ID_CONSOLE, PCI_CLASS_DISPLAY_OTHER, 0x00, 0); - if (s == NULL) - return NULL; - s->vdev.get_features = virtio_console_get_features; s->ivq = virtio_add_queue(&s->vdev, 128, virtio_console_handle_input); s->dvq = virtio_add_queue(&s->vdev, 128, virtio_console_handle_output); - s->chr = chr; - qemu_chr_add_handlers(chr, vcon_can_read, vcon_read, vcon_event, s); + s->chr = qdev_init_chardev(&pci_dev->qdev); + qemu_chr_add_handlers(s->chr, vcon_can_read, vcon_read, vcon_event, s); register_savevm("virtio-console", -1, 1, virtio_console_save, virtio_console_load, s); +} - return &s->vdev; +static void virtio_console_register_devices(void) +{ + pci_qdev_register("virtio-console", sizeof(VirtIOConsole), + virtio_console_init); } + +device_init(virtio_console_register_devices) diff --git a/hw/virtio-console.h b/hw/virtio-console.h index 2de9520..84d0717 100644 --- a/hw/virtio-console.h +++ b/hw/virtio-console.h @@ -16,7 +16,4 @@ /* The ID for virtio console */ #define VIRTIO_ID_CONSOLE 3 -/* Creates a virtio console */ -void *virtio_console_init(PCIBus *bus, CharDriverState *chr); - #endif |