* [Qemu-devel] [PATCH 1/3] qdev: es1370+ac97 description
2009-07-15 11:50 [Qemu-devel] [PATCH 0/3] qdev: driver updates Gerd Hoffmann
@ 2009-07-15 11:50 ` Gerd Hoffmann
2009-07-15 11:50 ` [Qemu-devel] [PATCH 2/3] qdev: convert all vga devices Gerd Hoffmann
2009-07-15 11:50 ` [Qemu-devel] [PATCH 3/3] qdev/pci: hook up i440fx Gerd Hoffmann
2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2009-07-15 11:50 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/ac97.c | 1 +
hw/es1370.c | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/hw/ac97.c b/hw/ac97.c
index f18fa52..6c818c9 100644
--- a/hw/ac97.c
+++ b/hw/ac97.c
@@ -1366,6 +1366,7 @@ int ac97_init (PCIBus *bus)
static PCIDeviceInfo ac97_info = {
.qdev.name = "AC97",
+ .qdev.desc = "Intel 82801AA AC97 Audio",
.qdev.size = sizeof (PCIAC97LinkState),
.init = ac97_initfn,
};
diff --git a/hw/es1370.c b/hw/es1370.c
index 8d5a9f9..5c9af0e 100644
--- a/hw/es1370.c
+++ b/hw/es1370.c
@@ -1054,6 +1054,7 @@ int es1370_init (PCIBus *bus)
static PCIDeviceInfo es1370_info = {
.qdev.name = "ES1370",
+ .qdev.desc = "ENSONIQ AudioPCI ES1370",
.qdev.size = sizeof (PCIES1370State),
.init = es1370_initfn,
};
--
1.6.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 2/3] qdev: convert all vga devices.
2009-07-15 11:50 [Qemu-devel] [PATCH 0/3] qdev: driver updates Gerd Hoffmann
2009-07-15 11:50 ` [Qemu-devel] [PATCH 1/3] qdev: es1370+ac97 description Gerd Hoffmann
@ 2009-07-15 11:50 ` Gerd Hoffmann
2009-07-15 11:50 ` [Qemu-devel] [PATCH 3/3] qdev/pci: hook up i440fx Gerd Hoffmann
2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2009-07-15 11:50 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/cirrus_vga.c | 85 ++++++++++++++++++++++++++---------------------
hw/vga.c | 98 ++++++++++++++++++++++++++++++++++--------------------
hw/vmware_vga.c | 26 +++++++++++---
3 files changed, 129 insertions(+), 80 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 902b3ee..1d800e9 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -3301,46 +3301,55 @@ static void pci_cirrus_write_config(PCIDevice *d,
cirrus_update_memory_access(s);
}
+static void pci_cirrus_vga_initfn(PCIDevice *dev)
+{
+ PCICirrusVGAState *d = DO_UPCAST(PCICirrusVGAState, dev, dev);
+ CirrusVGAState *s = &d->cirrus_vga;
+ uint8_t *pci_conf = d->dev.config;
+ int 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 */
+ pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_CIRRUS);
+ pci_config_set_device_id(pci_conf, device_id);
+ pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS;
+ pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_VGA);
+ pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL;
+
+ /* setup memory space */
+ /* memory #0 LFB */
+ /* memory #1 memory-mapped I/O */
+ /* XXX: s->vga.vram_size must be a power of two */
+ pci_register_bar((PCIDevice *)d, 0, 0x2000000,
+ PCI_ADDRESS_SPACE_MEM_PREFETCH, cirrus_pci_lfb_map);
+ if (device_id == CIRRUS_ID_CLGD5446) {
+ pci_register_bar((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE,
+ PCI_ADDRESS_SPACE_MEM, cirrus_pci_mmio_map);
+ }
+ /* XXX: ROM BIOS */
+}
+
void pci_cirrus_vga_init(PCIBus *bus)
{
- PCICirrusVGAState *d;
- uint8_t *pci_conf;
- CirrusVGAState *s;
- int device_id;
-
- device_id = CIRRUS_ID_CLGD5446;
-
- /* setup PCI configuration registers */
- 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_device_id(pci_conf, device_id);
- pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS;
- pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_VGA);
- 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);
+ pci_create_simple(bus, -1, "Cirrus VGA");
+}
- s->vga.pci_dev = (PCIDevice *)d;
+static PCIDeviceInfo cirrus_vga_info = {
+ .qdev.name = "Cirrus VGA",
+ .qdev.size = sizeof(PCICirrusVGAState),
+ .init = pci_cirrus_vga_initfn,
+ .config_write = pci_cirrus_write_config,
+};
- /* setup memory space */
- /* memory #0 LFB */
- /* memory #1 memory-mapped I/O */
- /* XXX: s->vga.vram_size must be a power of two */
- pci_register_bar((PCIDevice *)d, 0, 0x2000000,
- PCI_ADDRESS_SPACE_MEM_PREFETCH, cirrus_pci_lfb_map);
- if (device_id == CIRRUS_ID_CLGD5446) {
- pci_register_bar((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE,
- PCI_ADDRESS_SPACE_MEM, cirrus_pci_mmio_map);
- }
- /* XXX: ROM BIOS */
+static void cirrus_vga_register(void)
+{
+ pci_qdev_register(&cirrus_vga_info);
}
+device_init(cirrus_vga_register);
diff --git a/hw/vga.c b/hw/vga.c
index 403f6ff..9a3e075 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -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 */
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index accdac4..5ceebf1 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1210,14 +1210,11 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,
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_device_id(s->card.config, SVGA_PCI_DEVICE_ID);
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);
}
+
+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);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 3/3] qdev/pci: hook up i440fx.
2009-07-15 11:50 [Qemu-devel] [PATCH 0/3] qdev: driver updates Gerd Hoffmann
2009-07-15 11:50 ` [Qemu-devel] [PATCH 1/3] qdev: es1370+ac97 description Gerd Hoffmann
2009-07-15 11:50 ` [Qemu-devel] [PATCH 2/3] qdev: convert all vga devices Gerd Hoffmann
@ 2009-07-15 11:50 ` Gerd Hoffmann
2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2009-07-15 11:50 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Hook i44fx pcihost into sysbus.
Convert Host bridge and ISA bridge pci devices to qdev.
Tag as no-user.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/pci_host.h | 3 ++
hw/piix_pci.c | 108 +++++++++++++++++++++++++++++++++++++++++++--------------
2 files changed, 85 insertions(+), 26 deletions(-)
diff --git a/hw/pci_host.h b/hw/pci_host.h
index 757b0e2..48862b5 100644
--- a/hw/pci_host.h
+++ b/hw/pci_host.h
@@ -28,6 +28,8 @@
/* debug PCI */
//#define DEBUG_PCI
+#include "sysbus.h"
+
#ifdef DEBUG_PCI
#define PCI_DPRINTF(fmt, ...) \
do { printf("pci_host_data: " fmt , ## __VA_ARGS__); } while (0)
@@ -36,6 +38,7 @@ do { printf("pci_host_data: " fmt , ## __VA_ARGS__); } while (0)
#endif
typedef struct {
+ SysBusDevice busdev;
uint32_t config_reg;
PCIBus *bus;
} PCIHostState;
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index fce01d4..91cebc9 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -25,6 +25,7 @@
#include "hw.h"
#include "pc.h"
#include "pci.h"
+#include "sysbus.h"
typedef uint32_t pci_addr_t;
#include "pci_host.h"
@@ -169,16 +170,9 @@ static int i440fx_load(QEMUFile* f, void *opaque, int version_id)
return 0;
}
-PCIBus *i440fx_init(PCIDevice **pi440fx_state, qemu_irq *pic)
+static void i440fx_pcihost_initfn(SysBusDevice *dev)
{
- PCIBus *b;
- PCIDevice *d;
- I440FXState *s;
-
- s = qemu_mallocz(sizeof(I440FXState));
- b = pci_register_bus(NULL, "pci",
- piix3_set_irq, pci_slot_get_pirq, pic, 0, 4);
- s->bus = b;
+ I440FXState *s = FROM_SYSBUS(I440FXState, dev);
register_ioport_write(0xcf8, 4, 4, i440fx_addr_writel, s);
register_ioport_read(0xcf8, 4, 4, i440fx_addr_readl, s);
@@ -189,10 +183,10 @@ PCIBus *i440fx_init(PCIDevice **pi440fx_state, qemu_irq *pic)
register_ioport_read(0xcfc, 4, 1, pci_host_data_readb, s);
register_ioport_read(0xcfc, 4, 2, pci_host_data_readw, s);
register_ioport_read(0xcfc, 4, 4, pci_host_data_readl, s);
+}
- d = pci_register_device(b, "i440FX", sizeof(PCIDevice), 0,
- NULL, i440fx_write_config);
-
+static void i440fx_initfn(PCIDevice *d)
+{
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_INTEL);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_INTEL_82441);
d->config[0x08] = 0x02; // revision
@@ -202,7 +196,25 @@ PCIBus *i440fx_init(PCIDevice **pi440fx_state, qemu_irq *pic)
d->config[0x72] = 0x02; /* SMRAM */
register_savevm("I440FX", 0, 2, i440fx_save, i440fx_load, d);
+}
+
+PCIBus *i440fx_init(PCIDevice **pi440fx_state, qemu_irq *pic)
+{
+ DeviceState *dev;
+ PCIBus *b;
+ PCIDevice *d;
+ I440FXState *s;
+
+ dev = qdev_create(NULL, "i440FX-pcihost");
+ s = FROM_SYSBUS(I440FXState, sysbus_from_qdev(dev));
+ b = pci_register_bus(&s->busdev.qdev, NULL,
+ piix3_set_irq, pci_slot_get_pirq, pic, 0, 4);
+ s->bus = b;
+ qdev_init(dev);
+
+ d = pci_create_simple(b, 0, "i440FX");
*pi440fx_state = d;
+
return b;
}
@@ -326,49 +338,93 @@ static int piix_load(QEMUFile* f, void *opaque, int version_id)
return pci_device_load(d, f);
}
-int piix3_init(PCIBus *bus, int devfn)
+static void piix3_initfn(PCIDevice *d)
{
- PCIDevice *d;
uint8_t *pci_conf;
- d = pci_register_device(bus, "PIIX3", sizeof(PCIDevice),
- devfn, NULL, NULL);
register_savevm("PIIX3", 0, 2, piix_save, piix_load, d);
- piix3_dev = d;
pci_conf = d->config;
-
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371SB_0); // 82371SB PIIX3 PCI-to-ISA bridge (Step A1)
pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_ISA);
pci_conf[PCI_HEADER_TYPE] =
PCI_HEADER_TYPE_NORMAL | PCI_HEADER_TYPE_MULTI_FUNCTION; // header_type = PCI_multifunction, generic
+ piix3_dev = d;
piix3_reset(d);
qemu_register_reset(piix3_reset, d);
- return d->devfn;
}
-int piix4_init(PCIBus *bus, int devfn)
+static void piix4_initfn(PCIDevice *d)
{
- PCIDevice *d;
uint8_t *pci_conf;
- d = pci_register_device(bus, "PIIX4", sizeof(PCIDevice),
- devfn, NULL, NULL);
register_savevm("PIIX4", 0, 2, piix_save, piix_load, d);
- piix4_dev = d;
pci_conf = d->config;
-
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371AB_0); // 82371AB/EB/MB PIIX4 PCI-to-ISA bridge
pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_ISA);
pci_conf[PCI_HEADER_TYPE] =
PCI_HEADER_TYPE_NORMAL | PCI_HEADER_TYPE_MULTI_FUNCTION; // header_type = PCI_multifunction, generic
-
+ piix4_dev = d;
piix4_reset(d);
qemu_register_reset(piix4_reset, d);
+}
+
+int piix3_init(PCIBus *bus, int devfn)
+{
+ PCIDevice *d;
+
+ d = pci_create_simple(bus, devfn, "PIIX3");
return d->devfn;
}
+
+int piix4_init(PCIBus *bus, int devfn)
+{
+ PCIDevice *d;
+
+ d = pci_create_simple(bus, devfn, "PIIX4");
+ return d->devfn;
+}
+
+static PCIDeviceInfo i440fx_info[] = {
+ {
+ .qdev.name = "i440FX",
+ .qdev.desc = "Host bridge",
+ .qdev.size = sizeof(PCIDevice),
+ .qdev.no_user = 1,
+ .init = i440fx_initfn,
+ .config_write = i440fx_write_config,
+ },{
+ .qdev.name = "PIIX3",
+ .qdev.desc = "ISA bridge",
+ .qdev.size = sizeof(PCIDevice),
+ .qdev.no_user = 1,
+ .init = piix3_initfn,
+ },{
+ .qdev.name = "PIIX4",
+ .qdev.desc = "ISA bridge",
+ .qdev.size = sizeof(PCIDevice),
+ .qdev.no_user = 1,
+ .init = piix4_initfn,
+ },{
+ /* end of list */
+ }
+};
+
+static SysBusDeviceInfo i440fx_pcihost_info = {
+ .init = i440fx_pcihost_initfn,
+ .qdev.name = "i440FX-pcihost",
+ .qdev.size = sizeof(I440FXState),
+ .qdev.no_user = 1,
+};
+
+static void i440fx_register(void)
+{
+ sysbus_register_withprop(&i440fx_pcihost_info);
+ pci_qdev_register_many(i440fx_info);
+}
+device_init(i440fx_register);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread