Commit 0e058a8a6aab56565677dc3a7f994b0c8f191a48

Authored by Paul Brook
1 parent 2d72c572

Virtio-console conversion

Signed-off-by: Paul Brook <paul@codesourcery.com>
... ... @@ -33,7 +33,6 @@
33 33 #include "boards.h"
34 34 #include "monitor.h"
35 35 #include "fw_cfg.h"
36   -#include "virtio-console.h"
37 36 #include "hpet_emul.h"
38 37 #include "watchdog.h"
39 38 #include "smbios.h"
... ... @@ -1147,8 +1146,9 @@ static void pc_init1(ram_addr_t ram_size,
1147 1146 /* Add virtio console devices */
1148 1147 if (pci_enabled) {
1149 1148 for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
1150   - if (virtcon_hds[i])
1151   - virtio_console_init(pci_bus, virtcon_hds[i]);
  1149 + if (virtcon_hds[i]) {
  1150 + pci_create_simple(pci_bus, -1, "virtio-console");
  1151 + }
1152 1152 }
1153 1153 }
1154 1154 }
... ...
hw/ppc440_bamboo.c
... ... @@ -16,7 +16,6 @@
16 16 #include "net.h"
17 17 #include "hw.h"
18 18 #include "pci.h"
19   -#include "virtio-console.h"
20 19 #include "boards.h"
21 20 #include "sysemu.h"
22 21 #include "ppc440.h"
... ... @@ -118,8 +117,9 @@ static void bamboo_init(ram_addr_t ram_size,
118 117  
119 118 /* Add virtio console devices */
120 119 for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
121   - if (virtcon_hds[i])
122   - virtio_console_init(pcibus, virtcon_hds[i]);
  120 + if (virtcon_hds[i]) {
  121 + pci_create_simple(pcibus, -1, "virtio-console");
  122 + }
123 123 }
124 124  
125 125 /* Register network interfaces. */
... ...
hw/virtio-console.c
... ... @@ -123,35 +123,31 @@ static int virtio_console_load(QEMUFile *f, void *opaque, int version_id)
123 123 return 0;
124 124 }
125 125  
126   -void *virtio_console_init(PCIBus *bus, CharDriverState *chr)
  126 +static void virtio_console_init(PCIDevice *pci_dev)
127 127 {
128 128 VirtIOConsole *s;
129   - PCIDevice *d;
130   -
131   - d = pci_register_device(bus, "virtio-console", sizeof(VirtIOConsole),
132   - -1, NULL, NULL);
133   - if (!d)
134   - return NULL;
135   -
136   - s = (VirtIOConsole *)virtio_init_pci(d, "virtio-console",
  129 + s = (VirtIOConsole *)virtio_init_pci(pci_dev, "virtio-console",
137 130 PCI_VENDOR_ID_REDHAT_QUMRANET,
138 131 PCI_DEVICE_ID_VIRTIO_CONSOLE,
139 132 PCI_VENDOR_ID_REDHAT_QUMRANET,
140 133 VIRTIO_ID_CONSOLE,
141 134 PCI_CLASS_DISPLAY_OTHER, 0x00,
142 135 0);
143   - if (s == NULL)
144   - return NULL;
145   -
146 136 s->vdev.get_features = virtio_console_get_features;
147 137  
148 138 s->ivq = virtio_add_queue(&s->vdev, 128, virtio_console_handle_input);
149 139 s->dvq = virtio_add_queue(&s->vdev, 128, virtio_console_handle_output);
150 140  
151   - s->chr = chr;
152   - qemu_chr_add_handlers(chr, vcon_can_read, vcon_read, vcon_event, s);
  141 + s->chr = qdev_init_chardev(&pci_dev->qdev);
  142 + qemu_chr_add_handlers(s->chr, vcon_can_read, vcon_read, vcon_event, s);
153 143  
154 144 register_savevm("virtio-console", -1, 1, virtio_console_save, virtio_console_load, s);
  145 +}
155 146  
156   - return &s->vdev;
  147 +static void virtio_console_register_devices(void)
  148 +{
  149 + pci_qdev_register("virtio-console", sizeof(VirtIOConsole),
  150 + virtio_console_init);
157 151 }
  152 +
  153 +device_init(virtio_console_register_devices)
... ...
hw/virtio-console.h
... ... @@ -16,7 +16,4 @@
16 16 /* The ID for virtio console */
17 17 #define VIRTIO_ID_CONSOLE 3
18 18  
19   -/* Creates a virtio console */
20   -void *virtio_console_init(PCIBus *bus, CharDriverState *chr);
21   -
22 19 #endif
... ...