[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 54/61] pci: add opaque argument to pci_map_irq_fn().
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH 54/61] pci: add opaque argument to pci_map_irq_fn(). |
Date: |
Wed, 30 Sep 2009 19:18:30 +0900 |
To convert pci int pin to global irq or GSI, not only the pci device
which generates interrupt, but also the bus, like pci_set_irq_fn.
So pass the opaque argument to pci_map_irq_fn like pci_set_irq_fn.
Signed-off-by: Isaku Yamahata <address@hidden>
---
hw/pci.c | 8 +++++---
hw/pci.h | 5 +++--
hw/piix_pci.c | 4 ++--
hw/q35.c | 4 ++--
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 05cd2cb..600d9a1 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -155,6 +155,7 @@ PCIBus *pci_register_bus(DeviceState *parent, const char
*name,
}
PCIBus *pci_register_secondary_bus(PCIDevice *dev, pci_map_irq_fn map_irq,
+ void *irq_opaque,
const char* name, int devfn_min)
{
PCIBus *bus;
@@ -162,6 +163,7 @@ PCIBus *pci_register_secondary_bus(PCIDevice *dev,
pci_map_irq_fn map_irq,
bus = FROM_QBUS(PCIBus, qbus_create(&pci_bus_info, &dev->qdev, name));
bus->map_irq = map_irq;
+ bus->irq_opaque = irq_opaque;
bus->bus_num = dev->config[PCI_SECONDARY_BUS];
bus->devfn_min = devfn_min;
@@ -1068,7 +1070,7 @@ static void pci_set_irq(void *opaque, int irq_num, int
level)
pci_dev->irq_state[irq_num] = level;
for (;;) {
bus = pci_get_parent_bus(pci_dev);
- irq_num = bus->map_irq(pci_dev, irq_num);
+ irq_num = bus->map_irq(bus->irq_opaque, pci_dev, irq_num);
if (bus->set_irq)
break;
pci_dev = pci_bus_to_dev(bus);
@@ -1078,7 +1080,7 @@ static void pci_set_irq(void *opaque, int irq_num, int
level)
}
/* 0 <= pin <= 3 0 = INTA, 1 = INTB, 2 = INTC, 3 = INTD */
-int pci_swizzle_map_irq_fn(PCIDevice *pci_dev, int pin)
+int pci_swizzle_map_irq_fn(void *opauqe, PCIDevice *pci_dev, int pin)
{
return (pin + PCI_SLOT(pci_dev->devfn) - 1) % PCI_NUM_PINS;
}
@@ -1524,7 +1526,7 @@ PCIBus *pci_bridge_create_simple(PCIBus *bus, int devfn,
uint16_t vid,
pci_config_set_byte(d, PCI_SECONDARY_BUS, sec_bus);
pci_config_set_byte(d, PCI_SUBORDINATE_BUS, sub_bus);
- return pci_register_secondary_bus(d, map_irq, bus_name, 0);
+ return pci_register_secondary_bus(d, map_irq, d, name, 0);
}
PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid,
diff --git a/hw/pci.h b/hw/pci.h
index 27a5d33..a1c37db 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -355,13 +355,14 @@ int pci_device_load(PCIDevice *s, QEMUFile *f);
void pci_set_default_bus(PCIBus *bus);
typedef void (*pci_set_irq_fn)(void *opaque, int irq_num, int level);
-typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num);
+typedef int (*pci_map_irq_fn)(void *opaque, PCIDevice *pci_dev, int irq_num);
/* 0 <= pin <= 3 0 = INTA, 1 = INTB, 2 = INTC, 3 = INTD */
-int pci_swizzle_map_irq_fn(PCIDevice *pci_dev, int pin);
+int pci_swizzle_map_irq_fn(void *opaque, PCIDevice *pci_dev, int pin);
PCIBus *pci_register_bus(DeviceState *parent, const char *name,
pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
void *irq_opaque, int devfn_min, int nirq);
PCIBus *pci_register_secondary_bus(PCIDevice *dev, pci_map_irq_fn map_irq,
+ void *irq_opaque,
const char* name, int devfn_min);
PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 87cdbd9..a422d52 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -67,9 +67,9 @@ static void piix3_set_irq(void *opaque, int irq_num, int
level);
/* return the global irq number corresponding to a given device irq
pin. We could also use the bus number to have a more precise
mapping. */
-static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
+static int pci_slot_get_pirq(void *opaque, PCIDevice *pci_dev, int irq_num)
{
- return pci_swizzle_map_irq_fn(pci_dev, irq_num);
+ return pci_swizzle_map_irq_fn(NULL, pci_dev, irq_num);
}
static void update_pam(PCII440FXState *d, uint32_t start, uint32_t end, int r)
diff --git a/hw/q35.c b/hw/q35.c
index 8e07048..05267ea 100644
--- a/hw/q35.c
+++ b/hw/q35.c
@@ -157,9 +157,9 @@ static void ich9_lpc_set_irq(void *opaque, int irq_num, int
level);
/* return the global irq number corresponding to a given device irq
pin. We could also use the bus number to have a more precise
mapping. */
-static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
+static int pci_slot_get_pirq(void *opaque, PCIDevice *pci_dev, int irq_num)
{
- return pci_swizzle_map_irq_fn(pci_dev, irq_num);
+ return pci_swizzle_map_irq_fn(NULL, pci_dev, irq_num);
}
/* PAM */
--
1.6.0.2
- [Qemu-devel] [PATCH 59/61] ioapic: make irr accept more than 32 pins., (continued)
- [Qemu-devel] [PATCH 59/61] ioapic: make irr accept more than 32 pins., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 16/61] pc: split out basic device init from pc_init1() into pc_basic_device_init(), Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 14/61] pc: split out memory allocation from pc_init1() into pc_memory_init(), Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 56/61] ioapic: clean up of #ifdef DEBUG_IOAPIC., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 03/61] acpi: add acpi constants from linux header files and use them., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 49/61] pci hot add: pass opaque argument to callback., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 01/61] acpi: split out pc smbus routines from acpi.c into pc_smbus.c, Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 61/61] pc_q35: apic mode for pci interrupt routing., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 11/61] pc: introduce a function to allocate cpu irq., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 51/61] vmstate: add a macro for pointer to struct, VMSTATE_STRUCT_POINTER., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 54/61] pci: add opaque argument to pci_map_irq_fn().,
Isaku Yamahata <=
- [Qemu-devel] [PATCH 30/61] pci_host.h: split non-inline static function in pci_host.h into pci_host_c.h, Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 37/61] pci: add helper function for pci config write function to check address., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 36/61] pci: use QLIST_ macro instead of direct list manipulation., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 22/61] pci: use appropriate PRIs in PCI_DPRINTF()., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 43/61] pci: add helper function to initialize wmask., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 39/61] pci: factor out config update logic., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 55/61] ioapic: make ioapic_set_irq() static., Isaku Yamahata, 2009/09/30