* [Qemu-devel] [patch 0/5] PCI clean-up
@ 2009-02-23 9:18 Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 1/5] ioemu: Remove lsi_scsi_init()s devfn parameter as it is always passed as -1 Simon Horman
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Simon Horman @ 2009-02-23 9:18 UTC (permalink / raw)
To: qemu-devel
Hi,
please consider these cosmetic clean-ups to the PCI code.
--
Simon Horman
VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [patch 1/5] ioemu: Remove lsi_scsi_init()s devfn parameter as it is always passed as -1
2009-02-23 9:18 [Qemu-devel] [patch 0/5] PCI clean-up Simon Horman
@ 2009-02-23 9:18 ` Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 2/5] " Simon Horman
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2009-02-23 9:18 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: qemu-lsi_scsi_init-no-devfn-arg.patch --]
[-- Type: text/plain, Size: 3768 bytes --]
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: qemu/hw/lsi53c895a.c
===================================================================
--- qemu.orig/hw/lsi53c895a.c 2009-02-23 18:33:24.000000000 +1100
+++ qemu/hw/lsi53c895a.c 2009-02-23 18:33:29.000000000 +1100
@@ -1974,13 +1974,13 @@ static int lsi_scsi_uninit(PCIDevice *d)
return 0;
}
-void *lsi_scsi_init(PCIBus *bus, int devfn)
+void *lsi_scsi_init(PCIBus *bus)
{
LSIState *s;
uint8_t *pci_conf;
s = (LSIState *)pci_register_device(bus, "LSI53C895A SCSI HBA",
- sizeof(*s), devfn, NULL, NULL);
+ sizeof(*s), -1, NULL, NULL);
if (s == NULL) {
fprintf(stderr, "lsi-scsi: Failed to register PCI device\n");
return NULL;
Index: qemu/hw/pc.c
===================================================================
--- qemu.orig/hw/pc.c 2009-02-23 18:33:24.000000000 +1100
+++ qemu/hw/pc.c 2009-02-23 18:33:29.000000000 +1100
@@ -1078,7 +1078,7 @@ vga_bios_error:
max_bus = drive_get_max_bus(IF_SCSI);
for (bus = 0; bus <= max_bus; bus++) {
- scsi = lsi_scsi_init(pci_bus, -1);
+ scsi = lsi_scsi_init(pci_bus);
for (unit = 0; unit < LSI_MAX_DEVS; unit++) {
index = drive_get_index(IF_SCSI, bus, unit);
if (index == -1)
Index: qemu/hw/pci.h
===================================================================
--- qemu.orig/hw/pci.h 2009-02-23 18:33:24.000000000 +1100
+++ qemu/hw/pci.h 2009-02-23 18:33:29.000000000 +1100
@@ -263,7 +263,7 @@ pci_config_set_class(uint8_t *pci_config
/* lsi53c895a.c */
#define LSI_MAX_DEVS 7
void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id);
-void *lsi_scsi_init(PCIBus *bus, int devfn);
+void *lsi_scsi_init(PCIBus *bus);
/* vmware_vga.c */
void pci_vmsvga_init(PCIBus *bus, uint8_t *vga_ram_base,
Index: qemu/hw/realview.c
===================================================================
--- qemu.orig/hw/realview.c 2009-02-23 18:33:24.000000000 +1100
+++ qemu/hw/realview.c 2009-02-23 18:33:29.000000000 +1100
@@ -112,7 +112,7 @@ static void realview_init(ram_addr_t ram
fprintf(stderr, "qemu: too many SCSI bus\n");
exit(1);
}
- scsi_hba = lsi_scsi_init(pci_bus, -1);
+ scsi_hba = lsi_scsi_init(pci_bus);
for (n = 0; n < LSI_MAX_DEVS; n++) {
index = drive_get_index(IF_SCSI, 0, n);
if (index == -1)
Index: qemu/hw/versatilepb.c
===================================================================
--- qemu.orig/hw/versatilepb.c 2009-02-23 18:33:24.000000000 +1100
+++ qemu/hw/versatilepb.c 2009-02-23 18:33:29.000000000 +1100
@@ -207,7 +207,7 @@ static void versatile_init(ram_addr_t ra
fprintf(stderr, "qemu: too many SCSI bus\n");
exit(1);
}
- scsi_hba = lsi_scsi_init(pci_bus, -1);
+ scsi_hba = lsi_scsi_init(pci_bus);
for (n = 0; n < LSI_MAX_DEVS; n++) {
index = drive_get_index(IF_SCSI, 0, n);
if (index == -1)
Index: qemu/hw/pci-hotplug.c
===================================================================
--- qemu.orig/hw/pci-hotplug.c 2009-02-23 18:33:36.000000000 +1100
+++ qemu/hw/pci-hotplug.c 2009-02-23 18:33:43.000000000 +1100
@@ -112,7 +112,7 @@ static PCIDevice *qemu_pci_hot_add_stora
switch (type) {
case IF_SCSI:
- opaque = lsi_scsi_init (pci_bus, -1);
+ opaque = lsi_scsi_init (pci_bus);
if (opaque && drive_idx >= 0)
lsi_scsi_attach (opaque, drives_table[drive_idx].bdrv,
drives_table[drive_idx].unit);
--
--
Simon Horman
VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [patch 2/5] ioemu: Remove lsi_scsi_init()s devfn parameter as it is always passed as -1
2009-02-23 9:18 [Qemu-devel] [patch 0/5] PCI clean-up Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 1/5] ioemu: Remove lsi_scsi_init()s devfn parameter as it is always passed as -1 Simon Horman
@ 2009-02-23 9:18 ` Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 3/5] ioemu: Remove usb_ohci_init*()s devfn parameter as they are " Simon Horman
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2009-02-23 9:18 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: qemu-piix3_init-no-devfn-arg.patch --]
[-- Type: text/plain, Size: 1891 bytes --]
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: qemu/hw/pc.c
===================================================================
--- qemu.orig/hw/pc.c 2009-02-23 17:09:27.000000000 +1100
+++ qemu/hw/pc.c 2009-02-23 17:11:48.000000000 +1100
@@ -933,7 +933,7 @@ vga_bios_error:
if (pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, i8259);
- piix3_devfn = piix3_init(pci_bus, -1);
+ piix3_devfn = piix3_init(pci_bus);
} else {
pci_bus = NULL;
}
Index: qemu/hw/pc.h
===================================================================
--- qemu.orig/hw/pc.h 2009-02-20 19:47:46.000000000 +1100
+++ qemu/hw/pc.h 2009-02-23 17:11:48.000000000 +1100
@@ -113,7 +113,7 @@ int pcspk_audio_init(AudioState *, qemu_
/* piix_pci.c */
PCIBus *i440fx_init(PCIDevice **pi440fx_state, qemu_irq *pic);
void i440fx_set_smm(PCIDevice *d, int val);
-int piix3_init(PCIBus *bus, int devfn);
+int piix3_init(PCIBus *bus);
void i440fx_init_memory_mappings(PCIDevice *d);
extern PCIDevice *piix4_dev;
Index: qemu/hw/piix_pci.c
===================================================================
--- qemu.orig/hw/piix_pci.c 2009-02-20 19:47:46.000000000 +1100
+++ qemu/hw/piix_pci.c 2009-02-23 17:11:48.000000000 +1100
@@ -322,13 +322,13 @@ static int piix_load(QEMUFile* f, void *
return pci_device_load(d, f);
}
-int piix3_init(PCIBus *bus, int devfn)
+int piix3_init(PCIBus *bus)
{
PCIDevice *d;
uint8_t *pci_conf;
d = pci_register_device(bus, "PIIX3", sizeof(PCIDevice),
- devfn, NULL, NULL);
+ -1, NULL, NULL);
register_savevm("PIIX3", 0, 2, piix_save, piix_load, d);
piix3_dev = d;
--
--
Simon Horman
VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [patch 3/5] ioemu: Remove usb_ohci_init*()s devfn parameter as they are always passed as -1
2009-02-23 9:18 [Qemu-devel] [patch 0/5] PCI clean-up Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 1/5] ioemu: Remove lsi_scsi_init()s devfn parameter as it is always passed as -1 Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 2/5] " Simon Horman
@ 2009-02-23 9:18 ` Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 4/5] iommu: Define PCI_DEVFN_AUTO and use it Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 5/5] iommu: Use PCI_DEVFN, PCI_SLOT and PCI_FUNC Simon Horman
4 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2009-02-23 9:18 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: qemu-usb_ohci_init-no-devfn-arg.patch --]
[-- Type: text/plain, Size: 6774 bytes --]
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: qemu/hw/pci.h
===================================================================
--- qemu.orig/hw/pci.h 2009-02-23 18:42:23.000000000 +1100
+++ qemu/hw/pci.h 2009-02-23 18:44:19.000000000 +1100
@@ -274,7 +274,7 @@ void usb_uhci_piix3_init(PCIBus *bus, in
void usb_uhci_piix4_init(PCIBus *bus, int devfn);
/* usb-ohci.c */
-void usb_ohci_init_pci(struct PCIBus *bus, int num_ports, int devfn);
+void usb_ohci_init_pci(struct PCIBus *bus, int num_ports);
/* eepro100.c */
Index: qemu/hw/ppc_oldworld.c
===================================================================
--- qemu.orig/hw/ppc_oldworld.c 2009-02-23 18:28:47.000000000 +1100
+++ qemu/hw/ppc_oldworld.c 2009-02-23 18:44:19.000000000 +1100
@@ -358,7 +358,7 @@ static void ppc_heathrow_init (ram_addr_
escc_mem_index);
if (usb_enabled) {
- usb_ohci_init_pci(pci_bus, 3, -1);
+ usb_ohci_init_pci(pci_bus, 3);
}
if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
Index: qemu/hw/ppc_prep.c
===================================================================
--- qemu.orig/hw/ppc_prep.c 2009-02-23 18:28:47.000000000 +1100
+++ qemu/hw/ppc_prep.c 2009-02-23 18:44:19.000000000 +1100
@@ -734,7 +734,7 @@ static void ppc_prep_init (ram_addr_t ra
#endif
if (usb_enabled) {
- usb_ohci_init_pci(pci_bus, 3, -1);
+ usb_ohci_init_pci(pci_bus, 3);
}
m48t59 = m48t59_init(i8259[8], 0, 0x0074, NVRAM_SIZE, 59);
Index: qemu/hw/realview.c
===================================================================
--- qemu.orig/hw/realview.c 2009-02-23 18:42:23.000000000 +1100
+++ qemu/hw/realview.c 2009-02-23 18:44:19.000000000 +1100
@@ -106,7 +106,7 @@ static void realview_init(ram_addr_t ram
pci_bus = pci_vpb_init(pic, 48, 1);
if (usb_enabled) {
- usb_ohci_init_pci(pci_bus, 3, -1);
+ usb_ohci_init_pci(pci_bus, 3);
}
if (drive_get_max_bus(IF_SCSI) > 0) {
fprintf(stderr, "qemu: too many SCSI bus\n");
Index: qemu/hw/versatilepb.c
===================================================================
--- qemu.orig/hw/versatilepb.c 2009-02-23 18:42:23.000000000 +1100
+++ qemu/hw/versatilepb.c 2009-02-23 18:44:19.000000000 +1100
@@ -201,7 +201,7 @@ static void versatile_init(ram_addr_t ra
}
}
if (usb_enabled) {
- usb_ohci_init_pci(pci_bus, 3, -1);
+ usb_ohci_init_pci(pci_bus, 3);
}
if (drive_get_max_bus(IF_SCSI) > 0) {
fprintf(stderr, "qemu: too many SCSI bus\n");
Index: qemu/hw/usb-ohci.c
===================================================================
--- qemu.orig/hw/usb-ohci.c 2009-02-23 18:28:47.000000000 +1100
+++ qemu/hw/usb-ohci.c 2009-02-23 18:44:19.000000000 +1100
@@ -1619,7 +1619,7 @@ static CPUWriteMemoryFunc *ohci_writefn[
ohci_mem_write
};
-static void usb_ohci_init(OHCIState *ohci, int num_ports, int devfn,
+static void usb_ohci_init(OHCIState *ohci, int num_ports,
qemu_irq irq, enum ohci_type type, const char *name)
{
int i;
@@ -1668,12 +1668,12 @@ static void ohci_mapfunc(PCIDevice *pci_
cpu_register_physical_memory(addr, size, ohci->state.mem);
}
-void usb_ohci_init_pci(struct PCIBus *bus, int num_ports, int devfn)
+void usb_ohci_init_pci(struct PCIBus *bus, int num_ports)
{
OHCIPCIState *ohci;
ohci = (OHCIPCIState *)pci_register_device(bus, "OHCI USB", sizeof(*ohci),
- devfn, NULL, NULL);
+ -1, NULL, NULL);
if (ohci == NULL) {
fprintf(stderr, "usb-ohci: Failed to register PCI device\n");
return;
@@ -1685,20 +1685,18 @@ void usb_ohci_init_pci(struct PCIBus *bu
pci_config_set_class(ohci->pci_dev.config, PCI_CLASS_SERIAL_USB);
ohci->pci_dev.config[0x3d] = 0x01; /* interrupt pin 1 */
- usb_ohci_init(&ohci->state, num_ports, devfn, ohci->pci_dev.irq[0],
+ usb_ohci_init(&ohci->state, num_ports, ohci->pci_dev.irq[0],
OHCI_TYPE_PCI, ohci->pci_dev.name);
pci_register_io_region((struct PCIDevice *)ohci, 0, 256,
PCI_ADDRESS_SPACE_MEM, ohci_mapfunc);
}
-void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, int devfn,
- qemu_irq irq)
+void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, qemu_irq irq)
{
OHCIState *ohci = (OHCIState *)qemu_mallocz(sizeof(OHCIState));
- usb_ohci_init(ohci, num_ports, devfn, irq,
- OHCI_TYPE_PXA, "OHCI USB");
+ usb_ohci_init(ohci, num_ports, irq, OHCI_TYPE_PXA, "OHCI USB");
cpu_register_physical_memory(base, 0x1000, ohci->mem);
}
Index: qemu/hw/pxa.h
===================================================================
--- qemu.orig/hw/pxa.h 2009-02-23 18:28:47.000000000 +1100
+++ qemu/hw/pxa.h 2009-02-23 18:44:19.000000000 +1100
@@ -219,7 +219,6 @@ struct pxa2xx_state_s *pxa270_init(unsig
struct pxa2xx_state_s *pxa255_init(unsigned int sdram_size);
/* usb-ohci.c */
-void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, int devfn,
- qemu_irq irq);
+void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, qemu_irq irq);
#endif /* PXA_H */
Index: qemu/hw/pxa2xx.c
===================================================================
--- qemu.orig/hw/pxa2xx.c 2009-02-23 18:28:47.000000000 +1100
+++ qemu/hw/pxa2xx.c 2009-02-23 18:44:19.000000000 +1100
@@ -2112,7 +2112,7 @@ struct pxa2xx_state_s *pxa270_init(unsig
}
if (usb_enabled) {
- usb_ohci_init_pxa(0x4c000000, 3, -1, s->pic[PXA2XX_PIC_USBH1]);
+ usb_ohci_init_pxa(0x4c000000, 3, s->pic[PXA2XX_PIC_USBH1]);
}
s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000);
@@ -2234,7 +2234,7 @@ struct pxa2xx_state_s *pxa255_init(unsig
}
if (usb_enabled) {
- usb_ohci_init_pxa(0x4c000000, 3, -1, s->pic[PXA2XX_PIC_USBH1]);
+ usb_ohci_init_pxa(0x4c000000, 3, s->pic[PXA2XX_PIC_USBH1]);
}
s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000);
Index: qemu/hw/ppc_newworld.c
===================================================================
--- qemu.orig/hw/ppc_newworld.c 2009-02-23 18:45:13.000000000 +1100
+++ qemu/hw/ppc_newworld.c 2009-02-23 18:45:29.000000000 +1100
@@ -304,7 +304,7 @@ static void ppc_core99_init (ram_addr_t
escc_mem_index);
if (usb_enabled) {
- usb_ohci_init_pci(pci_bus, 3, -1);
+ usb_ohci_init_pci(pci_bus, 3);
}
if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
--
--
Simon Horman
VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [patch 4/5] iommu: Define PCI_DEVFN_AUTO and use it
2009-02-23 9:18 [Qemu-devel] [patch 0/5] PCI clean-up Simon Horman
` (2 preceding siblings ...)
2009-02-23 9:18 ` [Qemu-devel] [patch 3/5] ioemu: Remove usb_ohci_init*()s devfn parameter as they are " Simon Horman
@ 2009-02-23 9:18 ` Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 5/5] iommu: Use PCI_DEVFN, PCI_SLOT and PCI_FUNC Simon Horman
4 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2009-02-23 9:18 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: qemu-PCI_DEVFN_AUTO.patch --]
[-- Type: text/plain, Size: 16635 bytes --]
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: qemu/hw/pci.c
===================================================================
--- qemu.orig/hw/pci.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/pci.c 2009-02-23 18:46:30.000000000 +1100
@@ -235,7 +235,6 @@ int pci_assign_devaddr(const char *addr,
return pci_parse_devaddr(devaddr, domp, busp, slotp);
}
-/* -1 for devfn means auto assign */
PCIDevice *pci_register_device(PCIBus *bus, const char *name,
int instance_size, int devfn,
PCIConfigReadFunc *config_read,
@@ -246,7 +245,7 @@ PCIDevice *pci_register_device(PCIBus *b
if (pci_irq_index >= PCI_DEVICES_MAX)
return NULL;
- if (devfn < 0) {
+ if (devfn == PCI_DEVFN_AUTO) {
for(devfn = bus->devfn_min ; devfn < 256; devfn += 8) {
if (!bus->devices[devfn])
goto found;
Index: qemu/hw/ac97.c
===================================================================
--- qemu.orig/hw/ac97.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/ac97.c 2009-02-23 18:46:30.000000000 +1100
@@ -1326,7 +1326,7 @@ int ac97_init (PCIBus *bus, AudioState *
d = (PCIAC97LinkState *) pci_register_device (bus, "AC97",
sizeof (PCIAC97LinkState),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
if (!d) {
AUD_log ("ac97", "Failed to register PCI device\n");
Index: qemu/hw/cirrus_vga.c
===================================================================
--- qemu.orig/hw/cirrus_vga.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/cirrus_vga.c 2009-02-23 18:46:30.000000000 +1100
@@ -3373,7 +3373,8 @@ void pci_cirrus_vga_init(PCIBus *bus, ui
/* setup PCI configuration registers */
d = (PCICirrusVGAState *)pci_register_device(bus, "Cirrus VGA",
sizeof(PCICirrusVGAState),
- -1, NULL, pci_cirrus_write_config);
+ PCI_DEVFN_AUTO, 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);
Index: qemu/hw/eepro100.c
===================================================================
--- qemu.orig/hw/eepro100.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/eepro100.c 2009-02-23 18:46:30.000000000 +1100
@@ -1744,8 +1744,8 @@ static PCIDevice *nic_init(PCIBus * bus,
logout("\n");
d = (PCIEEPRO100State *) pci_register_device(bus, name,
- sizeof(PCIEEPRO100State), -1,
- NULL, NULL);
+ sizeof(PCIEEPRO100State),
+ PCI_DEVFN_AUTO, NULL, NULL);
s = &d->eepro100;
s->device = device;
Index: qemu/hw/es1370.c
===================================================================
--- qemu.orig/hw/es1370.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/es1370.c 2009-02-23 18:46:30.000000000 +1100
@@ -1023,7 +1023,7 @@ int es1370_init (PCIBus *bus, AudioState
d = (PCIES1370State *) pci_register_device (bus, "ES1370",
sizeof (PCIES1370State),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
if (!d) {
AUD_log (NULL, "Failed to register PCI device for ES1370\n");
Index: qemu/hw/ide.c
===================================================================
--- qemu.orig/hw/ide.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/ide.c 2009-02-23 18:46:30.000000000 +1100
@@ -3286,7 +3286,7 @@ void pci_cmd646_ide_init(PCIBus *bus, Bl
d = (PCIIDEState *)pci_register_device(bus, "CMD646 IDE",
sizeof(PCIIDEState),
- -1,
+ PCI_DEVFN_AUTO,
NULL, NULL);
d->type = IDE_TYPE_CMD646;
pci_conf = d->dev.config;
Index: qemu/hw/macio.c
===================================================================
--- qemu.orig/hw/macio.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/macio.c 2009-02-23 18:46:30.000000000 +1100
@@ -89,7 +89,7 @@ void macio_init (PCIBus *bus, int device
d = pci_register_device(bus, "macio",
sizeof(PCIDevice) + sizeof(macio_state_t),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
macio_state = (macio_state_t *)(d + 1);
macio_state->is_oldworld = is_oldworld;
macio_state->pic_mem_index = pic_mem_index;
Index: qemu/hw/openpic.c
===================================================================
--- qemu.orig/hw/openpic.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/openpic.c 2009-02-23 18:46:30.000000000 +1100
@@ -1143,7 +1143,7 @@ qemu_irq *openpic_init (PCIBus *bus, int
return NULL;
if (bus) {
opp = (openpic_t *)pci_register_device(bus, "OpenPIC", sizeof(openpic_t),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
if (opp == NULL)
return NULL;
pci_conf = opp->pci_dev.config;
Index: qemu/hw/pci.h
===================================================================
--- qemu.orig/hw/pci.h 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/pci.h 2009-02-23 18:46:30.000000000 +1100
@@ -144,6 +144,8 @@ typedef struct PCIIORegion {
#define PCI_ROM_SLOT 6
#define PCI_NUM_REGIONS 7
+#define PCI_DEVFN_AUTO -1
+
#define PCI_DEVICES_MAX 64
#define PCI_VENDOR_ID 0x00 /* 16 bits */
Index: qemu/hw/versatile_pci.c
===================================================================
--- qemu.orig/hw/versatile_pci.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/versatile_pci.c 2009-02-23 18:46:30.000000000 +1100
@@ -117,7 +117,8 @@ PCIBus *pci_vpb_init(qemu_irq *pic, int
/* Normal config area. */
cpu_register_physical_memory(base + 0x02000000, 0x1000000, mem_config);
- d = pci_register_device(s, name, sizeof(PCIDevice), -1, NULL, NULL);
+ d = pci_register_device(s, name, sizeof(PCIDevice), PCI_DEVFN_AUTO,
+ NULL, NULL);
if (realview) {
/* IO memory area. */
Index: qemu/hw/vga.c
===================================================================
--- qemu.orig/hw/vga.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/vga.c 2009-02-23 18:46:30.000000000 +1100
@@ -2492,7 +2492,7 @@ int pci_vga_init(PCIBus *bus, uint8_t *v
d = (PCIVGAState *)pci_register_device(bus, "VGA",
sizeof(PCIVGAState),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
if (!d)
return -1;
s = &d->vga_state;
Index: qemu/hw/vmware_vga.c
===================================================================
--- qemu.orig/hw/vmware_vga.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/vmware_vga.c 2009-02-23 18:46:30.000000000 +1100
@@ -1214,7 +1214,7 @@ void pci_vmsvga_init(PCIBus *bus, uint8_
/* Setup PCI configuration */
s = (struct pci_vmsvga_state_s *)
pci_register_device(bus, "QEMUware SVGA",
- sizeof(struct pci_vmsvga_state_s), -1, 0, 0);
+ sizeof(struct pci_vmsvga_state_s), PCI_DEVFN_AUTO, 0, 0);
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 */
Index: qemu/hw/lsi53c895a.c
===================================================================
--- qemu.orig/hw/lsi53c895a.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/lsi53c895a.c 2009-02-23 18:46:30.000000000 +1100
@@ -1980,7 +1980,7 @@ void *lsi_scsi_init(PCIBus *bus)
uint8_t *pci_conf;
s = (LSIState *)pci_register_device(bus, "LSI53C895A SCSI HBA",
- sizeof(*s), -1, NULL, NULL);
+ sizeof(*s), PCI_DEVFN_AUTO, NULL, NULL);
if (s == NULL) {
fprintf(stderr, "lsi-scsi: Failed to register PCI device\n");
return NULL;
Index: qemu/hw/mips_malta.c
===================================================================
--- qemu.orig/hw/mips_malta.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/mips_malta.c 2009-02-23 18:46:30.000000000 +1100
@@ -489,7 +489,7 @@ static void network_init (PCIBus *pci_bu
for(i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];
- int devfn = -1;
+ int devfn = PCI_DEVFN_AUTO;
if (i == 0 && (!nd->model || strcmp(nd->model, "pcnet") == 0))
/* The malta board has a PCNet card using PCI SLOT 11 */
Index: qemu/hw/pc.c
===================================================================
--- qemu.orig/hw/pc.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/pc.c 2009-02-23 18:46:30.000000000 +1100
@@ -1007,7 +1007,7 @@ vga_bios_error:
if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
pc_init_ne2k_isa(nd, i8259);
else
- pci_nic_init(pci_bus, nd, -1, "ne2k_pci");
+ pci_nic_init(pci_bus, nd, PCI_DEVFN_AUTO, "ne2k_pci");
}
qemu_system_hot_add_init();
Index: qemu/hw/ppc_oldworld.c
===================================================================
--- qemu.orig/hw/ppc_oldworld.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/ppc_oldworld.c 2009-02-23 18:46:30.000000000 +1100
@@ -306,7 +306,7 @@ static void ppc_heathrow_init (ram_addr_
serial_hds[1], ESCC_CLOCK, 4);
for(i = 0; i < nb_nics; i++)
- pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(pci_bus, &nd_table[i], PCI_DEVFN_AUTO, "ne2k_pci");
/* First IDE channel is a CMD646 on the PCI bus */
Index: qemu/hw/ppc_prep.c
===================================================================
--- qemu.orig/hw/ppc_prep.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/ppc_prep.c 2009-02-23 18:46:30.000000000 +1100
@@ -674,7 +674,7 @@ static void ppc_prep_init (ram_addr_t ra
if (strcmp(nd_table[i].model, "ne2k_isa") == 0) {
isa_ne2000_init(ne2000_io[i], i8259[ne2000_irq[i]], &nd_table[i]);
} else {
- pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(pci_bus, &nd_table[i], PCI_DEVFN_AUTO, "ne2k_pci");
}
}
Index: qemu/hw/realview.c
===================================================================
--- qemu.orig/hw/realview.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/realview.c 2009-02-23 18:46:30.000000000 +1100
@@ -126,7 +126,7 @@ static void realview_init(ram_addr_t ram
smc91c111_init(nd, 0x4e000000, pic[28]);
done_smc = 1;
} else {
- pci_nic_init(pci_bus, nd, -1, "rtl8139");
+ pci_nic_init(pci_bus, nd, PCI_DEVFN_AUTO, "rtl8139");
}
}
Index: qemu/hw/piix_pci.c
===================================================================
--- qemu.orig/hw/piix_pci.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/piix_pci.c 2009-02-23 18:46:30.000000000 +1100
@@ -328,7 +328,7 @@ int piix3_init(PCIBus *bus)
uint8_t *pci_conf;
d = pci_register_device(bus, "PIIX3", sizeof(PCIDevice),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
register_savevm("PIIX3", 0, 2, piix_save, piix_load, d);
piix3_dev = d;
Index: qemu/hw/usb-ohci.c
===================================================================
--- qemu.orig/hw/usb-ohci.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/usb-ohci.c 2009-02-23 18:46:30.000000000 +1100
@@ -1673,7 +1673,7 @@ void usb_ohci_init_pci(struct PCIBus *bu
OHCIPCIState *ohci;
ohci = (OHCIPCIState *)pci_register_device(bus, "OHCI USB", sizeof(*ohci),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
if (ohci == NULL) {
fprintf(stderr, "usb-ohci: Failed to register PCI device\n");
return;
Index: qemu/hw/pci-hotplug.c
===================================================================
--- qemu.orig/hw/pci-hotplug.c 2009-02-23 18:47:05.000000000 +1100
+++ qemu/hw/pci-hotplug.c 2009-02-23 18:47:25.000000000 +1100
@@ -40,7 +40,7 @@ static PCIDevice *qemu_pci_hot_add_nic(P
ret = net_client_init ("nic", opts);
if (ret < 0 || !nd_table[ret].model)
return NULL;
- return pci_nic_init (pci_bus, &nd_table[ret], -1, "rtl8139");
+ return pci_nic_init (pci_bus, &nd_table[ret], PCI_DEVFN_AUTO, "rtl8139");
}
void drive_hot_add(const char *pci_addr, const char *opts)
Index: qemu/hw/ppc440_bamboo.c
===================================================================
--- qemu.orig/hw/ppc440_bamboo.c 2009-02-23 18:47:43.000000000 +1100
+++ qemu/hw/ppc440_bamboo.c 2009-02-23 18:48:35.000000000 +1100
@@ -124,7 +124,7 @@ static void bamboo_init(ram_addr_t ram_s
for (i = 0; i < nb_nics; i++) {
/* There are no PCI NICs on the Bamboo board, but there are
* PCI slots, so we can pick whatever default model we want. */
- pci_nic_init(pcibus, &nd_table[i], -1, "e1000");
+ pci_nic_init(pcibus, &nd_table[i], PCI_DEVFN_AUTO, "e1000");
}
}
Index: qemu/hw/ppc_newworld.c
===================================================================
--- qemu.orig/hw/ppc_newworld.c 2009-02-23 18:48:18.000000000 +1100
+++ qemu/hw/ppc_newworld.c 2009-02-23 18:48:43.000000000 +1100
@@ -276,7 +276,7 @@ static void ppc_core99_init (ram_addr_t
serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);
for(i = 0; i < nb_nics; i++)
- pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(pci_bus, &nd_table[i], PCI_DEVFN_AUTO, "ne2k_pci");
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
Index: qemu/hw/r2d.c
===================================================================
--- qemu.orig/hw/r2d.c 2009-02-23 18:49:23.000000000 +1100
+++ qemu/hw/r2d.c 2009-02-23 18:49:38.000000000 +1100
@@ -230,7 +230,7 @@ static void r2d_init(ram_addr_t ram_size
/* NIC: rtl8139 on-board, and 2 slots. */
pci_nic_init(pci, &nd_table[0], 2 << 3, "rtl8139");
for (i = 1; i < nb_nics; i++)
- pci_nic_init(pci, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(pci, &nd_table[i], PCI_DEVFN_AUTO, "ne2k_pci");
/* Todo: register on board registers */
{
Index: qemu/hw/sun4u.c
===================================================================
--- qemu.orig/hw/sun4u.c 2009-02-23 18:49:23.000000000 +1100
+++ qemu/hw/sun4u.c 2009-02-23 18:50:41.000000000 +1100
@@ -510,7 +510,7 @@ static void sun4uv_init(ram_addr_t RAM_s
0, 0);
// XXX Should be pci_bus3
- pci_ebus_init(pci_bus, -1);
+ pci_ebus_init(pci_bus, PCI_DEVFN_AUTO);
i = 0;
if (hwdef->console_serial_base) {
@@ -533,7 +533,7 @@ static void sun4uv_init(ram_addr_t RAM_s
}
for(i = 0; i < nb_nics; i++)
- pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(pci_bus, &nd_table[i], PCI_DEVFN_AUTO, "ne2k_pci");
irq = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
Index: qemu/hw/versatilepb.c
===================================================================
--- qemu.orig/hw/versatilepb.c 2009-02-23 18:49:23.000000000 +1100
+++ qemu/hw/versatilepb.c 2009-02-23 18:50:49.000000000 +1100
@@ -197,7 +197,7 @@ static void versatile_init(ram_addr_t ra
smc91c111_init(nd, 0x10010000, sic[25]);
done_smc = 1;
} else {
- pci_nic_init(pci_bus, nd, -1, "rtl8139");
+ pci_nic_init(pci_bus, nd, PCI_DEVFN_AUTO, "rtl8139");
}
}
if (usb_enabled) {
--
--
Simon Horman
VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [patch 5/5] iommu: Use PCI_DEVFN, PCI_SLOT and PCI_FUNC
2009-02-23 9:18 [Qemu-devel] [patch 0/5] PCI clean-up Simon Horman
` (3 preceding siblings ...)
2009-02-23 9:18 ` [Qemu-devel] [patch 4/5] iommu: Define PCI_DEVFN_AUTO and use it Simon Horman
@ 2009-02-23 9:18 ` Simon Horman
4 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2009-02-23 9:18 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: qemu-PCI_DEVFN.patch --]
[-- Type: text/plain, Size: 6890 bytes --]
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: qemu/hw/apb_pci.c
===================================================================
--- qemu.orig/hw/apb_pci.c 2009-02-23 19:24:40.000000000 +1100
+++ qemu/hw/apb_pci.c 2009-02-23 19:24:42.000000000 +1100
@@ -265,10 +265,10 @@ PCIBus *pci_apb_init(target_phys_addr_t
d->config[0x0E] = 0x00; // header_type
/* APB secondary busses */
- *bus2 = pci_bridge_init(s->bus, 8, PCI_VENDOR_ID_SUN,
+ *bus2 = pci_bridge_init(s->bus, PCI_DEVFN((1, 0), PCI_VENDOR_ID_SUN,
PCI_DEVICE_ID_SUN_SIMBA, pci_apb_map_irq,
"Advanced PCI Bus secondary bridge 1");
- *bus3 = pci_bridge_init(s->bus, 9, PCI_VENDOR_ID_SUN,
+ *bus3 = pci_bridge_init(s->bus, PCI_DEVFN(1, 1), PCI_VENDOR_ID_SUN,
PCI_DEVICE_ID_SUN_SIMBA, pci_apb_map_irq,
"Advanced PCI Bus secondary bridge 2");
return s->bus;
Index: qemu/hw/mips_malta.c
===================================================================
--- qemu.orig/hw/mips_malta.c 2009-02-23 19:24:40.000000000 +1100
+++ qemu/hw/mips_malta.c 2009-02-23 19:24:42.000000000 +1100
@@ -493,7 +493,7 @@ static void network_init (PCIBus *pci_bu
if (i == 0 && (!nd->model || strcmp(nd->model, "pcnet") == 0))
/* The malta board has a PCNet card using PCI SLOT 11 */
- devfn = 88;
+ devfn = PCI_DEVFN(11, 0);
pci_nic_init(pci_bus, nd, devfn, "pcnet");
}
@@ -904,7 +904,7 @@ void mips_malta_init (ram_addr_t ram_siz
hd[i] = NULL;
}
- piix4_devfn = piix4_init(pci_bus, 80);
+ piix4_devfn = piix4_init(pci_bus, PCI_DEVFN(10, 0));
pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1, i8259);
usb_uhci_piix4_init(pci_bus, piix4_devfn + 2);
smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, i8259[9]);
Index: qemu/hw/unin_pci.c
===================================================================
--- qemu.orig/hw/unin_pci.c 2009-02-23 19:24:40.000000000 +1100
+++ qemu/hw/unin_pci.c 2009-02-23 19:29:47.000000000 +1100
@@ -147,7 +147,7 @@ static CPUReadMemoryFunc *pci_unin_read[
/* Don't know if this matches real hardware, but it agrees with OHW. */
static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
{
- return (irq_num + (pci_dev->devfn >> 3)) & 3;
+ return (irq_num + PCI_SLOT(pci_dev->devfn)) & 3;
}
static void pci_unin_set_irq(qemu_irq *pic, int irq_num, int level)
@@ -186,7 +186,7 @@ PCIBus *pci_pmac_init(qemu_irq *pic)
/* Uninorth main bus */
s = qemu_mallocz(sizeof(UNINState));
s->bus = pci_register_bus(pci_unin_set_irq, pci_unin_map_irq,
- pic, 11 << 3, 4);
+ pic, PCI_DEVFN(11, 0), 4);
pci_mem_config = cpu_register_io_memory(0, pci_unin_main_config_read,
pci_unin_main_config_write, s);
Index: qemu/hw/piix_pci.c
===================================================================
--- qemu.orig/hw/piix_pci.c 2009-02-23 19:25:48.000000000 +1100
+++ qemu/hw/piix_pci.c 2009-02-23 19:26:36.000000000 +1100
@@ -51,7 +51,7 @@ static void piix3_set_irq(qemu_irq *pic,
static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
{
int slot_addend;
- slot_addend = (pci_dev->devfn >> 3) - 1;
+ slot_addend = PCI_SLOT(pci_dev->devfn) - 1;
return (irq_num + slot_addend) & 3;
}
Index: qemu/hw/grackle_pci.c
===================================================================
--- qemu.orig/hw/grackle_pci.c 2009-02-23 19:27:49.000000000 +1100
+++ qemu/hw/grackle_pci.c 2009-02-23 19:28:09.000000000 +1100
@@ -96,7 +96,7 @@ static CPUReadMemoryFunc *pci_grackle_re
/* Don't know if this matches real hardware, but it agrees with OHW. */
static int pci_grackle_map_irq(PCIDevice *pci_dev, int irq_num)
{
- return (irq_num + (pci_dev->devfn >> 3)) & 3;
+ return (irq_num + PCI_SLOT(pci_dev->devfn)) & 3;
}
static void pci_grackle_set_irq(qemu_irq *pic, int irq_num, int level)
Index: qemu/hw/gt64xxx.c
===================================================================
--- qemu.orig/hw/gt64xxx.c 2009-02-23 19:27:49.000000000 +1100
+++ qemu/hw/gt64xxx.c 2009-02-23 19:28:20.000000000 +1100
@@ -870,7 +870,7 @@ static int pci_gt64120_map_irq(PCIDevice
{
int slot;
- slot = (pci_dev->devfn >> 3);
+ slot = PCI_SLOT(pci_dev->devfn);
switch (slot) {
/* PIIX4 USB */
Index: qemu/hw/pci.c
===================================================================
--- qemu.orig/hw/pci.c 2009-02-23 19:27:49.000000000 +1100
+++ qemu/hw/pci.c 2009-02-23 19:28:41.000000000 +1100
@@ -709,7 +709,7 @@ static void pci_info_device(PCIDevice *d
const pci_class_desc *desc;
term_printf(" Bus %2d, device %3d, function %d:\n",
- d->bus->bus_num, d->devfn >> 3, d->devfn & 7);
+ d->bus->bus_num, PCI_SLOT(d->devfn), PCI_FUNC(d->devfn));
class = le16_to_cpu(*((uint16_t *)(d->config + PCI_CLASS_DEVICE)));
term_printf(" ");
desc = pci_class_descriptions;
Index: qemu/hw/ppc4xx_pci.c
===================================================================
--- qemu.orig/hw/ppc4xx_pci.c 2009-02-23 19:27:49.000000000 +1100
+++ qemu/hw/ppc4xx_pci.c 2009-02-23 19:28:55.000000000 +1100
@@ -297,7 +297,7 @@ static void ppc4xx_pci_reset(void *opaqu
* may need further refactoring for other boards. */
static int ppc4xx_pci_map_irq(PCIDevice *pci_dev, int irq_num)
{
- int slot = pci_dev->devfn >> 3;
+ int slot = PCI_SLOT(pci_dev->devfn);
DPRINTF("%s: devfn %x irq %d -> %d\n", __func__,
pci_dev->devfn, irq_num, slot);
Index: qemu/hw/prep_pci.c
===================================================================
--- qemu.orig/hw/prep_pci.c 2009-02-23 19:27:49.000000000 +1100
+++ qemu/hw/prep_pci.c 2009-02-23 19:29:07.000000000 +1100
@@ -121,7 +121,7 @@ static CPUReadMemoryFunc *PPC_PCIIO_read
static int prep_map_irq(PCIDevice *pci_dev, int irq_num)
{
- return (irq_num + (pci_dev->devfn >> 3)) & 1;
+ return (irq_num + PCI_SLOT(pci_dev->devfn)) & 1;
}
static void prep_set_irq(qemu_irq *pic, int irq_num, int level)
Index: qemu/hw/r2d.c
===================================================================
--- qemu.orig/hw/r2d.c 2009-02-23 19:27:49.000000000 +1100
+++ qemu/hw/r2d.c 2009-02-23 19:29:24.000000000 +1100
@@ -187,7 +187,7 @@ static void r2d_pci_set_irq(qemu_irq *p,
static int r2d_pci_map_irq(PCIDevice *d, int irq_num)
{
const int intx[] = { PCI_INTA, PCI_INTB, PCI_INTC, PCI_INTD };
- return intx[d->devfn >> 3];
+ return intx[PCI_SLOT(d->devfn)];
}
static void r2d_init(ram_addr_t ram_size, int vga_ram_size,
--
--
Simon Horman
VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-02-23 9:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-23 9:18 [Qemu-devel] [patch 0/5] PCI clean-up Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 1/5] ioemu: Remove lsi_scsi_init()s devfn parameter as it is always passed as -1 Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 2/5] " Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 3/5] ioemu: Remove usb_ohci_init*()s devfn parameter as they are " Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 4/5] iommu: Define PCI_DEVFN_AUTO and use it Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 5/5] iommu: Use PCI_DEVFN, PCI_SLOT and PCI_FUNC Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).