diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2009-07-28 18:18:00 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-07-30 09:50:37 -0500 |
commit | a414c306c06c4ee9cb05af645b9fee6f8ea34038 (patch) | |
tree | c7f2bb5f0a4a37031ff866083fca0fdc5dc37c2e /hw/vga.c | |
parent | 9316d30fbb429fdb34c60a8ffc164db8b95edf31 (diff) |
qdev: convert all vga devices.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/vga.c')
-rw-r--r-- | hw/vga.c | 100 |
1 files changed, 63 insertions, 37 deletions
@@ -2480,52 +2480,78 @@ static void pci_vga_write_config(PCIDevice *d, s->map_addr = 0; } -int pci_vga_init(PCIBus *bus, - unsigned long vga_bios_offset, int vga_bios_size) -{ - PCIVGAState *d; - VGAState *s; - uint8_t *pci_conf; - - d = (PCIVGAState *)pci_register_device(bus, "VGA", - sizeof(PCIVGAState), - -1, NULL, pci_vga_write_config); - if (!d) - return -1; - s = &d->vga_state; - - vga_common_init(s, VGA_RAM_SIZE); - vga_init(s); - - s->ds = graphic_console_init(s->update, s->invalidate, - s->screen_dump, s->text_update, s); - - s->pci_dev = &d->dev; - - pci_conf = d->dev.config; - // dummy VGA (same as Bochs ID) - pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_QEMU); - pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_QEMU_VGA); - pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_VGA); - pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type - - /* XXX: VGA_RAM_SIZE must be a power of two */ - pci_register_bar(&d->dev, 0, VGA_RAM_SIZE, - PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map); - if (vga_bios_size != 0) { +static void pci_vga_initfn(PCIDevice *dev) +{ + PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev); + VGAState *s = &d->vga_state; + uint8_t *pci_conf = d->dev.config; + + // vga + console init + vga_common_init(s, VGA_RAM_SIZE); + vga_init(s); + s->pci_dev = &d->dev; + s->ds = graphic_console_init(s->update, s->invalidate, + s->screen_dump, s->text_update, s); + + // dummy VGA (same as Bochs ID) + pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_QEMU); + pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_QEMU_VGA); + pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_VGA); + pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type + + /* XXX: VGA_RAM_SIZE must be a power of two */ + pci_register_bar(&d->dev, 0, VGA_RAM_SIZE, + PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map); + + if (s->bios_size) { unsigned int bios_total_size; - s->bios_offset = vga_bios_offset; - s->bios_size = vga_bios_size; /* must be a power of two */ bios_total_size = 1; - while (bios_total_size < vga_bios_size) + while (bios_total_size < s->bios_size) bios_total_size <<= 1; pci_register_bar(&d->dev, PCI_ROM_SLOT, bios_total_size, - PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map); + PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map); } +} + +int pci_vga_init(PCIBus *bus, + unsigned long vga_bios_offset, int vga_bios_size) +{ + PCIDevice *dev; + + dev = pci_create("VGA", NULL); + qdev_prop_set_uint32(&dev->qdev, "bios-offset", vga_bios_offset); + qdev_prop_set_uint32(&dev->qdev, "bios-size", vga_bios_offset); + qdev_init(&dev->qdev); + return 0; } +static PCIDeviceInfo vga_info = { + .qdev.name = "VGA", + .qdev.size = sizeof(PCIVGAState), + .init = pci_vga_initfn, + .config_write = pci_vga_write_config, + .qdev.props = (Property[]) { + { + .name = "bios-offset", + .info = &qdev_prop_hex32, + .offset = offsetof(PCIVGAState, vga_state.bios_offset), + },{ + .name = "bios-size", + .info = &qdev_prop_hex32, + .offset = offsetof(PCIVGAState, vga_state.bios_size), + }, + {/* end of list */} + } +}; + +static void vga_register(void) +{ + pci_qdev_register(&vga_info); +} +device_init(vga_register); + /********************************************************/ /* vga screen dump */ |