mirror of https://github.com/xemu-project/xemu.git
qdev: convert all vga devices.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
9316d30fbb
commit
a414c306c0
|
@ -3302,37 +3302,28 @@ static void pci_cirrus_write_config(PCIDevice *d,
|
||||||
cirrus_update_memory_access(s);
|
cirrus_update_memory_access(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pci_cirrus_vga_init(PCIBus *bus)
|
static void pci_cirrus_vga_initfn(PCIDevice *dev)
|
||||||
{
|
{
|
||||||
PCICirrusVGAState *d;
|
PCICirrusVGAState *d = DO_UPCAST(PCICirrusVGAState, dev, dev);
|
||||||
uint8_t *pci_conf;
|
CirrusVGAState *s = &d->cirrus_vga;
|
||||||
CirrusVGAState *s;
|
uint8_t *pci_conf = d->dev.config;
|
||||||
int device_id;
|
int device_id = CIRRUS_ID_CLGD5446;
|
||||||
|
|
||||||
device_id = CIRRUS_ID_CLGD5446;
|
/* setup VGA */
|
||||||
|
vga_common_init(&s->vga, VGA_RAM_SIZE);
|
||||||
|
cirrus_init_common(s, device_id, 1);
|
||||||
|
s->vga.pci_dev = (PCIDevice *)d;
|
||||||
|
s->vga.ds = graphic_console_init(s->vga.update, s->vga.invalidate,
|
||||||
|
s->vga.screen_dump, s->vga.text_update,
|
||||||
|
&s->vga);
|
||||||
|
|
||||||
/* setup PCI configuration registers */
|
/* setup PCI */
|
||||||
d = (PCICirrusVGAState *)pci_register_device(bus, "Cirrus VGA",
|
|
||||||
sizeof(PCICirrusVGAState),
|
|
||||||
-1, NULL, pci_cirrus_write_config);
|
|
||||||
pci_conf = d->dev.config;
|
|
||||||
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_CIRRUS);
|
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_CIRRUS);
|
||||||
pci_config_set_device_id(pci_conf, device_id);
|
pci_config_set_device_id(pci_conf, device_id);
|
||||||
pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS;
|
pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS;
|
||||||
pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_VGA);
|
pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_VGA);
|
||||||
pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL;
|
pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL;
|
||||||
|
|
||||||
/* setup VGA */
|
|
||||||
s = &d->cirrus_vga;
|
|
||||||
vga_common_init(&s->vga, VGA_RAM_SIZE);
|
|
||||||
cirrus_init_common(s, device_id, 1);
|
|
||||||
|
|
||||||
s->vga.ds = graphic_console_init(s->vga.update, s->vga.invalidate,
|
|
||||||
s->vga.screen_dump, s->vga.text_update,
|
|
||||||
&s->vga);
|
|
||||||
|
|
||||||
s->vga.pci_dev = (PCIDevice *)d;
|
|
||||||
|
|
||||||
/* setup memory space */
|
/* setup memory space */
|
||||||
/* memory #0 LFB */
|
/* memory #0 LFB */
|
||||||
/* memory #1 memory-mapped I/O */
|
/* memory #1 memory-mapped I/O */
|
||||||
|
@ -3345,3 +3336,21 @@ void pci_cirrus_vga_init(PCIBus *bus)
|
||||||
}
|
}
|
||||||
/* XXX: ROM BIOS */
|
/* XXX: ROM BIOS */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pci_cirrus_vga_init(PCIBus *bus)
|
||||||
|
{
|
||||||
|
pci_create_simple(bus, -1, "Cirrus VGA");
|
||||||
|
}
|
||||||
|
|
||||||
|
static PCIDeviceInfo cirrus_vga_info = {
|
||||||
|
.qdev.name = "Cirrus VGA",
|
||||||
|
.qdev.size = sizeof(PCICirrusVGAState),
|
||||||
|
.init = pci_cirrus_vga_initfn,
|
||||||
|
.config_write = pci_cirrus_write_config,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void cirrus_vga_register(void)
|
||||||
|
{
|
||||||
|
pci_qdev_register(&cirrus_vga_info);
|
||||||
|
}
|
||||||
|
device_init(cirrus_vga_register);
|
||||||
|
|
66
hw/vga.c
66
hw/vga.c
|
@ -2480,29 +2480,19 @@ static void pci_vga_write_config(PCIDevice *d,
|
||||||
s->map_addr = 0;
|
s->map_addr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pci_vga_init(PCIBus *bus,
|
static void pci_vga_initfn(PCIDevice *dev)
|
||||||
unsigned long vga_bios_offset, int vga_bios_size)
|
|
||||||
{
|
{
|
||||||
PCIVGAState *d;
|
PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev);
|
||||||
VGAState *s;
|
VGAState *s = &d->vga_state;
|
||||||
uint8_t *pci_conf;
|
uint8_t *pci_conf = d->dev.config;
|
||||||
|
|
||||||
d = (PCIVGAState *)pci_register_device(bus, "VGA",
|
|
||||||
sizeof(PCIVGAState),
|
|
||||||
-1, NULL, pci_vga_write_config);
|
|
||||||
if (!d)
|
|
||||||
return -1;
|
|
||||||
s = &d->vga_state;
|
|
||||||
|
|
||||||
|
// vga + console init
|
||||||
vga_common_init(s, VGA_RAM_SIZE);
|
vga_common_init(s, VGA_RAM_SIZE);
|
||||||
vga_init(s);
|
vga_init(s);
|
||||||
|
s->pci_dev = &d->dev;
|
||||||
s->ds = graphic_console_init(s->update, s->invalidate,
|
s->ds = graphic_console_init(s->update, s->invalidate,
|
||||||
s->screen_dump, s->text_update, s);
|
s->screen_dump, s->text_update, s);
|
||||||
|
|
||||||
s->pci_dev = &d->dev;
|
|
||||||
|
|
||||||
pci_conf = d->dev.config;
|
|
||||||
// dummy VGA (same as Bochs ID)
|
// dummy VGA (same as Bochs ID)
|
||||||
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_QEMU);
|
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_device_id(pci_conf, PCI_DEVICE_ID_QEMU_VGA);
|
||||||
|
@ -2512,20 +2502,56 @@ int pci_vga_init(PCIBus *bus,
|
||||||
/* XXX: VGA_RAM_SIZE must be a power of two */
|
/* XXX: VGA_RAM_SIZE must be a power of two */
|
||||||
pci_register_bar(&d->dev, 0, VGA_RAM_SIZE,
|
pci_register_bar(&d->dev, 0, VGA_RAM_SIZE,
|
||||||
PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map);
|
PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map);
|
||||||
if (vga_bios_size != 0) {
|
|
||||||
|
if (s->bios_size) {
|
||||||
unsigned int bios_total_size;
|
unsigned int bios_total_size;
|
||||||
s->bios_offset = vga_bios_offset;
|
|
||||||
s->bios_size = vga_bios_size;
|
|
||||||
/* must be a power of two */
|
/* must be a power of two */
|
||||||
bios_total_size = 1;
|
bios_total_size = 1;
|
||||||
while (bios_total_size < vga_bios_size)
|
while (bios_total_size < s->bios_size)
|
||||||
bios_total_size <<= 1;
|
bios_total_size <<= 1;
|
||||||
pci_register_bar(&d->dev, PCI_ROM_SLOT, bios_total_size,
|
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;
|
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 */
|
/* vga screen dump */
|
||||||
|
|
||||||
|
|
|
@ -1210,14 +1210,11 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,
|
||||||
iomemtype);
|
iomemtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pci_vmsvga_init(PCIBus *bus)
|
static void pci_vmsvga_initfn(PCIDevice *dev)
|
||||||
{
|
{
|
||||||
struct pci_vmsvga_state_s *s;
|
struct pci_vmsvga_state_s *s =
|
||||||
|
DO_UPCAST(struct pci_vmsvga_state_s, card, dev);
|
||||||
|
|
||||||
/* Setup PCI configuration */
|
|
||||||
s = (struct pci_vmsvga_state_s *)
|
|
||||||
pci_register_device(bus, "QEMUware SVGA",
|
|
||||||
sizeof(struct pci_vmsvga_state_s), -1, NULL, NULL);
|
|
||||||
pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE);
|
pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE);
|
||||||
pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID);
|
pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID);
|
||||||
s->card.config[PCI_COMMAND] = 0x07; /* I/O + Memory */
|
s->card.config[PCI_COMMAND] = 0x07; /* I/O + Memory */
|
||||||
|
@ -1240,3 +1237,20 @@ void pci_vmsvga_init(PCIBus *bus)
|
||||||
|
|
||||||
register_savevm("vmware_vga", 0, 0, pci_vmsvga_save, pci_vmsvga_load, s);
|
register_savevm("vmware_vga", 0, 0, pci_vmsvga_save, pci_vmsvga_load, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pci_vmsvga_init(PCIBus *bus)
|
||||||
|
{
|
||||||
|
pci_create_simple(bus, -1, "QEMUware SVGA");
|
||||||
|
}
|
||||||
|
|
||||||
|
static PCIDeviceInfo vmsvga_info = {
|
||||||
|
.qdev.name = "QEMUware SVGA",
|
||||||
|
.qdev.size = sizeof(struct pci_vmsvga_state_s),
|
||||||
|
.init = pci_vmsvga_initfn,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void vmsvga_register(void)
|
||||||
|
{
|
||||||
|
pci_qdev_register(&vmsvga_info);
|
||||||
|
}
|
||||||
|
device_init(vmsvga_register);
|
||||||
|
|
Loading…
Reference in New Issue