summaryrefslogtreecommitdiffstats
path: root/meta/packages/qemu/files/qemu-pci-irq-sharing.patch
blob: c47e89895fe91a3f9bfe38fca9b84dce9bd6e96c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
diff -pNaur qemu-cvs-ts-orig/hw/pci.c qemu-cvs-ts/hw/pci.c
--- qemu-cvs-ts-orig/hw/pci.c	2006-08-17 10:46:34.000000000 +0000
+++ qemu-cvs-ts/hw/pci.c	2006-09-23 17:02:41.000000000 +0000
@@ -34,6 +34,7 @@ struct PCIBus {
     SetIRQFunc *low_set_irq;
     void *irq_opaque;
     PCIDevice *devices[256];
+    int irq_count[4];
 };
 
 static void pci_update_mappings(PCIDevice *d);
@@ -49,6 +50,7 @@ PCIBus *pci_register_bus(pci_set_irq_fn 
     bus->set_irq = set_irq;
     bus->irq_opaque = pic;
     bus->devfn_min = devfn_min;
+    memset(bus->irq_count, 0, sizeof(bus->irq_count));
     first_bus = bus;
     return bus;
 }
@@ -100,6 +102,7 @@ PCIDevice *pci_register_device(PCIBus *b
     pci_dev->bus = bus;
     pci_dev->devfn = devfn;
     pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
+    memset(pci_dev->irq_state, 0, sizeof(pci_dev->irq_state));
 
     if (!config_read)
         config_read = pci_default_read_config;
@@ -404,7 +407,10 @@ uint32_t pci_data_read(void *opaque, uin
 void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level)
 {
     PCIBus *bus = pci_dev->bus;
-    bus->set_irq(pci_dev, bus->irq_opaque, irq_num, level);
+    bus->irq_count[irq_num] += level - pci_dev->irq_state[irq_num];
+    pci_dev->irq_state[irq_num] = level;
+    bus->set_irq(pci_dev, bus->irq_opaque,
+                 irq_num, !!bus->irq_count[irq_num]);
 }
 
 /***********************************************************/
diff -pNaur qemu-cvs-ts-orig/vl.h qemu-cvs-ts/vl.h
--- qemu-cvs-ts-orig/vl.h	2006-09-18 01:15:29.000000000 +0000
+++ qemu-cvs-ts/vl.h	2006-09-23 17:15:21.000000000 +0000
@@ -733,6 +733,9 @@ struct PCIDevice {
     PCIConfigWriteFunc *config_write;
     /* ??? This is a PC-specific hack, and should be removed.  */
     int irq_index;
+
+    /* remember last irq levels */
+    int irq_state[4];
 };
 
 PCIDevice *pci_register_device(PCIBus *bus, const char *name,