@@ -108,6 +108,7 @@ static void pci_device_reset(PCIDevice *dev)
int r;
memset(dev->irq_state, 0, sizeof dev->irq_state);
+ dev->irq_status = 0;
dev->config[PCI_COMMAND] &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
PCI_COMMAND_MASTER);
dev->config[PCI_CACHE_LINE_SIZE] = 0x0;
@@ -318,7 +319,12 @@ void pci_device_save(PCIDevice *s, QEMUFile *f)
int pci_device_load(PCIDevice *s, QEMUFile *f)
{
- return vmstate_load_state(f, pci_get_vmstate(s), s, s->version_id);
+ int ret, i;
+ ret = vmstate_load_state(f, pci_get_vmstate(s), s, s->version_id);
+ for (i = 0; i < ARRAY_SIZE(s->irq_state); ++i) {
+ s->irq_status += s->irq_state[i];
+ }
+ return ret;
}
static int pci_set_default_subsystem_id(PCIDevice *pci_dev)
@@ -502,6 +508,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *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));
+ pci_dev->irq_status = 0;
pci_config_alloc(pci_dev);
header_type &= ~PCI_HEADER_TYPE_MULTI_FUNCTION;
@@ -906,6 +913,7 @@ static void pci_set_irq(void *opaque, int irq_num, int level)
return;
pci_dev->irq_state[irq_num] = level;
+ pci_dev->irq_status += change;
pci_change_irq_level(pci_dev, irq_num, change);
}
@@ -222,6 +222,9 @@ struct PCIDevice {
/* Current IRQ levels. Used internally by the generic PCI code. */
int irq_state[PCI_NUM_PINS];
+ /* Sum of all irq levels. Used to implement irq status register. */
+ int irq_status;
+
/* Capability bits */
uint32_t cap_present;
track IRQ status in preparation for PCI_STATUS_INTERRUPT support Signed-off-by: Michael S. Tsirkin <mst@redhat.com> --- hw/pci.c | 10 +++++++++- hw/pci.h | 3 +++ 2 files changed, 12 insertions(+), 1 deletions(-)