Skip to contentSkip to conversation

pci core reorg

PATCH NAK Michael S. Tsirkin 4 participants 19 messages Dec 12, 2012 Kbuild Page 1 of 2

lore
Share & tools
lore
#0 lore raw

cover pci core reorg

This patchset starts some cleanups of the pci core by rearranging the code: pci core is split out from devices into its own directory, pci internals.h is renamed as it's used externally a lot.

I'd like to merge this quickly to avoid conflicting with others work.
Plan to send pull request tomorrow, if you have concerns, speak up soon pls.

Thanks,

Michael S. Tsirkin (8):
pci: prepare makefiles for pci code reorganization
MAINTAINERS: add hw/pci/ to list of PCI files
pci: move pci core code to hw/pci
pci: update all users to look in pci/
pci: make external dependencies explicit
Revert "pci: prepare makefiles for pci code reorganization"
pci: rename pci_internals.h pci_bus.h
pci_bus: update comment

 MAINTAINERS              |    1 +
 arch_init.c              |    2 +-
 hw/Makefile.objs         |   10 +-
 hw/ac97.c                |    2 +-
 hw/acpi_ich9.c           |    2 +-
 hw/acpi_piix4.c          |    2 +-
 hw/alpha_sys.h           |    4 +-
 hw/apb_pci.c             |    8 +-
 hw/apic.c                |    2 +-
 hw/bonito.c              |    4 +-
 hw/cirrus_vga.c          |    2 +-
 hw/dec_pci.c             |    8 +-
 hw/e1000.c               |    2 +-
 hw/eepro100.c            |    2 +-
 hw/es1370.c              |    2 +-
 hw/esp-pci.c             |    2 +-
 hw/grackle_pci.c         |    4 +-
 hw/gt64xxx.c             |    4 +-
 hw/hda-audio.c           |    2 +-
 hw/i386/Makefile.objs    |    2 +-
 hw/i82378.c              |    2 +-
 hw/i82801b11.c           |    2 +-
 hw/ich9.h                |    8 +-
 hw/ide.h                 |    2 +-
 hw/ide/ahci.c            |    4 +-
 hw/ide/cmd646.c          |    2 +-
 hw/ide/core.c            |    2 +-
 hw/ide/ich.c             |    4 +-
 hw/ide/pci.c             |    2 +-
 hw/ide/piix.c            |    2 +-
 hw/ide/via.c             |    2 +-
 hw/intel-hda.c           |    4 +-
 hw/ioh3420.c             |    6 +-
 hw/ioh3420.h             |    2 +-
 hw/ivshmem.c             |    4 +-
 hw/kvm/apic.c            |    2 +-
 hw/kvm/pci-assign.c      |    4 +-
 hw/lpc_ich9.c            |    8 +-
 hw/lsi53c895a.c          |    2 +-
 hw/macio.c               |    2 +-
 hw/megasas.c             |    4 +-
 hw/mips_fulong2e.c       |    2 +-
 hw/mips_malta.c          |    2 +-
 hw/msi.c                 |  395 ---------
 hw/msi.h                 |   50 --
 hw/msix.c                |  562 ------------
 hw/msix.h                |   41 -
 hw/ne2000.c              |    2 +-
 hw/openpic.c             |    2 +-
 hw/pc.c                  |    4 +-
 hw/pc_piix.c             |    4 +-
 hw/pci-hotplug.c         |  293 -------
 hw/pci-stub.c            |   47 -
 hw/pci.c                 | 2168 ----------------------------------------------
 hw/pci.h                 |  684 ---------------
 hw/pci/Makefile.objs     |    6 +
 hw/pci/msi.c             |  395 +++++++++
 hw/pci/msi.h             |   50 ++
 hw/pci/msix.c            |  562 ++++++++++++
 hw/pci/msix.h            |   41 +
 hw/pci/pci-hotplug.c     |  293 +++++++
 hw/pci/pci-stub.c        |   47 +
 hw/pci/pci.c             | 2168 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/pci/pci.h             |  684 +++++++++++++++
 hw/pci/pci_bridge.c      |  363 ++++++++
 hw/pci/pci_bridge.h      |   66 ++
 hw/pci/pci_bus.h         |   74 ++
 hw/pci/pci_host.c        |  180 ++++
 hw/pci/pci_host.h        |   62 ++
 hw/pci/pci_ids.h         |  147 ++++
 hw/pci/pci_regs.h        |  717 +++++++++++++++
 hw/pci/pcie.c            |  555 ++++++++++++
 hw/pci/pcie.h            |  142 +++
 hw/pci/pcie_aer.c        | 1032 ++++++++++++++++++++++
 hw/pci/pcie_aer.h        |  106 +++
 hw/pci/pcie_host.c       |  161 ++++
 hw/pci/pcie_host.h       |   54 ++
 hw/pci/pcie_port.c       |  114 +++
 hw/pci/pcie_port.h       |   51 ++
 hw/pci/pcie_regs.h       |  156 ++++
 hw/pci/shpc.c            |  681 +++++++++++++++
 hw/pci/shpc.h            |   48 +
 hw/pci/slotid_cap.c      |   44 +
 hw/pci/slotid_cap.h      |   11 +
 hw/pci_bridge.c          |  363 --------
 hw/pci_bridge.h          |   66 --
 hw/pci_bridge_dev.c      |   12 +-
 hw/pci_host.c            |  180 ----
 hw/pci_host.h            |   62 --
 hw/pci_ids.h             |  147 ----
 hw/pci_internals.h       |   78 --
 hw/pci_regs.h            |  717 ---------------
 hw/pcie.c                |  555 ------------
 hw/pcie.h                |  142 ---
 hw/pcie_aer.c            | 1032 ----------------------
 hw/pcie_aer.h            |  106 ---
 hw/pcie_host.c           |  161 ----
 hw/pcie_host.h           |   54 --
 hw/pcie_port.c           |  114 ---
 hw/pcie_port.h           |   51 --
 hw/pcie_regs.h           |  156 ----
 hw/pcnet-pci.c           |    2 +-
 hw/piix4.c               |    2 +-
 hw/piix_pci.c            |    4 +-
 hw/ppc/Makefile.objs     |    2 +-
 hw/ppc/e500.c            |    2 +-
 hw/ppc440_bamboo.c       |    2 +-
 hw/ppc4xx.h              |    2 +-
 hw/ppc4xx_pci.c          |    4 +-
 hw/ppc_newworld.c        |    2 +-
 hw/ppc_oldworld.c        |    2 +-
 hw/ppc_prep.c            |    4 +-
 hw/ppce500_pci.c         |    4 +-
 hw/prep_pci.c            |    4 +-
 hw/q35.h                 |    4 +-
 hw/qxl.h                 |    2 +-
 hw/r2d.c                 |    2 +-
 hw/realview.c            |    2 +-
 hw/rtl8139.c             |    2 +-
 hw/serial-pci.c          |    2 +-
 hw/sga.c                 |    2 +-
 hw/sh_pci.c              |    4 +-
 hw/shpc.c                |  681 ---------------
 hw/shpc.h                |   48 -
 hw/slotid_cap.c          |   44 -
 hw/slotid_cap.h          |   11 -
 hw/smbus_ich9.c          |    2 +-
 hw/spapr.c               |    4 +-
 hw/spapr_pci.c           |   10 +-
 hw/spapr_pci.h           |    4 +-
 hw/sun4u.c               |    2 +-
 hw/unin_pci.c            |    4 +-
 hw/usb/hcd-ehci-pci.c    |    2 +-
 hw/usb/hcd-ohci.c        |    2 +-
 hw/usb/hcd-uhci.c        |    2 +-
 hw/usb/hcd-xhci.c        |    6 +-
 hw/versatile_pci.c       |    4 +-
 hw/versatilepb.c         |    2 +-
 hw/vfio_pci.c            |    6 +-
 hw/vga-pci.c             |    2 +-
 hw/vga.c                 |    2 +-
 hw/virtio-balloon.h      |    2 +-
 hw/virtio-net.h          |    2 +-
 hw/virtio-pci.c          |    6 +-
 hw/virtio-scsi.h         |    2 +-
 hw/vmware_vga.c          |    2 +-
 hw/vt82c686.c            |    4 +-
 hw/wdt_i6300esb.c        |    2 +-
 hw/xen-host-pci-device.h |    2 +-
 hw/xen_apic.c            |    2 +-
 hw/xen_platform.c        |    2 +-
 hw/xen_pt.c              |    2 +-
 hw/xen_pt.h              |    2 +-
 hw/xio3130_downstream.c  |    6 +-
 hw/xio3130_downstream.h  |    2 +-
 hw/xio3130_upstream.c    |    6 +-
 hw/xio3130_upstream.h    |    2 +-
 kvm-all.c                |    2 +-
 kvm-stub.c               |    2 +-
 monitor.c                |    2 +-
 target-i386/kvm.c        |    2 +-
 xen-all.c                |    2 +-
 162 files changed, 9173 insertions(+), 9176 deletions(-)
 delete mode 100644 hw/msi.c
 delete mode 100644 hw/msi.h
 delete mode 100644 hw/msix.c
 delete mode 100644 hw/msix.h
 delete mode 100644 hw/pci-hotplug.c
 delete mode 100644 hw/pci-stub.c
 delete mode 100644 hw/pci.c
 delete mode 100644 hw/pci.h
 create mode 100644 hw/pci/Makefile.objs
 create mode 100644 hw/pci/msi.c
 create mode 100644 hw/pci/msi.h
 create mode 100644 hw/pci/msix.c
 create mode 100644 hw/pci/msix.h
 create mode 100644 hw/pci/pci-hotplug.c
 create mode 100644 hw/pci/pci-stub.c
 create mode 100644 hw/pci/pci.c
 create mode 100644 hw/pci/pci.h
 create mode 100644 hw/pci/pci_bridge.c
 create mode 100644 hw/pci/pci_bridge.h
 create mode 100644 hw/pci/pci_bus.h
 create mode 100644 hw/pci/pci_host.c
 create mode 100644 hw/pci/pci_host.h
 create mode 100644 hw/pci/pci_ids.h
 create mode 100644 hw/pci/pci_regs.h
 create mode 100644 hw/pci/pcie.c
 create mode 100644 hw/pci/pcie.h
 create mode 100644 hw/pci/pcie_aer.c
 create mode 100644 hw/pci/pcie_aer.h
 create mode 100644 hw/pci/pcie_host.c
 create mode 100644 hw/pci/pcie_host.h
 create mode 100644 hw/pci/pcie_port.c
 create mode 100644 hw/pci/pcie_port.h
 create mode 100644 hw/pci/pcie_regs.h
 create mode 100644 hw/pci/shpc.c
 create mode 100644 hw/pci/shpc.h
 create mode 100644 hw/pci/slotid_cap.c
 create mode 100644 hw/pci/slotid_cap.h
 delete mode 100644 hw/pci_bridge.c
 delete mode 100644 hw/pci_bridge.h
 delete mode 100644 hw/pci_host.c
 delete mode 100644 hw/pci_host.h
 delete mode 100644 hw/pci_ids.h
 delete mode 100644 hw/pci_internals.h
 delete mode 100644 hw/pci_regs.h
 delete mode 100644 hw/pcie.c
 delete mode 100644 hw/pcie.h
 delete mode 100644 hw/pcie_aer.c
 delete mode 100644 hw/pcie_aer.h
 delete mode 100644 hw/pcie_host.c
 delete mode 100644 hw/pcie_host.h
 delete mode 100644 hw/pcie_port.c
 delete mode 100644 hw/pcie_port.h
 delete mode 100644 hw/pcie_regs.h
 delete mode 100644 hw/shpc.c
 delete mode 100644 hw/shpc.h
 delete mode 100644 hw/slotid_cap.c
 delete mode 100644 hw/slotid_cap.h
Signature · 1 line
MST
#1 lore raw

PATCH 1/8 pci: prepare makefiles for pci code reorganization

To make it easier to move code around without breaking build at intermedite steps, tweak makefiles
to look in pci/ and hw/ for include files, automatically. This will be reverted at the end of the reorganization.

---
 Makefile        | 1 +
 Makefile.target | 1 +
 Makefile.user   | 1 +
 hw/pci/hw       | 1 +
 4 files changed, 4 insertions(+)
 create mode 120000 hw/pci/hw
Makefile +1 -0
index 9ecbcbb..b9a81d1 100644
@@ -146,6 +146,7 @@ audio/audio.o audio/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS)
 QEMU_CFLAGS+=$(CURL_CFLAGS)
 
 QEMU_CFLAGS += -I$(SRC_PATH)/include
+QEMU_CFLAGS+=-I$(SRC_PATH)/hw/pci -I$(SRC_PATH)/hw
 
 ui/cocoa.o: ui/cocoa.m
 
Makefile.target +1 -0
index 8b658c0..e2e8840 100644
@@ -12,6 +12,7 @@ endif
 QEMU_CFLAGS += -I.. -I$(SRC_PATH)/target-$(TARGET_BASE_ARCH) -DNEED_CPU_H
 
 QEMU_CFLAGS+=-I$(SRC_PATH)/include
+QEMU_CFLAGS+=-I$(SRC_PATH)/hw/pci -I$(SRC_PATH)/hw
 
 ifdef CONFIG_USER_ONLY
 # user emulator name
Makefile.user +1 -0
index 9302d33..045ecd3 100644
@@ -11,6 +11,7 @@ $(call set-vpath, $(SRC_PATH))
 QEMU_CFLAGS+=-I..
 QEMU_CFLAGS += -I$(SRC_PATH)/include
 QEMU_CFLAGS += -DCONFIG_USER_ONLY
+QEMU_CFLAGS+=-I$(SRC_PATH)/hw/pci -I$(SRC_PATH)/hw
 
 include $(SRC_PATH)/Makefile.objs
 
hw/pci/hw new file +1 -0
new file mode 120000
index 0000000..945c9b4
@@ -0,0 +1 @@
+.
\ No newline at end of file
Signature · 1 line
MST
#10 lore raw

PATCH 6/8 Revert "pci: prepare makefiles for pci code reorganization"

In reply to Michael S. Tsirkin

This reverts commit 475d67c3bcd6ba9fef917b6e59d96ae69eb1a9b4.

Now that all users have been updated, we don't need the makefile hack or the softlink anymore.

---
 Makefile        | 1 -
 Makefile.target | 1 -
 Makefile.user   | 1 -
 hw/pci/hw       | 1 -
 4 files changed, 4 deletions(-)
 delete mode 120000 hw/pci/hw
Makefile +0 -1
index b9a81d1..9ecbcbb 100644
@@ -146,7 +146,6 @@ audio/audio.o audio/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS)
 QEMU_CFLAGS+=$(CURL_CFLAGS)
 
 QEMU_CFLAGS += -I$(SRC_PATH)/include
-QEMU_CFLAGS+=-I$(SRC_PATH)/hw/pci -I$(SRC_PATH)/hw
 
 ui/cocoa.o: ui/cocoa.m
 
Makefile.target +0 -1
index e2e8840..8b658c0 100644
@@ -12,7 +12,6 @@ endif
 QEMU_CFLAGS += -I.. -I$(SRC_PATH)/target-$(TARGET_BASE_ARCH) -DNEED_CPU_H
 
 QEMU_CFLAGS+=-I$(SRC_PATH)/include
-QEMU_CFLAGS+=-I$(SRC_PATH)/hw/pci -I$(SRC_PATH)/hw
 
 ifdef CONFIG_USER_ONLY
 # user emulator name
Makefile.user +0 -1
index 045ecd3..9302d33 100644
@@ -11,7 +11,6 @@ $(call set-vpath, $(SRC_PATH))
 QEMU_CFLAGS+=-I..
 QEMU_CFLAGS += -I$(SRC_PATH)/include
 QEMU_CFLAGS += -DCONFIG_USER_ONLY
-QEMU_CFLAGS+=-I$(SRC_PATH)/hw/pci -I$(SRC_PATH)/hw
 
 include $(SRC_PATH)/Makefile.objs
 
hw/pci/hw deleted +0 -1
deleted file mode 120000
index 945c9b4..0000000
@@ -1 +0,0 @@
-.
\ No newline at end of file
Signature · 1 line
MST
#6 lore raw

PATCH 4/8 pci: update all users to look in pci/

In reply to Michael S. Tsirkin

update all users so we can remove the makefile hack.

---
 arch_init.c              |  2 +-
 hw/ac97.c                |  2 +-
 hw/acpi_ich9.c           |  2 +-
 hw/acpi_piix4.c          |  2 +-
 hw/alpha_sys.h           |  4 ++--
 hw/apb_pci.c             |  8 ++++----
 hw/apic.c                |  2 +-
 hw/bonito.c              |  4 ++--
 hw/cirrus_vga.c          |  2 +-
 hw/dec_pci.c             |  8 ++++----
 hw/e1000.c               |  2 +-
 hw/eepro100.c            |  2 +-
 hw/es1370.c              |  2 +-
 hw/esp-pci.c             |  2 +-
 hw/grackle_pci.c         |  4 ++--
 hw/gt64xxx.c             |  4 ++--
 hw/hda-audio.c           |  2 +-
 hw/i82378.c              |  2 +-
 hw/i82801b11.c           |  2 +-
 hw/ich9.h                |  8 ++++----
 hw/ide.h                 |  2 +-
 hw/ide/ahci.c            |  4 ++--
 hw/ide/cmd646.c          |  2 +-
 hw/ide/core.c            |  2 +-
 hw/ide/ich.c             |  4 ++--
 hw/ide/pci.c             |  2 +-
 hw/ide/piix.c            |  2 +-
 hw/ide/via.c             |  2 +-
 hw/intel-hda.c           |  4 ++--
 hw/ioh3420.c             |  6 +++---
 hw/ioh3420.h             |  2 +-
 hw/ivshmem.c             |  4 ++--
 hw/kvm/apic.c            |  2 +-
 hw/kvm/pci-assign.c      |  4 ++--
 hw/lpc_ich9.c            |  8 ++++----
 hw/lsi53c895a.c          |  2 +-
 hw/macio.c               |  2 +-
 hw/megasas.c             |  4 ++--
 hw/mips_fulong2e.c       |  2 +-
 hw/mips_malta.c          |  2 +-
 hw/ne2000.c              |  2 +-
 hw/openpic.c             |  2 +-
 hw/pc.c                  |  4 ++--
 hw/pc_piix.c             |  4 ++--
 hw/pci_bridge_dev.c      | 12 ++++++------
 hw/pcnet-pci.c           |  2 +-
 hw/piix4.c               |  2 +-
 hw/piix_pci.c            |  4 ++--
 hw/ppc/e500.c            |  2 +-
 hw/ppc440_bamboo.c       |  2 +-
 hw/ppc4xx.h              |  2 +-
 hw/ppc4xx_pci.c          |  4 ++--
 hw/ppc_newworld.c        |  2 +-
 hw/ppc_oldworld.c        |  2 +-
 hw/ppc_prep.c            |  4 ++--
 hw/ppce500_pci.c         |  4 ++--
 hw/prep_pci.c            |  4 ++--
 hw/q35.h                 |  4 ++--
 hw/qxl.h                 |  2 +-
 hw/r2d.c                 |  2 +-
 hw/realview.c            |  2 +-
 hw/rtl8139.c             |  2 +-
 hw/serial-pci.c          |  2 +-
 hw/sga.c                 |  2 +-
 hw/sh_pci.c              |  4 ++--
 hw/smbus_ich9.c          |  2 +-
 hw/spapr.c               |  4 ++--
 hw/spapr_pci.c           | 10 +++++-----
 hw/spapr_pci.h           |  4 ++--
 hw/sun4u.c               |  2 +-
 hw/unin_pci.c            |  4 ++--
 hw/usb/hcd-ehci-pci.c    |  2 +-
 hw/usb/hcd-ohci.c        |  2 +-
 hw/usb/hcd-uhci.c        |  2 +-
 hw/usb/hcd-xhci.c        |  6 +++---
 hw/versatile_pci.c       |  4 ++--
 hw/versatilepb.c         |  2 +-
 hw/vfio_pci.c            |  6 +++---
 hw/vga-pci.c             |  2 +-
 hw/vga.c                 |  2 +-
 hw/virtio-balloon.h      |  2 +-
 hw/virtio-net.h          |  2 +-
 hw/virtio-pci.c          |  6 +++---
 hw/virtio-scsi.h         |  2 +-
 hw/vmware_vga.c          |  2 +-
 hw/vt82c686.c            |  4 ++--
 hw/wdt_i6300esb.c        |  2 +-
 hw/xen-host-pci-device.h |  2 +-
 hw/xen_apic.c            |  2 +-
 hw/xen_platform.c        |  2 +-
 hw/xen_pt.c              |  2 +-
 hw/xen_pt.h              |  2 +-
 hw/xio3130_downstream.c  |  6 +++---
 hw/xio3130_downstream.h  |  2 +-
 hw/xio3130_upstream.c    |  6 +++---
 hw/xio3130_upstream.h    |  2 +-
 kvm-all.c                |  2 +-
 kvm-stub.c               |  2 +-
 monitor.c                |  2 +-
 target-i386/kvm.c        |  2 +-
 xen-all.c                |  2 +-
 101 files changed, 158 insertions(+), 158 deletions(-)
arch_init.c +1 -1
index e6effe8..e307b23 100644
@@ -36,7 +36,7 @@
 #include "arch_init.h"
 #include "audio/audio.h"
 #include "hw/pc.h"
-#include "hw/pci.h"
+#include "hw/pci/pci.h"
 #include "hw/audiodev.h"
 #include "kvm.h"
 #include "migration.h"
hw/ac97.c +1 -1
index ce6a1dc..3e659b3 100644
@@ -20,7 +20,7 @@
 #include "hw.h"
 #include "audiodev.h"
 #include "audio/audio.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "dma.h"
 
 enum {
hw/acpi_ich9.c +1 -1
index 25c9d36..3e01556 100644
@@ -25,7 +25,7 @@
  */
 #include "hw.h"
 #include "pc.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "qemu-timer.h"
 #include "sysemu.h"
 #include "acpi.h"
hw/acpi_piix4.c +1 -1
index 519269a..846f40a 100644
@@ -22,7 +22,7 @@
 #include "pc.h"
 #include "apm.h"
 #include "pm_smbus.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "acpi.h"
 #include "sysemu.h"
 #include "range.h"
hw/alpha_sys.h +2 -2
index 7604d09..b1e5258 100644
@@ -3,8 +3,8 @@
 #ifndef HW_ALPHA_H
 #define HW_ALPHA_H 1
 
-#include "pci.h"
-#include "pci_host.h"
+#include "pci/pci.h"
+#include "pci/pci_host.h"
 #include "ide.h"
 #include "net.h"
 #include "pc.h"
hw/apb_pci.c +4 -4
index 054814f..de594f8 100644
@@ -27,10 +27,10 @@
    the secondary PCI bridge.  */
 
 #include "sysbus.h"
-#include "pci.h"
-#include "pci_host.h"
-#include "pci_bridge.h"
-#include "pci_internals.h"
+#include "pci/pci.h"
+#include "pci/pci_host.h"
+#include "pci/pci_bridge.h"
+#include "pci/pci_internals.h"
 #include "apb_pci.h"
 #include "sysemu.h"
 #include "exec-memory.h"
hw/apic.c +1 -1
index f73fc87..d66a476 100644
@@ -20,7 +20,7 @@
 #include "apic_internal.h"
 #include "apic.h"
 #include "ioapic.h"
-#include "msi.h"
+#include "pci/msi.h"
 #include "host-utils.h"
 #include "trace.h"
 #include "pc.h"
hw/bonito.c +2 -2
index 0bf6d4a..a1fc38c 100644
@@ -40,10 +40,10 @@
 #include <assert.h>
 
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "pc.h"
 #include "mips.h"
-#include "pci_host.h"
+#include "pci/pci_host.h"
 #include "sysemu.h"
 #include "exec-memory.h"
 
hw/cirrus_vga.c +1 -1
index 9bef96e..2364828 100644
@@ -27,7 +27,7 @@
  *   available at http://home.worldonline.dk/~finth/
  */
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "console.h"
 #include "vga_int.h"
 #include "loader.h"
hw/dec_pci.c +4 -4
index c30ade3..a6a7c84 100644
@@ -25,10 +25,10 @@
 
 #include "dec_pci.h"
 #include "sysbus.h"
-#include "pci.h"
-#include "pci_host.h"
-#include "pci_bridge.h"
-#include "pci_internals.h"
+#include "pci/pci.h"
+#include "pci/pci_host.h"
+#include "pci/pci_bridge.h"
+#include "pci/pci_internals.h"
 
 /* debug DEC */
 //#define DEBUG_DEC
hw/e1000.c +1 -1
index cb7e7e8..ecd81d8 100644
@@ -26,7 +26,7 @@
 
 
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "net.h"
 #include "net/checksum.h"
 #include "loader.h"
hw/eepro100.c +1 -1
index a189474..992f03a 100644
@@ -42,7 +42,7 @@
 
 #include <stddef.h>             /* offsetof */
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "net.h"
 #include "eeprom93xx.h"
 #include "sysemu.h"
hw/es1370.c +1 -1
index e0c9729..6536578 100644
@@ -29,7 +29,7 @@
 #include "hw.h"
 #include "audiodev.h"
 #include "audio/audio.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "dma.h"
 
 /* Missing stuff:
hw/esp-pci.c +1 -1
index d9a8e59..d433473 100644
@@ -23,7 +23,7 @@
  * THE SOFTWARE.
  */
 
-#include "pci.h"
+#include "pci/pci.h"
 #include "eeprom93xx.h"
 #include "esp.h"
 #include "trace.h"
hw/grackle_pci.c +2 -2
index 67da307..9484166 100644
@@ -23,9 +23,9 @@
  * THE SOFTWARE.
  */
 
-#include "pci_host.h"
+#include "pci/pci_host.h"
 #include "ppc_mac.h"
-#include "pci.h"
+#include "pci/pci.h"
 
 /* debug Grackle */
 //#define DEBUG_GRACKLE
hw/gt64xxx.c +2 -2
index 95d491d..5aa49c6 100644
@@ -24,8 +24,8 @@
 
 #include "hw.h"
 #include "mips.h"
-#include "pci.h"
-#include "pci_host.h"
+#include "pci/pci.h"
+#include "pci/pci_host.h"
 #include "pc.h"
 #include "exec-memory.h"
 
hw/hda-audio.c +1 -1
index 36761dd..92a91b5 100644
@@ -18,7 +18,7 @@
  */
 
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "intel-hda.h"
 #include "intel-hda-defs.h"
 #include "audio/audio.h"
hw/i82378.c +1 -1
index 99f35d4..c6b0b5e 100644
@@ -17,7 +17,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pci.h"
+#include "pci/pci.h"
 #include "pc.h"
 #include "i8254.h"
 #include "pcspk.h"
hw/i82801b11.c +1 -1
index 3d1f996..3dc1000 100644
@@ -41,7 +41,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>
  */
 
-#include "pci.h"
+#include "pci/pci.h"
 #include "ich9.h"
 
 
hw/ich9.h +4 -4
index de49135..247be94 100644
@@ -8,13 +8,13 @@
 #include "pc.h"
 #include "apm.h"
 #include "ioapic.h"
-#include "pci.h"
-#include "pcie_host.h"
-#include "pci_bridge.h"
+#include "pci/pci.h"
+#include "pci/pcie_host.h"
+#include "pci/pci_bridge.h"
 #include "acpi.h"
 #include "acpi_ich9.h"
 #include "pam.h"
-#include "pci_internals.h"
+#include "pci/pci_internals.h"
 
 void ich9_lpc_set_irq(void *opaque, int irq_num, int level);
 int ich9_lpc_map_irq(PCIDevice *pci_dev, int intx);
hw/ide.h +1 -1
index add742c..081c710 100644
@@ -2,7 +2,7 @@
 #define HW_IDE_H
 
 #include "isa.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "memory.h"
 
 #define MAX_IDE_DEVS	2
hw/ide/ahci.c +2 -2
index 67562db..2ea64bd 100644
@@ -22,9 +22,9 @@
  */
 
 #include <hw/hw.h>
-#include <hw/msi.h>
+#include <hw/pci/msi.h>
 #include <hw/pc.h>
-#include <hw/pci.h>
+#include <hw/pci/pci.h>
 #include <hw/sysbus.h>
 
 #include "monitor.h"
hw/ide/cmd646.c +1 -1
index 804db60..88210ea 100644
@@ -24,7 +24,7 @@
  */
 #include <hw/hw.h>
 #include <hw/pc.h>
-#include <hw/pci.h>
+#include <hw/pci/pci.h>
 #include <hw/isa.h>
 #include "block.h"
 #include "sysemu.h"
hw/ide/core.c +1 -1
index 8da894f..8ddafbb 100644
@@ -24,7 +24,7 @@
  */
 #include <hw/hw.h>
 #include <hw/pc.h>
-#include <hw/pci.h>
+#include <hw/pci/pci.h>
 #include <hw/isa.h>
 #include "qemu-error.h"
 #include "qemu-timer.h"
hw/ide/ich.c +2 -2
index 272b773..8e1a48e 100644
@@ -61,9 +61,9 @@
  */
 
 #include <hw/hw.h>
-#include <hw/msi.h>
+#include <hw/pci/msi.h>
 #include <hw/pc.h>
-#include <hw/pci.h>
+#include <hw/pci/pci.h>
 #include <hw/isa.h>
 #include "block.h"
 #include "dma.h"
hw/ide/pci.c +1 -1
index bcdd70e..23a0e23 100644
@@ -24,7 +24,7 @@
  */
 #include <hw/hw.h>
 #include <hw/pc.h>
-#include <hw/pci.h>
+#include <hw/pci/pci.h>
 #include <hw/isa.h>
 #include "block.h"
 #include "dma.h"
hw/ide/piix.c +1 -1
index 9431bad..5cf39cf 100644
@@ -25,7 +25,7 @@
 
 #include <hw/hw.h>
 #include <hw/pc.h>
-#include <hw/pci.h>
+#include <hw/pci/pci.h>
 #include <hw/isa.h>
 #include "blockdev.h"
 #include "sysemu.h"
hw/ide/via.c +1 -1
index efda173..8b4a24e 100644
@@ -25,7 +25,7 @@
  */
 #include <hw/hw.h>
 #include <hw/pc.h>
-#include <hw/pci.h>
+#include <hw/pci/pci.h>
 #include <hw/isa.h>
 #include "block.h"
 #include "sysemu.h"
hw/intel-hda.c +2 -2
index a68c368..c21bf72 100644
@@ -18,8 +18,8 @@
  */
 
 #include "hw.h"
-#include "pci.h"
-#include "msi.h"
+#include "pci/pci.h"
+#include "pci/msi.h"
 #include "qemu-timer.h"
 #include "audiodev.h"
 #include "intel-hda.h"
hw/ioh3420.c +3 -3
index 4d31473..d706e19 100644
@@ -20,9 +20,9 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pci_ids.h"
-#include "msi.h"
-#include "pcie.h"
+#include "pci/pci_ids.h"
+#include "pci/msi.h"
+#include "pci/pcie.h"
 #include "ioh3420.h"
 
 #define PCI_DEVICE_ID_IOH_EPORT         0x3420  /* D0:F0 express mode */
hw/ioh3420.h +1 -1
index 68c523a..046cf2c 100644
@@ -1,7 +1,7 @@
 #ifndef QEMU_IOH3420_H
 #define QEMU_IOH3420_H
 
-#include "pcie_port.h"
+#include "pci/pcie_port.h"
 
 PCIESlot *ioh3420_init(PCIBus *bus, int devfn, bool multifunction,
                        const char *bus_name, pci_map_irq_fn map_irq,
hw/ivshmem.c +2 -2
index f6dbb21..cf64f32 100644
@@ -18,8 +18,8 @@
  */
 #include "hw.h"
 #include "pc.h"
-#include "pci.h"
-#include "msix.h"
+#include "pci/pci.h"
+#include "pci/msix.h"
 #include "kvm.h"
 #include "migration.h"
 #include "qerror.h"
hw/kvm/apic.c +1 -1
index 8b65d51..beb418d 100644
@@ -10,7 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 #include "hw/apic_internal.h"
-#include "hw/msi.h"
+#include "hw/pci/msi.h"
 #include "kvm.h"
 
 static inline void kvm_apic_set_reg(struct kvm_lapic_state *kapic,
hw/kvm/pci-assign.c +2 -2
index e80dad0..4229159 100644
@@ -34,8 +34,8 @@
 #include "monitor.h"
 #include "range.h"
 #include "sysemu.h"
-#include "hw/pci.h"
-#include "hw/msi.h"
+#include "hw/pci/pci.h"
+#include "hw/pci/msi.h"
 #include "kvm_i386.h"
 
 #define MSIX_PAGE_SIZE 0x1000
hw/lpc_ich9.c +4 -4
index f253dbd..23dee88 100644
@@ -35,14 +35,14 @@
 #include "pc.h"
 #include "apm.h"
 #include "ioapic.h"
-#include "pci.h"
-#include "pcie_host.h"
-#include "pci_bridge.h"
+#include "pci/pci.h"
+#include "pci/pcie_host.h"
+#include "pci/pci_bridge.h"
 #include "ich9.h"
 #include "acpi.h"
 #include "acpi_ich9.h"
 #include "pam.h"
-#include "pci_internals.h"
+#include "pci/pci_internals.h"
 #include "exec-memory.h"
 
 static int ich9_lpc_sci_irq(ICH9LPCState *lpc);
hw/lsi53c895a.c +1 -1
index 04f2fae..4aac9a0 100644
@@ -13,7 +13,7 @@
 #include <assert.h>
 
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "scsi.h"
 #include "dma.h"
 
hw/macio.c +1 -1
index eb15b89..362afdc 100644
@@ -24,7 +24,7 @@
  */
 #include "hw.h"
 #include "ppc_mac.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "escc.h"
 
 typedef struct MacIOState
hw/megasas.c +2 -2
index 61b6527..f4fbe97 100644
@@ -19,9 +19,9 @@
  */
 
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "dma.h"
-#include "msix.h"
+#include "pci/msix.h"
 #include "iov.h"
 #include "scsi.h"
 #include "scsi-defs.h"
hw/mips_fulong2e.c +1 -1
index 5fcf900..d5cf33b 100644
@@ -29,7 +29,7 @@
 #include "flash.h"
 #include "mips.h"
 #include "mips_cpudevs.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "qemu-char.h"
 #include "sysemu.h"
 #include "audio/audio.h"
hw/mips_malta.c +1 -1
index 4d2464a..571903d 100644
@@ -33,7 +33,7 @@
 #include "flash.h"
 #include "mips.h"
 #include "mips_cpudevs.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "qemu-char.h"
 #include "sysemu.h"
 #include "arch_init.h"
hw/ne2000.c +1 -1
index d3dd9a6..fb78e5b 100644
@@ -22,7 +22,7 @@
  * THE SOFTWARE.
  */
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "net.h"
 #include "ne2000.h"
 #include "loader.h"
hw/openpic.c +1 -1
index 8b3784a..4791dc6 100644
@@ -35,7 +35,7 @@
  */
 #include "hw.h"
 #include "ppc_mac.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "openpic.h"
 
 //#define DEBUG_OPENPIC
hw/pc.c +2 -2
index 2b5bbbf..77470bc 100644
@@ -27,7 +27,7 @@
 #include "apic.h"
 #include "fdc.h"
 #include "ide.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "monitor.h"
 #include "fw_cfg.h"
 #include "hpet_emul.h"
@@ -38,7 +38,7 @@
 #include "mc146818rtc.h"
 #include "i8254.h"
 #include "pcspk.h"
-#include "msi.h"
+#include "pci/msi.h"
 #include "sysbus.h"
 #include "sysemu.h"
 #include "kvm.h"
hw/pc_piix.c +2 -2
index aa3e7f4..890a1d9 100644
@@ -27,8 +27,8 @@
 #include "hw.h"
 #include "pc.h"
 #include "apic.h"
-#include "pci.h"
-#include "pci_ids.h"
+#include "pci/pci.h"
+#include "pci/pci_ids.h"
 #include "usb.h"
 #include "net.h"
 #include "boards.h"
hw/pci_bridge_dev.c +6 -6
index f706396..5c9fc50 100644
@@ -19,13 +19,13 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pci_bridge.h"
-#include "pci_ids.h"
-#include "msi.h"
-#include "shpc.h"
-#include "slotid_cap.h"
+#include "pci/pci_bridge.h"
+#include "pci/pci_ids.h"
+#include "pci/msi.h"
+#include "pci/shpc.h"
+#include "pci/slotid_cap.h"
 #include "memory.h"
-#include "pci_internals.h"
+#include "pci/pci_internals.h"
 
 #define REDHAT_PCI_VENDOR_ID 0x1b36
 #define PCI_BRIDGE_DEV_VENDOR_ID REDHAT_PCI_VENDOR_ID
hw/pcnet-pci.c +1 -1
index 0bf438f..c1abbf8 100644
@@ -27,7 +27,7 @@
  * AMD Publication# 19436  Rev:E  Amendment/0  Issue Date: June 2000
  */
 
-#include "pci.h"
+#include "pci/pci.h"
 #include "net.h"
 #include "loader.h"
 #include "qemu-timer.h"
hw/piix4.c +1 -1
index ce4eb0d..799ed17 100644
@@ -24,7 +24,7 @@
 
 #include "hw.h"
 #include "pc.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "isa.h"
 #include "sysbus.h"
 
hw/piix_pci.c +2 -2
index ba1b3de..b5ea68b 100644
@@ -24,8 +24,8 @@
 
 #include "hw.h"
 #include "pc.h"
-#include "pci.h"
-#include "pci_host.h"
+#include "pci/pci.h"
+#include "pci/pci_host.h"
 #include "isa.h"
 #include "sysbus.h"
 #include "range.h"
hw/ppc/e500.c +1 -1
index 6749fff..f77c488 100644
@@ -20,7 +20,7 @@
 #include "net.h"
 #include "hw/hw.h"
 #include "hw/serial.h"
-#include "hw/pci.h"
+#include "hw/pci/pci.h"
 #include "hw/boards.h"
 #include "sysemu.h"
 #include "kvm.h"
hw/ppc440_bamboo.c +1 -1
index cc85607..0b39a81 100644
@@ -15,7 +15,7 @@
 #include "qemu-common.h"
 #include "net.h"
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "boards.h"
 #include "kvm.h"
 #include "kvm_ppc.h"
hw/ppc4xx.h +1 -1
index d795ced..2b96d47 100644
@@ -25,7 +25,7 @@
 #if !defined(PPC_4XX_H)
 #define PPC_4XX_H
 
-#include "pci.h"
+#include "pci/pci.h"
 
 /* PowerPC 4xx core initialization */
 CPUPPCState *ppc4xx_init (const char *cpu_model,
hw/ppc4xx_pci.c +2 -2
index d3ad6a0..3e8af11 100644
@@ -22,8 +22,8 @@
 #include "hw.h"
 #include "ppc.h"
 #include "ppc4xx.h"
-#include "pci.h"
-#include "pci_host.h"
+#include "pci/pci.h"
+#include "pci/pci_host.h"
 #include "exec-memory.h"
 
 #undef DEBUG
hw/ppc_newworld.c +1 -1
index 664747e..c1ff9d7 100644
@@ -52,7 +52,7 @@
 #include "adb.h"
 #include "mac_dbdma.h"
 #include "nvram.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "net.h"
 #include "sysemu.h"
 #include "boards.h"
hw/ppc_oldworld.c +1 -1
index e8138c0..3bc29c6 100644
@@ -32,7 +32,7 @@
 #include "sysemu.h"
 #include "net.h"
 #include "isa.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "boards.h"
 #include "fw_cfg.h"
 #include "escc.h"
hw/ppc_prep.c +2 -2
index bf15730..f6ffb59 100644
@@ -29,8 +29,8 @@
 #include "net.h"
 #include "sysemu.h"
 #include "isa.h"
-#include "pci.h"
-#include "pci_host.h"
+#include "pci/pci.h"
+#include "pci/pci_host.h"
 #include "ppc.h"
 #include "boards.h"
 #include "qemu-log.h"
hw/ppce500_pci.c +2 -2
index 2ff7438..39022aa 100644
@@ -15,8 +15,8 @@
  */
 
 #include "hw.h"
-#include "pci.h"
-#include "pci_host.h"
+#include "pci/pci.h"
+#include "pci/pci_host.h"
 #include "bswap.h"
 
 #ifdef DEBUG_PCI
hw/prep_pci.c +2 -2
index 0bc479c..5f22de6 100644
@@ -23,8 +23,8 @@
  */
 
 #include "hw.h"
-#include "pci.h"
-#include "pci_host.h"
+#include "pci/pci.h"
+#include "pci/pci_host.h"
 #include "pc.h"
 #include "exec-memory.h"
 
hw/q35.h +2 -2
index e34f7c1..2f951c8 100644
@@ -29,8 +29,8 @@
 #include "pc.h"
 #include "apm.h"
 #include "apic.h"
-#include "pci.h"
-#include "pcie_host.h"
+#include "pci/pci.h"
+#include "pci/pcie_host.h"
 #include "acpi.h"
 #include "acpi_ich9.h"
 #include "pam.h"
hw/qxl.h +1 -1
index e583cfb..41246c7 100644
@@ -2,7 +2,7 @@
 
 #include "console.h"
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "vga_int.h"
 #include "qemu-thread.h"
 
hw/r2d.c +1 -1
index 66212e9..e18c23b 100644
@@ -29,7 +29,7 @@
 #include "devices.h"
 #include "sysemu.h"
 #include "boards.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "net.h"
 #include "sh7750_regs.h"
 #include "ide.h"
hw/realview.c +1 -1
index e789c15..149bb56 100644
@@ -11,7 +11,7 @@
 #include "arm-misc.h"
 #include "primecell.h"
 #include "devices.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "net.h"
 #include "sysemu.h"
 #include "boards.h"
hw/rtl8139.c +1 -1
index e3aa8bf..e294a2a 100644
@@ -52,7 +52,7 @@
 #include <zlib.h>
 
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "dma.h"
 #include "qemu-timer.h"
 #include "net.h"
hw/serial-pci.c +1 -1
index 95dc5c8..6a2548a 100644
@@ -26,7 +26,7 @@
 /* see docs/specs/pci-serial.txt */
 
 #include "serial.h"
-#include "pci.h"
+#include "pci/pci.h"
 
 #define PCI_SERIAL_MAX_PORTS 4
 
hw/sga.c +1 -1
index a666349..5d80efd 100644
@@ -24,7 +24,7 @@
  * sgabios code originally available at code.google.com/p/sgabios
  *
  */
-#include "pci.h"
+#include "pci/pci.h"
 #include "pc.h"
 #include "loader.h"
 #include "sysemu.h"
hw/sh_pci.c +2 -2
index fdec71b..9ea08c8 100644
@@ -23,8 +23,8 @@
  */
 #include "sysbus.h"
 #include "sh.h"
-#include "pci.h"
-#include "pci_host.h"
+#include "pci/pci.h"
+#include "pci/pci_host.h"
 #include "bswap.h"
 #include "exec-memory.h"
 
hw/smbus_ich9.c +1 -1
index 6d31e24..0c52497 100644
@@ -27,7 +27,7 @@
 #include "hw.h"
 #include "pc.h"
 #include "pm_smbus.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "sysemu.h"
 #include "i2c.h"
 #include "smbus.h"
hw/spapr.c +2 -2
index ad3f0ea..b0125a8 100644
@@ -41,11 +41,11 @@
 #include "hw/spapr_vio.h"
 #include "hw/spapr_pci.h"
 #include "hw/xics.h"
-#include "hw/msi.h"
+#include "hw/pci/msi.h"
 
 #include "kvm.h"
 #include "kvm_ppc.h"
-#include "pci.h"
+#include "pci/pci.h"
 
 #include "exec-memory.h"
 #include "hw/usb.h"
hw/spapr_pci.c +5 -5
index a08ed11..e123866 100644
@@ -23,17 +23,17 @@
  * THE SOFTWARE.
  */
 #include "hw.h"
-#include "pci.h"
-#include "msi.h"
-#include "msix.h"
-#include "pci_host.h"
+#include "pci/pci.h"
+#include "pci/msi.h"
+#include "pci/msix.h"
+#include "pci/pci_host.h"
 #include "hw/spapr.h"
 #include "hw/spapr_pci.h"
 #include "exec-memory.h"
 #include <libfdt.h>
 #include "trace.h"
 
-#include "hw/pci_internals.h"
+#include "hw/pci/pci_internals.h"
 
 /* Copied from the kernel arch/powerpc/platforms/pseries/msi.c */
 #define RTAS_QUERY_FN           0
hw/spapr_pci.h +2 -2
index e307ac8..7b26ba1 100644
@@ -23,8 +23,8 @@
 #if !defined(__HW_SPAPR_PCI_H__)
 #define __HW_SPAPR_PCI_H__
 
-#include "hw/pci.h"
-#include "hw/pci_host.h"
+#include "hw/pci/pci.h"
+#include "hw/pci/pci_host.h"
 #include "hw/xics.h"
 
 #define SPAPR_MSIX_MAX_DEVS 32
hw/sun4u.c +1 -1
index b2b51e3..47bcf93 100644
@@ -22,7 +22,7 @@
  * THE SOFTWARE.
  */
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "apb_pci.h"
 #include "pc.h"
 #include "serial.h"
hw/unin_pci.c +2 -2
index 9981d94..4675792 100644
@@ -23,8 +23,8 @@
  */
 #include "hw.h"
 #include "ppc_mac.h"
-#include "pci.h"
-#include "pci_host.h"
+#include "pci/pci.h"
+#include "pci/pci_host.h"
 
 /* debug UniNorth */
 //#define DEBUG_UNIN
hw/usb/hcd-ehci-pci.c +1 -1
index 5887eab..c957c11 100644
@@ -16,7 +16,7 @@
  */
 
 #include "hw/usb/hcd-ehci.h"
-#include "hw/pci.h"
+#include "hw/pci/pci.h"
 #include "range.h"
 
 typedef struct EHCIPCIState {
hw/usb/hcd-ohci.c +1 -1
index 64de906..6b7c3dc 100644
@@ -29,7 +29,7 @@
 #include "hw/hw.h"
 #include "qemu-timer.h"
 #include "hw/usb.h"
-#include "hw/pci.h"
+#include "hw/pci/pci.h"
 #include "hw/sysbus.h"
 #include "hw/qdev-dma.h"
 
hw/usb/hcd-uhci.c +1 -1
index 8e47803..808b004 100644
@@ -27,7 +27,7 @@
  */
 #include "hw/hw.h"
 #include "hw/usb.h"
-#include "hw/pci.h"
+#include "hw/pci/pci.h"
 #include "qemu-timer.h"
 #include "iov.h"
 #include "dma.h"
hw/usb/hcd-xhci.c +3 -3
index 8ef4b07..93117ec 100644
@@ -21,9 +21,9 @@
 #include "hw/hw.h"
 #include "qemu-timer.h"
 #include "hw/usb.h"
-#include "hw/pci.h"
-#include "hw/msi.h"
-#include "hw/msix.h"
+#include "hw/pci/pci.h"
+#include "hw/pci/msi.h"
+#include "hw/pci/msix.h"
 #include "trace.h"
 
 //#define DEBUG_XHCI
hw/versatile_pci.c +2 -2
index e0c3ee3..7a543b4 100644
@@ -8,8 +8,8 @@
  */
 
 #include "sysbus.h"
-#include "pci.h"
-#include "pci_host.h"
+#include "pci/pci.h"
+#include "pci/pci_host.h"
 #include "exec-memory.h"
 
 typedef struct {
hw/versatilepb.c +1 -1
index 25e652b..41e39d8 100644
@@ -12,7 +12,7 @@
 #include "devices.h"
 #include "net.h"
 #include "sysemu.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "i2c.h"
 #include "boards.h"
 #include "blockdev.h"
hw/vfio_pci.c +3 -3
index 7c27834..45d90ab 100644
@@ -31,9 +31,9 @@
 #include "exec-memory.h"
 #include "kvm.h"
 #include "memory.h"
-#include "msi.h"
-#include "msix.h"
-#include "pci.h"
+#include "pci/msi.h"
+#include "pci/msix.h"
+#include "pci/pci.h"
 #include "qemu-common.h"
 #include "qemu-error.h"
 #include "qemu-queue.h"
hw/vga-pci.c +1 -1
index 947e35c..0cb318e 100644
@@ -25,7 +25,7 @@
  */
 #include "hw.h"
 #include "console.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "vga_int.h"
 #include "pixel_ops.h"
 #include "qemu-timer.h"
hw/vga.c +1 -1
index 2b0200a..6d56f8a 100644
@@ -25,7 +25,7 @@
 #include "vga.h"
 #include "console.h"
 #include "pc.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "vga_int.h"
 #include "pixel_ops.h"
 #include "qemu-timer.h"
hw/virtio-balloon.h +1 -1
index 73300dd..b1828f4 100644
@@ -16,7 +16,7 @@
 #define _QEMU_VIRTIO_BALLOON_H
 
 #include "virtio.h"
-#include "pci.h"
+#include "pci/pci.h"
 
 /* from Linux's linux/virtio_balloon.h */
 
hw/virtio-net.h +1 -1
index 36aa463..b13be7c 100644
@@ -16,7 +16,7 @@
 
 #include "virtio.h"
 #include "net.h"
-#include "pci.h"
+#include "pci/pci.h"
 
 #define ETH_ALEN    6
 
hw/virtio-pci.c +3 -3
index 71f4fb5..e9b722d 100644
@@ -22,10 +22,10 @@
 #include "virtio-net.h"
 #include "virtio-serial.h"
 #include "virtio-scsi.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "qemu-error.h"
-#include "msi.h"
-#include "msix.h"
+#include "pci/msi.h"
+#include "pci/msix.h"
 #include "net.h"
 #include "loader.h"
 #include "kvm.h"
hw/virtio-scsi.h +1 -1
index 91924f6..7d7cba7 100644
@@ -16,7 +16,7 @@
 
 #include "virtio.h"
 #include "net.h"
-#include "pci.h"
+#include "pci/pci.h"
 
 /* The ID for virtio_scsi */
 #define VIRTIO_ID_SCSI  8
hw/vmware_vga.c +1 -1
index 834588d..333ec8c 100644
@@ -24,7 +24,7 @@
 #include "hw.h"
 #include "loader.h"
 #include "console.h"
-#include "pci.h"
+#include "pci/pci.h"
 
 #undef VERBOSE
 #define HW_RECT_ACCEL
hw/vt82c686.c +2 -2
index 5d7c00c..620fb75 100644
@@ -15,7 +15,7 @@
 #include "vt82c686.h"
 #include "i2c.h"
 #include "smbus.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "isa.h"
 #include "sysbus.h"
 #include "mips.h"
@@ -26,7 +26,7 @@
 #include "qemu-timer.h"
 
 typedef uint32_t pci_addr_t;
-#include "pci_host.h"
+#include "pci/pci_host.h"
 //#define DEBUG_VT82C686B
 
 #ifdef DEBUG_VT82C686B
hw/wdt_i6300esb.c +1 -1
index da15c73..1817742 100644
@@ -25,7 +25,7 @@
 #include "qemu-timer.h"
 #include "watchdog.h"
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 
 /*#define I6300ESB_DEBUG 1*/
 
hw/xen-host-pci-device.h +1 -1
index 0079dac..942b24d 100644
@@ -1,7 +1,7 @@
 #ifndef XEN_HOST_PCI_DEVICE_H
 #define XEN_HOST_PCI_DEVICE_H
 
-#include "pci.h"
+#include "pci/pci.h"
 
 enum {
     XEN_HOST_PCI_REGION_TYPE_IO = 1 << 1,
hw/xen_apic.c +1 -1
index fc45366..a6632fe 100644
@@ -10,7 +10,7 @@
  * later. See the COPYING file in the top-level directory.
  */
 #include "hw/apic_internal.h"
-#include "hw/msi.h"
+#include "hw/pci/msi.h"
 #include "xen.h"
 
 static uint64_t xen_apic_mem_read(void *opaque, hwaddr addr,
hw/xen_platform.c +1 -1
index a54e7a2..10bb560 100644
@@ -27,7 +27,7 @@
 
 #include "hw.h"
 #include "pc.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "irq.h"
 #include "xen_common.h"
 #include "net.h"
hw/xen_pt.c +1 -1
index 7a3846e..c782cdb 100644
@@ -54,7 +54,7 @@
 
 #include <sys/ioctl.h>
 
-#include "pci.h"
+#include "pci/pci.h"
 #include "xen.h"
 #include "xen_backend.h"
 #include "xen_pt.h"
hw/xen_pt.h +1 -1
index f15e69a..e349730 100644
@@ -3,7 +3,7 @@
 
 #include "qemu-common.h"
 #include "xen_common.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "xen-host-pci-device.h"
 
 void xen_pt_log(const PCIDevice *d, const char *f, ...) GCC_FMT_ATTR(2, 3);
hw/xio3130_downstream.c +3 -3
index 0d8a5e7..2dcd46b 100644
@@ -19,9 +19,9 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pci_ids.h"
-#include "msi.h"
-#include "pcie.h"
+#include "pci/pci_ids.h"
+#include "pci/msi.h"
+#include "pci/pcie.h"
 #include "xio3130_downstream.h"
 
 #define PCI_DEVICE_ID_TI_XIO3130D       0x8233  /* downstream port */
hw/xio3130_downstream.h +1 -1
index 010487f..559dff6 100644
@@ -1,7 +1,7 @@
 #ifndef QEMU_XIO3130_DOWNSTREAM_H
 #define QEMU_XIO3130_DOWNSTREAM_H
 
-#include "pcie_port.h"
+#include "pci/pcie_port.h"
 
 PCIESlot *xio3130_downstream_init(PCIBus *bus, int devfn, bool multifunction,
                                   const char *bus_name, pci_map_irq_fn map_irq,
hw/xio3130_upstream.c +3 -3
index d46b86c..713caf2 100644
@@ -19,9 +19,9 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pci_ids.h"
-#include "msi.h"
-#include "pcie.h"
+#include "pci/pci_ids.h"
+#include "pci/msi.h"
+#include "pci/pcie.h"
 #include "xio3130_upstream.h"
 
 #define PCI_DEVICE_ID_TI_XIO3130U       0x8232  /* upstream port */
hw/xio3130_upstream.h +1 -1
index e996997..fa09656 100644
@@ -1,7 +1,7 @@
 #ifndef QEMU_XIO3130_UPSTREAM_H
 #define QEMU_XIO3130_UPSTREAM_H
 
-#include "pcie_port.h"
+#include "pci/pcie_port.h"
 
 PCIEPort *xio3130_upstream_init(PCIBus *bus, int devfn, bool multifunction,
                                 const char *bus_name, pci_map_irq_fn map_irq,
kvm-all.c +1 -1
index fb3180d..4bbad86 100644
@@ -26,7 +26,7 @@
 #include "qemu-config.h"
 #include "sysemu.h"
 #include "hw/hw.h"
-#include "hw/msi.h"
+#include "hw/pci/msi.h"
 #include "gdbstub.h"
 #include "kvm.h"
 #include "bswap.h"
kvm-stub.c +1 -1
index a3455e2..d65fd04 100644
@@ -12,7 +12,7 @@
 
 #include "qemu-common.h"
 #include "hw/hw.h"
-#include "hw/msi.h"
+#include "hw/pci/msi.h"
 #include "cpu.h"
 #include "gdbstub.h"
 #include "kvm.h"
monitor.c +1 -1
index c0e32d6..a92ab44 100644
@@ -27,7 +27,7 @@
 #include "hw/usb.h"
 #include "hw/pcmcia.h"
 #include "hw/pc.h"
-#include "hw/pci.h"
+#include "hw/pci/pci.h"
 #include "hw/watchdog.h"
 #include "hw/loader.h"
 #include "gdbstub.h"
target-i386/kvm.c +1 -1
index f669281..0901589 100644
@@ -31,7 +31,7 @@
 #include "hw/apic.h"
 #include "ioport.h"
 #include "hyperv.h"
-#include "hw/pci.h"
+#include "hw/pci/pci.h"
 
 //#define DEBUG_KVM
 
xen-all.c +1 -1
index 046cc2a..e3a51cc 100644
@@ -10,7 +10,7 @@
 
 #include <sys/mman.h>
 
-#include "hw/pci.h"
+#include "hw/pci/pci.h"
 #include "hw/pc.h"
 #include "hw/xen_common.h"
 #include "hw/xen_backend.h"
Signature · 1 line
MST
#14 lore raw

PATCH 8/8 pci_bus: update comment

In reply to Michael S. Tsirkin

Don't ask everyone to desist from including this header, simply recommend using accessors.

---
 hw/pci/pci_bus.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
hw/pci/pci_bus.h +3 -7
index 21d0ce6..8217f61 100644
@@ -2,14 +2,10 @@
 #define QEMU_PCI_INTERNALS_H
 
 /*
- * This header files is private to pci.c and pci_bridge.c
- * So following structures are opaque to others and shouldn't be
- * accessed.
+ * PCI Bus and Bridge datastructures.
  *
- * For pci-to-pci bridge needs to include this header file to embed
- * PCIBridge in its structure or to get sizeof(PCIBridge),
- * However, they shouldn't access those following members directly.
- * Use accessor function in pci.h, pci_bridge.h
+ * Do not access the following members directly;
+ * use accessor functions in pci.h, pci_bridge.h
  */
 
 #define TYPE_PCI_BUS "PCI"
Signature · 1 line
MST
#7 lore raw

PATCH 5/8 pci: make external dependencies explicit

In reply to Michael S. Tsirkin

Include dependencies from pci core using <> and the correct path.
Need to check whether they can be minimized, for now, at least make them explicit.

---
 hw/pci/msix.c        |  4 ++--
 hw/pci/pci-hotplug.c | 20 ++++++++++----------
 hw/pci/pci.c         | 16 ++++++++--------
 hw/pci/pci.h         | 10 +++++-----
 hw/pci/pci_host.h    |  2 +-
 hw/pci/pcie.h        |  2 +-
 hw/pci/pcie_aer.h    |  2 +-
 hw/pci/pcie_host.c   |  4 ++--
 8 files changed, 30 insertions(+), 30 deletions(-)
hw/pci/msix.c +2 -2
index 136ef09..ec35a5d 100644
@@ -14,11 +14,11 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw.h"
+#include <hw/hw.h>
 #include "msi.h"
 #include "msix.h"
 #include "pci.h"
-#include "range.h"
+#include <range.h>
 
 #define MSIX_CAP_LENGTH 12
 
hw/pci/pci-hotplug.c +10 -10
index 0ca5546..32ba449 100644
@@ -22,17 +22,17 @@
  * THE SOFTWARE.
  */
 
-#include "hw.h"
-#include "boards.h"
+#include <hw/hw.h>
+#include <hw/boards.h>
 #include "pci.h"
-#include "net.h"
-#include "pc.h"
-#include "monitor.h"
-#include "scsi.h"
-#include "virtio-blk.h"
-#include "qemu-config.h"
-#include "blockdev.h"
-#include "error.h"
+#include <net.h>
+#include <hw/pc.h>
+#include <monitor.h>
+#include <hw/scsi.h>
+#include <hw/virtio-blk.h>
+#include <qemu-config.h>
+#include <blockdev.h>
+#include <error.h>
 
 #if defined(TARGET_I386)
 static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
hw/pci/pci.c +8 -8
index 97a0cd7..6023ded 100644
@@ -21,19 +21,19 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include "hw.h"
+#include <hw/hw.h>
 #include "pci.h"
 #include "pci_bridge.h"
 #include "pci_internals.h"
-#include "monitor.h"
-#include "net.h"
-#include "sysemu.h"
-#include "loader.h"
-#include "range.h"
-#include "qmp-commands.h"
+#include <monitor.h>
+#include <net.h>
+#include <sysemu.h>
+#include <hw/loader.h>
+#include <range.h>
+#include <qmp-commands.h>
 #include "msi.h"
 #include "msix.h"
-#include "exec-memory.h"
+#include <exec-memory.h>
 
 //#define DEBUG_PCI
 #ifdef DEBUG_PCI
hw/pci/pci.h +5 -5
index 4da0c2a..b517995 100644
@@ -1,14 +1,14 @@
 #ifndef QEMU_PCI_H
 #define QEMU_PCI_H
 
-#include "qemu-common.h"
+#include <qemu-common.h>
 
-#include "qdev.h"
-#include "memory.h"
-#include "dma.h"
+#include <hw/qdev.h>
+#include <memory.h>
+#include <dma.h>
 
 /* PCI includes legacy ISA access.  */
-#include "isa.h"
+#include <hw/isa.h>
 
 #include "pcie.h"
 
hw/pci/pci_host.h +1 -1
index 4b9c300..6dfb38d 100644
@@ -28,7 +28,7 @@
 #ifndef PCI_HOST_H
 #define PCI_HOST_H
 
-#include "sysbus.h"
+#include <hw/sysbus.h>
 
 #define TYPE_PCI_HOST_BRIDGE "pci-host-bridge"
 #define PCI_HOST_BRIDGE(obj) \
hw/pci/pcie.h +1 -1
index 4889194..cc1f2c5 100644
@@ -21,7 +21,7 @@
 #ifndef QEMU_PCIE_H
 #define QEMU_PCIE_H
 
-#include "hw.h"
+#include <hw/hw.h>
 #include "pci_regs.h"
 #include "pcie_regs.h"
 #include "pcie_aer.h"
hw/pci/pcie_aer.h +1 -1
index 7539500..406a736 100644
@@ -21,7 +21,7 @@
 #ifndef QEMU_PCIE_AER_H
 #define QEMU_PCIE_AER_H
 
-#include "hw.h"
+#include <hw/hw.h>
 
 /* definitions which PCIExpressDevice uses */
 
hw/pci/pcie_host.c +2 -2
index c257fb4..4453cb0 100644
@@ -19,10 +19,10 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "hw.h"
+#include <hw/hw.h>
 #include "pci.h"
 #include "pcie_host.h"
-#include "exec-memory.h"
+#include <exec-memory.h>
 
 /*
  * PCI express mmcfig address
Signature · 1 line
MST
#11 lore raw

PATCH 7/8 pci: rename pci_internals.h pci_bus.h

In reply to Michael S. Tsirkin

There are lots of external users of pci_internals.h, apparently making it an internal interface only didn't work out. Let's stop pretending it's an internal header.

---
 hw/apb_pci.c           |  2 +-
 hw/dec_pci.c           |  2 +-
 hw/ich9.h              |  2 +-
 hw/lpc_ich9.c          |  2 +-
 hw/pci/pci.c           |  2 +-
 hw/pci/pci_bridge.c    |  2 +-
 hw/pci/pci_bus.h       | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/pci/pci_internals.h | 78 --------------------------------------------------
 hw/pci/pcie.c          |  2 +-
 hw/pci/pcie_aer.c      |  2 +-
 hw/pci/pcie_port.h     |  2 +-
 hw/pci/shpc.c          |  2 +-
 hw/pci_bridge_dev.c    |  2 +-
 hw/spapr_pci.c         |  2 +-
 14 files changed, 90 insertions(+), 90 deletions(-)
 create mode 100644 hw/pci/pci_bus.h
 delete mode 100644 hw/pci/pci_internals.h
hw/apb_pci.c +1 -1
index de594f8..fb7a07d 100644
@@ -30,7 +30,7 @@
 #include "pci/pci.h"
 #include "pci/pci_host.h"
 #include "pci/pci_bridge.h"
-#include "pci/pci_internals.h"
+#include "pci/pci_bus.h"
 #include "apb_pci.h"
 #include "sysemu.h"
 #include "exec-memory.h"
hw/dec_pci.c +1 -1
index a6a7c84..ee3f4ca 100644
@@ -28,7 +28,7 @@
 #include "pci/pci.h"
 #include "pci/pci_host.h"
 #include "pci/pci_bridge.h"
-#include "pci/pci_internals.h"
+#include "pci/pci_bus.h"
 
 /* debug DEC */
 //#define DEBUG_DEC
hw/ich9.h +1 -1
index 247be94..4e7442c 100644
@@ -14,7 +14,7 @@
 #include "acpi.h"
 #include "acpi_ich9.h"
 #include "pam.h"
-#include "pci/pci_internals.h"
+#include "pci/pci_bus.h"
 
 void ich9_lpc_set_irq(void *opaque, int irq_num, int level);
 int ich9_lpc_map_irq(PCIDevice *pci_dev, int intx);
hw/lpc_ich9.c +1 -1
index 23dee88..7bca061 100644
@@ -42,7 +42,7 @@
 #include "acpi.h"
 #include "acpi_ich9.h"
 #include "pam.h"
-#include "pci/pci_internals.h"
+#include "pci/pci_bus.h"
 #include "exec-memory.h"
 
 static int ich9_lpc_sci_irq(ICH9LPCState *lpc);
hw/pci/pci.c +1 -1
index 6023ded..c1a4b32 100644
@@ -24,7 +24,7 @@
 #include <hw/hw.h>
 #include "pci.h"
 #include "pci_bridge.h"
-#include "pci_internals.h"
+#include "pci_bus.h"
 #include <monitor.h>
 #include <net.h>
 #include <sysemu.h>
hw/pci/pci_bridge.c +1 -1
index 4680501..0fb7577 100644
@@ -30,7 +30,7 @@
  */
 
 #include "pci_bridge.h"
-#include "pci_internals.h"
+#include "pci_bus.h"
 #include "range.h"
 
 /* PCI bridge subsystem vendor ID helper functions */
hw/pci/pci_bus.h new file +78 -0

78 lines not on this page · raw message

hw/pci/pci_internals.h deleted +0 -78

78 lines not on this page · raw message

hw/pci/pcie.c +1 -1
index 7c92f19..d9c38b5 100644
@@ -23,7 +23,7 @@
 #include "pcie.h"
 #include "msix.h"
 #include "msi.h"
-#include "pci_internals.h"
+#include "pci_bus.h"
 #include "pcie_regs.h"
 #include "range.h"
 
hw/pci/pcie_aer.c +1 -1
index b04c164..3c3185c 100644
@@ -25,7 +25,7 @@
 #include "pcie.h"
 #include "msix.h"
 #include "msi.h"
-#include "pci_internals.h"
+#include "pci_bus.h"
 #include "pcie_regs.h"
 
 //#define DEBUG_PCIE
hw/pci/pcie_port.h +1 -1
index 3709583..36b2241 100644
@@ -22,7 +22,7 @@
 #define QEMU_PCIE_PORT_H
 
 #include "pci_bridge.h"
-#include "pci_internals.h"
+#include "pci_bus.h"
 
 struct PCIEPort {
     PCIBridge   br;
hw/pci/shpc.c +1 -1
index 4597bbd..9297af0 100644
@@ -4,7 +4,7 @@
 #include "range.h"
 #include "shpc.h"
 #include "pci.h"
-#include "pci_internals.h"
+#include "pci_bus.h"
 #include "msi.h"
 
 /* TODO: model power only and disabled slot states. */
hw/pci_bridge_dev.c +1 -1
index 5c9fc50..dbb4b3b 100644
@@ -25,7 +25,7 @@
 #include "pci/shpc.h"
 #include "pci/slotid_cap.h"
 #include "memory.h"
-#include "pci/pci_internals.h"
+#include "pci/pci_bus.h"
 
 #define REDHAT_PCI_VENDOR_ID 0x1b36
 #define PCI_BRIDGE_DEV_VENDOR_ID REDHAT_PCI_VENDOR_ID
hw/spapr_pci.c +1 -1
index e123866..6b05e5b 100644
@@ -33,7 +33,7 @@
 #include <libfdt.h>
 #include "trace.h"
 
-#include "hw/pci/pci_internals.h"
+#include "hw/pci/pci_bus.h"
 
 /* Copied from the kernel arch/powerpc/platforms/pseries/msi.c */
 #define RTAS_QUERY_FN           0
Signature · 1 line
MST
#3 lore raw

PATCH 3/8 pci: move pci core code to hw/pci

In reply to Michael S. Tsirkin

Move files and modify makefiles to pick them at the new location.

---
 hw/Makefile.objs       |   10 +-
 hw/i386/Makefile.objs  |    2 +-
 hw/msi.c               |  395 ---------
 hw/msi.h               |   50 --
 hw/msix.c              |  562 -------------
 hw/msix.h              |   41 -
 hw/pci-hotplug.c       |  293 -------
 hw/pci-stub.c          |   47 --
 hw/pci.c               | 2168 ------------------------------------------------
 hw/pci.h               |  684 ---------------
 hw/pci/Makefile.objs   |    6 +
 hw/pci/msi.c           |  395 +++++++++
 hw/pci/msi.h           |   50 ++
 hw/pci/msix.c          |  562 +++++++++++++
 hw/pci/msix.h          |   41 +
 hw/pci/pci-hotplug.c   |  293 +++++++
 hw/pci/pci-stub.c      |   47 ++
 hw/pci/pci.c           | 2168 ++++++++++++++++++++++++++++++++++++++++++++++++
 hw/pci/pci.h           |  684 +++++++++++++++
 hw/pci/pci_bridge.c    |  363 ++++++++
 hw/pci/pci_bridge.h    |   66 ++
 hw/pci/pci_host.c      |  180 ++++
 hw/pci/pci_host.h      |   62 ++
 hw/pci/pci_ids.h       |  147 ++++
 hw/pci/pci_internals.h |   78 ++
 hw/pci/pci_regs.h      |  717 ++++++++++++++++
 hw/pci/pcie.c          |  555 +++++++++++++
 hw/pci/pcie.h          |  142 ++++
 hw/pci/pcie_aer.c      | 1032 +++++++++++++++++++++++
 hw/pci/pcie_aer.h      |  106 +++
 hw/pci/pcie_host.c     |  161 ++++
 hw/pci/pcie_host.h     |   54 ++
 hw/pci/pcie_port.c     |  114 +++
 hw/pci/pcie_port.h     |   51 ++
 hw/pci/pcie_regs.h     |  156 ++++
 hw/pci/shpc.c          |  681 +++++++++++++++
 hw/pci/shpc.h          |   48 ++
 hw/pci/slotid_cap.c    |   44 +
 hw/pci/slotid_cap.h    |   11 +
 hw/pci_bridge.c        |  363 --------
 hw/pci_bridge.h        |   66 --
 hw/pci_host.c          |  180 ----
 hw/pci_host.h          |   62 --
 hw/pci_ids.h           |  147 ----
 hw/pci_internals.h     |   78 --
 hw/pci_regs.h          |  717 ----------------
 hw/pcie.c              |  555 -------------
 hw/pcie.h              |  142 ----
 hw/pcie_aer.c          | 1032 -----------------------
 hw/pcie_aer.h          |  106 ---
 hw/pcie_host.c         |  161 ----
 hw/pcie_host.h         |   54 --
 hw/pcie_port.c         |  114 ---
 hw/pcie_port.h         |   51 --
 hw/pcie_regs.h         |  156 ----
 hw/ppc/Makefile.objs   |    2 +-
 hw/shpc.c              |  681 ---------------
 hw/shpc.h              |   48 --
 hw/slotid_cap.c        |   44 -
 hw/slotid_cap.h        |   11 -
 60 files changed, 9018 insertions(+), 9018 deletions(-)
 delete mode 100644 hw/msi.c
 delete mode 100644 hw/msi.h
 delete mode 100644 hw/msix.c
 delete mode 100644 hw/msix.h
 delete mode 100644 hw/pci-hotplug.c
 delete mode 100644 hw/pci-stub.c
 delete mode 100644 hw/pci.c
 delete mode 100644 hw/pci.h
 create mode 100644 hw/pci/Makefile.objs
 create mode 100644 hw/pci/msi.c
 create mode 100644 hw/pci/msi.h
 create mode 100644 hw/pci/msix.c
 create mode 100644 hw/pci/msix.h
 create mode 100644 hw/pci/pci-hotplug.c
 create mode 100644 hw/pci/pci-stub.c
 create mode 100644 hw/pci/pci.c
 create mode 100644 hw/pci/pci.h
 create mode 100644 hw/pci/pci_bridge.c
 create mode 100644 hw/pci/pci_bridge.h
 create mode 100644 hw/pci/pci_host.c
 create mode 100644 hw/pci/pci_host.h
 create mode 100644 hw/pci/pci_ids.h
 create mode 100644 hw/pci/pci_internals.h
 create mode 100644 hw/pci/pci_regs.h
 create mode 100644 hw/pci/pcie.c
 create mode 100644 hw/pci/pcie.h
 create mode 100644 hw/pci/pcie_aer.c
 create mode 100644 hw/pci/pcie_aer.h
 create mode 100644 hw/pci/pcie_host.c
 create mode 100644 hw/pci/pcie_host.h
 create mode 100644 hw/pci/pcie_port.c
 create mode 100644 hw/pci/pcie_port.h
 create mode 100644 hw/pci/pcie_regs.h
 create mode 100644 hw/pci/shpc.c
 create mode 100644 hw/pci/shpc.h
 create mode 100644 hw/pci/slotid_cap.c
 create mode 100644 hw/pci/slotid_cap.h
 delete mode 100644 hw/pci_bridge.c
 delete mode 100644 hw/pci_bridge.h
 delete mode 100644 hw/pci_host.c
 delete mode 100644 hw/pci_host.h
 delete mode 100644 hw/pci_ids.h
 delete mode 100644 hw/pci_internals.h
 delete mode 100644 hw/pci_regs.h
 delete mode 100644 hw/pcie.c
 delete mode 100644 hw/pcie.h
 delete mode 100644 hw/pcie_aer.c
 delete mode 100644 hw/pcie_aer.h
 delete mode 100644 hw/pcie_host.c
 delete mode 100644 hw/pcie_host.h
 delete mode 100644 hw/pcie_port.c
 delete mode 100644 hw/pcie_port.h
 delete mode 100644 hw/pcie_regs.h
 delete mode 100644 hw/shpc.c
 delete mode 100644 hw/shpc.h
 delete mode 100644 hw/slotid_cap.c
 delete mode 100644 hw/slotid_cap.h
hw/Makefile.objs +2 -8
index d581d8d..228acd6 100644
@@ -1,14 +1,10 @@
-common-obj-y = usb/ ide/
+common-obj-y = usb/ ide/ pci/
 common-obj-y += loader.o
 common-obj-$(CONFIG_VIRTIO) += virtio-console.o
 common-obj-$(CONFIG_VIRTIO) += virtio-rng.o
 common-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
 common-obj-y += fw_cfg.o
-common-obj-$(CONFIG_PCI) += pci.o pci_bridge.o pci_bridge_dev.o
-common-obj-$(CONFIG_PCI) += msix.o msi.o
-common-obj-$(CONFIG_PCI) += shpc.o
-common-obj-$(CONFIG_PCI) += slotid_cap.o
-common-obj-$(CONFIG_PCI) += pci_host.o pcie_host.o
+common-obj-$(CONFIG_PCI) += pci_bridge_dev.o
 common-obj-$(CONFIG_PCI) += ioh3420.o xio3130_upstream.o xio3130_downstream.o
 common-obj-$(CONFIG_PCI) += i82801b11.o
 common-obj-y += watchdog.o
@@ -102,8 +98,6 @@ common-obj-$(CONFIG_XGMAC) += xgmac.o
 # PCI watchdog devices
 common-obj-$(CONFIG_PCI) += wdt_i6300esb.o
 
-common-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
-
 # PCI network cards
 common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
 common-obj-$(CONFIG_EEPRO100_PCI) += eepro100.o
hw/i386/Makefile.objs +1 -1
index 0d3f6a8..257f3c1 100644
@@ -2,7 +2,7 @@ obj-y += mc146818rtc.o pc.o
 obj-y += apic_common.o apic.o kvmvapic.o
 obj-y += sga.o ioapic_common.o ioapic.o piix_pci.o
 obj-y += vmport.o
-obj-y += pci-hotplug.o smbios.o wdt_ib700.o
+obj-y += pci/pci-hotplug.o smbios.o wdt_ib700.o
 obj-y += debugcon.o multiboot.o
 obj-y += pc_piix.o
 obj-y += pc_sysfw.o
hw/msi.c deleted +0 -395

395 lines not on this page · raw message

hw/msi.h deleted +0 -50

50 lines not on this page · raw message

hw/msix.c deleted +0 -562

562 lines not on this page · raw message

hw/msix.h deleted +0 -41

41 lines not on this page · raw message

hw/pci-hotplug.c deleted +0 -293

293 lines not on this page · raw message

hw/pci-stub.c deleted +0 -47

47 lines not on this page · raw message

hw/pci.c deleted +0 -2168

1,580 lines not on this page · raw message

hw/pci.h deleted +0 -684

684 lines not on this page · raw message

hw/pci/Makefile.objs new file +6 -0
new file mode 100644
index 0000000..9d21952

Lines of this file are not shown. View the raw message.

hw/pci/msi.c new file +395 -0

395 lines not on this page · raw message

hw/pci/msi.h new file +50 -0

50 lines not on this page · raw message

hw/pci/msix.c new file +562 -0

562 lines not on this page · raw message

hw/pci/msix.h new file +41 -0

41 lines not on this page · raw message

hw/pci/pci-hotplug.c new file +293 -0

293 lines not on this page · raw message

hw/pci/pci-stub.c new file +47 -0

47 lines not on this page · raw message

hw/pci/pci.c new file +2168 -0

2,168 lines not on this page · raw message

hw/pci/pci.h new file +684 -0

684 lines not on this page · raw message

hw/pci/pci_bridge.c new file +363 -0

363 lines not on this page · raw message

hw/pci/pci_bridge.h new file +66 -0

66 lines not on this page · raw message

hw/pci/pci_host.c new file +180 -0

180 lines not on this page · raw message

hw/pci/pci_host.h new file +62 -0

62 lines not on this page · raw message

hw/pci/pci_ids.h new file +147 -0

147 lines not on this page · raw message

hw/pci/pci_internals.h new file +78 -0

78 lines not on this page · raw message

hw/pci/pci_regs.h new file +717 -0

717 lines not on this page · raw message

hw/pci/pcie.c new file +555 -0

555 lines not on this page · raw message

hw/pci/pcie.h new file +142 -0

142 lines not on this page · raw message

hw/pci/pcie_aer.c new file +1032 -0

1,032 lines not on this page · raw message

hw/pci/pcie_aer.h new file +106 -0

106 lines not on this page · raw message

hw/pci/pcie_host.c new file +161 -0

161 lines not on this page · raw message

hw/pci/pcie_host.h new file +54 -0

54 lines not on this page · raw message

hw/pci/pcie_port.c new file +114 -0

114 lines not on this page · raw message

hw/pci/pcie_port.h new file +51 -0

51 lines not on this page · raw message

hw/pci/pcie_regs.h new file +156 -0

156 lines not on this page · raw message

hw/pci/shpc.c new file +681 -0

681 lines not on this page · raw message

hw/pci/shpc.h new file +48 -0

48 lines not on this page · raw message

hw/pci/slotid_cap.c new file +44 -0

44 lines not on this page · raw message

hw/pci/slotid_cap.h new file +11 -0
new file mode 100644
index 0000000..70db047

Lines of this file are not shown. View the raw message.

hw/pci_bridge.c deleted +0 -363

363 lines not on this page · raw message

hw/pci_bridge.h deleted +0 -66

66 lines not on this page · raw message

hw/pci_host.c deleted +0 -180

180 lines not on this page · raw message

hw/pci_host.h deleted +0 -62

62 lines not on this page · raw message

hw/pci_ids.h deleted +0 -147

147 lines not on this page · raw message

hw/pci_internals.h deleted +0 -78

78 lines not on this page · raw message

hw/pci_regs.h deleted +0 -717

717 lines not on this page · raw message

hw/pcie.c deleted +0 -555

555 lines not on this page · raw message

hw/pcie.h deleted +0 -142

142 lines not on this page · raw message

hw/pcie_aer.c deleted +0 -1032

1,032 lines not on this page · raw message

hw/pcie_aer.h deleted +0 -106

106 lines not on this page · raw message

hw/pcie_host.c deleted +0 -161

161 lines not on this page · raw message

hw/pcie_host.h deleted +0 -54

54 lines not on this page · raw message

hw/pcie_port.c deleted +0 -114

114 lines not on this page · raw message

hw/pcie_port.h deleted +0 -51

51 lines not on this page · raw message

hw/pcie_regs.h deleted +0 -156

156 lines not on this page · raw message

hw/ppc/Makefile.objs +1 -1
index 8fe2123..cb7cf8f 100644

Lines of this file are not shown. View the raw message.

hw/shpc.c deleted +0 -681

681 lines not on this page · raw message

hw/shpc.h deleted +0 -48

48 lines not on this page · raw message

hw/slotid_cap.c deleted +0 -44

44 lines not on this page · raw message

hw/slotid_cap.h deleted +0 -11
deleted file mode 100644
index 70db047..0000000

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
MST

Part of the diff is not shown here. View the raw message.

#15 lore raw
In reply to Michael S. Tsirkin
Quoted 9 lines · Michael S. Tsirkin

This patchset starts some cleanups of the pci core by rearranging the code: pci core is split out from devices into its own directory, pci internals.h is renamed as it's used externally a lot.

I'd like to merge this quickly to avoid conflicting with others work.
Plan to send pull request tomorrow, if you have concerns, speak up soon pls.

I'd like to see an Ack from Paolo as he's working on a tree-wide file movement right now.. Don't want to conflict with what he's doing unnecessarily.

Otherwise, this looks reasonable to me.

Regards,

Anthony Liguori

Quoted 238 lines

Thanks,

Michael S. Tsirkin (8):
pci: prepare makefiles for pci code reorganization
MAINTAINERS: add hw/pci/ to list of PCI files
pci: move pci core code to hw/pci
pci: update all users to look in pci/
pci: make external dependencies explicit
Revert "pci: prepare makefiles for pci code reorganization"
pci: rename pci_internals.h pci_bus.h
pci_bus: update comment

 MAINTAINERS              |    1 +
 arch_init.c              |    2 +-
 hw/Makefile.objs         |   10 +-
 hw/ac97.c                |    2 +-
 hw/acpi_ich9.c           |    2 +-
 hw/acpi_piix4.c          |    2 +-
 hw/alpha_sys.h           |    4 +-
 hw/apb_pci.c             |    8 +-
 hw/apic.c                |    2 +-
 hw/bonito.c              |    4 +-
 hw/cirrus_vga.c          |    2 +-
 hw/dec_pci.c             |    8 +-
 hw/e1000.c               |    2 +-
 hw/eepro100.c            |    2 +-
 hw/es1370.c              |    2 +-
 hw/esp-pci.c             |    2 +-
 hw/grackle_pci.c         |    4 +-
 hw/gt64xxx.c             |    4 +-
 hw/hda-audio.c           |    2 +-
 hw/i386/Makefile.objs    |    2 +-
 hw/i82378.c              |    2 +-
 hw/i82801b11.c           |    2 +-
 hw/ich9.h                |    8 +-
 hw/ide.h                 |    2 +-
 hw/ide/ahci.c            |    4 +-
 hw/ide/cmd646.c          |    2 +-
 hw/ide/core.c            |    2 +-
 hw/ide/ich.c             |    4 +-
 hw/ide/pci.c             |    2 +-
 hw/ide/piix.c            |    2 +-
 hw/ide/via.c             |    2 +-
 hw/intel-hda.c           |    4 +-
 hw/ioh3420.c             |    6 +-
 hw/ioh3420.h             |    2 +-
 hw/ivshmem.c             |    4 +-
 hw/kvm/apic.c            |    2 +-
 hw/kvm/pci-assign.c      |    4 +-
 hw/lpc_ich9.c            |    8 +-
 hw/lsi53c895a.c          |    2 +-
 hw/macio.c               |    2 +-
 hw/megasas.c             |    4 +-
 hw/mips_fulong2e.c       |    2 +-
 hw/mips_malta.c          |    2 +-
 hw/msi.c                 |  395 ---------
 hw/msi.h                 |   50 --
 hw/msix.c                |  562 ------------
 hw/msix.h                |   41 -
 hw/ne2000.c              |    2 +-
 hw/openpic.c             |    2 +-
 hw/pc.c                  |    4 +-
 hw/pc_piix.c             |    4 +-
 hw/pci-hotplug.c         |  293 -------
 hw/pci-stub.c            |   47 -
 hw/pci.c                 | 2168 ----------------------------------------------
 hw/pci.h                 |  684 ---------------
 hw/pci/Makefile.objs     |    6 +
 hw/pci/msi.c             |  395 +++++++++
 hw/pci/msi.h             |   50 ++
 hw/pci/msix.c            |  562 ++++++++++++
 hw/pci/msix.h            |   41 +
 hw/pci/pci-hotplug.c     |  293 +++++++
 hw/pci/pci-stub.c        |   47 +
 hw/pci/pci.c             | 2168 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/pci/pci.h             |  684 +++++++++++++++
 hw/pci/pci_bridge.c      |  363 ++++++++
 hw/pci/pci_bridge.h      |   66 ++
 hw/pci/pci_bus.h         |   74 ++
 hw/pci/pci_host.c        |  180 ++++
 hw/pci/pci_host.h        |   62 ++
 hw/pci/pci_ids.h         |  147 ++++
 hw/pci/pci_regs.h        |  717 +++++++++++++++
 hw/pci/pcie.c            |  555 ++++++++++++
 hw/pci/pcie.h            |  142 +++
 hw/pci/pcie_aer.c        | 1032 ++++++++++++++++++++++
 hw/pci/pcie_aer.h        |  106 +++
 hw/pci/pcie_host.c       |  161 ++++
 hw/pci/pcie_host.h       |   54 ++
 hw/pci/pcie_port.c       |  114 +++
 hw/pci/pcie_port.h       |   51 ++
 hw/pci/pcie_regs.h       |  156 ++++
 hw/pci/shpc.c            |  681 +++++++++++++++
 hw/pci/shpc.h            |   48 +
 hw/pci/slotid_cap.c      |   44 +
 hw/pci/slotid_cap.h      |   11 +
 hw/pci_bridge.c          |  363 --------
 hw/pci_bridge.h          |   66 --
 hw/pci_bridge_dev.c      |   12 +-
 hw/pci_host.c            |  180 ----
 hw/pci_host.h            |   62 --
 hw/pci_ids.h             |  147 ----
 hw/pci_internals.h       |   78 --
 hw/pci_regs.h            |  717 ---------------
 hw/pcie.c                |  555 ------------
 hw/pcie.h                |  142 ---
 hw/pcie_aer.c            | 1032 ----------------------
 hw/pcie_aer.h            |  106 ---
 hw/pcie_host.c           |  161 ----
 hw/pcie_host.h           |   54 --
 hw/pcie_port.c           |  114 ---
 hw/pcie_port.h           |   51 --
 hw/pcie_regs.h           |  156 ----
 hw/pcnet-pci.c           |    2 +-
 hw/piix4.c               |    2 +-
 hw/piix_pci.c            |    4 +-
 hw/ppc/Makefile.objs     |    2 +-
 hw/ppc/e500.c            |    2 +-
 hw/ppc440_bamboo.c       |    2 +-
 hw/ppc4xx.h              |    2 +-
 hw/ppc4xx_pci.c          |    4 +-
 hw/ppc_newworld.c        |    2 +-
 hw/ppc_oldworld.c        |    2 +-
 hw/ppc_prep.c            |    4 +-
 hw/ppce500_pci.c         |    4 +-
 hw/prep_pci.c            |    4 +-
 hw/q35.h                 |    4 +-
 hw/qxl.h                 |    2 +-
 hw/r2d.c                 |    2 +-
 hw/realview.c            |    2 +-
 hw/rtl8139.c             |    2 +-
 hw/serial-pci.c          |    2 +-
 hw/sga.c                 |    2 +-
 hw/sh_pci.c              |    4 +-
 hw/shpc.c                |  681 ---------------
 hw/shpc.h                |   48 -
 hw/slotid_cap.c          |   44 -
 hw/slotid_cap.h          |   11 -
 hw/smbus_ich9.c          |    2 +-
 hw/spapr.c               |    4 +-
 hw/spapr_pci.c           |   10 +-
 hw/spapr_pci.h           |    4 +-
 hw/sun4u.c               |    2 +-
 hw/unin_pci.c            |    4 +-
 hw/usb/hcd-ehci-pci.c    |    2 +-
 hw/usb/hcd-ohci.c        |    2 +-
 hw/usb/hcd-uhci.c        |    2 +-
 hw/usb/hcd-xhci.c        |    6 +-
 hw/versatile_pci.c       |    4 +-
 hw/versatilepb.c         |    2 +-
 hw/vfio_pci.c            |    6 +-
 hw/vga-pci.c             |    2 +-
 hw/vga.c                 |    2 +-
 hw/virtio-balloon.h      |    2 +-
 hw/virtio-net.h          |    2 +-
 hw/virtio-pci.c          |    6 +-
 hw/virtio-scsi.h         |    2 +-
 hw/vmware_vga.c          |    2 +-
 hw/vt82c686.c            |    4 +-
 hw/wdt_i6300esb.c        |    2 +-
 hw/xen-host-pci-device.h |    2 +-
 hw/xen_apic.c            |    2 +-
 hw/xen_platform.c        |    2 +-
 hw/xen_pt.c              |    2 +-
 hw/xen_pt.h              |    2 +-
 hw/xio3130_downstream.c  |    6 +-
 hw/xio3130_downstream.h  |    2 +-
 hw/xio3130_upstream.c    |    6 +-
 hw/xio3130_upstream.h    |    2 +-
 kvm-all.c                |    2 +-
 kvm-stub.c               |    2 +-
 monitor.c                |    2 +-
 target-i386/kvm.c        |    2 +-
 xen-all.c                |    2 +-
 162 files changed, 9173 insertions(+), 9176 deletions(-)
 delete mode 100644 hw/msi.c
 delete mode 100644 hw/msi.h
 delete mode 100644 hw/msix.c
 delete mode 100644 hw/msix.h
 delete mode 100644 hw/pci-hotplug.c
 delete mode 100644 hw/pci-stub.c
 delete mode 100644 hw/pci.c
 delete mode 100644 hw/pci.h
 create mode 100644 hw/pci/Makefile.objs
 create mode 100644 hw/pci/msi.c
 create mode 100644 hw/pci/msi.h
 create mode 100644 hw/pci/msix.c
 create mode 100644 hw/pci/msix.h
 create mode 100644 hw/pci/pci-hotplug.c
 create mode 100644 hw/pci/pci-stub.c
 create mode 100644 hw/pci/pci.c
 create mode 100644 hw/pci/pci.h
 create mode 100644 hw/pci/pci_bridge.c
 create mode 100644 hw/pci/pci_bridge.h
 create mode 100644 hw/pci/pci_bus.h
 create mode 100644 hw/pci/pci_host.c
 create mode 100644 hw/pci/pci_host.h
 create mode 100644 hw/pci/pci_ids.h
 create mode 100644 hw/pci/pci_regs.h
 create mode 100644 hw/pci/pcie.c
 create mode 100644 hw/pci/pcie.h
 create mode 100644 hw/pci/pcie_aer.c
 create mode 100644 hw/pci/pcie_aer.h
 create mode 100644 hw/pci/pcie_host.c
 create mode 100644 hw/pci/pcie_host.h
 create mode 100644 hw/pci/pcie_port.c
 create mode 100644 hw/pci/pcie_port.h
 create mode 100644 hw/pci/pcie_regs.h
 create mode 100644 hw/pci/shpc.c
 create mode 100644 hw/pci/shpc.h
 create mode 100644 hw/pci/slotid_cap.c
 create mode 100644 hw/pci/slotid_cap.h
 delete mode 100644 hw/pci_bridge.c
 delete mode 100644 hw/pci_bridge.h
 delete mode 100644 hw/pci_host.c
 delete mode 100644 hw/pci_host.h
 delete mode 100644 hw/pci_ids.h
 delete mode 100644 hw/pci_internals.h
 delete mode 100644 hw/pci_regs.h
 delete mode 100644 hw/pcie.c
 delete mode 100644 hw/pcie.h
 delete mode 100644 hw/pcie_aer.c
 delete mode 100644 hw/pcie_aer.h
 delete mode 100644 hw/pcie_host.c
 delete mode 100644 hw/pcie_host.h
 delete mode 100644 hw/pcie_port.c
 delete mode 100644 hw/pcie_port.h
 delete mode 100644 hw/pcie_regs.h
 delete mode 100644 hw/shpc.c
 delete mode 100644 hw/shpc.h
 delete mode 100644 hw/slotid_cap.c
 delete mode 100644 hw/slotid_cap.h
Signature · 1 line
MST
#16 lore raw

Il 12/12/2012 14:51, Anthony Liguori ha scritto:

Quoted 5 lines

I'd like to see an Ack from Paolo as he's working on a tree-wide file movement right now.. Don't want to conflict with what he's doing unnecessarily.

Otherwise, this looks reasonable to me.

My changes are 99% scripted, so no problem from me.

Alternatively, I can pull from Michael and send a combined pull to you.

Paolo

#8 lore raw

Re: [Qemu-devel] [PATCH 5/8] pci: make external dependencies explicit

In reply to Michael S. Tsirkin
Quoted 1 line · Michael S. Tsirkin

Include dependencies from pci core using <> and

Nack, the usual convention is to use <> for system headers like <stdio.h> and "" for local headers.

For example with MSVC the search path for angle brackets does not even include the local directory:
http://msdn.microsoft.com/en-us/library/36k2cdd4%28v=vs.80%29.aspx

Quoted 182 lines

the correct path.
Need to check whether they can be minimized, for now, at least make them explicit.

---
 hw/pci/msix.c        |  4 ++--
 hw/pci/pci-hotplug.c | 20 ++++++++++----------
 hw/pci/pci.c         | 16 ++++++++--------
 hw/pci/pci.h         | 10 +++++-----
 hw/pci/pci_host.h    |  2 +-
 hw/pci/pcie.h        |  2 +-
 hw/pci/pcie_aer.h    |  2 +-
 hw/pci/pcie_host.c   |  4 ++--
 8 files changed, 30 insertions(+), 30 deletions(-)
hw/pci/msix.c +2 -2
index 136ef09..ec35a5d 100644
@@ -14,11 +14,11 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw.h"
+#include <hw/hw.h>
 #include "msi.h"
 #include "msix.h"
 #include "pci.h"
-#include "range.h"
+#include <range.h>
 
 #define MSIX_CAP_LENGTH 12
 
hw/pci/pci-hotplug.c +10 -10
index 0ca5546..32ba449 100644
@@ -22,17 +22,17 @@
  * THE SOFTWARE.
  */
 
-#include "hw.h"
-#include "boards.h"
+#include <hw/hw.h>
+#include <hw/boards.h>
 #include "pci.h"
-#include "net.h"
-#include "pc.h"
-#include "monitor.h"
-#include "scsi.h"
-#include "virtio-blk.h"
-#include "qemu-config.h"
-#include "blockdev.h"
-#include "error.h"
+#include <net.h>
+#include <hw/pc.h>
+#include <monitor.h>
+#include <hw/scsi.h>
+#include <hw/virtio-blk.h>
+#include <qemu-config.h>
+#include <blockdev.h>
+#include <error.h>
 
 #if defined(TARGET_I386)
 static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
hw/pci/pci.c +8 -8
index 97a0cd7..6023ded 100644
@@ -21,19 +21,19 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include "hw.h"
+#include <hw/hw.h>
 #include "pci.h"
 #include "pci_bridge.h"
 #include "pci_internals.h"
-#include "monitor.h"
-#include "net.h"
-#include "sysemu.h"
-#include "loader.h"
-#include "range.h"
-#include "qmp-commands.h"
+#include <monitor.h>
+#include <net.h>
+#include <sysemu.h>
+#include <hw/loader.h>
+#include <range.h>
+#include <qmp-commands.h>
 #include "msi.h"
 #include "msix.h"
-#include "exec-memory.h"
+#include <exec-memory.h>
 
 //#define DEBUG_PCI
 #ifdef DEBUG_PCI
hw/pci/pci.h +5 -5
index 4da0c2a..b517995 100644
@@ -1,14 +1,14 @@
 #ifndef QEMU_PCI_H
 #define QEMU_PCI_H
 
-#include "qemu-common.h"
+#include <qemu-common.h>
 
-#include "qdev.h"
-#include "memory.h"
-#include "dma.h"
+#include <hw/qdev.h>
+#include <memory.h>
+#include <dma.h>
 
 /* PCI includes legacy ISA access.  */
-#include "isa.h"
+#include <hw/isa.h>
 
 #include "pcie.h"
 
hw/pci/pci_host.h +1 -1
index 4b9c300..6dfb38d 100644
@@ -28,7 +28,7 @@
 #ifndef PCI_HOST_H
 #define PCI_HOST_H
 
-#include "sysbus.h"
+#include <hw/sysbus.h>
 
 #define TYPE_PCI_HOST_BRIDGE "pci-host-bridge"
 #define PCI_HOST_BRIDGE(obj) \
hw/pci/pcie.h +1 -1
index 4889194..cc1f2c5 100644
@@ -21,7 +21,7 @@
 #ifndef QEMU_PCIE_H
 #define QEMU_PCIE_H
 
-#include "hw.h"
+#include <hw/hw.h>
 #include "pci_regs.h"
 #include "pcie_regs.h"
 #include "pcie_aer.h"
hw/pci/pcie_aer.h +1 -1
index 7539500..406a736 100644
@@ -21,7 +21,7 @@
 #ifndef QEMU_PCIE_AER_H
 #define QEMU_PCIE_AER_H
 
-#include "hw.h"
+#include <hw/hw.h>
 
 /* definitions which PCIExpressDevice uses */
 
hw/pci/pcie_host.c +2 -3
index c257fb4..4453cb0 100644
@@ -19,10 +19,10 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "hw.h"
+#include <hw/hw.h>
 #include "pci.h"
 #include "pcie_host.h"
-#include "exec-memory.h"
+#include <exec-memory.h>
 
 /*
  * PCI express mmcfig address
--

MST

#4 lore raw

Re: [Qemu-devel] [PATCH 3/8] pci: move pci core code to hw/pci

In reply to Michael S. Tsirkin
Quoted 2 lines · Michael S. Tsirkin

Move files and modify makefiles to pick them at the new location.

Please fix coding style before moving.

For easier review, please use git flag -M to detect renames.

Quoted 18,546 lines
---
 hw/Makefile.objs       |   10 +-
 hw/i386/Makefile.objs  |    2 +-
 hw/msi.c               |  395 ---------
 hw/msi.h               |   50 --
 hw/msix.c              |  562 -------------
 hw/msix.h              |   41 -
 hw/pci-hotplug.c       |  293 -------
 hw/pci-stub.c          |   47 --
 hw/pci.c               | 2168 ------------------------------------------------
 hw/pci.h               |  684 ---------------
 hw/pci/Makefile.objs   |    6 +
 hw/pci/msi.c           |  395 +++++++++
 hw/pci/msi.h           |   50 ++
 hw/pci/msix.c          |  562 +++++++++++++
 hw/pci/msix.h          |   41 +
 hw/pci/pci-hotplug.c   |  293 +++++++
 hw/pci/pci-stub.c      |   47 ++
 hw/pci/pci.c           | 2168 ++++++++++++++++++++++++++++++++++++++++++++++++
 hw/pci/pci.h           |  684 +++++++++++++++
 hw/pci/pci_bridge.c    |  363 ++++++++
 hw/pci/pci_bridge.h    |   66 ++
 hw/pci/pci_host.c      |  180 ++++
 hw/pci/pci_host.h      |   62 ++
 hw/pci/pci_ids.h       |  147 ++++
 hw/pci/pci_internals.h |   78 ++
 hw/pci/pci_regs.h      |  717 ++++++++++++++++
 hw/pci/pcie.c          |  555 +++++++++++++
 hw/pci/pcie.h          |  142 ++++
 hw/pci/pcie_aer.c      | 1032 +++++++++++++++++++++++
 hw/pci/pcie_aer.h      |  106 +++
 hw/pci/pcie_host.c     |  161 ++++
 hw/pci/pcie_host.h     |   54 ++
 hw/pci/pcie_port.c     |  114 +++
 hw/pci/pcie_port.h     |   51 ++
 hw/pci/pcie_regs.h     |  156 ++++
 hw/pci/shpc.c          |  681 +++++++++++++++
 hw/pci/shpc.h          |   48 ++
 hw/pci/slotid_cap.c    |   44 +
 hw/pci/slotid_cap.h    |   11 +
 hw/pci_bridge.c        |  363 --------
 hw/pci_bridge.h        |   66 --
 hw/pci_host.c          |  180 ----
 hw/pci_host.h          |   62 --
 hw/pci_ids.h           |  147 ----
 hw/pci_internals.h     |   78 --
 hw/pci_regs.h          |  717 ----------------
 hw/pcie.c              |  555 -------------
 hw/pcie.h              |  142 ----
 hw/pcie_aer.c          | 1032 -----------------------
 hw/pcie_aer.h          |  106 ---
 hw/pcie_host.c         |  161 ----
 hw/pcie_host.h         |   54 --
 hw/pcie_port.c         |  114 ---
 hw/pcie_port.h         |   51 --
 hw/pcie_regs.h         |  156 ----
 hw/ppc/Makefile.objs   |    2 +-
 hw/shpc.c              |  681 ---------------
 hw/shpc.h              |   48 --
 hw/slotid_cap.c        |   44 -
 hw/slotid_cap.h        |   11 -
 60 files changed, 9018 insertions(+), 9018 deletions(-)
 delete mode 100644 hw/msi.c
 delete mode 100644 hw/msi.h
 delete mode 100644 hw/msix.c
 delete mode 100644 hw/msix.h
 delete mode 100644 hw/pci-hotplug.c
 delete mode 100644 hw/pci-stub.c
 delete mode 100644 hw/pci.c
 delete mode 100644 hw/pci.h
 create mode 100644 hw/pci/Makefile.objs
 create mode 100644 hw/pci/msi.c
 create mode 100644 hw/pci/msi.h
 create mode 100644 hw/pci/msix.c
 create mode 100644 hw/pci/msix.h
 create mode 100644 hw/pci/pci-hotplug.c
 create mode 100644 hw/pci/pci-stub.c
 create mode 100644 hw/pci/pci.c
 create mode 100644 hw/pci/pci.h
 create mode 100644 hw/pci/pci_bridge.c
 create mode 100644 hw/pci/pci_bridge.h
 create mode 100644 hw/pci/pci_host.c
 create mode 100644 hw/pci/pci_host.h
 create mode 100644 hw/pci/pci_ids.h
 create mode 100644 hw/pci/pci_internals.h
 create mode 100644 hw/pci/pci_regs.h
 create mode 100644 hw/pci/pcie.c
 create mode 100644 hw/pci/pcie.h
 create mode 100644 hw/pci/pcie_aer.c
 create mode 100644 hw/pci/pcie_aer.h
 create mode 100644 hw/pci/pcie_host.c
 create mode 100644 hw/pci/pcie_host.h
 create mode 100644 hw/pci/pcie_port.c
 create mode 100644 hw/pci/pcie_port.h
 create mode 100644 hw/pci/pcie_regs.h
 create mode 100644 hw/pci/shpc.c
 create mode 100644 hw/pci/shpc.h
 create mode 100644 hw/pci/slotid_cap.c
 create mode 100644 hw/pci/slotid_cap.h
 delete mode 100644 hw/pci_bridge.c
 delete mode 100644 hw/pci_bridge.h
 delete mode 100644 hw/pci_host.c
 delete mode 100644 hw/pci_host.h
 delete mode 100644 hw/pci_ids.h
 delete mode 100644 hw/pci_internals.h
 delete mode 100644 hw/pci_regs.h
 delete mode 100644 hw/pcie.c
 delete mode 100644 hw/pcie.h
 delete mode 100644 hw/pcie_aer.c
 delete mode 100644 hw/pcie_aer.h
 delete mode 100644 hw/pcie_host.c
 delete mode 100644 hw/pcie_host.h
 delete mode 100644 hw/pcie_port.c
 delete mode 100644 hw/pcie_port.h
 delete mode 100644 hw/pcie_regs.h
 delete mode 100644 hw/shpc.c
 delete mode 100644 hw/shpc.h
 delete mode 100644 hw/slotid_cap.c
 delete mode 100644 hw/slotid_cap.h
hw/Makefile.objs +2 -8
index d581d8d..228acd6 100644
@@ -1,14 +1,10 @@
-common-obj-y = usb/ ide/
+common-obj-y = usb/ ide/ pci/
 common-obj-y += loader.o
 common-obj-$(CONFIG_VIRTIO) += virtio-console.o
 common-obj-$(CONFIG_VIRTIO) += virtio-rng.o
 common-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
 common-obj-y += fw_cfg.o
-common-obj-$(CONFIG_PCI) += pci.o pci_bridge.o pci_bridge_dev.o
-common-obj-$(CONFIG_PCI) += msix.o msi.o
-common-obj-$(CONFIG_PCI) += shpc.o
-common-obj-$(CONFIG_PCI) += slotid_cap.o
-common-obj-$(CONFIG_PCI) += pci_host.o pcie_host.o
+common-obj-$(CONFIG_PCI) += pci_bridge_dev.o
 common-obj-$(CONFIG_PCI) += ioh3420.o xio3130_upstream.o xio3130_downstream.o
 common-obj-$(CONFIG_PCI) += i82801b11.o
 common-obj-y += watchdog.o
@@ -102,8 +98,6 @@ common-obj-$(CONFIG_XGMAC) += xgmac.o
 # PCI watchdog devices
 common-obj-$(CONFIG_PCI) += wdt_i6300esb.o
 
-common-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
-
 # PCI network cards
 common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
 common-obj-$(CONFIG_EEPRO100_PCI) += eepro100.o
hw/i386/Makefile.objs +1 -1
index 0d3f6a8..257f3c1 100644
@@ -2,7 +2,7 @@ obj-y += mc146818rtc.o pc.o
 obj-y += apic_common.o apic.o kvmvapic.o
 obj-y += sga.o ioapic_common.o ioapic.o piix_pci.o
 obj-y += vmport.o
-obj-y += pci-hotplug.o smbios.o wdt_ib700.o
+obj-y += pci/pci-hotplug.o smbios.o wdt_ib700.o
 obj-y += debugcon.o multiboot.o
 obj-y += pc_piix.o
 obj-y += pc_sysfw.o
hw/msi.c deleted +0 -395
deleted file mode 100644
index 33037a8..0000000
@@ -1,395 +0,0 @@
-/*
- * msi.c
- *
- * Copyright (c) 2010 Isaku Yamahata <yamahata at valinux co jp>
- *                    VA Linux Systems Japan K.K.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "msi.h"
-#include "range.h"
-
-/* Eventually those constants should go to Linux pci_regs.h */
-#define PCI_MSI_PENDING_32      0x10
-#define PCI_MSI_PENDING_64      0x14
-
-/* PCI_MSI_ADDRESS_LO */
-#define PCI_MSI_ADDRESS_LO_MASK         (~0x3)
-
-/* If we get rid of cap allocator, we won't need those. */
-#define PCI_MSI_32_SIZEOF       0x0a
-#define PCI_MSI_64_SIZEOF       0x0e
-#define PCI_MSI_32M_SIZEOF      0x14
-#define PCI_MSI_64M_SIZEOF      0x18
-
-#define PCI_MSI_VECTORS_MAX     32
-
-/* Flag for interrupt controller to declare MSI/MSI-X support */
-bool msi_supported;
-
-/* If we get rid of cap allocator, we won't need this. */
-static inline uint8_t msi_cap_sizeof(uint16_t flags)
-{
-    switch (flags & (PCI_MSI_FLAGS_MASKBIT | PCI_MSI_FLAGS_64BIT)) {
-    case PCI_MSI_FLAGS_MASKBIT | PCI_MSI_FLAGS_64BIT:
-        return PCI_MSI_64M_SIZEOF;
-    case PCI_MSI_FLAGS_64BIT:
-        return PCI_MSI_64_SIZEOF;
-    case PCI_MSI_FLAGS_MASKBIT:
-        return PCI_MSI_32M_SIZEOF;
-    case 0:
-        return PCI_MSI_32_SIZEOF;
-    default:
-        abort();
-        break;
-    }
-    return 0;
-}
-
-//#define MSI_DEBUG
-
-#ifdef MSI_DEBUG
-# define MSI_DPRINTF(fmt, ...)                                          \
-    fprintf(stderr, "%s:%d " fmt, __func__, __LINE__, ## __VA_ARGS__)
-#else
-# define MSI_DPRINTF(fmt, ...)  do { } while (0)
-#endif
-#define MSI_DEV_PRINTF(dev, fmt, ...)                                   \
-    MSI_DPRINTF("%s:%x " fmt, (dev)->name, (dev)->devfn, ## __VA_ARGS__)
-
-static inline unsigned int msi_nr_vectors(uint16_t flags)
-{
-    return 1U <<
-        ((flags & PCI_MSI_FLAGS_QSIZE) >> (ffs(PCI_MSI_FLAGS_QSIZE) - 1));
-}
-
-static inline uint8_t msi_flags_off(const PCIDevice* dev)
-{
-    return dev->msi_cap + PCI_MSI_FLAGS;
-}
-
-static inline uint8_t msi_address_lo_off(const PCIDevice* dev)
-{
-    return dev->msi_cap + PCI_MSI_ADDRESS_LO;
-}
-
-static inline uint8_t msi_address_hi_off(const PCIDevice* dev)
-{
-    return dev->msi_cap + PCI_MSI_ADDRESS_HI;
-}
-
-static inline uint8_t msi_data_off(const PCIDevice* dev, bool msi64bit)
-{
-    return dev->msi_cap + (msi64bit ? PCI_MSI_DATA_64 : PCI_MSI_DATA_32);
-}
-
-static inline uint8_t msi_mask_off(const PCIDevice* dev, bool msi64bit)
-{
-    return dev->msi_cap + (msi64bit ? PCI_MSI_MASK_64 : PCI_MSI_MASK_32);
-}
-
-static inline uint8_t msi_pending_off(const PCIDevice* dev, bool msi64bit)
-{
-    return dev->msi_cap + (msi64bit ? PCI_MSI_PENDING_64 : PCI_MSI_PENDING_32);
-}
-
-/*
- * Special API for POWER to configure the vectors through
- * a side channel. Should never be used by devices.
- */
-void msi_set_message(PCIDevice *dev, MSIMessage msg)
-{
-    uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
-    bool msi64bit = flags & PCI_MSI_FLAGS_64BIT;
-
-    if (msi64bit) {
-        pci_set_quad(dev->config + msi_address_lo_off(dev), msg.address);
-    } else {
-        pci_set_long(dev->config + msi_address_lo_off(dev), msg.address);
-    }
-    pci_set_word(dev->config + msi_data_off(dev, msi64bit), msg.data);
-}
-
-MSIMessage msi_get_message(PCIDevice *dev, unsigned int vector)
-{
-    uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
-    bool msi64bit = flags & PCI_MSI_FLAGS_64BIT;
-    unsigned int nr_vectors = msi_nr_vectors(flags);
-    MSIMessage msg;
-
-    assert(vector < nr_vectors);
-
-    if (msi64bit) {
-        msg.address = pci_get_quad(dev->config + msi_address_lo_off(dev));
-    } else {
-        msg.address = pci_get_long(dev->config + msi_address_lo_off(dev));
-    }
-
-    /* upper bit 31:16 is zero */
-    msg.data = pci_get_word(dev->config + msi_data_off(dev, msi64bit));
-    if (nr_vectors > 1) {
-        msg.data &= ~(nr_vectors - 1);
-        msg.data |= vector;
-    }
-
-    return msg;
-}
-
-bool msi_enabled(const PCIDevice *dev)
-{
-    return msi_present(dev) &&
-        (pci_get_word(dev->config + msi_flags_off(dev)) &
-         PCI_MSI_FLAGS_ENABLE);
-}
-
-int msi_init(struct PCIDevice *dev, uint8_t offset,
-             unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask)
-{
-    unsigned int vectors_order;
-    uint16_t flags;
-    uint8_t cap_size;
-    int config_offset;
-
-    if (!msi_supported) {
-        return -ENOTSUP;
-    }
-
-    MSI_DEV_PRINTF(dev,
-                   "init offset: 0x%"PRIx8" vector: %"PRId8
-                   " 64bit %d mask %d\n",
-                   offset, nr_vectors, msi64bit, msi_per_vector_mask);
-
-    assert(!(nr_vectors & (nr_vectors - 1)));   /* power of 2 */
-    assert(nr_vectors > 0);
-    assert(nr_vectors <= PCI_MSI_VECTORS_MAX);
-    /* the nr of MSI vectors is up to 32 */
-    vectors_order = ffs(nr_vectors) - 1;
-
-    flags = vectors_order << (ffs(PCI_MSI_FLAGS_QMASK) - 1);
-    if (msi64bit) {
-        flags |= PCI_MSI_FLAGS_64BIT;
-    }
-    if (msi_per_vector_mask) {
-        flags |= PCI_MSI_FLAGS_MASKBIT;
-    }
-
-    cap_size = msi_cap_sizeof(flags);
-    config_offset = pci_add_capability(dev, PCI_CAP_ID_MSI, offset, cap_size);
-    if (config_offset < 0) {
-        return config_offset;
-    }
-
-    dev->msi_cap = config_offset;
-    dev->cap_present |= QEMU_PCI_CAP_MSI;
-
-    pci_set_word(dev->config + msi_flags_off(dev), flags);
-    pci_set_word(dev->wmask + msi_flags_off(dev),
-                 PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);
-    pci_set_long(dev->wmask + msi_address_lo_off(dev),
-                 PCI_MSI_ADDRESS_LO_MASK);
-    if (msi64bit) {
-        pci_set_long(dev->wmask + msi_address_hi_off(dev), 0xffffffff);
-    }
-    pci_set_word(dev->wmask + msi_data_off(dev, msi64bit), 0xffff);
-
-    if (msi_per_vector_mask) {
-        /* Make mask bits 0 to nr_vectors - 1 writable. */
-        pci_set_long(dev->wmask + msi_mask_off(dev, msi64bit),
-                     0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors));
-    }
-    return config_offset;
-}
-
-void msi_uninit(struct PCIDevice *dev)
-{
-    uint16_t flags;
-    uint8_t cap_size;
-
-    if (!msi_present(dev)) {
-        return;
-    }
-    flags = pci_get_word(dev->config + msi_flags_off(dev));
-    cap_size = msi_cap_sizeof(flags);
-    pci_del_capability(dev, PCI_CAP_ID_MSI, cap_size);
-    dev->cap_present &= ~QEMU_PCI_CAP_MSI;
-
-    MSI_DEV_PRINTF(dev, "uninit\n");
-}
-
-void msi_reset(PCIDevice *dev)
-{
-    uint16_t flags;
-    bool msi64bit;
-
-    if (!msi_present(dev)) {
-        return;
-    }
-
-    flags = pci_get_word(dev->config + msi_flags_off(dev));
-    flags &= ~(PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);
-    msi64bit = flags & PCI_MSI_FLAGS_64BIT;
-
-    pci_set_word(dev->config + msi_flags_off(dev), flags);
-    pci_set_long(dev->config + msi_address_lo_off(dev), 0);
-    if (msi64bit) {
-        pci_set_long(dev->config + msi_address_hi_off(dev), 0);
-    }
-    pci_set_word(dev->config + msi_data_off(dev, msi64bit), 0);
-    if (flags & PCI_MSI_FLAGS_MASKBIT) {
-        pci_set_long(dev->config + msi_mask_off(dev, msi64bit), 0);
-        pci_set_long(dev->config + msi_pending_off(dev, msi64bit), 0);
-    }
-    MSI_DEV_PRINTF(dev, "reset\n");
-}
-
-static bool msi_is_masked(const PCIDevice *dev, unsigned int vector)
-{
-    uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
-    uint32_t mask;
-    assert(vector < PCI_MSI_VECTORS_MAX);
-
-    if (!(flags & PCI_MSI_FLAGS_MASKBIT)) {
-        return false;
-    }
-
-    mask = pci_get_long(dev->config +
-                        msi_mask_off(dev, flags & PCI_MSI_FLAGS_64BIT));
-    return mask & (1U << vector);
-}
-
-void msi_notify(PCIDevice *dev, unsigned int vector)
-{
-    uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
-    bool msi64bit = flags & PCI_MSI_FLAGS_64BIT;
-    unsigned int nr_vectors = msi_nr_vectors(flags);
-    MSIMessage msg;
-
-    assert(vector < nr_vectors);
-    if (msi_is_masked(dev, vector)) {
-        assert(flags & PCI_MSI_FLAGS_MASKBIT);
-        pci_long_test_and_set_mask(
-            dev->config + msi_pending_off(dev, msi64bit), 1U << vector);
-        MSI_DEV_PRINTF(dev, "pending vector 0x%x\n", vector);
-        return;
-    }
-
-    msg = msi_get_message(dev, vector);
-
-    MSI_DEV_PRINTF(dev,
-                   "notify vector 0x%x"
-                   " address: 0x%"PRIx64" data: 0x%"PRIx32"\n",
-                   vector, msg.address, msg.data);
-    stl_le_phys(msg.address, msg.data);
-}
-
-/* Normally called by pci_default_write_config(). */
-void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len)
-{
-    uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
-    bool msi64bit = flags & PCI_MSI_FLAGS_64BIT;
-    bool msi_per_vector_mask = flags & PCI_MSI_FLAGS_MASKBIT;
-    unsigned int nr_vectors;
-    uint8_t log_num_vecs;
-    uint8_t log_max_vecs;
-    unsigned int vector;
-    uint32_t pending;
-
-    if (!msi_present(dev) ||
-        !ranges_overlap(addr, len, dev->msi_cap, msi_cap_sizeof(flags))) {
-        return;
-    }
-
-#ifdef MSI_DEBUG
-    MSI_DEV_PRINTF(dev, "addr 0x%"PRIx32" val 0x%"PRIx32" len %d\n",
-                   addr, val, len);
-    MSI_DEV_PRINTF(dev, "ctrl: 0x%"PRIx16" address: 0x%"PRIx32,
-                   flags,
-                   pci_get_long(dev->config + msi_address_lo_off(dev)));
-    if (msi64bit) {
-        fprintf(stderr, " address-hi: 0x%"PRIx32,
-                pci_get_long(dev->config + msi_address_hi_off(dev)));
-    }
-    fprintf(stderr, " data: 0x%"PRIx16,
-            pci_get_word(dev->config + msi_data_off(dev, msi64bit)));
-    if (flags & PCI_MSI_FLAGS_MASKBIT) {
-        fprintf(stderr, " mask 0x%"PRIx32" pending 0x%"PRIx32,
-                pci_get_long(dev->config + msi_mask_off(dev, msi64bit)),
-                pci_get_long(dev->config + msi_pending_off(dev, msi64bit)));
-    }
-    fprintf(stderr, "\n");
-#endif
-
-    if (!(flags & PCI_MSI_FLAGS_ENABLE)) {
-        return;
-    }
-
-    /*
-     * Now MSI is enabled, clear INTx# interrupts.
-     * the driver is prohibited from writing enable bit to mask
-     * a service request. But the guest OS could do this.
-     * So we just discard the interrupts as moderate fallback.
-     *
-     * 6.8.3.3. Enabling Operation
-     *   While enabled for MSI or MSI-X operation, a function is prohibited
-     *   from using its INTx# pin (if implemented) to request
-     *   service (MSI, MSI-X, and INTx# are mutually exclusive).
-     */
-    pci_device_deassert_intx(dev);
-
-    /*
-     * nr_vectors might be set bigger than capable. So clamp it.
-     * This is not legal by spec, so we can do anything we like,
-     * just don't crash the host
-     */
-    log_num_vecs =
-        (flags & PCI_MSI_FLAGS_QSIZE) >> (ffs(PCI_MSI_FLAGS_QSIZE) - 1);
-    log_max_vecs =
-        (flags & PCI_MSI_FLAGS_QMASK) >> (ffs(PCI_MSI_FLAGS_QMASK) - 1);
-    if (log_num_vecs > log_max_vecs) {
-        flags &= ~PCI_MSI_FLAGS_QSIZE;
-        flags |= log_max_vecs << (ffs(PCI_MSI_FLAGS_QSIZE) - 1);
-        pci_set_word(dev->config + msi_flags_off(dev), flags);
-    }
-
-    if (!msi_per_vector_mask) {
-        /* if per vector masking isn't supported,
-           there is no pending interrupt. */
-        return;
-    }
-
-    nr_vectors = msi_nr_vectors(flags);
-
-    /* This will discard pending interrupts, if any. */
-    pending = pci_get_long(dev->config + msi_pending_off(dev, msi64bit));
-    pending &= 0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors);
-    pci_set_long(dev->config + msi_pending_off(dev, msi64bit), pending);
-
-    /* deliver pending interrupts which are unmasked */
-    for (vector = 0; vector < nr_vectors; ++vector) {
-        if (msi_is_masked(dev, vector) || !(pending & (1U << vector))) {
-            continue;
-        }
-
-        pci_long_test_and_clear_mask(
-            dev->config + msi_pending_off(dev, msi64bit), 1U << vector);
-        msi_notify(dev, vector);
-    }
-}
-
-unsigned int msi_nr_vectors_allocated(const PCIDevice *dev)
-{
-    uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
-    return msi_nr_vectors(flags);
-}
hw/msi.h deleted +0 -50
deleted file mode 100644
index 150b09a..0000000
@@ -1,50 +0,0 @@
-/*
- * msi.h
- *
- * Copyright (c) 2010 Isaku Yamahata <yamahata at valinux co jp>
- *                    VA Linux Systems Japan K.K.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef QEMU_MSI_H
-#define QEMU_MSI_H
-
-#include "qemu-common.h"
-#include "pci.h"
-
-struct MSIMessage {
-    uint64_t address;
-    uint32_t data;
-};
-
-extern bool msi_supported;
-
-void msi_set_message(PCIDevice *dev, MSIMessage msg);
-MSIMessage msi_get_message(PCIDevice *dev, unsigned int vector);
-bool msi_enabled(const PCIDevice *dev);
-int msi_init(struct PCIDevice *dev, uint8_t offset,
-             unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask);
-void msi_uninit(struct PCIDevice *dev);
-void msi_reset(PCIDevice *dev);
-void msi_notify(PCIDevice *dev, unsigned int vector);
-void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len);
-unsigned int msi_nr_vectors_allocated(const PCIDevice *dev);
-
-static inline bool msi_present(const PCIDevice *dev)
-{
-    return dev->cap_present & QEMU_PCI_CAP_MSI;
-}
-
-#endif /* QEMU_MSI_H */
hw/msix.c deleted +0 -562
deleted file mode 100644
index 136ef09..0000000
@@ -1,562 +0,0 @@
-/*
- * MSI-X device support
- *
- * This module includes support for MSI-X in pci devices.
- *
- * Author: Michael S. Tsirkin <[email protected]>
- *
- *  Copyright (c) 2009, Red Hat Inc, Michael S. Tsirkin ([email protected])
- *
- * This work is licensed under the terms of the GNU GPL, version 2.  See
- * the COPYING file in the top-level directory.
- *
- * Contributions after 2012-01-13 are licensed under the terms of the
- * GNU GPL, version 2 or (at your option) any later version.
- */
-
-#include "hw.h"
-#include "msi.h"
-#include "msix.h"
-#include "pci.h"
-#include "range.h"
-
-#define MSIX_CAP_LENGTH 12
-
-/* MSI enable bit and maskall bit are in byte 1 in FLAGS register */
-#define MSIX_CONTROL_OFFSET (PCI_MSIX_FLAGS + 1)
-#define MSIX_ENABLE_MASK (PCI_MSIX_FLAGS_ENABLE >> 8)
-#define MSIX_MASKALL_MASK (PCI_MSIX_FLAGS_MASKALL >> 8)
-
-static MSIMessage msix_get_message(PCIDevice *dev, unsigned vector)
-{
-    uint8_t *table_entry = dev->msix_table + vector * PCI_MSIX_ENTRY_SIZE;
-    MSIMessage msg;
-
-    msg.address = pci_get_quad(table_entry + PCI_MSIX_ENTRY_LOWER_ADDR);
-    msg.data = pci_get_long(table_entry + PCI_MSIX_ENTRY_DATA);
-    return msg;
-}
-
-/*
- * Special API for POWER to configure the vectors through
- * a side channel. Should never be used by devices.
- */
-void msix_set_message(PCIDevice *dev, int vector, struct MSIMessage msg)
-{
-    uint8_t *table_entry = dev->msix_table + vector * PCI_MSIX_ENTRY_SIZE;
-
-    pci_set_quad(table_entry + PCI_MSIX_ENTRY_LOWER_ADDR, msg.address);
-    pci_set_long(table_entry + PCI_MSIX_ENTRY_DATA, msg.data);
-    table_entry[PCI_MSIX_ENTRY_VECTOR_CTRL] &= ~PCI_MSIX_ENTRY_CTRL_MASKBIT;
-}
-
-static uint8_t msix_pending_mask(int vector)
-{
-    return 1 << (vector % 8);
-}
-
-static uint8_t *msix_pending_byte(PCIDevice *dev, int vector)
-{
-    return dev->msix_pba + vector / 8;
-}
-
-static int msix_is_pending(PCIDevice *dev, int vector)
-{
-    return *msix_pending_byte(dev, vector) & msix_pending_mask(vector);
-}
-
-static void msix_set_pending(PCIDevice *dev, int vector)
-{
-    *msix_pending_byte(dev, vector) |= msix_pending_mask(vector);
-}
-
-static void msix_clr_pending(PCIDevice *dev, int vector)
-{
-    *msix_pending_byte(dev, vector) &= ~msix_pending_mask(vector);
-}
-
-static bool msix_vector_masked(PCIDevice *dev, int vector, bool fmask)
-{
-    unsigned offset = vector * PCI_MSIX_ENTRY_SIZE + PCI_MSIX_ENTRY_VECTOR_CTRL;
-    return fmask || dev->msix_table[offset] & PCI_MSIX_ENTRY_CTRL_MASKBIT;
-}
-
-static bool msix_is_masked(PCIDevice *dev, int vector)
-{
-    return msix_vector_masked(dev, vector, dev->msix_function_masked);
-}
-
-static void msix_fire_vector_notifier(PCIDevice *dev,
-                                      unsigned int vector, bool is_masked)
-{
-    MSIMessage msg;
-    int ret;
-
-    if (!dev->msix_vector_use_notifier) {
-        return;
-    }
-    if (is_masked) {
-        dev->msix_vector_release_notifier(dev, vector);
-    } else {
-        msg = msix_get_message(dev, vector);
-        ret = dev->msix_vector_use_notifier(dev, vector, msg);
-        assert(ret >= 0);
-    }
-}
-
-static void msix_handle_mask_update(PCIDevice *dev, int vector, bool was_masked)
-{
-    bool is_masked = msix_is_masked(dev, vector);
-
-    if (is_masked == was_masked) {
-        return;
-    }
-
-    msix_fire_vector_notifier(dev, vector, is_masked);
-
-    if (!is_masked && msix_is_pending(dev, vector)) {
-        msix_clr_pending(dev, vector);
-        msix_notify(dev, vector);
-    }
-}
-
-static void msix_update_function_masked(PCIDevice *dev)
-{
-    dev->msix_function_masked = !msix_enabled(dev) ||
-        (dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] & MSIX_MASKALL_MASK);
-}
-
-/* Handle MSI-X capability config write. */
-void msix_write_config(PCIDevice *dev, uint32_t addr,
-                       uint32_t val, int len)
-{
-    unsigned enable_pos = dev->msix_cap + MSIX_CONTROL_OFFSET;
-    int vector;
-    bool was_masked;
-
-    if (!msix_present(dev) || !range_covers_byte(addr, len, enable_pos)) {
-        return;
-    }
-
-    was_masked = dev->msix_function_masked;
-    msix_update_function_masked(dev);
-
-    if (!msix_enabled(dev)) {
-        return;
-    }
-
-    pci_device_deassert_intx(dev);
-
-    if (dev->msix_function_masked == was_masked) {
-        return;
-    }
-
-    for (vector = 0; vector < dev->msix_entries_nr; ++vector) {
-        msix_handle_mask_update(dev, vector,
-                                msix_vector_masked(dev, vector, was_masked));
-    }
-}
-
-static uint64_t msix_table_mmio_read(void *opaque, hwaddr addr,
-                                     unsigned size)
-{
-    PCIDevice *dev = opaque;
-
-    return pci_get_long(dev->msix_table + addr);
-}
-
-static void msix_table_mmio_write(void *opaque, hwaddr addr,
-                                  uint64_t val, unsigned size)
-{
-    PCIDevice *dev = opaque;
-    int vector = addr / PCI_MSIX_ENTRY_SIZE;
-    bool was_masked;
-
-    was_masked = msix_is_masked(dev, vector);
-    pci_set_long(dev->msix_table + addr, val);
-    msix_handle_mask_update(dev, vector, was_masked);
-}
-
-static const MemoryRegionOps msix_table_mmio_ops = {
-    .read = msix_table_mmio_read,
-    .write = msix_table_mmio_write,
-    /* TODO: MSIX should be LITTLE_ENDIAN. */
-    .endianness = DEVICE_NATIVE_ENDIAN,
-    .valid = {
-        .min_access_size = 4,
-        .max_access_size = 4,
-    },
-};
-
-static uint64_t msix_pba_mmio_read(void *opaque, hwaddr addr,
-                                   unsigned size)
-{
-    PCIDevice *dev = opaque;
-
-    return pci_get_long(dev->msix_pba + addr);
-}
-
-static const MemoryRegionOps msix_pba_mmio_ops = {
-    .read = msix_pba_mmio_read,
-    /* TODO: MSIX should be LITTLE_ENDIAN. */
-    .endianness = DEVICE_NATIVE_ENDIAN,
-    .valid = {
-        .min_access_size = 4,
-        .max_access_size = 4,
-    },
-};
-
-static void msix_mask_all(struct PCIDevice *dev, unsigned nentries)
-{
-    int vector;
-
-    for (vector = 0; vector < nentries; ++vector) {
-        unsigned offset =
-            vector * PCI_MSIX_ENTRY_SIZE + PCI_MSIX_ENTRY_VECTOR_CTRL;
-        bool was_masked = msix_is_masked(dev, vector);
-
-        dev->msix_table[offset] |= PCI_MSIX_ENTRY_CTRL_MASKBIT;
-        msix_handle_mask_update(dev, vector, was_masked);
-    }
-}
-
-/* Initialize the MSI-X structures */
-int msix_init(struct PCIDevice *dev, unsigned short nentries,
-              MemoryRegion *table_bar, uint8_t table_bar_nr,
-              unsigned table_offset, MemoryRegion *pba_bar,
-              uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos)
-{
-    int cap;
-    unsigned table_size, pba_size;
-    uint8_t *config;
-
-    /* Nothing to do if MSI is not supported by interrupt controller */
-    if (!msi_supported) {
-        return -ENOTSUP;
-    }
-
-    if (nentries < 1 || nentries > PCI_MSIX_FLAGS_QSIZE + 1) {
-        return -EINVAL;
-    }
-
-    table_size = nentries * PCI_MSIX_ENTRY_SIZE;
-    pba_size = QEMU_ALIGN_UP(nentries, 64) / 8;
-
-    /* Sanity test: table & pba don't overlap, fit within BARs, min aligned */
-    if ((table_bar_nr == pba_bar_nr &&
-         ranges_overlap(table_offset, table_size, pba_offset, pba_size)) ||
-        table_offset + table_size > memory_region_size(table_bar) ||
-        pba_offset + pba_size > memory_region_size(pba_bar) ||
-        (table_offset | pba_offset) & PCI_MSIX_FLAGS_BIRMASK) {
-        return -EINVAL;
-    }
-
-    cap = pci_add_capability(dev, PCI_CAP_ID_MSIX, cap_pos, MSIX_CAP_LENGTH);
-    if (cap < 0) {
-        return cap;
-    }
-
-    dev->msix_cap = cap;
-    dev->cap_present |= QEMU_PCI_CAP_MSIX;
-    config = dev->config + cap;
-
-    pci_set_word(config + PCI_MSIX_FLAGS, nentries - 1);
-    dev->msix_entries_nr = nentries;
-    dev->msix_function_masked = true;
-
-    pci_set_long(config + PCI_MSIX_TABLE, table_offset | table_bar_nr);
-    pci_set_long(config + PCI_MSIX_PBA, pba_offset | pba_bar_nr);
-
-    /* Make flags bit writable. */
-    dev->wmask[cap + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK |
-                                             MSIX_MASKALL_MASK;
-
-    dev->msix_table = g_malloc0(table_size);
-    dev->msix_pba = g_malloc0(pba_size);
-    dev->msix_entry_used = g_malloc0(nentries * sizeof *dev->msix_entry_used);
-
-    msix_mask_all(dev, nentries);
-
-    memory_region_init_io(&dev->msix_table_mmio, &msix_table_mmio_ops, dev,
-                          "msix-table", table_size);
-    memory_region_add_subregion(table_bar, table_offset, &dev->msix_table_mmio);
-    memory_region_init_io(&dev->msix_pba_mmio, &msix_pba_mmio_ops, dev,
-                          "msix-pba", pba_size);
-    memory_region_add_subregion(pba_bar, pba_offset, &dev->msix_pba_mmio);
-
-    return 0;
-}
-
-int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
-                            uint8_t bar_nr)
-{
-    int ret;
-    char *name;
-
-    /*
-     * Migration compatibility dictates that this remains a 4k
-     * BAR with the vector table in the lower half and PBA in
-     * the upper half.  Do not use these elsewhere!
-     */
-#define MSIX_EXCLUSIVE_BAR_SIZE 4096
-#define MSIX_EXCLUSIVE_BAR_TABLE_OFFSET 0
-#define MSIX_EXCLUSIVE_BAR_PBA_OFFSET (MSIX_EXCLUSIVE_BAR_SIZE / 2)
-#define MSIX_EXCLUSIVE_CAP_OFFSET 0
-
-    if (nentries * PCI_MSIX_ENTRY_SIZE > MSIX_EXCLUSIVE_BAR_PBA_OFFSET) {
-        return -EINVAL;
-    }
-
-    name = g_strdup_printf("%s-msix", dev->name);
-    memory_region_init(&dev->msix_exclusive_bar, name, MSIX_EXCLUSIVE_BAR_SIZE);
-    g_free(name);
-
-    ret = msix_init(dev, nentries, &dev->msix_exclusive_bar, bar_nr,
-                    MSIX_EXCLUSIVE_BAR_TABLE_OFFSET, &dev->msix_exclusive_bar,
-                    bar_nr, MSIX_EXCLUSIVE_BAR_PBA_OFFSET,
-                    MSIX_EXCLUSIVE_CAP_OFFSET);
-    if (ret) {
-        memory_region_destroy(&dev->msix_exclusive_bar);
-        return ret;
-    }
-
-    pci_register_bar(dev, bar_nr, PCI_BASE_ADDRESS_SPACE_MEMORY,
-                     &dev->msix_exclusive_bar);
-
-    return 0;
-}
-
-static void msix_free_irq_entries(PCIDevice *dev)
-{
-    int vector;
-
-    for (vector = 0; vector < dev->msix_entries_nr; ++vector) {
-        dev->msix_entry_used[vector] = 0;
-        msix_clr_pending(dev, vector);
-    }
-}
-
-static void msix_clear_all_vectors(PCIDevice *dev)
-{
-    int vector;
-
-    for (vector = 0; vector < dev->msix_entries_nr; ++vector) {
-        msix_clr_pending(dev, vector);
-    }
-}
-
-/* Clean up resources for the device. */
-void msix_uninit(PCIDevice *dev, MemoryRegion *table_bar, MemoryRegion *pba_bar)
-{
-    if (!msix_present(dev)) {
-        return;
-    }
-    pci_del_capability(dev, PCI_CAP_ID_MSIX, MSIX_CAP_LENGTH);
-    dev->msix_cap = 0;
-    msix_free_irq_entries(dev);
-    dev->msix_entries_nr = 0;
-    memory_region_del_subregion(pba_bar, &dev->msix_pba_mmio);
-    memory_region_destroy(&dev->msix_pba_mmio);
-    g_free(dev->msix_pba);
-    dev->msix_pba = NULL;
-    memory_region_del_subregion(table_bar, &dev->msix_table_mmio);
-    memory_region_destroy(&dev->msix_table_mmio);
-    g_free(dev->msix_table);
-    dev->msix_table = NULL;
-    g_free(dev->msix_entry_used);
-    dev->msix_entry_used = NULL;
-    dev->cap_present &= ~QEMU_PCI_CAP_MSIX;
-}
-
-void msix_uninit_exclusive_bar(PCIDevice *dev)
-{
-    if (msix_present(dev)) {
-        msix_uninit(dev, &dev->msix_exclusive_bar, &dev->msix_exclusive_bar);
-        memory_region_destroy(&dev->msix_exclusive_bar);
-    }
-}
-
-void msix_save(PCIDevice *dev, QEMUFile *f)
-{
-    unsigned n = dev->msix_entries_nr;
-
-    if (!msix_present(dev)) {
-        return;
-    }
-
-    qemu_put_buffer(f, dev->msix_table, n * PCI_MSIX_ENTRY_SIZE);
-    qemu_put_buffer(f, dev->msix_pba, (n + 7) / 8);
-}
-
-/* Should be called after restoring the config space. */
-void msix_load(PCIDevice *dev, QEMUFile *f)
-{
-    unsigned n = dev->msix_entries_nr;
-    unsigned int vector;
-
-    if (!msix_present(dev)) {
-        return;
-    }
-
-    msix_clear_all_vectors(dev);
-    qemu_get_buffer(f, dev->msix_table, n * PCI_MSIX_ENTRY_SIZE);
-    qemu_get_buffer(f, dev->msix_pba, (n + 7) / 8);
-    msix_update_function_masked(dev);
-
-    for (vector = 0; vector < n; vector++) {
-        msix_handle_mask_update(dev, vector, true);
-    }
-}
-
-/* Does device support MSI-X? */
-int msix_present(PCIDevice *dev)
-{
-    return dev->cap_present & QEMU_PCI_CAP_MSIX;
-}
-
-/* Is MSI-X enabled? */
-int msix_enabled(PCIDevice *dev)
-{
-    return (dev->cap_present & QEMU_PCI_CAP_MSIX) &&
-        (dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &
-         MSIX_ENABLE_MASK);
-}
-
-/* Send an MSI-X message */
-void msix_notify(PCIDevice *dev, unsigned vector)
-{
-    MSIMessage msg;
-
-    if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])
-        return;
-    if (msix_is_masked(dev, vector)) {
-        msix_set_pending(dev, vector);
-        return;
-    }
-
-    msg = msix_get_message(dev, vector);
-
-    stl_le_phys(msg.address, msg.data);
-}
-
-void msix_reset(PCIDevice *dev)
-{
-    if (!msix_present(dev)) {
-        return;
-    }
-    msix_clear_all_vectors(dev);
-    dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &=
-           ~dev->wmask[dev->msix_cap + MSIX_CONTROL_OFFSET];
-    memset(dev->msix_table, 0, dev->msix_entries_nr * PCI_MSIX_ENTRY_SIZE);
-    memset(dev->msix_pba, 0, QEMU_ALIGN_UP(dev->msix_entries_nr, 64) / 8);
-    msix_mask_all(dev, dev->msix_entries_nr);
-}
-
-/* PCI spec suggests that devices make it possible for software to configure
- * less vectors than supported by the device, but does not specify a standard
- * mechanism for devices to do so.
- *
- * We support this by asking devices to declare vectors software is going to
- * actually use, and checking this on the notification path. Devices that
- * don't want to follow the spec suggestion can declare all vectors as used. */
-
-/* Mark vector as used. */
-int msix_vector_use(PCIDevice *dev, unsigned vector)
-{
-    if (vector >= dev->msix_entries_nr)
-        return -EINVAL;
-    dev->msix_entry_used[vector]++;
-    return 0;
-}
-
-/* Mark vector as unused. */
-void msix_vector_unuse(PCIDevice *dev, unsigned vector)
-{
-    if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector]) {
-        return;
-    }
-    if (--dev->msix_entry_used[vector]) {
-        return;
-    }
-    msix_clr_pending(dev, vector);
-}
-
-void msix_unuse_all_vectors(PCIDevice *dev)
-{
-    if (!msix_present(dev)) {
-        return;
-    }
-    msix_free_irq_entries(dev);
-}
-
-unsigned int msix_nr_vectors_allocated(const PCIDevice *dev)
-{
-    return dev->msix_entries_nr;
-}
-
-static int msix_set_notifier_for_vector(PCIDevice *dev, unsigned int vector)
-{
-    MSIMessage msg;
-
-    if (msix_is_masked(dev, vector)) {
-        return 0;
-    }
-    msg = msix_get_message(dev, vector);
-    return dev->msix_vector_use_notifier(dev, vector, msg);
-}
-
-static void msix_unset_notifier_for_vector(PCIDevice *dev, unsigned int vector)
-{
-    if (msix_is_masked(dev, vector)) {
-        return;
-    }
-    dev->msix_vector_release_notifier(dev, vector);
-}
-
-int msix_set_vector_notifiers(PCIDevice *dev,
-                              MSIVectorUseNotifier use_notifier,
-                              MSIVectorReleaseNotifier release_notifier)
-{
-    int vector, ret;
-
-    assert(use_notifier && release_notifier);
-
-    dev->msix_vector_use_notifier = use_notifier;
-    dev->msix_vector_release_notifier = release_notifier;
-
-    if ((dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &
-        (MSIX_ENABLE_MASK | MSIX_MASKALL_MASK)) == MSIX_ENABLE_MASK) {
-        for (vector = 0; vector < dev->msix_entries_nr; vector++) {
-            ret = msix_set_notifier_for_vector(dev, vector);
-            if (ret < 0) {
-                goto undo;
-            }
-        }
-    }
-    return 0;
-
-undo:
-    while (--vector >= 0) {
-        msix_unset_notifier_for_vector(dev, vector);
-    }
-    dev->msix_vector_use_notifier = NULL;
-    dev->msix_vector_release_notifier = NULL;
-    return ret;
-}
-
-void msix_unset_vector_notifiers(PCIDevice *dev)
-{
-    int vector;
-
-    assert(dev->msix_vector_use_notifier &&
-           dev->msix_vector_release_notifier);
-
-    if ((dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &
-        (MSIX_ENABLE_MASK | MSIX_MASKALL_MASK)) == MSIX_ENABLE_MASK) {
-        for (vector = 0; vector < dev->msix_entries_nr; vector++) {
-            msix_unset_notifier_for_vector(dev, vector);
-        }
-    }
-    dev->msix_vector_use_notifier = NULL;
-    dev->msix_vector_release_notifier = NULL;
-}
hw/msix.h deleted +0 -41
deleted file mode 100644
index 15211cb..0000000
@@ -1,41 +0,0 @@
-#ifndef QEMU_MSIX_H
-#define QEMU_MSIX_H
-
-#include "qemu-common.h"
-#include "pci.h"
-
-void msix_set_message(PCIDevice *dev, int vector, MSIMessage msg);
-int msix_init(PCIDevice *dev, unsigned short nentries,
-              MemoryRegion *table_bar, uint8_t table_bar_nr,
-              unsigned table_offset, MemoryRegion *pba_bar,
-              uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos);
-int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
-                            uint8_t bar_nr);
-
-void msix_write_config(PCIDevice *dev, uint32_t address, uint32_t val, int len);
-
-void msix_uninit(PCIDevice *dev, MemoryRegion *table_bar,
-                 MemoryRegion *pba_bar);
-void msix_uninit_exclusive_bar(PCIDevice *dev);
-
-unsigned int msix_nr_vectors_allocated(const PCIDevice *dev);
-
-void msix_save(PCIDevice *dev, QEMUFile *f);
-void msix_load(PCIDevice *dev, QEMUFile *f);
-
-int msix_enabled(PCIDevice *dev);
-int msix_present(PCIDevice *dev);
-
-int msix_vector_use(PCIDevice *dev, unsigned vector);
-void msix_vector_unuse(PCIDevice *dev, unsigned vector);
-void msix_unuse_all_vectors(PCIDevice *dev);
-
-void msix_notify(PCIDevice *dev, unsigned vector);
-
-void msix_reset(PCIDevice *dev);
-
-int msix_set_vector_notifiers(PCIDevice *dev,
-                              MSIVectorUseNotifier use_notifier,
-                              MSIVectorReleaseNotifier release_notifier);
-void msix_unset_vector_notifiers(PCIDevice *dev);
-#endif
hw/pci-hotplug.c deleted +0 -293
deleted file mode 100644
index 0ca5546..0000000
@@ -1,293 +0,0 @@
-/*
- * QEMU PCI hotplug support
- *
- * Copyright (c) 2004 Fabrice Bellard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "hw.h"
-#include "boards.h"
-#include "pci.h"
-#include "net.h"
-#include "pc.h"
-#include "monitor.h"
-#include "scsi.h"
-#include "virtio-blk.h"
-#include "qemu-config.h"
-#include "blockdev.h"
-#include "error.h"
-
-#if defined(TARGET_I386)
-static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
-                                       const char *devaddr,
-                                       const char *opts_str)
-{
-    Error *local_err = NULL;
-    QemuOpts *opts;
-    PCIBus *bus;
-    int ret, devfn;
-
-    bus = pci_get_bus_devfn(&devfn, devaddr);
-    if (!bus) {
-        monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
-        return NULL;
-    }
-    if (!((BusState*)bus)->allow_hotplug) {
-        monitor_printf(mon, "PCI bus doesn't support hotplug\n");
-        return NULL;
-    }
-
-    opts = qemu_opts_parse(qemu_find_opts("net"), opts_str ? opts_str : "", 0);
-    if (!opts) {
-        return NULL;
-    }
-
-    qemu_opt_set(opts, "type", "nic");
-
-    ret = net_client_init(opts, 0, &local_err);
-    if (error_is_set(&local_err)) {
-        qerror_report_err(local_err);
-        error_free(local_err);
-        return NULL;
-    }
-    if (nd_table[ret].devaddr) {
-        monitor_printf(mon, "Parameter addr not supported\n");
-        return NULL;
-    }
-    return pci_nic_init(&nd_table[ret], "rtl8139", devaddr);
-}
-
-static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
-                        DriveInfo *dinfo, int printinfo)
-{
-    SCSIBus *scsibus;
-    SCSIDevice *scsidev;
-
-    scsibus = (SCSIBus *)
-        object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
-                            TYPE_SCSI_BUS);
-    if (!scsibus) {
-       error_report("Device is not a SCSI adapter");
-       return -1;
-    }
-
-    /*
-     * drive_init() tries to find a default for dinfo->unit.  Doesn't
-     * work at all for hotplug though as we assign the device to a
-     * specific bus instead of the first bus with spare scsi ids.
-     *
-     * Ditch the calculated value and reload from option string (if
-     * specified).
-     */
-    dinfo->unit = qemu_opt_get_number(dinfo->opts, "unit", -1);
-    dinfo->bus = scsibus->busnr;
-    scsidev = scsi_bus_legacy_add_drive(scsibus, dinfo->bdrv, dinfo->unit,
-                                        false, -1);
-    if (!scsidev) {
-        return -1;
-    }
-    dinfo->unit = scsidev->id;
-
-    if (printinfo)
-        monitor_printf(mon, "OK bus %d, unit %d\n",
-                       scsibus->busnr, scsidev->id);
-    return 0;
-}
-
-int pci_drive_hot_add(Monitor *mon, const QDict *qdict,
-                      DriveInfo *dinfo, int type)
-{
-    int dom, pci_bus;
-    unsigned slot;
-    PCIDevice *dev;
-    const char *pci_addr = qdict_get_str(qdict, "pci_addr");
-
-    switch (type) {
-    case IF_SCSI:
-        if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
-            goto err;
-        }
-        dev = pci_find_device(pci_find_root_bus(dom), pci_bus,
-                              PCI_DEVFN(slot, 0));
-        if (!dev) {
-            monitor_printf(mon, "no pci device with address %s\n", pci_addr);
-            goto err;
-        }
-        if (scsi_hot_add(mon, &dev->qdev, dinfo, 1) != 0) {
-            goto err;
-        }
-        break;
-    default:
-        monitor_printf(mon, "Can't hot-add drive to type %d\n", type);
-        goto err;
-    }
-
-    return 0;
-err:
-    return -1;
-}
-
-static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
-                                           const char *devaddr,
-                                           const char *opts)
-{
-    PCIDevice *dev;
-    DriveInfo *dinfo = NULL;
-    int type = -1;
-    char buf[128];
-    PCIBus *bus;
-    int devfn;
-
-    if (get_param_value(buf, sizeof(buf), "if", opts)) {
-        if (!strcmp(buf, "scsi"))
-            type = IF_SCSI;
-        else if (!strcmp(buf, "virtio")) {
-            type = IF_VIRTIO;
-        } else {
-            monitor_printf(mon, "type %s not a hotpluggable PCI device.\n", buf);
-            return NULL;
-        }
-    } else {
-        monitor_printf(mon, "no if= specified\n");
-        return NULL;
-    }
-
-    if (get_param_value(buf, sizeof(buf), "file", opts)) {
-        dinfo = add_init_drive(opts);
-        if (!dinfo)
-            return NULL;
-        if (dinfo->devaddr) {
-            monitor_printf(mon, "Parameter addr not supported\n");
-            return NULL;
-        }
-    } else {
-        dinfo = NULL;
-    }
-
-    bus = pci_get_bus_devfn(&devfn, devaddr);
-    if (!bus) {
-        monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
-        return NULL;
-    }
-    if (!((BusState*)bus)->allow_hotplug) {
-        monitor_printf(mon, "PCI bus doesn't support hotplug\n");
-        return NULL;
-    }
-
-    switch (type) {
-    case IF_SCSI:
-        dev = pci_create(bus, devfn, "lsi53c895a");
-        if (qdev_init(&dev->qdev) < 0)
-            dev = NULL;
-        if (dev && dinfo) {
-            if (scsi_hot_add(mon, &dev->qdev, dinfo, 0) != 0) {
-                qdev_unplug(&dev->qdev, NULL);
-                dev = NULL;
-            }
-        }
-        break;
-    case IF_VIRTIO:
-        if (!dinfo) {
-            monitor_printf(mon, "virtio requires a backing file/device.\n");
-            return NULL;
-        }
-        dev = pci_create(bus, devfn, "virtio-blk-pci");
-        if (qdev_prop_set_drive(&dev->qdev, "drive", dinfo->bdrv) < 0) {
-            qdev_free(&dev->qdev);
-            dev = NULL;
-            break;
-        }
-        if (qdev_init(&dev->qdev) < 0)
-            dev = NULL;
-        break;
-    default:
-        dev = NULL;
-    }
-    return dev;
-}
-
-void pci_device_hot_add(Monitor *mon, const QDict *qdict)
-{
-    PCIDevice *dev = NULL;
-    const char *pci_addr = qdict_get_str(qdict, "pci_addr");
-    const char *type = qdict_get_str(qdict, "type");
-    const char *opts = qdict_get_try_str(qdict, "opts");
-
-    /* strip legacy tag */
-    if (!strncmp(pci_addr, "pci_addr=", 9)) {
-        pci_addr += 9;
-    }
-
-    if (!opts) {
-        opts = "";
-    }
-
-    if (!strcmp(pci_addr, "auto"))
-        pci_addr = NULL;
-
-    if (strcmp(type, "nic") == 0) {
-        dev = qemu_pci_hot_add_nic(mon, pci_addr, opts);
-    } else if (strcmp(type, "storage") == 0) {
-        dev = qemu_pci_hot_add_storage(mon, pci_addr, opts);
-    } else {
-        monitor_printf(mon, "invalid type: %s\n", type);
-    }
-
-    if (dev) {
-        monitor_printf(mon, "OK domain %d, bus %d, slot %d, function %d\n",
-                       pci_find_domain(dev->bus),
-                       pci_bus_num(dev->bus), PCI_SLOT(dev->devfn),
-                       PCI_FUNC(dev->devfn));
-    } else
-        monitor_printf(mon, "failed to add %s\n", opts);
-}
-#endif
-
-static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)
-{
-    PCIDevice *d;
-    int dom, bus;
-    unsigned slot;
-    Error *local_err = NULL;
-
-    if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) {
-        return -1;
-    }
-
-    d = pci_find_device(pci_find_root_bus(dom), bus, PCI_DEVFN(slot, 0));
-    if (!d) {
-        monitor_printf(mon, "slot %d empty\n", slot);
-        return -1;
-    }
-
-    qdev_unplug(&d->qdev, &local_err);
-    if (error_is_set(&local_err)) {
-        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
-        error_free(local_err);
-        return -1;
-    }
-
-    return 0;
-}
-
-void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict)
-{
-    pci_device_hot_remove(mon, qdict_get_str(qdict, "pci_addr"));
-}
hw/pci-stub.c deleted +0 -47
deleted file mode 100644
index 134c448..0000000
@@ -1,47 +0,0 @@
-/*
- * PCI stubs for platforms that don't support pci bus.
- *
- * Copyright (c) 2010 Isaku Yamahata <yamahata at valinux co jp>
- *                    VA Linux Systems Japan K.K.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "sysemu.h"
-#include "monitor.h"
-#include "pci.h"
-#include "qmp-commands.h"
-
-PciInfoList *qmp_query_pci(Error **errp)
-{
-    error_set(errp, QERR_UNSUPPORTED);
-    return NULL;
-}
-
-static void pci_error_message(Monitor *mon)
-{
-    monitor_printf(mon, "PCI devices not supported\n");
-}
-
-int do_pcie_aer_inject_error(Monitor *mon,
-                             const QDict *qdict, QObject **ret_data)
-{
-    pci_error_message(mon);
-    return -ENOSYS;
-}
-
-void pcie_aer_inject_error_print(Monitor *mon, const QObject *data)
-{
-    pci_error_message(mon);
-}
hw/pci.c deleted +0 -2168
deleted file mode 100644
index 97a0cd7..0000000
@@ -1,2168 +0,0 @@
-/*
- * QEMU PCI bus manager
- *
- * Copyright (c) 2004 Fabrice Bellard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#include "hw.h"
-#include "pci.h"
-#include "pci_bridge.h"
-#include "pci_internals.h"
-#include "monitor.h"
-#include "net.h"
-#include "sysemu.h"
-#include "loader.h"
-#include "range.h"
-#include "qmp-commands.h"
-#include "msi.h"
-#include "msix.h"
-#include "exec-memory.h"
-
-//#define DEBUG_PCI
-#ifdef DEBUG_PCI
-# define PCI_DPRINTF(format, ...)       printf(format, ## __VA_ARGS__)
-#else
-# define PCI_DPRINTF(format, ...)       do { } while (0)
-#endif
-
-static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent);
-static char *pcibus_get_dev_path(DeviceState *dev);
-static char *pcibus_get_fw_dev_path(DeviceState *dev);
-static int pcibus_reset(BusState *qbus);
-
-static Property pci_props[] = {
-    DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
-    DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
-    DEFINE_PROP_UINT32("rombar",  PCIDevice, rom_bar, 1),
-    DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present,
-                    QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false),
-    DEFINE_PROP_BIT("command_serr_enable", PCIDevice, cap_present,
-                    QEMU_PCI_CAP_SERR_BITNR, true),
-    DEFINE_PROP_END_OF_LIST()
-};
-
-static void pci_bus_class_init(ObjectClass *klass, void *data)
-{
-    BusClass *k = BUS_CLASS(klass);
-
-    k->print_dev = pcibus_dev_print;
-    k->get_dev_path = pcibus_get_dev_path;
-    k->get_fw_dev_path = pcibus_get_fw_dev_path;
-    k->reset = pcibus_reset;
-}
-
-static const TypeInfo pci_bus_info = {
-    .name = TYPE_PCI_BUS,
-    .parent = TYPE_BUS,
-    .instance_size = sizeof(PCIBus),
-    .class_init = pci_bus_class_init,
-};
-
-static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num);
-static void pci_update_mappings(PCIDevice *d);
-static void pci_set_irq(void *opaque, int irq_num, int level);
-static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom);
-static void pci_del_option_rom(PCIDevice *pdev);
-
-static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET;
-static uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU;
-
-struct PCIHostBus {
-    int domain;
-    struct PCIBus *bus;
-    QLIST_ENTRY(PCIHostBus) next;
-};
-static QLIST_HEAD(, PCIHostBus) host_buses;
-
-static const VMStateDescription vmstate_pcibus = {
-    .name = "PCIBUS",
-    .version_id = 1,
-    .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
-        VMSTATE_INT32_EQUAL(nirq, PCIBus),
-        VMSTATE_VARRAY_INT32(irq_count, PCIBus, nirq, 0, vmstate_info_int32, int32_t),
-        VMSTATE_END_OF_LIST()
-    }
-};
-static int pci_bar(PCIDevice *d, int reg)
-{
-    uint8_t type;
-
-    if (reg != PCI_ROM_SLOT)
-        return PCI_BASE_ADDRESS_0 + reg * 4;
-
-    type = d->config[PCI_HEADER_TYPE] & ~PCI_HEADER_TYPE_MULTI_FUNCTION;
-    return type == PCI_HEADER_TYPE_BRIDGE ? PCI_ROM_ADDRESS1 : PCI_ROM_ADDRESS;
-}
-
-static inline int pci_irq_state(PCIDevice *d, int irq_num)
-{
-       return (d->irq_state >> irq_num) & 0x1;
-}
-
-static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level)
-{
-       d->irq_state &= ~(0x1 << irq_num);
-       d->irq_state |= level << irq_num;
-}
-
-static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change)
-{
-    PCIBus *bus;
-    for (;;) {
-        bus = pci_dev->bus;
-        irq_num = bus->map_irq(pci_dev, irq_num);
-        if (bus->set_irq)
-            break;
-        pci_dev = bus->parent_dev;
-    }
-    bus->irq_count[irq_num] += change;
-    bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0);
-}
-
-int pci_bus_get_irq_level(PCIBus *bus, int irq_num)
-{
-    assert(irq_num >= 0);
-    assert(irq_num < bus->nirq);
-    return !!bus->irq_count[irq_num];
-}
-
-/* Update interrupt status bit in config space on interrupt
- * state change. */
-static void pci_update_irq_status(PCIDevice *dev)
-{
-    if (dev->irq_state) {
-        dev->config[PCI_STATUS] |= PCI_STATUS_INTERRUPT;
-    } else {
-        dev->config[PCI_STATUS] &= ~PCI_STATUS_INTERRUPT;
-    }
-}
-
-void pci_device_deassert_intx(PCIDevice *dev)
-{
-    int i;
-    for (i = 0; i < PCI_NUM_PINS; ++i) {
-        qemu_set_irq(dev->irq[i], 0);
-    }
-}
-
-/*
- * This function is called on #RST and FLR.
- * FLR if PCI_EXP_DEVCTL_BCR_FLR is set
- */
-void pci_device_reset(PCIDevice *dev)
-{
-    int r;
-
-    qdev_reset_all(&dev->qdev);
-
-    dev->irq_state = 0;
-    pci_update_irq_status(dev);
-    pci_device_deassert_intx(dev);
-    /* Clear all writable bits */
-    pci_word_test_and_clear_mask(dev->config + PCI_COMMAND,
-                                 pci_get_word(dev->wmask + PCI_COMMAND) |
-                                 pci_get_word(dev->w1cmask + PCI_COMMAND));
-    pci_word_test_and_clear_mask(dev->config + PCI_STATUS,
-                                 pci_get_word(dev->wmask + PCI_STATUS) |
-                                 pci_get_word(dev->w1cmask + PCI_STATUS));
-    dev->config[PCI_CACHE_LINE_SIZE] = 0x0;
-    dev->config[PCI_INTERRUPT_LINE] = 0x0;
-    for (r = 0; r < PCI_NUM_REGIONS; ++r) {
-        PCIIORegion *region = &dev->io_regions[r];
-        if (!region->size) {
-            continue;
-        }
-
-        if (!(region->type & PCI_BASE_ADDRESS_SPACE_IO) &&
-            region->type & PCI_BASE_ADDRESS_MEM_TYPE_64) {
-            pci_set_quad(dev->config + pci_bar(dev, r), region->type);
-        } else {
-            pci_set_long(dev->config + pci_bar(dev, r), region->type);
-        }
-    }
-    pci_update_mappings(dev);
-
-    msi_reset(dev);
-    msix_reset(dev);
-}
-
-/*
- * Trigger pci bus reset under a given bus.
- * To be called on RST# assert.
- */
-void pci_bus_reset(PCIBus *bus)
-{
-    int i;
-
-    for (i = 0; i < bus->nirq; i++) {
-        bus->irq_count[i] = 0;
-    }
-    for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
-        if (bus->devices[i]) {
-            pci_device_reset(bus->devices[i]);
-        }
-    }
-}
-
-static int pcibus_reset(BusState *qbus)
-{
-    pci_bus_reset(DO_UPCAST(PCIBus, qbus, qbus));
-
-    /* topology traverse is done by pci_bus_reset().
-       Tell qbus/qdev walker not to traverse the tree */
-    return 1;
-}
-
-static void pci_host_bus_register(int domain, PCIBus *bus)
-{
-    struct PCIHostBus *host;
-    host = g_malloc0(sizeof(*host));
-    host->domain = domain;
-    host->bus = bus;
-    QLIST_INSERT_HEAD(&host_buses, host, next);
-}
-
-PCIBus *pci_find_root_bus(int domain)
-{
-    struct PCIHostBus *host;
-
-    QLIST_FOREACH(host, &host_buses, next) {
-        if (host->domain == domain) {
-            return host->bus;
-        }
-    }
-
-    return NULL;
-}
-
-int pci_find_domain(const PCIBus *bus)
-{
-    PCIDevice *d;
-    struct PCIHostBus *host;
-
-    /* obtain root bus */
-    while ((d = bus->parent_dev) != NULL) {
-        bus = d->bus;
-    }
-
-    QLIST_FOREACH(host, &host_buses, next) {
-        if (host->bus == bus) {
-            return host->domain;
-        }
-    }
-
-    abort();    /* should not be reached */
-    return -1;
-}
-
-void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
-                         const char *name,
-                         MemoryRegion *address_space_mem,
-                         MemoryRegion *address_space_io,
-                         uint8_t devfn_min)
-{
-    qbus_create_inplace(&bus->qbus, TYPE_PCI_BUS, parent, name);
-    assert(PCI_FUNC(devfn_min) == 0);
-    bus->devfn_min = devfn_min;
-    bus->address_space_mem = address_space_mem;
-    bus->address_space_io = address_space_io;
-
-    /* host bridge */
-    QLIST_INIT(&bus->child);
-    pci_host_bus_register(0, bus); /* for now only pci domain 0 is supported */
-
-    vmstate_register(NULL, -1, &vmstate_pcibus, bus);
-}
-
-PCIBus *pci_bus_new(DeviceState *parent, const char *name,
-                    MemoryRegion *address_space_mem,
-                    MemoryRegion *address_space_io,
-                    uint8_t devfn_min)
-{
-    PCIBus *bus;
-
-    bus = g_malloc0(sizeof(*bus));
-    pci_bus_new_inplace(bus, parent, name, address_space_mem,
-                        address_space_io, devfn_min);
-    OBJECT(bus)->free = g_free;
-    return bus;
-}
-
-void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
-                  void *irq_opaque, int nirq)
-{
-    bus->set_irq = set_irq;
-    bus->map_irq = map_irq;
-    bus->irq_opaque = irq_opaque;
-    bus->nirq = nirq;
-    bus->irq_count = g_malloc0(nirq * sizeof(bus->irq_count[0]));
-}
-
-void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug, DeviceState *qdev)
-{
-    bus->qbus.allow_hotplug = 1;
-    bus->hotplug = hotplug;
-    bus->hotplug_qdev = qdev;
-}
-
-PCIBus *pci_register_bus(DeviceState *parent, const char *name,
-                         pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
-                         void *irq_opaque,
-                         MemoryRegion *address_space_mem,
-                         MemoryRegion *address_space_io,
-                         uint8_t devfn_min, int nirq)
-{
-    PCIBus *bus;
-
-    bus = pci_bus_new(parent, name, address_space_mem,
-                      address_space_io, devfn_min);
-    pci_bus_irqs(bus, set_irq, map_irq, irq_opaque, nirq);
-    return bus;
-}
-
-int pci_bus_num(PCIBus *s)
-{
-    if (!s->parent_dev)
-        return 0;       /* pci host bridge */
-    return s->parent_dev->config[PCI_SECONDARY_BUS];
-}
-
-static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
-{
-    PCIDevice *s = container_of(pv, PCIDevice, config);
-    uint8_t *config;
-    int i;
-
-    assert(size == pci_config_size(s));
-    config = g_malloc(size);
-
-    qemu_get_buffer(f, config, size);
-    for (i = 0; i < size; ++i) {
-        if ((config[i] ^ s->config[i]) &
-            s->cmask[i] & ~s->wmask[i] & ~s->w1cmask[i]) {
-            g_free(config);
-            return -EINVAL;
-        }
-    }
-    memcpy(s->config, config, size);
-
-    pci_update_mappings(s);
-
-    memory_region_set_enabled(&s->bus_master_enable_region,
-                              pci_get_word(s->config + PCI_COMMAND)
-                              & PCI_COMMAND_MASTER);
-
-    g_free(config);
-    return 0;
-}
-
-/* just put buffer */
-static void put_pci_config_device(QEMUFile *f, void *pv, size_t size)
-{
-    const uint8_t **v = pv;
-    assert(size == pci_config_size(container_of(pv, PCIDevice, config)));
-    qemu_put_buffer(f, *v, size);
-}
-
-static VMStateInfo vmstate_info_pci_config = {
-    .name = "pci config",
-    .get  = get_pci_config_device,
-    .put  = put_pci_config_device,
-};
-
-static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)
-{
-    PCIDevice *s = container_of(pv, PCIDevice, irq_state);
-    uint32_t irq_state[PCI_NUM_PINS];
-    int i;
-    for (i = 0; i < PCI_NUM_PINS; ++i) {
-        irq_state[i] = qemu_get_be32(f);
-        if (irq_state[i] != 0x1 && irq_state[i] != 0) {
-            fprintf(stderr, "irq state %d: must be 0 or 1.\n",
-                    irq_state[i]);
-            return -EINVAL;
-        }
-    }
-
-    for (i = 0; i < PCI_NUM_PINS; ++i) {
-        pci_set_irq_state(s, i, irq_state[i]);
-    }
-
-    return 0;
-}
-
-static void put_pci_irq_state(QEMUFile *f, void *pv, size_t size)
-{
-    int i;
-    PCIDevice *s = container_of(pv, PCIDevice, irq_state);
-
-    for (i = 0; i < PCI_NUM_PINS; ++i) {
-        qemu_put_be32(f, pci_irq_state(s, i));
-    }
-}
-
-static VMStateInfo vmstate_info_pci_irq_state = {
-    .name = "pci irq state",
-    .get  = get_pci_irq_state,
-    .put  = put_pci_irq_state,
-};
-
-const VMStateDescription vmstate_pci_device = {
-    .name = "PCIDevice",
-    .version_id = 2,
-    .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
-        VMSTATE_INT32_LE(version_id, PCIDevice),
-        VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0,
-                                   vmstate_info_pci_config,
-                                   PCI_CONFIG_SPACE_SIZE),
-        VMSTATE_BUFFER_UNSAFE_INFO(irq_state, PCIDevice, 2,
-                                  vmstate_info_pci_irq_state,
-                                  PCI_NUM_PINS * sizeof(int32_t)),
-        VMSTATE_END_OF_LIST()
-    }
-};
-
-const VMStateDescription vmstate_pcie_device = {
-    .name = "PCIEDevice",
-    .version_id = 2,
-    .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
-        VMSTATE_INT32_LE(version_id, PCIDevice),
-        VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0,
-                                   vmstate_info_pci_config,
-                                   PCIE_CONFIG_SPACE_SIZE),
-        VMSTATE_BUFFER_UNSAFE_INFO(irq_state, PCIDevice, 2,
-                                  vmstate_info_pci_irq_state,
-                                  PCI_NUM_PINS * sizeof(int32_t)),
-        VMSTATE_END_OF_LIST()
-    }
-};
-
-static inline const VMStateDescription *pci_get_vmstate(PCIDevice *s)
-{
-    return pci_is_express(s) ? &vmstate_pcie_device : &vmstate_pci_device;
-}
-
-void pci_device_save(PCIDevice *s, QEMUFile *f)
-{
-    /* Clear interrupt status bit: it is implicit
-     * in irq_state which we are saving.
-     * This makes us compatible with old devices
-     * which never set or clear this bit. */
-    s->config[PCI_STATUS] &= ~PCI_STATUS_INTERRUPT;
-    vmstate_save_state(f, pci_get_vmstate(s), s);
-    /* Restore the interrupt status bit. */
-    pci_update_irq_status(s);
-}
-
-int pci_device_load(PCIDevice *s, QEMUFile *f)
-{
-    int ret;
-    ret = vmstate_load_state(f, pci_get_vmstate(s), s, s->version_id);
-    /* Restore the interrupt status bit. */
-    pci_update_irq_status(s);
-    return ret;
-}
-
-static void pci_set_default_subsystem_id(PCIDevice *pci_dev)
-{
-    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID,
-                 pci_default_sub_vendor_id);
-    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID,
-                 pci_default_sub_device_id);
-}
-
-/*
- * Parse [[<domain>:]<bus>:]<slot>, return -1 on error if funcp == NULL
- *       [[<domain>:]<bus>:]<slot>.<func>, return -1 on error
- */
-static int pci_parse_devaddr(const char *addr, int *domp, int *busp,
-                      unsigned int *slotp, unsigned int *funcp)
-{
-    const char *p;
-    char *e;
-    unsigned long val;
-    unsigned long dom = 0, bus = 0;
-    unsigned int slot = 0;
-    unsigned int func = 0;
-
-    p = addr;
-    val = strtoul(p, &e, 16);
-    if (e == p)
-       return -1;
-    if (*e == ':') {
-       bus = val;
-       p = e + 1;
-       val = strtoul(p, &e, 16);
-       if (e == p)
-           return -1;
-       if (*e == ':') {
-           dom = bus;
-           bus = val;
-           p = e + 1;
-           val = strtoul(p, &e, 16);
-           if (e == p)
-               return -1;
-       }
-    }
-
-    slot = val;
-
-    if (funcp != NULL) {
-        if (*e != '.')
-            return -1;
-
-        p = e + 1;
-        val = strtoul(p, &e, 16);
-        if (e == p)
-            return -1;
-
-        func = val;
-    }
-
-    /* if funcp == NULL func is 0 */
-    if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7)
-       return -1;
-
-    if (*e)
-       return -1;
-
-    *domp = dom;
-    *busp = bus;
-    *slotp = slot;
-    if (funcp != NULL)
-        *funcp = func;
-    return 0;
-}
-
-int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
-                     unsigned *slotp)
-{
-    /* strip legacy tag */
-    if (!strncmp(addr, "pci_addr=", 9)) {
-        addr += 9;
-    }
-    if (pci_parse_devaddr(addr, domp, busp, slotp, NULL)) {
-        monitor_printf(mon, "Invalid pci address\n");
-        return -1;
-    }
-    return 0;
-}
-
-PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
-{
-    int dom, bus;
-    unsigned slot;
-
-    if (!devaddr) {
-        *devfnp = -1;
-        return pci_find_bus_nr(pci_find_root_bus(0), 0);
-    }
-
-    if (pci_parse_devaddr(devaddr, &dom, &bus, &slot, NULL) < 0) {
-        return NULL;
-    }
-
-    *devfnp = PCI_DEVFN(slot, 0);
-    return pci_find_bus_nr(pci_find_root_bus(dom), bus);
-}
-
-static void pci_init_cmask(PCIDevice *dev)
-{
-    pci_set_word(dev->cmask + PCI_VENDOR_ID, 0xffff);
-    pci_set_word(dev->cmask + PCI_DEVICE_ID, 0xffff);
-    dev->cmask[PCI_STATUS] = PCI_STATUS_CAP_LIST;
-    dev->cmask[PCI_REVISION_ID] = 0xff;
-    dev->cmask[PCI_CLASS_PROG] = 0xff;
-    pci_set_word(dev->cmask + PCI_CLASS_DEVICE, 0xffff);
-    dev->cmask[PCI_HEADER_TYPE] = 0xff;
-    dev->cmask[PCI_CAPABILITY_LIST] = 0xff;
-}
-
-static void pci_init_wmask(PCIDevice *dev)
-{
-    int config_size = pci_config_size(dev);
-
-    dev->wmask[PCI_CACHE_LINE_SIZE] = 0xff;
-    dev->wmask[PCI_INTERRUPT_LINE] = 0xff;
-    pci_set_word(dev->wmask + PCI_COMMAND,
-                 PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
-                 PCI_COMMAND_INTX_DISABLE);
-    if (dev->cap_present & QEMU_PCI_CAP_SERR) {
-        pci_word_test_and_set_mask(dev->wmask + PCI_COMMAND, PCI_COMMAND_SERR);
-    }
-
-    memset(dev->wmask + PCI_CONFIG_HEADER_SIZE, 0xff,
-           config_size - PCI_CONFIG_HEADER_SIZE);
-}
-
-static void pci_init_w1cmask(PCIDevice *dev)
-{
-    /*
-     * Note: It's okay to set w1cmask even for readonly bits as
-     * long as their value is hardwired to 0.
-     */
-    pci_set_word(dev->w1cmask + PCI_STATUS,
-                 PCI_STATUS_PARITY | PCI_STATUS_SIG_TARGET_ABORT |
-                 PCI_STATUS_REC_TARGET_ABORT | PCI_STATUS_REC_MASTER_ABORT |
-                 PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY);
-}
-
-static void pci_init_mask_bridge(PCIDevice *d)
-{
-    /* PCI_PRIMARY_BUS, PCI_SECONDARY_BUS, PCI_SUBORDINATE_BUS and
-       PCI_SEC_LETENCY_TIMER */
-    memset(d->wmask + PCI_PRIMARY_BUS, 0xff, 4);
-
-    /* base and limit */
-    d->wmask[PCI_IO_BASE] = PCI_IO_RANGE_MASK & 0xff;
-    d->wmask[PCI_IO_LIMIT] = PCI_IO_RANGE_MASK & 0xff;
-    pci_set_word(d->wmask + PCI_MEMORY_BASE,
-                 PCI_MEMORY_RANGE_MASK & 0xffff);
-    pci_set_word(d->wmask + PCI_MEMORY_LIMIT,
-                 PCI_MEMORY_RANGE_MASK & 0xffff);
-    pci_set_word(d->wmask + PCI_PREF_MEMORY_BASE,
-                 PCI_PREF_RANGE_MASK & 0xffff);
-    pci_set_word(d->wmask + PCI_PREF_MEMORY_LIMIT,
-                 PCI_PREF_RANGE_MASK & 0xffff);
-
-    /* PCI_PREF_BASE_UPPER32 and PCI_PREF_LIMIT_UPPER32 */
-    memset(d->wmask + PCI_PREF_BASE_UPPER32, 0xff, 8);
-
-    /* Supported memory and i/o types */
-    d->config[PCI_IO_BASE] |= PCI_IO_RANGE_TYPE_16;
-    d->config[PCI_IO_LIMIT] |= PCI_IO_RANGE_TYPE_16;
-    pci_word_test_and_set_mask(d->config + PCI_PREF_MEMORY_BASE,
-                               PCI_PREF_RANGE_TYPE_64);
-    pci_word_test_and_set_mask(d->config + PCI_PREF_MEMORY_LIMIT,
-                               PCI_PREF_RANGE_TYPE_64);
-
-/* TODO: add this define to pci_regs.h in linux and then in qemu. */
-#define  PCI_BRIDGE_CTL_VGA_16BIT      0x10    /* VGA 16-bit decode */
-#define  PCI_BRIDGE_CTL_DISCARD                0x100   /* Primary discard timer */
-#define  PCI_BRIDGE_CTL_SEC_DISCARD    0x200   /* Secondary discard timer */
-#define  PCI_BRIDGE_CTL_DISCARD_STATUS 0x400   /* Discard timer status */
-#define  PCI_BRIDGE_CTL_DISCARD_SERR   0x800   /* Discard timer SERR# enable */
-    pci_set_word(d->wmask + PCI_BRIDGE_CONTROL,
-                 PCI_BRIDGE_CTL_PARITY |
-                 PCI_BRIDGE_CTL_SERR |
-                 PCI_BRIDGE_CTL_ISA |
-                 PCI_BRIDGE_CTL_VGA |
-                 PCI_BRIDGE_CTL_VGA_16BIT |
-                 PCI_BRIDGE_CTL_MASTER_ABORT |
-                 PCI_BRIDGE_CTL_BUS_RESET |
-                 PCI_BRIDGE_CTL_FAST_BACK |
-                 PCI_BRIDGE_CTL_DISCARD |
-                 PCI_BRIDGE_CTL_SEC_DISCARD |
-                 PCI_BRIDGE_CTL_DISCARD_SERR);
-    /* Below does not do anything as we never set this bit, put here for
-     * completeness. */
-    pci_set_word(d->w1cmask + PCI_BRIDGE_CONTROL,
-                 PCI_BRIDGE_CTL_DISCARD_STATUS);
-    d->cmask[PCI_IO_BASE] |= PCI_IO_RANGE_TYPE_MASK;
-    d->cmask[PCI_IO_LIMIT] |= PCI_IO_RANGE_TYPE_MASK;
-    pci_word_test_and_set_mask(d->cmask + PCI_PREF_MEMORY_BASE,
-                               PCI_PREF_RANGE_TYPE_MASK);
-    pci_word_test_and_set_mask(d->cmask + PCI_PREF_MEMORY_LIMIT,
-                               PCI_PREF_RANGE_TYPE_MASK);
-}
-
-static int pci_init_multifunction(PCIBus *bus, PCIDevice *dev)
-{
-    uint8_t slot = PCI_SLOT(dev->devfn);
-    uint8_t func;
-
-    if (dev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
-        dev->config[PCI_HEADER_TYPE] |= PCI_HEADER_TYPE_MULTI_FUNCTION;
-    }
-
-    /*
-     * multifunction bit is interpreted in two ways as follows.
-     *   - all functions must set the bit to 1.
-     *     Example: Intel X53
-     *   - function 0 must set the bit, but the rest function (> 0)
-     *     is allowed to leave the bit to 0.
-     *     Example: PIIX3(also in qemu), PIIX4(also in qemu), ICH10,
-     *
-     * So OS (at least Linux) checks the bit of only function 0,
-     * and doesn't see the bit of function > 0.
-     *
-     * The below check allows both interpretation.
-     */
-    if (PCI_FUNC(dev->devfn)) {
-        PCIDevice *f0 = bus->devices[PCI_DEVFN(slot, 0)];
-        if (f0 && !(f0->cap_present & QEMU_PCI_CAP_MULTIFUNCTION)) {
-            /* function 0 should set multifunction bit */
-            error_report("PCI: single function device can't be populated "
-                         "in function %x.%x", slot, PCI_FUNC(dev->devfn));
-            return -1;
-        }
-        return 0;
-    }
-
-    if (dev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
-        return 0;
-    }
-    /* function 0 indicates single function, so function > 0 must be NULL */
-    for (func = 1; func < PCI_FUNC_MAX; ++func) {
-        if (bus->devices[PCI_DEVFN(slot, func)]) {
-            error_report("PCI: %x.0 indicates single function, "
-                         "but %x.%x is already populated.",
-                         slot, slot, func);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-static void pci_config_alloc(PCIDevice *pci_dev)
-{
-    int config_size = pci_config_size(pci_dev);
-
-    pci_dev->config = g_malloc0(config_size);
-    pci_dev->cmask = g_malloc0(config_size);
-    pci_dev->wmask = g_malloc0(config_size);
-    pci_dev->w1cmask = g_malloc0(config_size);
-    pci_dev->used = g_malloc0(config_size);
-}
-
-static void pci_config_free(PCIDevice *pci_dev)
-{
-    g_free(pci_dev->config);
-    g_free(pci_dev->cmask);
-    g_free(pci_dev->wmask);
-    g_free(pci_dev->w1cmask);
-    g_free(pci_dev->used);
-}
-
-/* -1 for devfn means auto assign */
-static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
-                                         const char *name, int devfn)
-{
-    PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
-    PCIConfigReadFunc *config_read = pc->config_read;
-    PCIConfigWriteFunc *config_write = pc->config_write;
-
-    if (devfn < 0) {
-        for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
-            devfn += PCI_FUNC_MAX) {
-            if (!bus->devices[devfn])
-                goto found;
-        }
-        error_report("PCI: no slot/function available for %s, all in use", name);
-        return NULL;
-    found: ;
-    } else if (bus->devices[devfn]) {
-        error_report("PCI: slot %d function %d not available for %s, in use by %s",
-                     PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name);
-        return NULL;
-    }
-    pci_dev->bus = bus;
-    if (bus->dma_context_fn) {
-        pci_dev->dma = bus->dma_context_fn(bus, bus->dma_context_opaque, devfn);
-    } else {
-        /* FIXME: Make dma_context_fn use MemoryRegions instead, so this path is
-         * taken unconditionally */
-        /* FIXME: inherit memory region from bus creator */
-        memory_region_init_alias(&pci_dev->bus_master_enable_region, "bus master",
-                                 get_system_memory(), 0,
-                                 memory_region_size(get_system_memory()));
-        memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
-        address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region);
-        pci_dev->dma = g_new(DMAContext, 1);
-        dma_context_init(pci_dev->dma, &pci_dev->bus_master_as, NULL, NULL, NULL);
-    }
-    pci_dev->devfn = devfn;
-    pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
-    pci_dev->irq_state = 0;
-    pci_config_alloc(pci_dev);
-
-    pci_config_set_vendor_id(pci_dev->config, pc->vendor_id);
-    pci_config_set_device_id(pci_dev->config, pc->device_id);
-    pci_config_set_revision(pci_dev->config, pc->revision);
-    pci_config_set_class(pci_dev->config, pc->class_id);
-
-    if (!pc->is_bridge) {
-        if (pc->subsystem_vendor_id || pc->subsystem_id) {
-            pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID,
-                         pc->subsystem_vendor_id);
-            pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID,
-                         pc->subsystem_id);
-        } else {
-            pci_set_default_subsystem_id(pci_dev);
-        }
-    } else {
-        /* subsystem_vendor_id/subsystem_id are only for header type 0 */
-        assert(!pc->subsystem_vendor_id);
-        assert(!pc->subsystem_id);
-    }
-    pci_init_cmask(pci_dev);
-    pci_init_wmask(pci_dev);
-    pci_init_w1cmask(pci_dev);
-    if (pc->is_bridge) {
-        pci_init_mask_bridge(pci_dev);
-    }
-    if (pci_init_multifunction(bus, pci_dev)) {
-        pci_config_free(pci_dev);
-        return NULL;
-    }
-
-    if (!config_read)
-        config_read = pci_default_read_config;
-    if (!config_write)
-        config_write = pci_default_write_config;
-    pci_dev->config_read = config_read;
-    pci_dev->config_write = config_write;
-    bus->devices[devfn] = pci_dev;
-    pci_dev->irq = qemu_allocate_irqs(pci_set_irq, pci_dev, PCI_NUM_PINS);
-    pci_dev->version_id = 2; /* Current pci device vmstate version */
-    return pci_dev;
-}
-
-static void do_pci_unregister_device(PCIDevice *pci_dev)
-{
-    qemu_free_irqs(pci_dev->irq);
-    pci_dev->bus->devices[pci_dev->devfn] = NULL;
-    pci_config_free(pci_dev);
-
-    if (!pci_dev->bus->dma_context_fn) {
-        address_space_destroy(&pci_dev->bus_master_as);
-        memory_region_destroy(&pci_dev->bus_master_enable_region);
-        g_free(pci_dev->dma);
-        pci_dev->dma = NULL;
-    }
-}
-
-static void pci_unregister_io_regions(PCIDevice *pci_dev)
-{
-    PCIIORegion *r;
-    int i;
-
-    for(i = 0; i < PCI_NUM_REGIONS; i++) {
-        r = &pci_dev->io_regions[i];
-        if (!r->size || r->addr == PCI_BAR_UNMAPPED)
-            continue;
-        memory_region_del_subregion(r->address_space, r->memory);
-    }
-}
-
-static int pci_unregister_device(DeviceState *dev)
-{
-    PCIDevice *pci_dev = PCI_DEVICE(dev);
-    PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
-
-    pci_unregister_io_regions(pci_dev);
-    pci_del_option_rom(pci_dev);
-
-    if (pc->exit) {
-        pc->exit(pci_dev);
-    }
-
-    do_pci_unregister_device(pci_dev);
-    return 0;
-}
-
-void pci_register_bar(PCIDevice *pci_dev, int region_num,
-                      uint8_t type, MemoryRegion *memory)
-{
-    PCIIORegion *r;
-    uint32_t addr;
-    uint64_t wmask;
-    pcibus_t size = memory_region_size(memory);
-
-    assert(region_num >= 0);
-    assert(region_num < PCI_NUM_REGIONS);
-    if (size & (size-1)) {
-        fprintf(stderr, "ERROR: PCI region size must be pow2 "
-                    "type=0x%x, size=0x%"FMT_PCIBUS"\n", type, size);
-        exit(1);
-    }
-
-    r = &pci_dev->io_regions[region_num];
-    r->addr = PCI_BAR_UNMAPPED;
-    r->size = size;
-    r->type = type;
-    r->memory = NULL;
-
-    wmask = ~(size - 1);
-    addr = pci_bar(pci_dev, region_num);
-    if (region_num == PCI_ROM_SLOT) {
-        /* ROM enable bit is writable */
-        wmask |= PCI_ROM_ADDRESS_ENABLE;
-    }
-    pci_set_long(pci_dev->config + addr, type);
-    if (!(r->type & PCI_BASE_ADDRESS_SPACE_IO) &&
-        r->type & PCI_BASE_ADDRESS_MEM_TYPE_64) {
-        pci_set_quad(pci_dev->wmask + addr, wmask);
-        pci_set_quad(pci_dev->cmask + addr, ~0ULL);
-    } else {
-        pci_set_long(pci_dev->wmask + addr, wmask & 0xffffffff);
-        pci_set_long(pci_dev->cmask + addr, 0xffffffff);
-    }
-    pci_dev->io_regions[region_num].memory = memory;
-    pci_dev->io_regions[region_num].address_space
-        = type & PCI_BASE_ADDRESS_SPACE_IO
-        ? pci_dev->bus->address_space_io
-        : pci_dev->bus->address_space_mem;
-}
-
-pcibus_t pci_get_bar_addr(PCIDevice *pci_dev, int region_num)
-{
-    return pci_dev->io_regions[region_num].addr;
-}
-
-static pcibus_t pci_bar_address(PCIDevice *d,
-                               int reg, uint8_t type, pcibus_t size)
-{
-    pcibus_t new_addr, last_addr;
-    int bar = pci_bar(d, reg);
-    uint16_t cmd = pci_get_word(d->config + PCI_COMMAND);
-
-    if (type & PCI_BASE_ADDRESS_SPACE_IO) {
-        if (!(cmd & PCI_COMMAND_IO)) {
-            return PCI_BAR_UNMAPPED;
-        }
-        new_addr = pci_get_long(d->config + bar) & ~(size - 1);
-        last_addr = new_addr + size - 1;
-        /* NOTE: we have only 64K ioports on PC */
-        if (last_addr <= new_addr || new_addr == 0 || last_addr > UINT16_MAX) {
-            return PCI_BAR_UNMAPPED;
-        }
-        return new_addr;
-    }
-
-    if (!(cmd & PCI_COMMAND_MEMORY)) {
-        return PCI_BAR_UNMAPPED;
-    }
-    if (type & PCI_BASE_ADDRESS_MEM_TYPE_64) {
-        new_addr = pci_get_quad(d->config + bar);
-    } else {
-        new_addr = pci_get_long(d->config + bar);
-    }
-    /* the ROM slot has a specific enable bit */
-    if (reg == PCI_ROM_SLOT && !(new_addr & PCI_ROM_ADDRESS_ENABLE)) {
-        return PCI_BAR_UNMAPPED;
-    }
-    new_addr &= ~(size - 1);
-    last_addr = new_addr + size - 1;
-    /* NOTE: we do not support wrapping */
-    /* XXX: as we cannot support really dynamic
-       mappings, we handle specific values as invalid
-       mappings. */
-    if (last_addr <= new_addr || new_addr == 0 ||
-        last_addr == PCI_BAR_UNMAPPED) {
-        return PCI_BAR_UNMAPPED;
-    }
-
-    /* Now pcibus_t is 64bit.
-     * Check if 32 bit BAR wraps around explicitly.
-     * Without this, PC ide doesn't work well.
-     * TODO: remove this work around.
-     */
-    if  (!(type & PCI_BASE_ADDRESS_MEM_TYPE_64) && last_addr >= UINT32_MAX) {
-        return PCI_BAR_UNMAPPED;
-    }
-
-    /*
-     * OS is allowed to set BAR beyond its addressable
-     * bits. For example, 32 bit OS can set 64bit bar
-     * to >4G. Check it. TODO: we might need to support
-     * it in the future for e.g. PAE.
-     */
-    if (last_addr >= HWADDR_MAX) {
-        return PCI_BAR_UNMAPPED;
-    }
-
-    return new_addr;
-}
-
-static void pci_update_mappings(PCIDevice *d)
-{
-    PCIIORegion *r;
-    int i;
-    pcibus_t new_addr;
-
-    for(i = 0; i < PCI_NUM_REGIONS; i++) {
-        r = &d->io_regions[i];
-
-        /* this region isn't registered */
-        if (!r->size)
-            continue;
-
-        new_addr = pci_bar_address(d, i, r->type, r->size);
-
-        /* This bar isn't changed */
-        if (new_addr == r->addr)
-            continue;
-
-        /* now do the real mapping */
-        if (r->addr != PCI_BAR_UNMAPPED) {
-            memory_region_del_subregion(r->address_space, r->memory);
-        }
-        r->addr = new_addr;
-        if (r->addr != PCI_BAR_UNMAPPED) {
-            memory_region_add_subregion_overlap(r->address_space,
-                                                r->addr, r->memory, 1);
-        }
-    }
-}
-
-static inline int pci_irq_disabled(PCIDevice *d)
-{
-    return pci_get_word(d->config + PCI_COMMAND) & PCI_COMMAND_INTX_DISABLE;
-}
-
-/* Called after interrupt disabled field update in config space,
- * assert/deassert interrupts if necessary.
- * Gets original interrupt disable bit value (before update). */
-static void pci_update_irq_disabled(PCIDevice *d, int was_irq_disabled)
-{
-    int i, disabled = pci_irq_disabled(d);
-    if (disabled == was_irq_disabled)
-        return;
-    for (i = 0; i < PCI_NUM_PINS; ++i) {
-        int state = pci_irq_state(d, i);
-        pci_change_irq_level(d, i, disabled ? -state : state);
-    }
-}
-
-uint32_t pci_default_read_config(PCIDevice *d,
-                                 uint32_t address, int len)
-{
-    uint32_t val = 0;
-
-    memcpy(&val, d->config + address, len);
-    return le32_to_cpu(val);
-}
-
-void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l)
-{
-    int i, was_irq_disabled = pci_irq_disabled(d);
-
-    for (i = 0; i < l; val >>= 8, ++i) {
-        uint8_t wmask = d->wmask[addr + i];
-        uint8_t w1cmask = d->w1cmask[addr + i];
-        assert(!(wmask & w1cmask));
-        d->config[addr + i] = (d->config[addr + i] & ~wmask) | (val & wmask);
-        d->config[addr + i] &= ~(val & w1cmask); /* W1C: Write 1 to Clear */
-    }
-    if (ranges_overlap(addr, l, PCI_BASE_ADDRESS_0, 24) ||
-        ranges_overlap(addr, l, PCI_ROM_ADDRESS, 4) ||
-        ranges_overlap(addr, l, PCI_ROM_ADDRESS1, 4) ||
-        range_covers_byte(addr, l, PCI_COMMAND))
-        pci_update_mappings(d);
-
-    if (range_covers_byte(addr, l, PCI_COMMAND)) {
-        pci_update_irq_disabled(d, was_irq_disabled);
-        memory_region_set_enabled(&d->bus_master_enable_region,
-                                  pci_get_word(d->config + PCI_COMMAND)
-                                    & PCI_COMMAND_MASTER);
-    }
-
-    msi_write_config(d, addr, val, l);
-    msix_write_config(d, addr, val, l);
-}
-
-/***********************************************************/
-/* generic PCI irq support */
-
-/* 0 <= irq_num <= 3. level must be 0 or 1 */
-static void pci_set_irq(void *opaque, int irq_num, int level)
-{
-    PCIDevice *pci_dev = opaque;
-    int change;
-
-    change = level - pci_irq_state(pci_dev, irq_num);
-    if (!change)
-        return;
-
-    pci_set_irq_state(pci_dev, irq_num, level);
-    pci_update_irq_status(pci_dev);
-    if (pci_irq_disabled(pci_dev))
-        return;
-    pci_change_irq_level(pci_dev, irq_num, change);
-}
-
-/* Special hooks used by device assignment */
-void pci_bus_set_route_irq_fn(PCIBus *bus, pci_route_irq_fn route_intx_to_irq)
-{
-    assert(!bus->parent_dev);
-    bus->route_intx_to_irq = route_intx_to_irq;
-}
-
-PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin)
-{
-    PCIBus *bus;
-
-    do {
-         bus = dev->bus;
-         pin = bus->map_irq(dev, pin);
-         dev = bus->parent_dev;
-    } while (dev);
-
-    if (!bus->route_intx_to_irq) {
-        error_report("PCI: Bug - unimplemented PCI INTx routing (%s)\n",
-                     object_get_typename(OBJECT(bus->qbus.parent)));
-        return (PCIINTxRoute) { PCI_INTX_DISABLED, -1 };
-    }
-
-    return bus->route_intx_to_irq(bus->irq_opaque, pin);
-}
-
-bool pci_intx_route_changed(PCIINTxRoute *old, PCIINTxRoute *new)
-{
-    return old->mode != new->mode || old->irq != new->irq;
-}
-
-void pci_bus_fire_intx_routing_notifier(PCIBus *bus)
-{
-    PCIDevice *dev;
-    PCIBus *sec;
-    int i;
-
-    for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
-        dev = bus->devices[i];
-        if (dev && dev->intx_routing_notifier) {
-            dev->intx_routing_notifier(dev);
-        }
-        QLIST_FOREACH(sec, &bus->child, sibling) {
-            pci_bus_fire_intx_routing_notifier(sec);
-        }
-    }
-}
-
-void pci_device_set_intx_routing_notifier(PCIDevice *dev,
-                                          PCIINTxRoutingNotifier notifier)
-{
-    dev->intx_routing_notifier = notifier;
-}
-
-/*
- * PCI-to-PCI bridge specification
- * 9.1: Interrupt routing. Table 9-1
- *
- * the PCI Express Base Specification, Revision 2.1
- * 2.2.8.1: INTx interrutp signaling - Rules
- *          the Implementation Note
- *          Table 2-20
- */
-/*
- * 0 <= pin <= 3 0 = INTA, 1 = INTB, 2 = INTC, 3 = INTD
- * 0-origin unlike PCI interrupt pin register.
- */
-int pci_swizzle_map_irq_fn(PCIDevice *pci_dev, int pin)
-{
-    return (pin + PCI_SLOT(pci_dev->devfn)) % PCI_NUM_PINS;
-}
-
-/***********************************************************/
-/* monitor info on PCI */
-
-typedef struct {
-    uint16_t class;
-    const char *desc;
-    const char *fw_name;
-    uint16_t fw_ign_bits;
-} pci_class_desc;
-
-static const pci_class_desc pci_class_descriptions[] =
-{
-    { 0x0001, "VGA controller", "display"},
-    { 0x0100, "SCSI controller", "scsi"},
-    { 0x0101, "IDE controller", "ide"},
-    { 0x0102, "Floppy controller", "fdc"},
-    { 0x0103, "IPI controller", "ipi"},
-    { 0x0104, "RAID controller", "raid"},
-    { 0x0106, "SATA controller"},
-    { 0x0107, "SAS controller"},
-    { 0x0180, "Storage controller"},
-    { 0x0200, "Ethernet controller", "ethernet"},
-    { 0x0201, "Token Ring controller", "token-ring"},
-    { 0x0202, "FDDI controller", "fddi"},
-    { 0x0203, "ATM controller", "atm"},
-    { 0x0280, "Network controller"},
-    { 0x0300, "VGA controller", "display", 0x00ff},
-    { 0x0301, "XGA controller"},
-    { 0x0302, "3D controller"},
-    { 0x0380, "Display controller"},
-    { 0x0400, "Video controller", "video"},
-    { 0x0401, "Audio controller", "sound"},
-    { 0x0402, "Phone"},
-    { 0x0403, "Audio controller", "sound"},
-    { 0x0480, "Multimedia controller"},
-    { 0x0500, "RAM controller", "memory"},
-    { 0x0501, "Flash controller", "flash"},
-    { 0x0580, "Memory controller"},
-    { 0x0600, "Host bridge", "host"},
-    { 0x0601, "ISA bridge", "isa"},
-    { 0x0602, "EISA bridge", "eisa"},
-    { 0x0603, "MC bridge", "mca"},
-    { 0x0604, "PCI bridge", "pci"},
-    { 0x0605, "PCMCIA bridge", "pcmcia"},
-    { 0x0606, "NUBUS bridge", "nubus"},
-    { 0x0607, "CARDBUS bridge", "cardbus"},
-    { 0x0608, "RACEWAY bridge"},
-    { 0x0680, "Bridge"},
-    { 0x0700, "Serial port", "serial"},
-    { 0x0701, "Parallel port", "parallel"},
-    { 0x0800, "Interrupt controller", "interrupt-controller"},
-    { 0x0801, "DMA controller", "dma-controller"},
-    { 0x0802, "Timer", "timer"},
-    { 0x0803, "RTC", "rtc"},
-    { 0x0900, "Keyboard", "keyboard"},
-    { 0x0901, "Pen", "pen"},
-    { 0x0902, "Mouse", "mouse"},
-    { 0x0A00, "Dock station", "dock", 0x00ff},
-    { 0x0B00, "i386 cpu", "cpu", 0x00ff},
-    { 0x0c00, "Fireware contorller", "fireware"},
-    { 0x0c01, "Access bus controller", "access-bus"},
-    { 0x0c02, "SSA controller", "ssa"},
-    { 0x0c03, "USB controller", "usb"},
-    { 0x0c04, "Fibre channel controller", "fibre-channel"},
-    { 0x0c05, "SMBus"},
-    { 0, NULL}
-};
-
-static void pci_for_each_device_under_bus(PCIBus *bus,
-                                          void (*fn)(PCIBus *b, PCIDevice *d,
-                                                     void *opaque),
-                                          void *opaque)
-{
-    PCIDevice *d;
-    int devfn;
-
-    for(devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
-        d = bus->devices[devfn];
-        if (d) {
-            fn(bus, d, opaque);
-        }
-    }
-}
-
-void pci_for_each_device(PCIBus *bus, int bus_num,
-                         void (*fn)(PCIBus *b, PCIDevice *d, void *opaque),
-                         void *opaque)
-{
-    bus = pci_find_bus_nr(bus, bus_num);
-
-    if (bus) {
-        pci_for_each_device_under_bus(bus, fn, opaque);
-    }
-}
-
-static const pci_class_desc *get_class_desc(int class)
-{
-    const pci_class_desc *desc;
-
-    desc = pci_class_descriptions;
-    while (desc->desc && class != desc->class) {
-        desc++;
-    }
-
-    return desc;
-}
-
-static PciDeviceInfoList *qmp_query_pci_devices(PCIBus *bus, int bus_num);
-
-static PciMemoryRegionList *qmp_query_pci_regions(const PCIDevice *dev)
-{
-    PciMemoryRegionList *head = NULL, *cur_item = NULL;
-    int i;
-
-    for (i = 0; i < PCI_NUM_REGIONS; i++) {
-        const PCIIORegion *r = &dev->io_regions[i];
-        PciMemoryRegionList *region;
-
-        if (!r->size) {
-            continue;
-        }
-
-        region = g_malloc0(sizeof(*region));
-        region->value = g_malloc0(sizeof(*region->value));
-
-        if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
-            region->value->type = g_strdup("io");
-        } else {
-            region->value->type = g_strdup("memory");
-            region->value->has_prefetch = true;
-            region->value->prefetch = !!(r->type & PCI_BASE_ADDRESS_MEM_PREFETCH);
-            region->value->has_mem_type_64 = true;
-            region->value->mem_type_64 = !!(r->type & PCI_BASE_ADDRESS_MEM_TYPE_64);
-        }
-
-        region->value->bar = i;
-        region->value->address = r->addr;
-        region->value->size = r->size;
-
-        /* XXX: waiting for the qapi to support GSList */
-        if (!cur_item) {
-            head = cur_item = region;
-        } else {
-            cur_item->next = region;
-            cur_item = region;
-        }
-    }
-
-    return head;
-}
-
-static PciBridgeInfo *qmp_query_pci_bridge(PCIDevice *dev, PCIBus *bus,
-                                           int bus_num)
-{
-    PciBridgeInfo *info;
-
-    info = g_malloc0(sizeof(*info));
-
-    info->bus.number = dev->config[PCI_PRIMARY_BUS];
-    info->bus.secondary = dev->config[PCI_SECONDARY_BUS];
-    info->bus.subordinate = dev->config[PCI_SUBORDINATE_BUS];
-
-    info->bus.io_range = g_malloc0(sizeof(*info->bus.io_range));
-    info->bus.io_range->base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_IO);
-    info->bus.io_range->limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_IO);
-
-    info->bus.memory_range = g_malloc0(sizeof(*info->bus.memory_range));
-    info->bus.memory_range->base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);
-    info->bus.memory_range->limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);
-
-    info->bus.prefetchable_range = g_malloc0(sizeof(*info->bus.prefetchable_range));
-    info->bus.prefetchable_range->base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
-    info->bus.prefetchable_range->limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
-
-    if (dev->config[PCI_SECONDARY_BUS] != 0) {
-        PCIBus *child_bus = pci_find_bus_nr(bus, dev->config[PCI_SECONDARY_BUS]);
-        if (child_bus) {
-            info->has_devices = true;
-            info->devices = qmp_query_pci_devices(child_bus, dev->config[PCI_SECONDARY_BUS]);
-        }
-    }
-
-    return info;
-}
-
-static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus,
-                                           int bus_num)
-{
-    const pci_class_desc *desc;
-    PciDeviceInfo *info;
-    uint8_t type;
-    int class;
-
-    info = g_malloc0(sizeof(*info));
-    info->bus = bus_num;
-    info->slot = PCI_SLOT(dev->devfn);
-    info->function = PCI_FUNC(dev->devfn);
-
-    class = pci_get_word(dev->config + PCI_CLASS_DEVICE);
-    info->class_info.class = class;
-    desc = get_class_desc(class);
-    if (desc->desc) {
-        info->class_info.has_desc = true;
-        info->class_info.desc = g_strdup(desc->desc);
-    }
-
-    info->id.vendor = pci_get_word(dev->config + PCI_VENDOR_ID);
-    info->id.device = pci_get_word(dev->config + PCI_DEVICE_ID);
-    info->regions = qmp_query_pci_regions(dev);
-    info->qdev_id = g_strdup(dev->qdev.id ? dev->qdev.id : "");
-
-    if (dev->config[PCI_INTERRUPT_PIN] != 0) {
-        info->has_irq = true;
-        info->irq = dev->config[PCI_INTERRUPT_LINE];
-    }
-
-    type = dev->config[PCI_HEADER_TYPE] & ~PCI_HEADER_TYPE_MULTI_FUNCTION;
-    if (type == PCI_HEADER_TYPE_BRIDGE) {
-        info->has_pci_bridge = true;
-        info->pci_bridge = qmp_query_pci_bridge(dev, bus, bus_num);
-    }
-
-    return info;
-}
-
-static PciDeviceInfoList *qmp_query_pci_devices(PCIBus *bus, int bus_num)
-{
-    PciDeviceInfoList *info, *head = NULL, *cur_item = NULL;
-    PCIDevice *dev;
-    int devfn;
-
-    for (devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
-        dev = bus->devices[devfn];
-        if (dev) {
-            info = g_malloc0(sizeof(*info));
-            info->value = qmp_query_pci_device(dev, bus, bus_num);
-
-            /* XXX: waiting for the qapi to support GSList */
-            if (!cur_item) {
-                head = cur_item = info;
-            } else {
-                cur_item->next = info;
-                cur_item = info;
-            }
-        }
-    }
-
-    return head;
-}
-
-static PciInfo *qmp_query_pci_bus(PCIBus *bus, int bus_num)
-{
-    PciInfo *info = NULL;
-
-    bus = pci_find_bus_nr(bus, bus_num);
-    if (bus) {
-        info = g_malloc0(sizeof(*info));
-        info->bus = bus_num;
-        info->devices = qmp_query_pci_devices(bus, bus_num);
-    }
-
-    return info;
-}
-
-PciInfoList *qmp_query_pci(Error **errp)
-{
-    PciInfoList *info, *head = NULL, *cur_item = NULL;
-    struct PCIHostBus *host;
-
-    QLIST_FOREACH(host, &host_buses, next) {
-        info = g_malloc0(sizeof(*info));
-        info->value = qmp_query_pci_bus(host->bus, 0);
-
-        /* XXX: waiting for the qapi to support GSList */
-        if (!cur_item) {
-            head = cur_item = info;
-        } else {
-            cur_item->next = info;
-            cur_item = info;
-        }
-    }
-
-    return head;
-}
-
-static const char * const pci_nic_models[] = {
-    "ne2k_pci",
-    "i82551",
-    "i82557b",
-    "i82559er",
-    "rtl8139",
-    "e1000",
-    "pcnet",
-    "virtio",
-    NULL
-};
-
-static const char * const pci_nic_names[] = {
-    "ne2k_pci",
-    "i82551",
-    "i82557b",
-    "i82559er",
-    "rtl8139",
-    "e1000",
-    "pcnet",
-    "virtio-net-pci",
-    NULL
-};
-
-/* Initialize a PCI NIC.  */
-/* FIXME callers should check for failure, but don't */
-PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
-                        const char *default_devaddr)
-{
-    const char *devaddr = nd->devaddr ? nd->devaddr : default_devaddr;
-    PCIBus *bus;
-    int devfn;
-    PCIDevice *pci_dev;
-    DeviceState *dev;
-    int i;
-
-    i = qemu_find_nic_model(nd, pci_nic_models, default_model);
-    if (i < 0)
-        return NULL;
-
-    bus = pci_get_bus_devfn(&devfn, devaddr);
-    if (!bus) {
-        error_report("Invalid PCI device address %s for device %s",
-                     devaddr, pci_nic_names[i]);
-        return NULL;
-    }
-
-    pci_dev = pci_create(bus, devfn, pci_nic_names[i]);
-    dev = &pci_dev->qdev;
-    qdev_set_nic_properties(dev, nd);
-    if (qdev_init(dev) < 0)
-        return NULL;
-    return pci_dev;
-}
-
-PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
-                               const char *default_devaddr)
-{
-    PCIDevice *res;
-
-    if (qemu_show_nic_models(nd->model, pci_nic_models))
-        exit(0);
-
-    res = pci_nic_init(nd, default_model, default_devaddr);
-    if (!res)
-        exit(1);
-    return res;
-}
-
-PCIDevice *pci_vga_init(PCIBus *bus)
-{
-    switch (vga_interface_type) {
-    case VGA_CIRRUS:
-        return pci_create_simple(bus, -1, "cirrus-vga");
-    case VGA_QXL:
-        return pci_create_simple(bus, -1, "qxl-vga");
-    case VGA_STD:
-        return pci_create_simple(bus, -1, "VGA");
-    case VGA_VMWARE:
-        return pci_create_simple(bus, -1, "vmware-svga");
-    case VGA_NONE:
-    default: /* Other non-PCI types. Checking for unsupported types is already
-                done in vl.c. */
-        return NULL;
-    }
-}
-
-/* Whether a given bus number is in range of the secondary
- * bus of the given bridge device. */
-static bool pci_secondary_bus_in_range(PCIDevice *dev, int bus_num)
-{
-    return !(pci_get_word(dev->config + PCI_BRIDGE_CONTROL) &
-             PCI_BRIDGE_CTL_BUS_RESET) /* Don't walk the bus if it's reset. */ &&
-        dev->config[PCI_SECONDARY_BUS] < bus_num &&
-        bus_num <= dev->config[PCI_SUBORDINATE_BUS];
-}
-
-static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num)
-{
-    PCIBus *sec;
-
-    if (!bus) {
-        return NULL;
-    }
-
-    if (pci_bus_num(bus) == bus_num) {
-        return bus;
-    }
-
-    /* Consider all bus numbers in range for the host pci bridge. */
-    if (bus->parent_dev &&
-        !pci_secondary_bus_in_range(bus->parent_dev, bus_num)) {
-        return NULL;
-    }
-
-    /* try child bus */
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

hw/pci.h deleted +0 -684
deleted file mode 100644
index 4da0c2a..0000000

Lines of this file are not shown. View the raw message.

hw/pci/Makefile.objs new file +6 -0
new file mode 100644
index 0000000..9d21952

Lines of this file are not shown. View the raw message.

hw/pci/msi.c new file +395 -0
new file mode 100644
index 0000000..33037a8

Lines of this file are not shown. View the raw message.

hw/pci/msi.h new file +50 -0
new file mode 100644
index 0000000..150b09a

Lines of this file are not shown. View the raw message.

hw/pci/msix.c new file +562 -0
new file mode 100644
index 0000000..136ef09

Lines of this file are not shown. View the raw message.

hw/pci/msix.h new file +41 -0
new file mode 100644
index 0000000..15211cb

Lines of this file are not shown. View the raw message.

hw/pci/pci-hotplug.c new file +293 -0
new file mode 100644
index 0000000..0ca5546

Lines of this file are not shown. View the raw message.

hw/pci/pci-stub.c new file +47 -0
new file mode 100644
index 0000000..134c448

Lines of this file are not shown. View the raw message.

hw/pci/pci.c new file +2168 -0
new file mode 100644
index 0000000..97a0cd7

Lines of this file are not shown. View the raw message.

hw/pci/pci.h new file +684 -0
new file mode 100644
index 0000000..4da0c2a

Lines of this file are not shown. View the raw message.

hw/pci/pci_bridge.c new file +363 -0
new file mode 100644
index 0000000..4680501

Lines of this file are not shown. View the raw message.

hw/pci/pci_bridge.h new file +66 -0
new file mode 100644
index 0000000..a00accc

Lines of this file are not shown. View the raw message.

hw/pci/pci_host.c new file +180 -0
new file mode 100644
index 0000000..68e328c

Lines of this file are not shown. View the raw message.

hw/pci/pci_host.h new file +62 -0
new file mode 100644
index 0000000..4b9c300

Lines of this file are not shown. View the raw message.

hw/pci/pci_ids.h new file +147 -0
new file mode 100644
index 0000000..5df7245

Lines of this file are not shown. View the raw message.

hw/pci/pci_internals.h new file +78 -0
new file mode 100644
index 0000000..21d0ce6

Lines of this file are not shown. View the raw message.

hw/pci/pci_regs.h new file +717 -0
new file mode 100644
index 0000000..56a404b

Lines of this file are not shown. View the raw message.

hw/pci/pcie.c new file +555 -0
new file mode 100644
index 0000000..7c92f19

Lines of this file are not shown. View the raw message.

hw/pci/pcie.h new file +142 -0
new file mode 100644
index 0000000..4889194

Lines of this file are not shown. View the raw message.

hw/pci/pcie_aer.c new file +1032 -0
new file mode 100644
index 0000000..b04c164

Lines of this file are not shown. View the raw message.

hw/pci/pcie_aer.h new file +106 -0
new file mode 100644
index 0000000..7539500

Lines of this file are not shown. View the raw message.

hw/pci/pcie_host.c new file +161 -0
new file mode 100644
index 0000000..c257fb4

Lines of this file are not shown. View the raw message.

hw/pci/pcie_host.h new file +54 -0
new file mode 100644
index 0000000..3921935

Lines of this file are not shown. View the raw message.

hw/pci/pcie_port.c new file +114 -0
new file mode 100644
index 0000000..d6350e5

Lines of this file are not shown. View the raw message.

hw/pci/pcie_port.h new file +51 -0
new file mode 100644
index 0000000..3709583

Lines of this file are not shown. View the raw message.

hw/pci/pcie_regs.h new file +156 -0
new file mode 100644
index 0000000..4d123d9

Lines of this file are not shown. View the raw message.

hw/pci/shpc.c new file +681 -0
new file mode 100644
index 0000000..4597bbd

Lines of this file are not shown. View the raw message.

hw/pci/shpc.h new file +48 -0
new file mode 100644
index 0000000..130b71d

Lines of this file are not shown. View the raw message.

hw/pci/slotid_cap.c new file +44 -0
new file mode 100644
index 0000000..0106452

Lines of this file are not shown. View the raw message.

hw/pci/slotid_cap.h new file +11 -0
new file mode 100644
index 0000000..70db047

Lines of this file are not shown. View the raw message.

hw/pci_bridge.c deleted +0 -363
deleted file mode 100644
index 4680501..0000000

Lines of this file are not shown. View the raw message.

hw/pci_bridge.h deleted +0 -66
deleted file mode 100644
index a00accc..0000000

Lines of this file are not shown. View the raw message.

hw/pci_host.c deleted +0 -180
deleted file mode 100644
index 68e328c..0000000

Lines of this file are not shown. View the raw message.

hw/pci_host.h deleted +0 -62
deleted file mode 100644
index 4b9c300..0000000

Lines of this file are not shown. View the raw message.

hw/pci_ids.h deleted +0 -147
deleted file mode 100644
index 5df7245..0000000

Lines of this file are not shown. View the raw message.

hw/pci_internals.h deleted +0 -78
deleted file mode 100644
index 21d0ce6..0000000

Lines of this file are not shown. View the raw message.

hw/pci_regs.h deleted +0 -717
deleted file mode 100644
index 56a404b..0000000

Lines of this file are not shown. View the raw message.

hw/pcie.c deleted +0 -555
deleted file mode 100644
index 7c92f19..0000000

Lines of this file are not shown. View the raw message.

hw/pcie.h deleted +0 -142
deleted file mode 100644
index 4889194..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_aer.c deleted +0 -1032
deleted file mode 100644
index b04c164..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_aer.h deleted +0 -106
deleted file mode 100644
index 7539500..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_host.c deleted +0 -161
deleted file mode 100644
index c257fb4..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_host.h deleted +0 -54
deleted file mode 100644
index 3921935..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_port.c deleted +0 -114
deleted file mode 100644
index d6350e5..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_port.h deleted +0 -51
deleted file mode 100644
index 3709583..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_regs.h deleted +0 -156
deleted file mode 100644
index 4d123d9..0000000

Lines of this file are not shown. View the raw message.

hw/ppc/Makefile.objs +1 -1
index 8fe2123..cb7cf8f 100644

Lines of this file are not shown. View the raw message.

hw/shpc.c deleted +0 -681
deleted file mode 100644
index 4597bbd..0000000

Lines of this file are not shown. View the raw message.

hw/shpc.h deleted +0 -48
deleted file mode 100644
index 130b71d..0000000

Lines of this file are not shown. View the raw message.

hw/slotid_cap.c deleted +0 -44
deleted file mode 100644
index 0106452..0000000

Lines of this file are not shown. View the raw message.

hw/slotid_cap.h deleted +0 -12
deleted file mode 100644
index 70db047..0000000

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

MST

Part of the diff is not shown here. View the raw message.

#12 lore raw

Re: [Qemu-devel] [PATCH 7/8] pci: rename pci_internals.h pci_bus.h

In reply to Michael S. Tsirkin
Quoted 108 lines · Michael S. Tsirkin

There are lots of external users of pci_internals.h, apparently making it an internal interface only didn't work out. Let's stop pretending it's an internal header.

---
 hw/apb_pci.c           |  2 +-
 hw/dec_pci.c           |  2 +-
 hw/ich9.h              |  2 +-
 hw/lpc_ich9.c          |  2 +-
 hw/pci/pci.c           |  2 +-
 hw/pci/pci_bridge.c    |  2 +-
 hw/pci/pci_bus.h       | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/pci/pci_internals.h | 78 --------------------------------------------------
 hw/pci/pcie.c          |  2 +-
 hw/pci/pcie_aer.c      |  2 +-
 hw/pci/pcie_port.h     |  2 +-
 hw/pci/shpc.c          |  2 +-
 hw/pci_bridge_dev.c    |  2 +-
 hw/spapr_pci.c         |  2 +-
 14 files changed, 90 insertions(+), 90 deletions(-)
 create mode 100644 hw/pci/pci_bus.h
 delete mode 100644 hw/pci/pci_internals.h
hw/apb_pci.c +1 -1
index de594f8..fb7a07d 100644
@@ -30,7 +30,7 @@
 #include "pci/pci.h"
 #include "pci/pci_host.h"
 #include "pci/pci_bridge.h"
-#include "pci/pci_internals.h"
+#include "pci/pci_bus.h"
 #include "apb_pci.h"
 #include "sysemu.h"
 #include "exec-memory.h"
hw/dec_pci.c +1 -1
index a6a7c84..ee3f4ca 100644
@@ -28,7 +28,7 @@
 #include "pci/pci.h"
 #include "pci/pci_host.h"
 #include "pci/pci_bridge.h"
-#include "pci/pci_internals.h"
+#include "pci/pci_bus.h"
 
 /* debug DEC */
 //#define DEBUG_DEC
hw/ich9.h +1 -1
index 247be94..4e7442c 100644
@@ -14,7 +14,7 @@
 #include "acpi.h"
 #include "acpi_ich9.h"
 #include "pam.h"
-#include "pci/pci_internals.h"
+#include "pci/pci_bus.h"
 
 void ich9_lpc_set_irq(void *opaque, int irq_num, int level);
 int ich9_lpc_map_irq(PCIDevice *pci_dev, int intx);
hw/lpc_ich9.c +1 -1
index 23dee88..7bca061 100644
@@ -42,7 +42,7 @@
 #include "acpi.h"
 #include "acpi_ich9.h"
 #include "pam.h"
-#include "pci/pci_internals.h"
+#include "pci/pci_bus.h"
 #include "exec-memory.h"
 
 static int ich9_lpc_sci_irq(ICH9LPCState *lpc);
hw/pci/pci.c +1 -1
index 6023ded..c1a4b32 100644
@@ -24,7 +24,7 @@
 #include <hw/hw.h>
 #include "pci.h"
 #include "pci_bridge.h"
-#include "pci_internals.h"
+#include "pci_bus.h"
 #include <monitor.h>
 #include <net.h>
 #include <sysemu.h>
hw/pci/pci_bridge.c +1 -1
index 4680501..0fb7577 100644
@@ -30,7 +30,7 @@
  */
 
 #include "pci_bridge.h"
-#include "pci_internals.h"
+#include "pci_bus.h"
 #include "range.h"
 
 /* PCI bridge subsystem vendor ID helper functions */
hw/pci/pci_bus.h new file +0 -0
new file mode 100644
index 0000000..21d0ce6

hw/pci/pci_bus.h line 2

Quoted 2 lines
hw/pci/pci_bus.h new file +2 -0
@@ -0,0 +1,78 @@
+#ifndef QEMU_PCI_INTERNALS_H
+#define QEMU_PCI_INTERNALS_H

This should become QEMU_PCI_BUS_H or something similar.

Quoted 242 lines
hw/pci/pci_bus.h new file +76 -0
+
+/*
+ * This header files is private to pci.c and pci_bridge.c
+ * So following structures are opaque to others and shouldn't be
+ * accessed.
+ *
+ * For pci-to-pci bridge needs to include this header file to embed
+ * PCIBridge in its structure or to get sizeof(PCIBridge),
+ * However, they shouldn't access those following members directly.
+ * Use accessor function in pci.h, pci_bridge.h
+ */
+
+#define TYPE_PCI_BUS "PCI"
+#define PCI_BUS(obj) OBJECT_CHECK(PCIBus, (obj), TYPE_PCI_BUS)
+
+struct PCIBus {
+    BusState qbus;
+    PCIDMAContextFunc dma_context_fn;
+    void *dma_context_opaque;
+    uint8_t devfn_min;
+    pci_set_irq_fn set_irq;
+    pci_map_irq_fn map_irq;
+    pci_route_irq_fn route_intx_to_irq;
+    pci_hotplug_fn hotplug;
+    DeviceState *hotplug_qdev;
+    void *irq_opaque;
+    PCIDevice *devices[PCI_SLOT_MAX * PCI_FUNC_MAX];
+    PCIDevice *parent_dev;
+    MemoryRegion *address_space_mem;
+    MemoryRegion *address_space_io;
+
+    QLIST_HEAD(, PCIBus) child; /* this will be replaced by qdev later */
+    QLIST_ENTRY(PCIBus) sibling;/* this will be replaced by qdev later */
+
+    /* The bus IRQ state is the logical OR of the connected devices.
+       Keep a count of the number of devices with raised IRQs.  */
+    int nirq;
+    int *irq_count;
+};
+
+typedef struct PCIBridgeWindows PCIBridgeWindows;
+
+/*
+ * Aliases for each of the address space windows that the bridge
+ * can forward. Mapped into the bridge's parent's address space,
+ * as subregions.
+ */
+struct PCIBridgeWindows {
+    MemoryRegion alias_pref_mem;
+    MemoryRegion alias_mem;
+    MemoryRegion alias_io;
+};
+
+struct PCIBridge {
+    PCIDevice dev;
+
+    /* private member */
+    PCIBus sec_bus;
+    /*
+     * Memory regions for the bridge's address spaces.  These regions are not
+     * directly added to system_memory/system_io or its descendants.
+     * Bridge's secondary bus points to these, so that devices
+     * under the bridge see these regions as its address spaces.
+     * The regions are as large as the entire address space -
+     * they don't take into account any windows.
+     */
+    MemoryRegion address_space_mem;
+    MemoryRegion address_space_io;
+
+    PCIBridgeWindows *windows;
+
+    pci_map_irq_fn map_irq;
+    const char *bus_name;
+};
+
+#endif /* QEMU_PCI_INTERNALS_H */
hw/pci/pci_internals.h deleted +0 -78
deleted file mode 100644
index 21d0ce6..0000000
@@ -1,78 +0,0 @@
-#ifndef QEMU_PCI_INTERNALS_H
-#define QEMU_PCI_INTERNALS_H
-
-/*
- * This header files is private to pci.c and pci_bridge.c
- * So following structures are opaque to others and shouldn't be
- * accessed.
- *
- * For pci-to-pci bridge needs to include this header file to embed
- * PCIBridge in its structure or to get sizeof(PCIBridge),
- * However, they shouldn't access those following members directly.
- * Use accessor function in pci.h, pci_bridge.h
- */
-
-#define TYPE_PCI_BUS "PCI"
-#define PCI_BUS(obj) OBJECT_CHECK(PCIBus, (obj), TYPE_PCI_BUS)
-
-struct PCIBus {
-    BusState qbus;
-    PCIDMAContextFunc dma_context_fn;
-    void *dma_context_opaque;
-    uint8_t devfn_min;
-    pci_set_irq_fn set_irq;
-    pci_map_irq_fn map_irq;
-    pci_route_irq_fn route_intx_to_irq;
-    pci_hotplug_fn hotplug;
-    DeviceState *hotplug_qdev;
-    void *irq_opaque;
-    PCIDevice *devices[PCI_SLOT_MAX * PCI_FUNC_MAX];
-    PCIDevice *parent_dev;
-    MemoryRegion *address_space_mem;
-    MemoryRegion *address_space_io;
-
-    QLIST_HEAD(, PCIBus) child; /* this will be replaced by qdev later */
-    QLIST_ENTRY(PCIBus) sibling;/* this will be replaced by qdev later */
-
-    /* The bus IRQ state is the logical OR of the connected devices.
-       Keep a count of the number of devices with raised IRQs.  */
-    int nirq;
-    int *irq_count;
-};
-
-typedef struct PCIBridgeWindows PCIBridgeWindows;
-
-/*
- * Aliases for each of the address space windows that the bridge
- * can forward. Mapped into the bridge's parent's address space,
- * as subregions.
- */
-struct PCIBridgeWindows {
-    MemoryRegion alias_pref_mem;
-    MemoryRegion alias_mem;
-    MemoryRegion alias_io;
-};
-
-struct PCIBridge {
-    PCIDevice dev;
-
-    /* private member */
-    PCIBus sec_bus;
-    /*
-     * Memory regions for the bridge's address spaces.  These regions are not
-     * directly added to system_memory/system_io or its descendants.
-     * Bridge's secondary bus points to these, so that devices
-     * under the bridge see these regions as its address spaces.
-     * The regions are as large as the entire address space -
-     * they don't take into account any windows.
-     */
-    MemoryRegion address_space_mem;
-    MemoryRegion address_space_io;
-
-    PCIBridgeWindows *windows;
-
-    pci_map_irq_fn map_irq;
-    const char *bus_name;
-};
-
-#endif /* QEMU_PCI_INTERNALS_H */
hw/pci/pcie.c +1 -1
index 7c92f19..d9c38b5 100644
@@ -23,7 +23,7 @@
 #include "pcie.h"
 #include "msix.h"
 #include "msi.h"
-#include "pci_internals.h"
+#include "pci_bus.h"
 #include "pcie_regs.h"
 #include "range.h"
 
hw/pci/pcie_aer.c +1 -1
index b04c164..3c3185c 100644
@@ -25,7 +25,7 @@
 #include "pcie.h"
 #include "msix.h"
 #include "msi.h"
-#include "pci_internals.h"
+#include "pci_bus.h"
 #include "pcie_regs.h"
 
 //#define DEBUG_PCIE
hw/pci/pcie_port.h +1 -1
index 3709583..36b2241 100644
@@ -22,7 +22,7 @@
 #define QEMU_PCIE_PORT_H
 
 #include "pci_bridge.h"
-#include "pci_internals.h"
+#include "pci_bus.h"
 
 struct PCIEPort {
     PCIBridge   br;
hw/pci/shpc.c +1 -1
index 4597bbd..9297af0 100644
@@ -4,7 +4,7 @@
 #include "range.h"
 #include "shpc.h"
 #include "pci.h"
-#include "pci_internals.h"
+#include "pci_bus.h"
 #include "msi.h"
 
 /* TODO: model power only and disabled slot states. */
hw/pci_bridge_dev.c +1 -1
index 5c9fc50..dbb4b3b 100644
@@ -25,7 +25,7 @@
 #include "pci/shpc.h"
 #include "pci/slotid_cap.h"
 #include "memory.h"
-#include "pci/pci_internals.h"
+#include "pci/pci_bus.h"
 
 #define REDHAT_PCI_VENDOR_ID 0x1b36
 #define PCI_BRIDGE_DEV_VENDOR_ID REDHAT_PCI_VENDOR_ID
hw/spapr_pci.c +1 -2
index e123866..6b05e5b 100644
@@ -33,7 +33,7 @@
 #include <libfdt.h>
 #include "trace.h"
 
-#include "hw/pci/pci_internals.h"
+#include "hw/pci/pci_bus.h"
 
 /* Copied from the kernel arch/powerpc/platforms/pseries/msi.c */
 #define RTAS_QUERY_FN           0
--

MST

#17 lore raw
In reply to Michael S. Tsirkin
Quoted 9 lines · Michael S. Tsirkin

This patchset starts some cleanups of the pci core by rearranging the code: pci core is split out from devices into its own directory, pci internals.h is renamed as it's used externally a lot.

I'd like to merge this quickly to avoid conflicting with others work.
Plan to send pull request tomorrow, if you have concerns, speak up soon pls.

I had a few comments and one nack but otherwise nice cleanup.

Quoted 239 lines

Thanks,

Michael S. Tsirkin (8):
pci: prepare makefiles for pci code reorganization
MAINTAINERS: add hw/pci/ to list of PCI files
pci: move pci core code to hw/pci
pci: update all users to look in pci/
pci: make external dependencies explicit
Revert "pci: prepare makefiles for pci code reorganization"
pci: rename pci_internals.h pci_bus.h
pci_bus: update comment

 MAINTAINERS              |    1 +
 arch_init.c              |    2 +-
 hw/Makefile.objs         |   10 +-
 hw/ac97.c                |    2 +-
 hw/acpi_ich9.c           |    2 +-
 hw/acpi_piix4.c          |    2 +-
 hw/alpha_sys.h           |    4 +-
 hw/apb_pci.c             |    8 +-
 hw/apic.c                |    2 +-
 hw/bonito.c              |    4 +-
 hw/cirrus_vga.c          |    2 +-
 hw/dec_pci.c             |    8 +-
 hw/e1000.c               |    2 +-
 hw/eepro100.c            |    2 +-
 hw/es1370.c              |    2 +-
 hw/esp-pci.c             |    2 +-
 hw/grackle_pci.c         |    4 +-
 hw/gt64xxx.c             |    4 +-
 hw/hda-audio.c           |    2 +-
 hw/i386/Makefile.objs    |    2 +-
 hw/i82378.c              |    2 +-
 hw/i82801b11.c           |    2 +-
 hw/ich9.h                |    8 +-
 hw/ide.h                 |    2 +-
 hw/ide/ahci.c            |    4 +-
 hw/ide/cmd646.c          |    2 +-
 hw/ide/core.c            |    2 +-
 hw/ide/ich.c             |    4 +-
 hw/ide/pci.c             |    2 +-
 hw/ide/piix.c            |    2 +-
 hw/ide/via.c             |    2 +-
 hw/intel-hda.c           |    4 +-
 hw/ioh3420.c             |    6 +-
 hw/ioh3420.h             |    2 +-
 hw/ivshmem.c             |    4 +-
 hw/kvm/apic.c            |    2 +-
 hw/kvm/pci-assign.c      |    4 +-
 hw/lpc_ich9.c            |    8 +-
 hw/lsi53c895a.c          |    2 +-
 hw/macio.c               |    2 +-
 hw/megasas.c             |    4 +-
 hw/mips_fulong2e.c       |    2 +-
 hw/mips_malta.c          |    2 +-
 hw/msi.c                 |  395 ---------
 hw/msi.h                 |   50 --
 hw/msix.c                |  562 ------------
 hw/msix.h                |   41 -
 hw/ne2000.c              |    2 +-
 hw/openpic.c             |    2 +-
 hw/pc.c                  |    4 +-
 hw/pc_piix.c             |    4 +-
 hw/pci-hotplug.c         |  293 -------
 hw/pci-stub.c            |   47 -
 hw/pci.c                 | 2168 ----------------------------------------------
 hw/pci.h                 |  684 ---------------
 hw/pci/Makefile.objs     |    6 +
 hw/pci/msi.c             |  395 +++++++++
 hw/pci/msi.h             |   50 ++
 hw/pci/msix.c            |  562 ++++++++++++
 hw/pci/msix.h            |   41 +
 hw/pci/pci-hotplug.c     |  293 +++++++
 hw/pci/pci-stub.c        |   47 +
 hw/pci/pci.c             | 2168 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/pci/pci.h             |  684 +++++++++++++++
 hw/pci/pci_bridge.c      |  363 ++++++++
 hw/pci/pci_bridge.h      |   66 ++
 hw/pci/pci_bus.h         |   74 ++
 hw/pci/pci_host.c        |  180 ++++
 hw/pci/pci_host.h        |   62 ++
 hw/pci/pci_ids.h         |  147 ++++
 hw/pci/pci_regs.h        |  717 +++++++++++++++
 hw/pci/pcie.c            |  555 ++++++++++++
 hw/pci/pcie.h            |  142 +++
 hw/pci/pcie_aer.c        | 1032 ++++++++++++++++++++++
 hw/pci/pcie_aer.h        |  106 +++
 hw/pci/pcie_host.c       |  161 ++++
 hw/pci/pcie_host.h       |   54 ++
 hw/pci/pcie_port.c       |  114 +++
 hw/pci/pcie_port.h       |   51 ++
 hw/pci/pcie_regs.h       |  156 ++++
 hw/pci/shpc.c            |  681 +++++++++++++++
 hw/pci/shpc.h            |   48 +
 hw/pci/slotid_cap.c      |   44 +
 hw/pci/slotid_cap.h      |   11 +
 hw/pci_bridge.c          |  363 --------
 hw/pci_bridge.h          |   66 --
 hw/pci_bridge_dev.c      |   12 +-
 hw/pci_host.c            |  180 ----
 hw/pci_host.h            |   62 --
 hw/pci_ids.h             |  147 ----
 hw/pci_internals.h       |   78 --
 hw/pci_regs.h            |  717 ---------------
 hw/pcie.c                |  555 ------------
 hw/pcie.h                |  142 ---
 hw/pcie_aer.c            | 1032 ----------------------
 hw/pcie_aer.h            |  106 ---
 hw/pcie_host.c           |  161 ----
 hw/pcie_host.h           |   54 --
 hw/pcie_port.c           |  114 ---
 hw/pcie_port.h           |   51 --
 hw/pcie_regs.h           |  156 ----
 hw/pcnet-pci.c           |    2 +-
 hw/piix4.c               |    2 +-
 hw/piix_pci.c            |    4 +-
 hw/ppc/Makefile.objs     |    2 +-
 hw/ppc/e500.c            |    2 +-
 hw/ppc440_bamboo.c       |    2 +-
 hw/ppc4xx.h              |    2 +-
 hw/ppc4xx_pci.c          |    4 +-
 hw/ppc_newworld.c        |    2 +-
 hw/ppc_oldworld.c        |    2 +-
 hw/ppc_prep.c            |    4 +-
 hw/ppce500_pci.c         |    4 +-
 hw/prep_pci.c            |    4 +-
 hw/q35.h                 |    4 +-
 hw/qxl.h                 |    2 +-
 hw/r2d.c                 |    2 +-
 hw/realview.c            |    2 +-
 hw/rtl8139.c             |    2 +-
 hw/serial-pci.c          |    2 +-
 hw/sga.c                 |    2 +-
 hw/sh_pci.c              |    4 +-
 hw/shpc.c                |  681 ---------------
 hw/shpc.h                |   48 -
 hw/slotid_cap.c          |   44 -
 hw/slotid_cap.h          |   11 -
 hw/smbus_ich9.c          |    2 +-
 hw/spapr.c               |    4 +-
 hw/spapr_pci.c           |   10 +-
 hw/spapr_pci.h           |    4 +-
 hw/sun4u.c               |    2 +-
 hw/unin_pci.c            |    4 +-
 hw/usb/hcd-ehci-pci.c    |    2 +-
 hw/usb/hcd-ohci.c        |    2 +-
 hw/usb/hcd-uhci.c        |    2 +-
 hw/usb/hcd-xhci.c        |    6 +-
 hw/versatile_pci.c       |    4 +-
 hw/versatilepb.c         |    2 +-
 hw/vfio_pci.c            |    6 +-
 hw/vga-pci.c             |    2 +-
 hw/vga.c                 |    2 +-
 hw/virtio-balloon.h      |    2 +-
 hw/virtio-net.h          |    2 +-
 hw/virtio-pci.c          |    6 +-
 hw/virtio-scsi.h         |    2 +-
 hw/vmware_vga.c          |    2 +-
 hw/vt82c686.c            |    4 +-
 hw/wdt_i6300esb.c        |    2 +-
 hw/xen-host-pci-device.h |    2 +-
 hw/xen_apic.c            |    2 +-
 hw/xen_platform.c        |    2 +-
 hw/xen_pt.c              |    2 +-
 hw/xen_pt.h              |    2 +-
 hw/xio3130_downstream.c  |    6 +-
 hw/xio3130_downstream.h  |    2 +-
 hw/xio3130_upstream.c    |    6 +-
 hw/xio3130_upstream.h    |    2 +-
 kvm-all.c                |    2 +-
 kvm-stub.c               |    2 +-
 monitor.c                |    2 +-
 target-i386/kvm.c        |    2 +-
 xen-all.c                |    2 +-
 162 files changed, 9173 insertions(+), 9176 deletions(-)
 delete mode 100644 hw/msi.c
 delete mode 100644 hw/msi.h
 delete mode 100644 hw/msix.c
 delete mode 100644 hw/msix.h
 delete mode 100644 hw/pci-hotplug.c
 delete mode 100644 hw/pci-stub.c
 delete mode 100644 hw/pci.c
 delete mode 100644 hw/pci.h
 create mode 100644 hw/pci/Makefile.objs
 create mode 100644 hw/pci/msi.c
 create mode 100644 hw/pci/msi.h
 create mode 100644 hw/pci/msix.c
 create mode 100644 hw/pci/msix.h
 create mode 100644 hw/pci/pci-hotplug.c
 create mode 100644 hw/pci/pci-stub.c
 create mode 100644 hw/pci/pci.c
 create mode 100644 hw/pci/pci.h
 create mode 100644 hw/pci/pci_bridge.c
 create mode 100644 hw/pci/pci_bridge.h
 create mode 100644 hw/pci/pci_bus.h
 create mode 100644 hw/pci/pci_host.c
 create mode 100644 hw/pci/pci_host.h
 create mode 100644 hw/pci/pci_ids.h
 create mode 100644 hw/pci/pci_regs.h
 create mode 100644 hw/pci/pcie.c
 create mode 100644 hw/pci/pcie.h
 create mode 100644 hw/pci/pcie_aer.c
 create mode 100644 hw/pci/pcie_aer.h
 create mode 100644 hw/pci/pcie_host.c
 create mode 100644 hw/pci/pcie_host.h
 create mode 100644 hw/pci/pcie_port.c
 create mode 100644 hw/pci/pcie_port.h
 create mode 100644 hw/pci/pcie_regs.h
 create mode 100644 hw/pci/shpc.c
 create mode 100644 hw/pci/shpc.h
 create mode 100644 hw/pci/slotid_cap.c
 create mode 100644 hw/pci/slotid_cap.h
 delete mode 100644 hw/pci_bridge.c
 delete mode 100644 hw/pci_bridge.h
 delete mode 100644 hw/pci_host.c
 delete mode 100644 hw/pci_host.h
 delete mode 100644 hw/pci_ids.h
 delete mode 100644 hw/pci_internals.h
 delete mode 100644 hw/pci_regs.h
 delete mode 100644 hw/pcie.c
 delete mode 100644 hw/pcie.h
 delete mode 100644 hw/pcie_aer.c
 delete mode 100644 hw/pcie_aer.h
 delete mode 100644 hw/pcie_host.c
 delete mode 100644 hw/pcie_host.h
 delete mode 100644 hw/pcie_port.c
 delete mode 100644 hw/pcie_port.h
 delete mode 100644 hw/pcie_regs.h
 delete mode 100644 hw/shpc.c
 delete mode 100644 hw/shpc.h
 delete mode 100644 hw/slotid_cap.c
 delete mode 100644 hw/slotid_cap.h

--
MST

#9 lore raw

Re: [Qemu-devel] [PATCH 5/8] pci: make external dependencies explicit

In reply to Blue Swirl
Quoted 9 lines · Blue Swirl
Quoted 1 line · Michael S. Tsirkin

Include dependencies from pci core using <> and

Nack, the usual convention is to use <> for system headers like <stdio.h> and "" for local headers.

For example with MSVC the search path for angle brackets does not even include the local directory:
http://msdn.microsoft.com/en-us/library/36k2cdd4%28v=vs.80%29.aspx

This convention is non standard:
When hw/pci/pci.h includes hw/hw.h the lookup that succeeds is not from the current directory - it's from the -I search path. So "" simply slows the preprocessor down and increases chances of picking the wrong header, for no real benefit.

Oh well another qemu coding style eccentricity. I'll change them to "".

Quoted 182 lines
Quoted 182 lines

the correct path.
Need to check whether they can be minimized, for now, at least make them explicit.

---
 hw/pci/msix.c        |  4 ++--
 hw/pci/pci-hotplug.c | 20 ++++++++++----------
 hw/pci/pci.c         | 16 ++++++++--------
 hw/pci/pci.h         | 10 +++++-----
 hw/pci/pci_host.h    |  2 +-
 hw/pci/pcie.h        |  2 +-
 hw/pci/pcie_aer.h    |  2 +-
 hw/pci/pcie_host.c   |  4 ++--
 8 files changed, 30 insertions(+), 30 deletions(-)
hw/pci/msix.c +2 -2
index 136ef09..ec35a5d 100644
@@ -14,11 +14,11 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw.h"
+#include <hw/hw.h>
 #include "msi.h"
 #include "msix.h"
 #include "pci.h"
-#include "range.h"
+#include <range.h>
 
 #define MSIX_CAP_LENGTH 12
 
hw/pci/pci-hotplug.c +10 -10
index 0ca5546..32ba449 100644
@@ -22,17 +22,17 @@
  * THE SOFTWARE.
  */
 
-#include "hw.h"
-#include "boards.h"
+#include <hw/hw.h>
+#include <hw/boards.h>
 #include "pci.h"
-#include "net.h"
-#include "pc.h"
-#include "monitor.h"
-#include "scsi.h"
-#include "virtio-blk.h"
-#include "qemu-config.h"
-#include "blockdev.h"
-#include "error.h"
+#include <net.h>
+#include <hw/pc.h>
+#include <monitor.h>
+#include <hw/scsi.h>
+#include <hw/virtio-blk.h>
+#include <qemu-config.h>
+#include <blockdev.h>
+#include <error.h>
 
 #if defined(TARGET_I386)
 static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
hw/pci/pci.c +8 -8
index 97a0cd7..6023ded 100644
@@ -21,19 +21,19 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include "hw.h"
+#include <hw/hw.h>
 #include "pci.h"
 #include "pci_bridge.h"
 #include "pci_internals.h"
-#include "monitor.h"
-#include "net.h"
-#include "sysemu.h"
-#include "loader.h"
-#include "range.h"
-#include "qmp-commands.h"
+#include <monitor.h>
+#include <net.h>
+#include <sysemu.h>
+#include <hw/loader.h>
+#include <range.h>
+#include <qmp-commands.h>
 #include "msi.h"
 #include "msix.h"
-#include "exec-memory.h"
+#include <exec-memory.h>
 
 //#define DEBUG_PCI
 #ifdef DEBUG_PCI
hw/pci/pci.h +5 -5
index 4da0c2a..b517995 100644
@@ -1,14 +1,14 @@
 #ifndef QEMU_PCI_H
 #define QEMU_PCI_H
 
-#include "qemu-common.h"
+#include <qemu-common.h>
 
-#include "qdev.h"
-#include "memory.h"
-#include "dma.h"
+#include <hw/qdev.h>
+#include <memory.h>
+#include <dma.h>
 
 /* PCI includes legacy ISA access.  */
-#include "isa.h"
+#include <hw/isa.h>
 
 #include "pcie.h"
 
hw/pci/pci_host.h +1 -1
index 4b9c300..6dfb38d 100644
@@ -28,7 +28,7 @@
 #ifndef PCI_HOST_H
 #define PCI_HOST_H
 
-#include "sysbus.h"
+#include <hw/sysbus.h>
 
 #define TYPE_PCI_HOST_BRIDGE "pci-host-bridge"
 #define PCI_HOST_BRIDGE(obj) \
hw/pci/pcie.h +1 -1
index 4889194..cc1f2c5 100644
@@ -21,7 +21,7 @@
 #ifndef QEMU_PCIE_H
 #define QEMU_PCIE_H
 
-#include "hw.h"
+#include <hw/hw.h>
 #include "pci_regs.h"
 #include "pcie_regs.h"
 #include "pcie_aer.h"
hw/pci/pcie_aer.h +1 -1
index 7539500..406a736 100644
@@ -21,7 +21,7 @@
 #ifndef QEMU_PCIE_AER_H
 #define QEMU_PCIE_AER_H
 
-#include "hw.h"
+#include <hw/hw.h>
 
 /* definitions which PCIExpressDevice uses */
 
hw/pci/pcie_host.c +2 -3
index c257fb4..4453cb0 100644
@@ -19,10 +19,10 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "hw.h"
+#include <hw/hw.h>
 #include "pci.h"
 #include "pcie_host.h"
-#include "exec-memory.h"
+#include <exec-memory.h>
 
 /*
  * PCI express mmcfig address
--

MST

#5 lore raw

Re: [Qemu-devel] [PATCH 3/8] pci: move pci core code to hw/pci

In reply to Blue Swirl
Quoted 5 lines · Blue Swirl
Quoted 2 lines · Michael S. Tsirkin

Move files and modify makefiles to pick them at the new location.

Please fix coding style before moving.

Nah I'll fix it after moving. No reason to mix
multiple changes.

Quoted 1 line

For easier review, please use git flag -M to detect renames.

I'll note that for future thanks. I don't intend to repost this huge patchset though - it'll go in through a pull request.

Quoted 18,546 lines
Quoted 18,546 lines
---
 hw/Makefile.objs       |   10 +-
 hw/i386/Makefile.objs  |    2 +-
 hw/msi.c               |  395 ---------
 hw/msi.h               |   50 --
 hw/msix.c              |  562 -------------
 hw/msix.h              |   41 -
 hw/pci-hotplug.c       |  293 -------
 hw/pci-stub.c          |   47 --
 hw/pci.c               | 2168 ------------------------------------------------
 hw/pci.h               |  684 ---------------
 hw/pci/Makefile.objs   |    6 +
 hw/pci/msi.c           |  395 +++++++++
 hw/pci/msi.h           |   50 ++
 hw/pci/msix.c          |  562 +++++++++++++
 hw/pci/msix.h          |   41 +
 hw/pci/pci-hotplug.c   |  293 +++++++
 hw/pci/pci-stub.c      |   47 ++
 hw/pci/pci.c           | 2168 ++++++++++++++++++++++++++++++++++++++++++++++++
 hw/pci/pci.h           |  684 +++++++++++++++
 hw/pci/pci_bridge.c    |  363 ++++++++
 hw/pci/pci_bridge.h    |   66 ++
 hw/pci/pci_host.c      |  180 ++++
 hw/pci/pci_host.h      |   62 ++
 hw/pci/pci_ids.h       |  147 ++++
 hw/pci/pci_internals.h |   78 ++
 hw/pci/pci_regs.h      |  717 ++++++++++++++++
 hw/pci/pcie.c          |  555 +++++++++++++
 hw/pci/pcie.h          |  142 ++++
 hw/pci/pcie_aer.c      | 1032 +++++++++++++++++++++++
 hw/pci/pcie_aer.h      |  106 +++
 hw/pci/pcie_host.c     |  161 ++++
 hw/pci/pcie_host.h     |   54 ++
 hw/pci/pcie_port.c     |  114 +++
 hw/pci/pcie_port.h     |   51 ++
 hw/pci/pcie_regs.h     |  156 ++++
 hw/pci/shpc.c          |  681 +++++++++++++++
 hw/pci/shpc.h          |   48 ++
 hw/pci/slotid_cap.c    |   44 +
 hw/pci/slotid_cap.h    |   11 +
 hw/pci_bridge.c        |  363 --------
 hw/pci_bridge.h        |   66 --
 hw/pci_host.c          |  180 ----
 hw/pci_host.h          |   62 --
 hw/pci_ids.h           |  147 ----
 hw/pci_internals.h     |   78 --
 hw/pci_regs.h          |  717 ----------------
 hw/pcie.c              |  555 -------------
 hw/pcie.h              |  142 ----
 hw/pcie_aer.c          | 1032 -----------------------
 hw/pcie_aer.h          |  106 ---
 hw/pcie_host.c         |  161 ----
 hw/pcie_host.h         |   54 --
 hw/pcie_port.c         |  114 ---
 hw/pcie_port.h         |   51 --
 hw/pcie_regs.h         |  156 ----
 hw/ppc/Makefile.objs   |    2 +-
 hw/shpc.c              |  681 ---------------
 hw/shpc.h              |   48 --
 hw/slotid_cap.c        |   44 -
 hw/slotid_cap.h        |   11 -
 60 files changed, 9018 insertions(+), 9018 deletions(-)
 delete mode 100644 hw/msi.c
 delete mode 100644 hw/msi.h
 delete mode 100644 hw/msix.c
 delete mode 100644 hw/msix.h
 delete mode 100644 hw/pci-hotplug.c
 delete mode 100644 hw/pci-stub.c
 delete mode 100644 hw/pci.c
 delete mode 100644 hw/pci.h
 create mode 100644 hw/pci/Makefile.objs
 create mode 100644 hw/pci/msi.c
 create mode 100644 hw/pci/msi.h
 create mode 100644 hw/pci/msix.c
 create mode 100644 hw/pci/msix.h
 create mode 100644 hw/pci/pci-hotplug.c
 create mode 100644 hw/pci/pci-stub.c
 create mode 100644 hw/pci/pci.c
 create mode 100644 hw/pci/pci.h
 create mode 100644 hw/pci/pci_bridge.c
 create mode 100644 hw/pci/pci_bridge.h
 create mode 100644 hw/pci/pci_host.c
 create mode 100644 hw/pci/pci_host.h
 create mode 100644 hw/pci/pci_ids.h
 create mode 100644 hw/pci/pci_internals.h
 create mode 100644 hw/pci/pci_regs.h
 create mode 100644 hw/pci/pcie.c
 create mode 100644 hw/pci/pcie.h
 create mode 100644 hw/pci/pcie_aer.c
 create mode 100644 hw/pci/pcie_aer.h
 create mode 100644 hw/pci/pcie_host.c
 create mode 100644 hw/pci/pcie_host.h
 create mode 100644 hw/pci/pcie_port.c
 create mode 100644 hw/pci/pcie_port.h
 create mode 100644 hw/pci/pcie_regs.h
 create mode 100644 hw/pci/shpc.c
 create mode 100644 hw/pci/shpc.h
 create mode 100644 hw/pci/slotid_cap.c
 create mode 100644 hw/pci/slotid_cap.h
 delete mode 100644 hw/pci_bridge.c
 delete mode 100644 hw/pci_bridge.h
 delete mode 100644 hw/pci_host.c
 delete mode 100644 hw/pci_host.h
 delete mode 100644 hw/pci_ids.h
 delete mode 100644 hw/pci_internals.h
 delete mode 100644 hw/pci_regs.h
 delete mode 100644 hw/pcie.c
 delete mode 100644 hw/pcie.h
 delete mode 100644 hw/pcie_aer.c
 delete mode 100644 hw/pcie_aer.h
 delete mode 100644 hw/pcie_host.c
 delete mode 100644 hw/pcie_host.h
 delete mode 100644 hw/pcie_port.c
 delete mode 100644 hw/pcie_port.h
 delete mode 100644 hw/pcie_regs.h
 delete mode 100644 hw/shpc.c
 delete mode 100644 hw/shpc.h
 delete mode 100644 hw/slotid_cap.c
 delete mode 100644 hw/slotid_cap.h
hw/Makefile.objs +2 -8
index d581d8d..228acd6 100644
@@ -1,14 +1,10 @@
-common-obj-y = usb/ ide/
+common-obj-y = usb/ ide/ pci/
 common-obj-y += loader.o
 common-obj-$(CONFIG_VIRTIO) += virtio-console.o
 common-obj-$(CONFIG_VIRTIO) += virtio-rng.o
 common-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
 common-obj-y += fw_cfg.o
-common-obj-$(CONFIG_PCI) += pci.o pci_bridge.o pci_bridge_dev.o
-common-obj-$(CONFIG_PCI) += msix.o msi.o
-common-obj-$(CONFIG_PCI) += shpc.o
-common-obj-$(CONFIG_PCI) += slotid_cap.o
-common-obj-$(CONFIG_PCI) += pci_host.o pcie_host.o
+common-obj-$(CONFIG_PCI) += pci_bridge_dev.o
 common-obj-$(CONFIG_PCI) += ioh3420.o xio3130_upstream.o xio3130_downstream.o
 common-obj-$(CONFIG_PCI) += i82801b11.o
 common-obj-y += watchdog.o
@@ -102,8 +98,6 @@ common-obj-$(CONFIG_XGMAC) += xgmac.o
 # PCI watchdog devices
 common-obj-$(CONFIG_PCI) += wdt_i6300esb.o
 
-common-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
-
 # PCI network cards
 common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
 common-obj-$(CONFIG_EEPRO100_PCI) += eepro100.o
hw/i386/Makefile.objs +1 -1
index 0d3f6a8..257f3c1 100644
@@ -2,7 +2,7 @@ obj-y += mc146818rtc.o pc.o
 obj-y += apic_common.o apic.o kvmvapic.o
 obj-y += sga.o ioapic_common.o ioapic.o piix_pci.o
 obj-y += vmport.o
-obj-y += pci-hotplug.o smbios.o wdt_ib700.o
+obj-y += pci/pci-hotplug.o smbios.o wdt_ib700.o
 obj-y += debugcon.o multiboot.o
 obj-y += pc_piix.o
 obj-y += pc_sysfw.o
hw/msi.c deleted +0 -395
deleted file mode 100644
index 33037a8..0000000
@@ -1,395 +0,0 @@
-/*
- * msi.c
- *
- * Copyright (c) 2010 Isaku Yamahata <yamahata at valinux co jp>
- *                    VA Linux Systems Japan K.K.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "msi.h"
-#include "range.h"
-
-/* Eventually those constants should go to Linux pci_regs.h */
-#define PCI_MSI_PENDING_32      0x10
-#define PCI_MSI_PENDING_64      0x14
-
-/* PCI_MSI_ADDRESS_LO */
-#define PCI_MSI_ADDRESS_LO_MASK         (~0x3)
-
-/* If we get rid of cap allocator, we won't need those. */
-#define PCI_MSI_32_SIZEOF       0x0a
-#define PCI_MSI_64_SIZEOF       0x0e
-#define PCI_MSI_32M_SIZEOF      0x14
-#define PCI_MSI_64M_SIZEOF      0x18
-
-#define PCI_MSI_VECTORS_MAX     32
-
-/* Flag for interrupt controller to declare MSI/MSI-X support */
-bool msi_supported;
-
-/* If we get rid of cap allocator, we won't need this. */
-static inline uint8_t msi_cap_sizeof(uint16_t flags)
-{
-    switch (flags & (PCI_MSI_FLAGS_MASKBIT | PCI_MSI_FLAGS_64BIT)) {
-    case PCI_MSI_FLAGS_MASKBIT | PCI_MSI_FLAGS_64BIT:
-        return PCI_MSI_64M_SIZEOF;
-    case PCI_MSI_FLAGS_64BIT:
-        return PCI_MSI_64_SIZEOF;
-    case PCI_MSI_FLAGS_MASKBIT:
-        return PCI_MSI_32M_SIZEOF;
-    case 0:
-        return PCI_MSI_32_SIZEOF;
-    default:
-        abort();
-        break;
-    }
-    return 0;
-}
-
-//#define MSI_DEBUG
-
-#ifdef MSI_DEBUG
-# define MSI_DPRINTF(fmt, ...)                                          \
-    fprintf(stderr, "%s:%d " fmt, __func__, __LINE__, ## __VA_ARGS__)
-#else
-# define MSI_DPRINTF(fmt, ...)  do { } while (0)
-#endif
-#define MSI_DEV_PRINTF(dev, fmt, ...)                                   \
-    MSI_DPRINTF("%s:%x " fmt, (dev)->name, (dev)->devfn, ## __VA_ARGS__)
-
-static inline unsigned int msi_nr_vectors(uint16_t flags)
-{
-    return 1U <<
-        ((flags & PCI_MSI_FLAGS_QSIZE) >> (ffs(PCI_MSI_FLAGS_QSIZE) - 1));
-}
-
-static inline uint8_t msi_flags_off(const PCIDevice* dev)
-{
-    return dev->msi_cap + PCI_MSI_FLAGS;
-}
-
-static inline uint8_t msi_address_lo_off(const PCIDevice* dev)
-{
-    return dev->msi_cap + PCI_MSI_ADDRESS_LO;
-}
-
-static inline uint8_t msi_address_hi_off(const PCIDevice* dev)
-{
-    return dev->msi_cap + PCI_MSI_ADDRESS_HI;
-}
-
-static inline uint8_t msi_data_off(const PCIDevice* dev, bool msi64bit)
-{
-    return dev->msi_cap + (msi64bit ? PCI_MSI_DATA_64 : PCI_MSI_DATA_32);
-}
-
-static inline uint8_t msi_mask_off(const PCIDevice* dev, bool msi64bit)
-{
-    return dev->msi_cap + (msi64bit ? PCI_MSI_MASK_64 : PCI_MSI_MASK_32);
-}
-
-static inline uint8_t msi_pending_off(const PCIDevice* dev, bool msi64bit)
-{
-    return dev->msi_cap + (msi64bit ? PCI_MSI_PENDING_64 : PCI_MSI_PENDING_32);
-}
-
-/*
- * Special API for POWER to configure the vectors through
- * a side channel. Should never be used by devices.
- */
-void msi_set_message(PCIDevice *dev, MSIMessage msg)
-{
-    uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
-    bool msi64bit = flags & PCI_MSI_FLAGS_64BIT;
-
-    if (msi64bit) {
-        pci_set_quad(dev->config + msi_address_lo_off(dev), msg.address);
-    } else {
-        pci_set_long(dev->config + msi_address_lo_off(dev), msg.address);
-    }
-    pci_set_word(dev->config + msi_data_off(dev, msi64bit), msg.data);
-}
-
-MSIMessage msi_get_message(PCIDevice *dev, unsigned int vector)
-{
-    uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
-    bool msi64bit = flags & PCI_MSI_FLAGS_64BIT;
-    unsigned int nr_vectors = msi_nr_vectors(flags);
-    MSIMessage msg;
-
-    assert(vector < nr_vectors);
-
-    if (msi64bit) {
-        msg.address = pci_get_quad(dev->config + msi_address_lo_off(dev));
-    } else {
-        msg.address = pci_get_long(dev->config + msi_address_lo_off(dev));
-    }
-
-    /* upper bit 31:16 is zero */
-    msg.data = pci_get_word(dev->config + msi_data_off(dev, msi64bit));
-    if (nr_vectors > 1) {
-        msg.data &= ~(nr_vectors - 1);
-        msg.data |= vector;
-    }
-
-    return msg;
-}
-
-bool msi_enabled(const PCIDevice *dev)
-{
-    return msi_present(dev) &&
-        (pci_get_word(dev->config + msi_flags_off(dev)) &
-         PCI_MSI_FLAGS_ENABLE);
-}
-
-int msi_init(struct PCIDevice *dev, uint8_t offset,
-             unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask)
-{
-    unsigned int vectors_order;
-    uint16_t flags;
-    uint8_t cap_size;
-    int config_offset;
-
-    if (!msi_supported) {
-        return -ENOTSUP;
-    }
-
-    MSI_DEV_PRINTF(dev,
-                   "init offset: 0x%"PRIx8" vector: %"PRId8
-                   " 64bit %d mask %d\n",
-                   offset, nr_vectors, msi64bit, msi_per_vector_mask);
-
-    assert(!(nr_vectors & (nr_vectors - 1)));   /* power of 2 */
-    assert(nr_vectors > 0);
-    assert(nr_vectors <= PCI_MSI_VECTORS_MAX);
-    /* the nr of MSI vectors is up to 32 */
-    vectors_order = ffs(nr_vectors) - 1;
-
-    flags = vectors_order << (ffs(PCI_MSI_FLAGS_QMASK) - 1);
-    if (msi64bit) {
-        flags |= PCI_MSI_FLAGS_64BIT;
-    }
-    if (msi_per_vector_mask) {
-        flags |= PCI_MSI_FLAGS_MASKBIT;
-    }
-
-    cap_size = msi_cap_sizeof(flags);
-    config_offset = pci_add_capability(dev, PCI_CAP_ID_MSI, offset, cap_size);
-    if (config_offset < 0) {
-        return config_offset;
-    }
-
-    dev->msi_cap = config_offset;
-    dev->cap_present |= QEMU_PCI_CAP_MSI;
-
-    pci_set_word(dev->config + msi_flags_off(dev), flags);
-    pci_set_word(dev->wmask + msi_flags_off(dev),
-                 PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);
-    pci_set_long(dev->wmask + msi_address_lo_off(dev),
-                 PCI_MSI_ADDRESS_LO_MASK);
-    if (msi64bit) {
-        pci_set_long(dev->wmask + msi_address_hi_off(dev), 0xffffffff);
-    }
-    pci_set_word(dev->wmask + msi_data_off(dev, msi64bit), 0xffff);
-
-    if (msi_per_vector_mask) {
-        /* Make mask bits 0 to nr_vectors - 1 writable. */
-        pci_set_long(dev->wmask + msi_mask_off(dev, msi64bit),
-                     0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors));
-    }
-    return config_offset;
-}
-
-void msi_uninit(struct PCIDevice *dev)
-{
-    uint16_t flags;
-    uint8_t cap_size;
-
-    if (!msi_present(dev)) {
-        return;
-    }
-    flags = pci_get_word(dev->config + msi_flags_off(dev));
-    cap_size = msi_cap_sizeof(flags);
-    pci_del_capability(dev, PCI_CAP_ID_MSI, cap_size);
-    dev->cap_present &= ~QEMU_PCI_CAP_MSI;
-
-    MSI_DEV_PRINTF(dev, "uninit\n");
-}
-
-void msi_reset(PCIDevice *dev)
-{
-    uint16_t flags;
-    bool msi64bit;
-
-    if (!msi_present(dev)) {
-        return;
-    }
-
-    flags = pci_get_word(dev->config + msi_flags_off(dev));
-    flags &= ~(PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);
-    msi64bit = flags & PCI_MSI_FLAGS_64BIT;
-
-    pci_set_word(dev->config + msi_flags_off(dev), flags);
-    pci_set_long(dev->config + msi_address_lo_off(dev), 0);
-    if (msi64bit) {
-        pci_set_long(dev->config + msi_address_hi_off(dev), 0);
-    }
-    pci_set_word(dev->config + msi_data_off(dev, msi64bit), 0);
-    if (flags & PCI_MSI_FLAGS_MASKBIT) {
-        pci_set_long(dev->config + msi_mask_off(dev, msi64bit), 0);
-        pci_set_long(dev->config + msi_pending_off(dev, msi64bit), 0);
-    }
-    MSI_DEV_PRINTF(dev, "reset\n");
-}
-
-static bool msi_is_masked(const PCIDevice *dev, unsigned int vector)
-{
-    uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
-    uint32_t mask;
-    assert(vector < PCI_MSI_VECTORS_MAX);
-
-    if (!(flags & PCI_MSI_FLAGS_MASKBIT)) {
-        return false;
-    }
-
-    mask = pci_get_long(dev->config +
-                        msi_mask_off(dev, flags & PCI_MSI_FLAGS_64BIT));
-    return mask & (1U << vector);
-}
-
-void msi_notify(PCIDevice *dev, unsigned int vector)
-{
-    uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
-    bool msi64bit = flags & PCI_MSI_FLAGS_64BIT;
-    unsigned int nr_vectors = msi_nr_vectors(flags);
-    MSIMessage msg;
-
-    assert(vector < nr_vectors);
-    if (msi_is_masked(dev, vector)) {
-        assert(flags & PCI_MSI_FLAGS_MASKBIT);
-        pci_long_test_and_set_mask(
-            dev->config + msi_pending_off(dev, msi64bit), 1U << vector);
-        MSI_DEV_PRINTF(dev, "pending vector 0x%x\n", vector);
-        return;
-    }
-
-    msg = msi_get_message(dev, vector);
-
-    MSI_DEV_PRINTF(dev,
-                   "notify vector 0x%x"
-                   " address: 0x%"PRIx64" data: 0x%"PRIx32"\n",
-                   vector, msg.address, msg.data);
-    stl_le_phys(msg.address, msg.data);
-}
-
-/* Normally called by pci_default_write_config(). */
-void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len)
-{
-    uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
-    bool msi64bit = flags & PCI_MSI_FLAGS_64BIT;
-    bool msi_per_vector_mask = flags & PCI_MSI_FLAGS_MASKBIT;
-    unsigned int nr_vectors;
-    uint8_t log_num_vecs;
-    uint8_t log_max_vecs;
-    unsigned int vector;
-    uint32_t pending;
-
-    if (!msi_present(dev) ||
-        !ranges_overlap(addr, len, dev->msi_cap, msi_cap_sizeof(flags))) {
-        return;
-    }
-
-#ifdef MSI_DEBUG
-    MSI_DEV_PRINTF(dev, "addr 0x%"PRIx32" val 0x%"PRIx32" len %d\n",
-                   addr, val, len);
-    MSI_DEV_PRINTF(dev, "ctrl: 0x%"PRIx16" address: 0x%"PRIx32,
-                   flags,
-                   pci_get_long(dev->config + msi_address_lo_off(dev)));
-    if (msi64bit) {
-        fprintf(stderr, " address-hi: 0x%"PRIx32,
-                pci_get_long(dev->config + msi_address_hi_off(dev)));
-    }
-    fprintf(stderr, " data: 0x%"PRIx16,
-            pci_get_word(dev->config + msi_data_off(dev, msi64bit)));
-    if (flags & PCI_MSI_FLAGS_MASKBIT) {
-        fprintf(stderr, " mask 0x%"PRIx32" pending 0x%"PRIx32,
-                pci_get_long(dev->config + msi_mask_off(dev, msi64bit)),
-                pci_get_long(dev->config + msi_pending_off(dev, msi64bit)));
-    }
-    fprintf(stderr, "\n");
-#endif
-
-    if (!(flags & PCI_MSI_FLAGS_ENABLE)) {
-        return;
-    }
-
-    /*
-     * Now MSI is enabled, clear INTx# interrupts.
-     * the driver is prohibited from writing enable bit to mask
-     * a service request. But the guest OS could do this.
-     * So we just discard the interrupts as moderate fallback.
-     *
-     * 6.8.3.3. Enabling Operation
-     *   While enabled for MSI or MSI-X operation, a function is prohibited
-     *   from using its INTx# pin (if implemented) to request
-     *   service (MSI, MSI-X, and INTx# are mutually exclusive).
-     */
-    pci_device_deassert_intx(dev);
-
-    /*
-     * nr_vectors might be set bigger than capable. So clamp it.
-     * This is not legal by spec, so we can do anything we like,
-     * just don't crash the host
-     */
-    log_num_vecs =
-        (flags & PCI_MSI_FLAGS_QSIZE) >> (ffs(PCI_MSI_FLAGS_QSIZE) - 1);
-    log_max_vecs =
-        (flags & PCI_MSI_FLAGS_QMASK) >> (ffs(PCI_MSI_FLAGS_QMASK) - 1);
-    if (log_num_vecs > log_max_vecs) {
-        flags &= ~PCI_MSI_FLAGS_QSIZE;
-        flags |= log_max_vecs << (ffs(PCI_MSI_FLAGS_QSIZE) - 1);
-        pci_set_word(dev->config + msi_flags_off(dev), flags);
-    }
-
-    if (!msi_per_vector_mask) {
-        /* if per vector masking isn't supported,
-           there is no pending interrupt. */
-        return;
-    }
-
-    nr_vectors = msi_nr_vectors(flags);
-
-    /* This will discard pending interrupts, if any. */
-    pending = pci_get_long(dev->config + msi_pending_off(dev, msi64bit));
-    pending &= 0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors);
-    pci_set_long(dev->config + msi_pending_off(dev, msi64bit), pending);
-
-    /* deliver pending interrupts which are unmasked */
-    for (vector = 0; vector < nr_vectors; ++vector) {
-        if (msi_is_masked(dev, vector) || !(pending & (1U << vector))) {
-            continue;
-        }
-
-        pci_long_test_and_clear_mask(
-            dev->config + msi_pending_off(dev, msi64bit), 1U << vector);
-        msi_notify(dev, vector);
-    }
-}
-
-unsigned int msi_nr_vectors_allocated(const PCIDevice *dev)
-{
-    uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
-    return msi_nr_vectors(flags);
-}
hw/msi.h deleted +0 -50
deleted file mode 100644
index 150b09a..0000000
@@ -1,50 +0,0 @@
-/*
- * msi.h
- *
- * Copyright (c) 2010 Isaku Yamahata <yamahata at valinux co jp>
- *                    VA Linux Systems Japan K.K.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef QEMU_MSI_H
-#define QEMU_MSI_H
-
-#include "qemu-common.h"
-#include "pci.h"
-
-struct MSIMessage {
-    uint64_t address;
-    uint32_t data;
-};
-
-extern bool msi_supported;
-
-void msi_set_message(PCIDevice *dev, MSIMessage msg);
-MSIMessage msi_get_message(PCIDevice *dev, unsigned int vector);
-bool msi_enabled(const PCIDevice *dev);
-int msi_init(struct PCIDevice *dev, uint8_t offset,
-             unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask);
-void msi_uninit(struct PCIDevice *dev);
-void msi_reset(PCIDevice *dev);
-void msi_notify(PCIDevice *dev, unsigned int vector);
-void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len);
-unsigned int msi_nr_vectors_allocated(const PCIDevice *dev);
-
-static inline bool msi_present(const PCIDevice *dev)
-{
-    return dev->cap_present & QEMU_PCI_CAP_MSI;
-}
-
-#endif /* QEMU_MSI_H */
hw/msix.c deleted +0 -562
deleted file mode 100644
index 136ef09..0000000
@@ -1,562 +0,0 @@
-/*
- * MSI-X device support
- *
- * This module includes support for MSI-X in pci devices.
- *
- * Author: Michael S. Tsirkin <[email protected]>
- *
- *  Copyright (c) 2009, Red Hat Inc, Michael S. Tsirkin ([email protected])
- *
- * This work is licensed under the terms of the GNU GPL, version 2.  See
- * the COPYING file in the top-level directory.
- *
- * Contributions after 2012-01-13 are licensed under the terms of the
- * GNU GPL, version 2 or (at your option) any later version.
- */
-
-#include "hw.h"
-#include "msi.h"
-#include "msix.h"
-#include "pci.h"
-#include "range.h"
-
-#define MSIX_CAP_LENGTH 12
-
-/* MSI enable bit and maskall bit are in byte 1 in FLAGS register */
-#define MSIX_CONTROL_OFFSET (PCI_MSIX_FLAGS + 1)
-#define MSIX_ENABLE_MASK (PCI_MSIX_FLAGS_ENABLE >> 8)
-#define MSIX_MASKALL_MASK (PCI_MSIX_FLAGS_MASKALL >> 8)
-
-static MSIMessage msix_get_message(PCIDevice *dev, unsigned vector)
-{
-    uint8_t *table_entry = dev->msix_table + vector * PCI_MSIX_ENTRY_SIZE;
-    MSIMessage msg;
-
-    msg.address = pci_get_quad(table_entry + PCI_MSIX_ENTRY_LOWER_ADDR);
-    msg.data = pci_get_long(table_entry + PCI_MSIX_ENTRY_DATA);
-    return msg;
-}
-
-/*
- * Special API for POWER to configure the vectors through
- * a side channel. Should never be used by devices.
- */
-void msix_set_message(PCIDevice *dev, int vector, struct MSIMessage msg)
-{
-    uint8_t *table_entry = dev->msix_table + vector * PCI_MSIX_ENTRY_SIZE;
-
-    pci_set_quad(table_entry + PCI_MSIX_ENTRY_LOWER_ADDR, msg.address);
-    pci_set_long(table_entry + PCI_MSIX_ENTRY_DATA, msg.data);
-    table_entry[PCI_MSIX_ENTRY_VECTOR_CTRL] &= ~PCI_MSIX_ENTRY_CTRL_MASKBIT;
-}
-
-static uint8_t msix_pending_mask(int vector)
-{
-    return 1 << (vector % 8);
-}
-
-static uint8_t *msix_pending_byte(PCIDevice *dev, int vector)
-{
-    return dev->msix_pba + vector / 8;
-}
-
-static int msix_is_pending(PCIDevice *dev, int vector)
-{
-    return *msix_pending_byte(dev, vector) & msix_pending_mask(vector);
-}
-
-static void msix_set_pending(PCIDevice *dev, int vector)
-{
-    *msix_pending_byte(dev, vector) |= msix_pending_mask(vector);
-}
-
-static void msix_clr_pending(PCIDevice *dev, int vector)
-{
-    *msix_pending_byte(dev, vector) &= ~msix_pending_mask(vector);
-}
-
-static bool msix_vector_masked(PCIDevice *dev, int vector, bool fmask)
-{
-    unsigned offset = vector * PCI_MSIX_ENTRY_SIZE + PCI_MSIX_ENTRY_VECTOR_CTRL;
-    return fmask || dev->msix_table[offset] & PCI_MSIX_ENTRY_CTRL_MASKBIT;
-}
-
-static bool msix_is_masked(PCIDevice *dev, int vector)
-{
-    return msix_vector_masked(dev, vector, dev->msix_function_masked);
-}
-
-static void msix_fire_vector_notifier(PCIDevice *dev,
-                                      unsigned int vector, bool is_masked)
-{
-    MSIMessage msg;
-    int ret;
-
-    if (!dev->msix_vector_use_notifier) {
-        return;
-    }
-    if (is_masked) {
-        dev->msix_vector_release_notifier(dev, vector);
-    } else {
-        msg = msix_get_message(dev, vector);
-        ret = dev->msix_vector_use_notifier(dev, vector, msg);
-        assert(ret >= 0);
-    }
-}
-
-static void msix_handle_mask_update(PCIDevice *dev, int vector, bool was_masked)
-{
-    bool is_masked = msix_is_masked(dev, vector);
-
-    if (is_masked == was_masked) {
-        return;
-    }
-
-    msix_fire_vector_notifier(dev, vector, is_masked);
-
-    if (!is_masked && msix_is_pending(dev, vector)) {
-        msix_clr_pending(dev, vector);
-        msix_notify(dev, vector);
-    }
-}
-
-static void msix_update_function_masked(PCIDevice *dev)
-{
-    dev->msix_function_masked = !msix_enabled(dev) ||
-        (dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] & MSIX_MASKALL_MASK);
-}
-
-/* Handle MSI-X capability config write. */
-void msix_write_config(PCIDevice *dev, uint32_t addr,
-                       uint32_t val, int len)
-{
-    unsigned enable_pos = dev->msix_cap + MSIX_CONTROL_OFFSET;
-    int vector;
-    bool was_masked;
-
-    if (!msix_present(dev) || !range_covers_byte(addr, len, enable_pos)) {
-        return;
-    }
-
-    was_masked = dev->msix_function_masked;
-    msix_update_function_masked(dev);
-
-    if (!msix_enabled(dev)) {
-        return;
-    }
-
-    pci_device_deassert_intx(dev);
-
-    if (dev->msix_function_masked == was_masked) {
-        return;
-    }
-
-    for (vector = 0; vector < dev->msix_entries_nr; ++vector) {
-        msix_handle_mask_update(dev, vector,
-                                msix_vector_masked(dev, vector, was_masked));
-    }
-}
-
-static uint64_t msix_table_mmio_read(void *opaque, hwaddr addr,
-                                     unsigned size)
-{
-    PCIDevice *dev = opaque;
-
-    return pci_get_long(dev->msix_table + addr);
-}
-
-static void msix_table_mmio_write(void *opaque, hwaddr addr,
-                                  uint64_t val, unsigned size)
-{
-    PCIDevice *dev = opaque;
-    int vector = addr / PCI_MSIX_ENTRY_SIZE;
-    bool was_masked;
-
-    was_masked = msix_is_masked(dev, vector);
-    pci_set_long(dev->msix_table + addr, val);
-    msix_handle_mask_update(dev, vector, was_masked);
-}
-
-static const MemoryRegionOps msix_table_mmio_ops = {
-    .read = msix_table_mmio_read,
-    .write = msix_table_mmio_write,
-    /* TODO: MSIX should be LITTLE_ENDIAN. */
-    .endianness = DEVICE_NATIVE_ENDIAN,
-    .valid = {
-        .min_access_size = 4,
-        .max_access_size = 4,
-    },
-};
-
-static uint64_t msix_pba_mmio_read(void *opaque, hwaddr addr,
-                                   unsigned size)
-{
-    PCIDevice *dev = opaque;
-
-    return pci_get_long(dev->msix_pba + addr);
-}
-
-static const MemoryRegionOps msix_pba_mmio_ops = {
-    .read = msix_pba_mmio_read,
-    /* TODO: MSIX should be LITTLE_ENDIAN. */
-    .endianness = DEVICE_NATIVE_ENDIAN,
-    .valid = {
-        .min_access_size = 4,
-        .max_access_size = 4,
-    },
-};
-
-static void msix_mask_all(struct PCIDevice *dev, unsigned nentries)
-{
-    int vector;
-
-    for (vector = 0; vector < nentries; ++vector) {
-        unsigned offset =
-            vector * PCI_MSIX_ENTRY_SIZE + PCI_MSIX_ENTRY_VECTOR_CTRL;
-        bool was_masked = msix_is_masked(dev, vector);
-
-        dev->msix_table[offset] |= PCI_MSIX_ENTRY_CTRL_MASKBIT;
-        msix_handle_mask_update(dev, vector, was_masked);
-    }
-}
-
-/* Initialize the MSI-X structures */
-int msix_init(struct PCIDevice *dev, unsigned short nentries,
-              MemoryRegion *table_bar, uint8_t table_bar_nr,
-              unsigned table_offset, MemoryRegion *pba_bar,
-              uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos)
-{
-    int cap;
-    unsigned table_size, pba_size;
-    uint8_t *config;
-
-    /* Nothing to do if MSI is not supported by interrupt controller */
-    if (!msi_supported) {
-        return -ENOTSUP;
-    }
-
-    if (nentries < 1 || nentries > PCI_MSIX_FLAGS_QSIZE + 1) {
-        return -EINVAL;
-    }
-
-    table_size = nentries * PCI_MSIX_ENTRY_SIZE;
-    pba_size = QEMU_ALIGN_UP(nentries, 64) / 8;
-
-    /* Sanity test: table & pba don't overlap, fit within BARs, min aligned */
-    if ((table_bar_nr == pba_bar_nr &&
-         ranges_overlap(table_offset, table_size, pba_offset, pba_size)) ||
-        table_offset + table_size > memory_region_size(table_bar) ||
-        pba_offset + pba_size > memory_region_size(pba_bar) ||
-        (table_offset | pba_offset) & PCI_MSIX_FLAGS_BIRMASK) {
-        return -EINVAL;
-    }
-
-    cap = pci_add_capability(dev, PCI_CAP_ID_MSIX, cap_pos, MSIX_CAP_LENGTH);
-    if (cap < 0) {
-        return cap;
-    }
-
-    dev->msix_cap = cap;
-    dev->cap_present |= QEMU_PCI_CAP_MSIX;
-    config = dev->config + cap;
-
-    pci_set_word(config + PCI_MSIX_FLAGS, nentries - 1);
-    dev->msix_entries_nr = nentries;
-    dev->msix_function_masked = true;
-
-    pci_set_long(config + PCI_MSIX_TABLE, table_offset | table_bar_nr);
-    pci_set_long(config + PCI_MSIX_PBA, pba_offset | pba_bar_nr);
-
-    /* Make flags bit writable. */
-    dev->wmask[cap + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK |
-                                             MSIX_MASKALL_MASK;
-
-    dev->msix_table = g_malloc0(table_size);
-    dev->msix_pba = g_malloc0(pba_size);
-    dev->msix_entry_used = g_malloc0(nentries * sizeof *dev->msix_entry_used);
-
-    msix_mask_all(dev, nentries);
-
-    memory_region_init_io(&dev->msix_table_mmio, &msix_table_mmio_ops, dev,
-                          "msix-table", table_size);
-    memory_region_add_subregion(table_bar, table_offset, &dev->msix_table_mmio);
-    memory_region_init_io(&dev->msix_pba_mmio, &msix_pba_mmio_ops, dev,
-                          "msix-pba", pba_size);
-    memory_region_add_subregion(pba_bar, pba_offset, &dev->msix_pba_mmio);
-
-    return 0;
-}
-
-int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
-                            uint8_t bar_nr)
-{
-    int ret;
-    char *name;
-
-    /*
-     * Migration compatibility dictates that this remains a 4k
-     * BAR with the vector table in the lower half and PBA in
-     * the upper half.  Do not use these elsewhere!
-     */
-#define MSIX_EXCLUSIVE_BAR_SIZE 4096
-#define MSIX_EXCLUSIVE_BAR_TABLE_OFFSET 0
-#define MSIX_EXCLUSIVE_BAR_PBA_OFFSET (MSIX_EXCLUSIVE_BAR_SIZE / 2)
-#define MSIX_EXCLUSIVE_CAP_OFFSET 0
-
-    if (nentries * PCI_MSIX_ENTRY_SIZE > MSIX_EXCLUSIVE_BAR_PBA_OFFSET) {
-        return -EINVAL;
-    }
-
-    name = g_strdup_printf("%s-msix", dev->name);
-    memory_region_init(&dev->msix_exclusive_bar, name, MSIX_EXCLUSIVE_BAR_SIZE);
-    g_free(name);
-
-    ret = msix_init(dev, nentries, &dev->msix_exclusive_bar, bar_nr,
-                    MSIX_EXCLUSIVE_BAR_TABLE_OFFSET, &dev->msix_exclusive_bar,
-                    bar_nr, MSIX_EXCLUSIVE_BAR_PBA_OFFSET,
-                    MSIX_EXCLUSIVE_CAP_OFFSET);
-    if (ret) {
-        memory_region_destroy(&dev->msix_exclusive_bar);
-        return ret;
-    }
-
-    pci_register_bar(dev, bar_nr, PCI_BASE_ADDRESS_SPACE_MEMORY,
-                     &dev->msix_exclusive_bar);
-
-    return 0;
-}
-
-static void msix_free_irq_entries(PCIDevice *dev)
-{
-    int vector;
-
-    for (vector = 0; vector < dev->msix_entries_nr; ++vector) {
-        dev->msix_entry_used[vector] = 0;
-        msix_clr_pending(dev, vector);
-    }
-}
-
-static void msix_clear_all_vectors(PCIDevice *dev)
-{
-    int vector;
-
-    for (vector = 0; vector < dev->msix_entries_nr; ++vector) {
-        msix_clr_pending(dev, vector);
-    }
-}
-
-/* Clean up resources for the device. */
-void msix_uninit(PCIDevice *dev, MemoryRegion *table_bar, MemoryRegion *pba_bar)
-{
-    if (!msix_present(dev)) {
-        return;
-    }
-    pci_del_capability(dev, PCI_CAP_ID_MSIX, MSIX_CAP_LENGTH);
-    dev->msix_cap = 0;
-    msix_free_irq_entries(dev);
-    dev->msix_entries_nr = 0;
-    memory_region_del_subregion(pba_bar, &dev->msix_pba_mmio);
-    memory_region_destroy(&dev->msix_pba_mmio);
-    g_free(dev->msix_pba);
-    dev->msix_pba = NULL;
-    memory_region_del_subregion(table_bar, &dev->msix_table_mmio);
-    memory_region_destroy(&dev->msix_table_mmio);
-    g_free(dev->msix_table);
-    dev->msix_table = NULL;
-    g_free(dev->msix_entry_used);
-    dev->msix_entry_used = NULL;
-    dev->cap_present &= ~QEMU_PCI_CAP_MSIX;
-}
-
-void msix_uninit_exclusive_bar(PCIDevice *dev)
-{
-    if (msix_present(dev)) {
-        msix_uninit(dev, &dev->msix_exclusive_bar, &dev->msix_exclusive_bar);
-        memory_region_destroy(&dev->msix_exclusive_bar);
-    }
-}
-
-void msix_save(PCIDevice *dev, QEMUFile *f)
-{
-    unsigned n = dev->msix_entries_nr;
-
-    if (!msix_present(dev)) {
-        return;
-    }
-
-    qemu_put_buffer(f, dev->msix_table, n * PCI_MSIX_ENTRY_SIZE);
-    qemu_put_buffer(f, dev->msix_pba, (n + 7) / 8);
-}
-
-/* Should be called after restoring the config space. */
-void msix_load(PCIDevice *dev, QEMUFile *f)
-{
-    unsigned n = dev->msix_entries_nr;
-    unsigned int vector;
-
-    if (!msix_present(dev)) {
-        return;
-    }
-
-    msix_clear_all_vectors(dev);
-    qemu_get_buffer(f, dev->msix_table, n * PCI_MSIX_ENTRY_SIZE);
-    qemu_get_buffer(f, dev->msix_pba, (n + 7) / 8);
-    msix_update_function_masked(dev);
-
-    for (vector = 0; vector < n; vector++) {
-        msix_handle_mask_update(dev, vector, true);
-    }
-}
-
-/* Does device support MSI-X? */
-int msix_present(PCIDevice *dev)
-{
-    return dev->cap_present & QEMU_PCI_CAP_MSIX;
-}
-
-/* Is MSI-X enabled? */
-int msix_enabled(PCIDevice *dev)
-{
-    return (dev->cap_present & QEMU_PCI_CAP_MSIX) &&
-        (dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &
-         MSIX_ENABLE_MASK);
-}
-
-/* Send an MSI-X message */
-void msix_notify(PCIDevice *dev, unsigned vector)
-{
-    MSIMessage msg;
-
-    if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])
-        return;
-    if (msix_is_masked(dev, vector)) {
-        msix_set_pending(dev, vector);
-        return;
-    }
-
-    msg = msix_get_message(dev, vector);
-
-    stl_le_phys(msg.address, msg.data);
-}
-
-void msix_reset(PCIDevice *dev)
-{
-    if (!msix_present(dev)) {
-        return;
-    }
-    msix_clear_all_vectors(dev);
-    dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &=
-           ~dev->wmask[dev->msix_cap + MSIX_CONTROL_OFFSET];
-    memset(dev->msix_table, 0, dev->msix_entries_nr * PCI_MSIX_ENTRY_SIZE);
-    memset(dev->msix_pba, 0, QEMU_ALIGN_UP(dev->msix_entries_nr, 64) / 8);
-    msix_mask_all(dev, dev->msix_entries_nr);
-}
-
-/* PCI spec suggests that devices make it possible for software to configure
- * less vectors than supported by the device, but does not specify a standard
- * mechanism for devices to do so.
- *
- * We support this by asking devices to declare vectors software is going to
- * actually use, and checking this on the notification path. Devices that
- * don't want to follow the spec suggestion can declare all vectors as used. */
-
-/* Mark vector as used. */
-int msix_vector_use(PCIDevice *dev, unsigned vector)
-{
-    if (vector >= dev->msix_entries_nr)
-        return -EINVAL;
-    dev->msix_entry_used[vector]++;
-    return 0;
-}
-
-/* Mark vector as unused. */
-void msix_vector_unuse(PCIDevice *dev, unsigned vector)
-{
-    if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector]) {
-        return;
-    }
-    if (--dev->msix_entry_used[vector]) {
-        return;
-    }
-    msix_clr_pending(dev, vector);
-}
-
-void msix_unuse_all_vectors(PCIDevice *dev)
-{
-    if (!msix_present(dev)) {
-        return;
-    }
-    msix_free_irq_entries(dev);
-}
-
-unsigned int msix_nr_vectors_allocated(const PCIDevice *dev)
-{
-    return dev->msix_entries_nr;
-}
-
-static int msix_set_notifier_for_vector(PCIDevice *dev, unsigned int vector)
-{
-    MSIMessage msg;
-
-    if (msix_is_masked(dev, vector)) {
-        return 0;
-    }
-    msg = msix_get_message(dev, vector);
-    return dev->msix_vector_use_notifier(dev, vector, msg);
-}
-
-static void msix_unset_notifier_for_vector(PCIDevice *dev, unsigned int vector)
-{
-    if (msix_is_masked(dev, vector)) {
-        return;
-    }
-    dev->msix_vector_release_notifier(dev, vector);
-}
-
-int msix_set_vector_notifiers(PCIDevice *dev,
-                              MSIVectorUseNotifier use_notifier,
-                              MSIVectorReleaseNotifier release_notifier)
-{
-    int vector, ret;
-
-    assert(use_notifier && release_notifier);
-
-    dev->msix_vector_use_notifier = use_notifier;
-    dev->msix_vector_release_notifier = release_notifier;
-
-    if ((dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &
-        (MSIX_ENABLE_MASK | MSIX_MASKALL_MASK)) == MSIX_ENABLE_MASK) {
-        for (vector = 0; vector < dev->msix_entries_nr; vector++) {
-            ret = msix_set_notifier_for_vector(dev, vector);
-            if (ret < 0) {
-                goto undo;
-            }
-        }
-    }
-    return 0;
-
-undo:
-    while (--vector >= 0) {
-        msix_unset_notifier_for_vector(dev, vector);
-    }
-    dev->msix_vector_use_notifier = NULL;
-    dev->msix_vector_release_notifier = NULL;
-    return ret;
-}
-
-void msix_unset_vector_notifiers(PCIDevice *dev)
-{
-    int vector;
-
-    assert(dev->msix_vector_use_notifier &&
-           dev->msix_vector_release_notifier);
-
-    if ((dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] &
-        (MSIX_ENABLE_MASK | MSIX_MASKALL_MASK)) == MSIX_ENABLE_MASK) {
-        for (vector = 0; vector < dev->msix_entries_nr; vector++) {
-            msix_unset_notifier_for_vector(dev, vector);
-        }
-    }
-    dev->msix_vector_use_notifier = NULL;
-    dev->msix_vector_release_notifier = NULL;
-}
hw/msix.h deleted +0 -41
deleted file mode 100644
index 15211cb..0000000
@@ -1,41 +0,0 @@
-#ifndef QEMU_MSIX_H
-#define QEMU_MSIX_H
-
-#include "qemu-common.h"
-#include "pci.h"
-
-void msix_set_message(PCIDevice *dev, int vector, MSIMessage msg);
-int msix_init(PCIDevice *dev, unsigned short nentries,
-              MemoryRegion *table_bar, uint8_t table_bar_nr,
-              unsigned table_offset, MemoryRegion *pba_bar,
-              uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos);
-int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
-                            uint8_t bar_nr);
-
-void msix_write_config(PCIDevice *dev, uint32_t address, uint32_t val, int len);
-
-void msix_uninit(PCIDevice *dev, MemoryRegion *table_bar,
-                 MemoryRegion *pba_bar);
-void msix_uninit_exclusive_bar(PCIDevice *dev);
-
-unsigned int msix_nr_vectors_allocated(const PCIDevice *dev);
-
-void msix_save(PCIDevice *dev, QEMUFile *f);
-void msix_load(PCIDevice *dev, QEMUFile *f);
-
-int msix_enabled(PCIDevice *dev);
-int msix_present(PCIDevice *dev);
-
-int msix_vector_use(PCIDevice *dev, unsigned vector);
-void msix_vector_unuse(PCIDevice *dev, unsigned vector);
-void msix_unuse_all_vectors(PCIDevice *dev);
-
-void msix_notify(PCIDevice *dev, unsigned vector);
-
-void msix_reset(PCIDevice *dev);
-
-int msix_set_vector_notifiers(PCIDevice *dev,
-                              MSIVectorUseNotifier use_notifier,
-                              MSIVectorReleaseNotifier release_notifier);
-void msix_unset_vector_notifiers(PCIDevice *dev);
-#endif
hw/pci-hotplug.c deleted +0 -293
deleted file mode 100644
index 0ca5546..0000000
@@ -1,293 +0,0 @@
-/*
- * QEMU PCI hotplug support
- *
- * Copyright (c) 2004 Fabrice Bellard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "hw.h"
-#include "boards.h"
-#include "pci.h"
-#include "net.h"
-#include "pc.h"
-#include "monitor.h"
-#include "scsi.h"
-#include "virtio-blk.h"
-#include "qemu-config.h"
-#include "blockdev.h"
-#include "error.h"
-
-#if defined(TARGET_I386)
-static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
-                                       const char *devaddr,
-                                       const char *opts_str)
-{
-    Error *local_err = NULL;
-    QemuOpts *opts;
-    PCIBus *bus;
-    int ret, devfn;
-
-    bus = pci_get_bus_devfn(&devfn, devaddr);
-    if (!bus) {
-        monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
-        return NULL;
-    }
-    if (!((BusState*)bus)->allow_hotplug) {
-        monitor_printf(mon, "PCI bus doesn't support hotplug\n");
-        return NULL;
-    }
-
-    opts = qemu_opts_parse(qemu_find_opts("net"), opts_str ? opts_str : "", 0);
-    if (!opts) {
-        return NULL;
-    }
-
-    qemu_opt_set(opts, "type", "nic");
-
-    ret = net_client_init(opts, 0, &local_err);
-    if (error_is_set(&local_err)) {
-        qerror_report_err(local_err);
-        error_free(local_err);
-        return NULL;
-    }
-    if (nd_table[ret].devaddr) {
-        monitor_printf(mon, "Parameter addr not supported\n");
-        return NULL;
-    }
-    return pci_nic_init(&nd_table[ret], "rtl8139", devaddr);
-}
-
-static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
-                        DriveInfo *dinfo, int printinfo)
-{
-    SCSIBus *scsibus;
-    SCSIDevice *scsidev;
-
-    scsibus = (SCSIBus *)
-        object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
-                            TYPE_SCSI_BUS);
-    if (!scsibus) {
-       error_report("Device is not a SCSI adapter");
-       return -1;
-    }
-
-    /*
-     * drive_init() tries to find a default for dinfo->unit.  Doesn't
-     * work at all for hotplug though as we assign the device to a
-     * specific bus instead of the first bus with spare scsi ids.
-     *
-     * Ditch the calculated value and reload from option string (if
-     * specified).
-     */
-    dinfo->unit = qemu_opt_get_number(dinfo->opts, "unit", -1);
-    dinfo->bus = scsibus->busnr;
-    scsidev = scsi_bus_legacy_add_drive(scsibus, dinfo->bdrv, dinfo->unit,
-                                        false, -1);
-    if (!scsidev) {
-        return -1;
-    }
-    dinfo->unit = scsidev->id;
-
-    if (printinfo)
-        monitor_printf(mon, "OK bus %d, unit %d\n",
-                       scsibus->busnr, scsidev->id);
-    return 0;
-}
-
-int pci_drive_hot_add(Monitor *mon, const QDict *qdict,
-                      DriveInfo *dinfo, int type)
-{
-    int dom, pci_bus;
-    unsigned slot;
-    PCIDevice *dev;
-    const char *pci_addr = qdict_get_str(qdict, "pci_addr");
-
-    switch (type) {
-    case IF_SCSI:
-        if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
-            goto err;
-        }
-        dev = pci_find_device(pci_find_root_bus(dom), pci_bus,
-                              PCI_DEVFN(slot, 0));
-        if (!dev) {
-            monitor_printf(mon, "no pci device with address %s\n", pci_addr);
-            goto err;
-        }
-        if (scsi_hot_add(mon, &dev->qdev, dinfo, 1) != 0) {
-            goto err;
-        }
-        break;
-    default:
-        monitor_printf(mon, "Can't hot-add drive to type %d\n", type);
-        goto err;
-    }
-
-    return 0;
-err:
-    return -1;
-}
-
-static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
-                                           const char *devaddr,
-                                           const char *opts)
-{
-    PCIDevice *dev;
-    DriveInfo *dinfo = NULL;
-    int type = -1;
-    char buf[128];
-    PCIBus *bus;
-    int devfn;
-
-    if (get_param_value(buf, sizeof(buf), "if", opts)) {
-        if (!strcmp(buf, "scsi"))
-            type = IF_SCSI;
-        else if (!strcmp(buf, "virtio")) {
-            type = IF_VIRTIO;
-        } else {
-            monitor_printf(mon, "type %s not a hotpluggable PCI device.\n", buf);
-            return NULL;
-        }
-    } else {
-        monitor_printf(mon, "no if= specified\n");
-        return NULL;
-    }
-
-    if (get_param_value(buf, sizeof(buf), "file", opts)) {
-        dinfo = add_init_drive(opts);
-        if (!dinfo)
-            return NULL;
-        if (dinfo->devaddr) {
-            monitor_printf(mon, "Parameter addr not supported\n");
-            return NULL;
-        }
-    } else {
-        dinfo = NULL;
-    }
-
-    bus = pci_get_bus_devfn(&devfn, devaddr);
-    if (!bus) {
-        monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
-        return NULL;
-    }
-    if (!((BusState*)bus)->allow_hotplug) {
-        monitor_printf(mon, "PCI bus doesn't support hotplug\n");
-        return NULL;
-    }
-
-    switch (type) {
-    case IF_SCSI:
-        dev = pci_create(bus, devfn, "lsi53c895a");
-        if (qdev_init(&dev->qdev) < 0)
-            dev = NULL;
-        if (dev && dinfo) {
-            if (scsi_hot_add(mon, &dev->qdev, dinfo, 0) != 0) {
-                qdev_unplug(&dev->qdev, NULL);
-                dev = NULL;
-            }
-        }
-        break;
-    case IF_VIRTIO:
-        if (!dinfo) {
-            monitor_printf(mon, "virtio requires a backing file/device.\n");
-            return NULL;
-        }
-        dev = pci_create(bus, devfn, "virtio-blk-pci");
-        if (qdev_prop_set_drive(&dev->qdev, "drive", dinfo->bdrv) < 0) {
-            qdev_free(&dev->qdev);
-            dev = NULL;
-            break;
-        }
-        if (qdev_init(&dev->qdev) < 0)
-            dev = NULL;
-        break;
-    default:
-        dev = NULL;
-    }
-    return dev;
-}
-
-void pci_device_hot_add(Monitor *mon, const QDict *qdict)
-{
-    PCIDevice *dev = NULL;
-    const char *pci_addr = qdict_get_str(qdict, "pci_addr");
-    const char *type = qdict_get_str(qdict, "type");
-    const char *opts = qdict_get_try_str(qdict, "opts");
-
-    /* strip legacy tag */
-    if (!strncmp(pci_addr, "pci_addr=", 9)) {
-        pci_addr += 9;
-    }
-
-    if (!opts) {
-        opts = "";
-    }
-
-    if (!strcmp(pci_addr, "auto"))
-        pci_addr = NULL;
-
-    if (strcmp(type, "nic") == 0) {
-        dev = qemu_pci_hot_add_nic(mon, pci_addr, opts);
-    } else if (strcmp(type, "storage") == 0) {
-        dev = qemu_pci_hot_add_storage(mon, pci_addr, opts);
-    } else {
-        monitor_printf(mon, "invalid type: %s\n", type);
-    }
-
-    if (dev) {
-        monitor_printf(mon, "OK domain %d, bus %d, slot %d, function %d\n",
-                       pci_find_domain(dev->bus),
-                       pci_bus_num(dev->bus), PCI_SLOT(dev->devfn),
-                       PCI_FUNC(dev->devfn));
-    } else
-        monitor_printf(mon, "failed to add %s\n", opts);
-}
-#endif
-
-static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)
-{
-    PCIDevice *d;
-    int dom, bus;
-    unsigned slot;
-    Error *local_err = NULL;
-
-    if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) {
-        return -1;
-    }
-
-    d = pci_find_device(pci_find_root_bus(dom), bus, PCI_DEVFN(slot, 0));
-    if (!d) {
-        monitor_printf(mon, "slot %d empty\n", slot);
-        return -1;
-    }
-
-    qdev_unplug(&d->qdev, &local_err);
-    if (error_is_set(&local_err)) {
-        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
-        error_free(local_err);
-        return -1;
-    }
-
-    return 0;
-}
-
-void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict)
-{
-    pci_device_hot_remove(mon, qdict_get_str(qdict, "pci_addr"));
-}
hw/pci-stub.c deleted +0 -47
deleted file mode 100644
index 134c448..0000000
@@ -1,47 +0,0 @@
-/*
- * PCI stubs for platforms that don't support pci bus.
- *
- * Copyright (c) 2010 Isaku Yamahata <yamahata at valinux co jp>
- *                    VA Linux Systems Japan K.K.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "sysemu.h"
-#include "monitor.h"
-#include "pci.h"
-#include "qmp-commands.h"
-
-PciInfoList *qmp_query_pci(Error **errp)
-{
-    error_set(errp, QERR_UNSUPPORTED);
-    return NULL;
-}
-
-static void pci_error_message(Monitor *mon)
-{
-    monitor_printf(mon, "PCI devices not supported\n");
-}
-
-int do_pcie_aer_inject_error(Monitor *mon,
-                             const QDict *qdict, QObject **ret_data)
-{
-    pci_error_message(mon);
-    return -ENOSYS;
-}
-
-void pcie_aer_inject_error_print(Monitor *mon, const QObject *data)
-{
-    pci_error_message(mon);
-}
hw/pci.c deleted +0 -2168
deleted file mode 100644
index 97a0cd7..0000000
@@ -1,2168 +0,0 @@
-/*
- * QEMU PCI bus manager
- *
- * Copyright (c) 2004 Fabrice Bellard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#include "hw.h"
-#include "pci.h"
-#include "pci_bridge.h"
-#include "pci_internals.h"
-#include "monitor.h"
-#include "net.h"
-#include "sysemu.h"
-#include "loader.h"
-#include "range.h"
-#include "qmp-commands.h"
-#include "msi.h"
-#include "msix.h"
-#include "exec-memory.h"
-
-//#define DEBUG_PCI
-#ifdef DEBUG_PCI
-# define PCI_DPRINTF(format, ...)       printf(format, ## __VA_ARGS__)
-#else
-# define PCI_DPRINTF(format, ...)       do { } while (0)
-#endif
-
-static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent);
-static char *pcibus_get_dev_path(DeviceState *dev);
-static char *pcibus_get_fw_dev_path(DeviceState *dev);
-static int pcibus_reset(BusState *qbus);
-
-static Property pci_props[] = {
-    DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
-    DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
-    DEFINE_PROP_UINT32("rombar",  PCIDevice, rom_bar, 1),
-    DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present,
-                    QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false),
-    DEFINE_PROP_BIT("command_serr_enable", PCIDevice, cap_present,
-                    QEMU_PCI_CAP_SERR_BITNR, true),
-    DEFINE_PROP_END_OF_LIST()
-};
-
-static void pci_bus_class_init(ObjectClass *klass, void *data)
-{
-    BusClass *k = BUS_CLASS(klass);
-
-    k->print_dev = pcibus_dev_print;
-    k->get_dev_path = pcibus_get_dev_path;
-    k->get_fw_dev_path = pcibus_get_fw_dev_path;
-    k->reset = pcibus_reset;
-}
-
-static const TypeInfo pci_bus_info = {
-    .name = TYPE_PCI_BUS,
-    .parent = TYPE_BUS,
-    .instance_size = sizeof(PCIBus),
-    .class_init = pci_bus_class_init,
-};
-
-static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num);
-static void pci_update_mappings(PCIDevice *d);
-static void pci_set_irq(void *opaque, int irq_num, int level);
-static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom);
-static void pci_del_option_rom(PCIDevice *pdev);
-
-static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET;
-static uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU;
-
-struct PCIHostBus {
-    int domain;
-    struct PCIBus *bus;
-    QLIST_ENTRY(PCIHostBus) next;
-};
-static QLIST_HEAD(, PCIHostBus) host_buses;
-
-static const VMStateDescription vmstate_pcibus = {
-    .name = "PCIBUS",
-    .version_id = 1,
-    .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
-        VMSTATE_INT32_EQUAL(nirq, PCIBus),
-        VMSTATE_VARRAY_INT32(irq_count, PCIBus, nirq, 0, vmstate_info_int32, int32_t),
-        VMSTATE_END_OF_LIST()
-    }
-};
-static int pci_bar(PCIDevice *d, int reg)
-{
-    uint8_t type;
-
-    if (reg != PCI_ROM_SLOT)
-        return PCI_BASE_ADDRESS_0 + reg * 4;
-
-    type = d->config[PCI_HEADER_TYPE] & ~PCI_HEADER_TYPE_MULTI_FUNCTION;
-    return type == PCI_HEADER_TYPE_BRIDGE ? PCI_ROM_ADDRESS1 : PCI_ROM_ADDRESS;
-}
-
-static inline int pci_irq_state(PCIDevice *d, int irq_num)
-{
-       return (d->irq_state >> irq_num) & 0x1;
-}
-
-static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level)
-{
-       d->irq_state &= ~(0x1 << irq_num);
-       d->irq_state |= level << irq_num;
-}
-
-static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change)
-{
-    PCIBus *bus;
-    for (;;) {
-        bus = pci_dev->bus;
-        irq_num = bus->map_irq(pci_dev, irq_num);
-        if (bus->set_irq)
-            break;
-        pci_dev = bus->parent_dev;
-    }
-    bus->irq_count[irq_num] += change;
-    bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0);
-}
-
-int pci_bus_get_irq_level(PCIBus *bus, int irq_num)
-{
-    assert(irq_num >= 0);
-    assert(irq_num < bus->nirq);
-    return !!bus->irq_count[irq_num];
-}
-
-/* Update interrupt status bit in config space on interrupt
- * state change. */
-static void pci_update_irq_status(PCIDevice *dev)
-{
-    if (dev->irq_state) {
-        dev->config[PCI_STATUS] |= PCI_STATUS_INTERRUPT;
-    } else {
-        dev->config[PCI_STATUS] &= ~PCI_STATUS_INTERRUPT;
-    }
-}
-
-void pci_device_deassert_intx(PCIDevice *dev)
-{
-    int i;
-    for (i = 0; i < PCI_NUM_PINS; ++i) {
-        qemu_set_irq(dev->irq[i], 0);
-    }
-}
-
-/*
- * This function is called on #RST and FLR.
- * FLR if PCI_EXP_DEVCTL_BCR_FLR is set
- */
-void pci_device_reset(PCIDevice *dev)
-{
-    int r;
-
-    qdev_reset_all(&dev->qdev);
-
-    dev->irq_state = 0;
-    pci_update_irq_status(dev);
-    pci_device_deassert_intx(dev);
-    /* Clear all writable bits */
-    pci_word_test_and_clear_mask(dev->config + PCI_COMMAND,
-                                 pci_get_word(dev->wmask + PCI_COMMAND) |
-                                 pci_get_word(dev->w1cmask + PCI_COMMAND));
-    pci_word_test_and_clear_mask(dev->config + PCI_STATUS,
-                                 pci_get_word(dev->wmask + PCI_STATUS) |
-                                 pci_get_word(dev->w1cmask + PCI_STATUS));
-    dev->config[PCI_CACHE_LINE_SIZE] = 0x0;
-    dev->config[PCI_INTERRUPT_LINE] = 0x0;
-    for (r = 0; r < PCI_NUM_REGIONS; ++r) {
-        PCIIORegion *region = &dev->io_regions[r];
-        if (!region->size) {
-            continue;
-        }
-
-        if (!(region->type & PCI_BASE_ADDRESS_SPACE_IO) &&
-            region->type & PCI_BASE_ADDRESS_MEM_TYPE_64) {
-            pci_set_quad(dev->config + pci_bar(dev, r), region->type);
-        } else {
-            pci_set_long(dev->config + pci_bar(dev, r), region->type);
-        }
-    }
-    pci_update_mappings(dev);
-
-    msi_reset(dev);
-    msix_reset(dev);
-}
-
-/*
- * Trigger pci bus reset under a given bus.
- * To be called on RST# assert.
- */
-void pci_bus_reset(PCIBus *bus)
-{
-    int i;
-
-    for (i = 0; i < bus->nirq; i++) {
-        bus->irq_count[i] = 0;
-    }
-    for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
-        if (bus->devices[i]) {
-            pci_device_reset(bus->devices[i]);
-        }
-    }
-}
-
-static int pcibus_reset(BusState *qbus)
-{
-    pci_bus_reset(DO_UPCAST(PCIBus, qbus, qbus));
-
-    /* topology traverse is done by pci_bus_reset().
-       Tell qbus/qdev walker not to traverse the tree */
-    return 1;
-}
-
-static void pci_host_bus_register(int domain, PCIBus *bus)
-{
-    struct PCIHostBus *host;
-    host = g_malloc0(sizeof(*host));
-    host->domain = domain;
-    host->bus = bus;
-    QLIST_INSERT_HEAD(&host_buses, host, next);
-}
-
-PCIBus *pci_find_root_bus(int domain)
-{
-    struct PCIHostBus *host;
-
-    QLIST_FOREACH(host, &host_buses, next) {
-        if (host->domain == domain) {
-            return host->bus;
-        }
-    }
-
-    return NULL;
-}
-
-int pci_find_domain(const PCIBus *bus)
-{
-    PCIDevice *d;
-    struct PCIHostBus *host;
-
-    /* obtain root bus */
-    while ((d = bus->parent_dev) != NULL) {
-        bus = d->bus;
-    }
-
-    QLIST_FOREACH(host, &host_buses, next) {
-        if (host->bus == bus) {
-            return host->domain;
-        }
-    }
-
-    abort();    /* should not be reached */
-    return -1;
-}
-
-void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
-                         const char *name,
-                         MemoryRegion *address_space_mem,
-                         MemoryRegion *address_space_io,
-                         uint8_t devfn_min)
-{
-    qbus_create_inplace(&bus->qbus, TYPE_PCI_BUS, parent, name);
-    assert(PCI_FUNC(devfn_min) == 0);
-    bus->devfn_min = devfn_min;
-    bus->address_space_mem = address_space_mem;
-    bus->address_space_io = address_space_io;
-
-    /* host bridge */
-    QLIST_INIT(&bus->child);
-    pci_host_bus_register(0, bus); /* for now only pci domain 0 is supported */
-
-    vmstate_register(NULL, -1, &vmstate_pcibus, bus);
-}
-
-PCIBus *pci_bus_new(DeviceState *parent, const char *name,
-                    MemoryRegion *address_space_mem,
-                    MemoryRegion *address_space_io,
-                    uint8_t devfn_min)
-{
-    PCIBus *bus;
-
-    bus = g_malloc0(sizeof(*bus));
-    pci_bus_new_inplace(bus, parent, name, address_space_mem,
-                        address_space_io, devfn_min);
-    OBJECT(bus)->free = g_free;
-    return bus;
-}
-
-void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
-                  void *irq_opaque, int nirq)
-{
-    bus->set_irq = set_irq;
-    bus->map_irq = map_irq;
-    bus->irq_opaque = irq_opaque;
-    bus->nirq = nirq;
-    bus->irq_count = g_malloc0(nirq * sizeof(bus->irq_count[0]));
-}
-
-void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug, DeviceState *qdev)
-{
-    bus->qbus.allow_hotplug = 1;
-    bus->hotplug = hotplug;
-    bus->hotplug_qdev = qdev;
-}
-
-PCIBus *pci_register_bus(DeviceState *parent, const char *name,
-                         pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
-                         void *irq_opaque,
-                         MemoryRegion *address_space_mem,
-                         MemoryRegion *address_space_io,
-                         uint8_t devfn_min, int nirq)
-{
-    PCIBus *bus;
-
-    bus = pci_bus_new(parent, name, address_space_mem,
-                      address_space_io, devfn_min);
-    pci_bus_irqs(bus, set_irq, map_irq, irq_opaque, nirq);
-    return bus;
-}
-
-int pci_bus_num(PCIBus *s)
-{
-    if (!s->parent_dev)
-        return 0;       /* pci host bridge */
-    return s->parent_dev->config[PCI_SECONDARY_BUS];
-}
-
-static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
-{
-    PCIDevice *s = container_of(pv, PCIDevice, config);
-    uint8_t *config;
-    int i;
-
-    assert(size == pci_config_size(s));
-    config = g_malloc(size);
-
-    qemu_get_buffer(f, config, size);
-    for (i = 0; i < size; ++i) {
-        if ((config[i] ^ s->config[i]) &
-            s->cmask[i] & ~s->wmask[i] & ~s->w1cmask[i]) {
-            g_free(config);
-            return -EINVAL;
-        }
-    }
-    memcpy(s->config, config, size);
-
-    pci_update_mappings(s);
-
-    memory_region_set_enabled(&s->bus_master_enable_region,
-                              pci_get_word(s->config + PCI_COMMAND)
-                              & PCI_COMMAND_MASTER);
-
-    g_free(config);
-    return 0;
-}
-
-/* just put buffer */
-static void put_pci_config_device(QEMUFile *f, void *pv, size_t size)
-{
-    const uint8_t **v = pv;
-    assert(size == pci_config_size(container_of(pv, PCIDevice, config)));
-    qemu_put_buffer(f, *v, size);
-}
-
-static VMStateInfo vmstate_info_pci_config = {
-    .name = "pci config",
-    .get  = get_pci_config_device,
-    .put  = put_pci_config_device,
-};
-
-static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)
-{
-    PCIDevice *s = container_of(pv, PCIDevice, irq_state);
-    uint32_t irq_state[PCI_NUM_PINS];
-    int i;
-    for (i = 0; i < PCI_NUM_PINS; ++i) {
-        irq_state[i] = qemu_get_be32(f);
-        if (irq_state[i] != 0x1 && irq_state[i] != 0) {
-            fprintf(stderr, "irq state %d: must be 0 or 1.\n",
-                    irq_state[i]);
-            return -EINVAL;
-        }
-    }
-
-    for (i = 0; i < PCI_NUM_PINS; ++i) {
-        pci_set_irq_state(s, i, irq_state[i]);
-    }
-
-    return 0;
-}
-
-static void put_pci_irq_state(QEMUFile *f, void *pv, size_t size)
-{
-    int i;
-    PCIDevice *s = container_of(pv, PCIDevice, irq_state);
-
-    for (i = 0; i < PCI_NUM_PINS; ++i) {
-        qemu_put_be32(f, pci_irq_state(s, i));
-    }
-}
-
-static VMStateInfo vmstate_info_pci_irq_state = {
-    .name = "pci irq state",
-    .get  = get_pci_irq_state,
-    .put  = put_pci_irq_state,
-};
-
-const VMStateDescription vmstate_pci_device = {
-    .name = "PCIDevice",
-    .version_id = 2,
-    .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
-        VMSTATE_INT32_LE(version_id, PCIDevice),
-        VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0,
-                                   vmstate_info_pci_config,
-                                   PCI_CONFIG_SPACE_SIZE),
-        VMSTATE_BUFFER_UNSAFE_INFO(irq_state, PCIDevice, 2,
-                                  vmstate_info_pci_irq_state,
-                                  PCI_NUM_PINS * sizeof(int32_t)),
-        VMSTATE_END_OF_LIST()
-    }
-};
-
-const VMStateDescription vmstate_pcie_device = {
-    .name = "PCIEDevice",
-    .version_id = 2,
-    .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
-        VMSTATE_INT32_LE(version_id, PCIDevice),
-        VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0,
-                                   vmstate_info_pci_config,
-                                   PCIE_CONFIG_SPACE_SIZE),
-        VMSTATE_BUFFER_UNSAFE_INFO(irq_state, PCIDevice, 2,
-                                  vmstate_info_pci_irq_state,
-                                  PCI_NUM_PINS * sizeof(int32_t)),
-        VMSTATE_END_OF_LIST()
-    }
-};
-
-static inline const VMStateDescription *pci_get_vmstate(PCIDevice *s)
-{
-    return pci_is_express(s) ? &vmstate_pcie_device : &vmstate_pci_device;
-}
-
-void pci_device_save(PCIDevice *s, QEMUFile *f)
-{
-    /* Clear interrupt status bit: it is implicit
-     * in irq_state which we are saving.
-     * This makes us compatible with old devices
-     * which never set or clear this bit. */
-    s->config[PCI_STATUS] &= ~PCI_STATUS_INTERRUPT;
-    vmstate_save_state(f, pci_get_vmstate(s), s);
-    /* Restore the interrupt status bit. */
-    pci_update_irq_status(s);
-}
-
-int pci_device_load(PCIDevice *s, QEMUFile *f)
-{
-    int ret;
-    ret = vmstate_load_state(f, pci_get_vmstate(s), s, s->version_id);
-    /* Restore the interrupt status bit. */
-    pci_update_irq_status(s);
-    return ret;
-}
-
-static void pci_set_default_subsystem_id(PCIDevice *pci_dev)
-{
-    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID,
-                 pci_default_sub_vendor_id);
-    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID,
-                 pci_default_sub_device_id);
-}
-
-/*
- * Parse [[<domain>:]<bus>:]<slot>, return -1 on error if funcp == NULL
- *       [[<domain>:]<bus>:]<slot>.<func>, return -1 on error
- */
-static int pci_parse_devaddr(const char *addr, int *domp, int *busp,
-                      unsigned int *slotp, unsigned int *funcp)
-{
-    const char *p;
-    char *e;
-    unsigned long val;
-    unsigned long dom = 0, bus = 0;
-    unsigned int slot = 0;
-    unsigned int func = 0;
-
-    p = addr;
-    val = strtoul(p, &e, 16);
-    if (e == p)
-       return -1;
-    if (*e == ':') {
-       bus = val;
-       p = e + 1;
-       val = strtoul(p, &e, 16);
-       if (e == p)
-           return -1;
-       if (*e == ':') {
-           dom = bus;
-           bus = val;
-           p = e + 1;
-           val = strtoul(p, &e, 16);
-           if (e == p)
-               return -1;
-       }
-    }
-
-    slot = val;
-
-    if (funcp != NULL) {
-        if (*e != '.')
-            return -1;
-
-        p = e + 1;
-        val = strtoul(p, &e, 16);
-        if (e == p)
-            return -1;
-
-        func = val;
-    }
-
-    /* if funcp == NULL func is 0 */
-    if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7)
-       return -1;
-
-    if (*e)
-       return -1;
-
-    *domp = dom;
-    *busp = bus;
-    *slotp = slot;
-    if (funcp != NULL)
-        *funcp = func;
-    return 0;
-}
-
-int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
-                     unsigned *slotp)
-{
-    /* strip legacy tag */
-    if (!strncmp(addr, "pci_addr=", 9)) {
-        addr += 9;
-    }
-    if (pci_parse_devaddr(addr, domp, busp, slotp, NULL)) {
-        monitor_printf(mon, "Invalid pci address\n");
-        return -1;
-    }
-    return 0;
-}
-
-PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
-{
-    int dom, bus;
-    unsigned slot;
-
-    if (!devaddr) {
-        *devfnp = -1;
-        return pci_find_bus_nr(pci_find_root_bus(0), 0);
-    }
-
-    if (pci_parse_devaddr(devaddr, &dom, &bus, &slot, NULL) < 0) {
-        return NULL;
-    }
-
-    *devfnp = PCI_DEVFN(slot, 0);
-    return pci_find_bus_nr(pci_find_root_bus(dom), bus);
-}
-
-static void pci_init_cmask(PCIDevice *dev)
-{
-    pci_set_word(dev->cmask + PCI_VENDOR_ID, 0xffff);
-    pci_set_word(dev->cmask + PCI_DEVICE_ID, 0xffff);
-    dev->cmask[PCI_STATUS] = PCI_STATUS_CAP_LIST;
-    dev->cmask[PCI_REVISION_ID] = 0xff;
-    dev->cmask[PCI_CLASS_PROG] = 0xff;
-    pci_set_word(dev->cmask + PCI_CLASS_DEVICE, 0xffff);
-    dev->cmask[PCI_HEADER_TYPE] = 0xff;
-    dev->cmask[PCI_CAPABILITY_LIST] = 0xff;
-}
-
-static void pci_init_wmask(PCIDevice *dev)
-{
-    int config_size = pci_config_size(dev);
-
-    dev->wmask[PCI_CACHE_LINE_SIZE] = 0xff;
-    dev->wmask[PCI_INTERRUPT_LINE] = 0xff;
-    pci_set_word(dev->wmask + PCI_COMMAND,
-                 PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
-                 PCI_COMMAND_INTX_DISABLE);
-    if (dev->cap_present & QEMU_PCI_CAP_SERR) {
-        pci_word_test_and_set_mask(dev->wmask + PCI_COMMAND, PCI_COMMAND_SERR);
-    }
-
-    memset(dev->wmask + PCI_CONFIG_HEADER_SIZE, 0xff,
-           config_size - PCI_CONFIG_HEADER_SIZE);
-}
-
-static void pci_init_w1cmask(PCIDevice *dev)
-{
-    /*
-     * Note: It's okay to set w1cmask even for readonly bits as
-     * long as their value is hardwired to 0.
-     */
-    pci_set_word(dev->w1cmask + PCI_STATUS,
-                 PCI_STATUS_PARITY | PCI_STATUS_SIG_TARGET_ABORT |
-                 PCI_STATUS_REC_TARGET_ABORT | PCI_STATUS_REC_MASTER_ABORT |
-                 PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY);
-}
-
-static void pci_init_mask_bridge(PCIDevice *d)
-{
-    /* PCI_PRIMARY_BUS, PCI_SECONDARY_BUS, PCI_SUBORDINATE_BUS and
-       PCI_SEC_LETENCY_TIMER */
-    memset(d->wmask + PCI_PRIMARY_BUS, 0xff, 4);
-
-    /* base and limit */
-    d->wmask[PCI_IO_BASE] = PCI_IO_RANGE_MASK & 0xff;
-    d->wmask[PCI_IO_LIMIT] = PCI_IO_RANGE_MASK & 0xff;
-    pci_set_word(d->wmask + PCI_MEMORY_BASE,
-                 PCI_MEMORY_RANGE_MASK & 0xffff);
-    pci_set_word(d->wmask + PCI_MEMORY_LIMIT,
-                 PCI_MEMORY_RANGE_MASK & 0xffff);
-    pci_set_word(d->wmask + PCI_PREF_MEMORY_BASE,
-                 PCI_PREF_RANGE_MASK & 0xffff);
-    pci_set_word(d->wmask + PCI_PREF_MEMORY_LIMIT,
-                 PCI_PREF_RANGE_MASK & 0xffff);
-
-    /* PCI_PREF_BASE_UPPER32 and PCI_PREF_LIMIT_UPPER32 */
-    memset(d->wmask + PCI_PREF_BASE_UPPER32, 0xff, 8);
-
-    /* Supported memory and i/o types */
-    d->config[PCI_IO_BASE] |= PCI_IO_RANGE_TYPE_16;
-    d->config[PCI_IO_LIMIT] |= PCI_IO_RANGE_TYPE_16;
-    pci_word_test_and_set_mask(d->config + PCI_PREF_MEMORY_BASE,
-                               PCI_PREF_RANGE_TYPE_64);
-    pci_word_test_and_set_mask(d->config + PCI_PREF_MEMORY_LIMIT,
-                               PCI_PREF_RANGE_TYPE_64);
-
-/* TODO: add this define to pci_regs.h in linux and then in qemu. */
-#define  PCI_BRIDGE_CTL_VGA_16BIT      0x10    /* VGA 16-bit decode */
-#define  PCI_BRIDGE_CTL_DISCARD                0x100   /* Primary discard timer */
-#define  PCI_BRIDGE_CTL_SEC_DISCARD    0x200   /* Secondary discard timer */
-#define  PCI_BRIDGE_CTL_DISCARD_STATUS 0x400   /* Discard timer status */
-#define  PCI_BRIDGE_CTL_DISCARD_SERR   0x800   /* Discard timer SERR# enable */
-    pci_set_word(d->wmask + PCI_BRIDGE_CONTROL,
-                 PCI_BRIDGE_CTL_PARITY |
-                 PCI_BRIDGE_CTL_SERR |
-                 PCI_BRIDGE_CTL_ISA |
-                 PCI_BRIDGE_CTL_VGA |
-                 PCI_BRIDGE_CTL_VGA_16BIT |
-                 PCI_BRIDGE_CTL_MASTER_ABORT |
-                 PCI_BRIDGE_CTL_BUS_RESET |
-                 PCI_BRIDGE_CTL_FAST_BACK |
-                 PCI_BRIDGE_CTL_DISCARD |
-                 PCI_BRIDGE_CTL_SEC_DISCARD |
-                 PCI_BRIDGE_CTL_DISCARD_SERR);
-    /* Below does not do anything as we never set this bit, put here for
-     * completeness. */
-    pci_set_word(d->w1cmask + PCI_BRIDGE_CONTROL,
-                 PCI_BRIDGE_CTL_DISCARD_STATUS);
-    d->cmask[PCI_IO_BASE] |= PCI_IO_RANGE_TYPE_MASK;
-    d->cmask[PCI_IO_LIMIT] |= PCI_IO_RANGE_TYPE_MASK;
-    pci_word_test_and_set_mask(d->cmask + PCI_PREF_MEMORY_BASE,
-                               PCI_PREF_RANGE_TYPE_MASK);
-    pci_word_test_and_set_mask(d->cmask + PCI_PREF_MEMORY_LIMIT,
-                               PCI_PREF_RANGE_TYPE_MASK);
-}
-
-static int pci_init_multifunction(PCIBus *bus, PCIDevice *dev)
-{
-    uint8_t slot = PCI_SLOT(dev->devfn);
-    uint8_t func;
-
-    if (dev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
-        dev->config[PCI_HEADER_TYPE] |= PCI_HEADER_TYPE_MULTI_FUNCTION;
-    }
-
-    /*
-     * multifunction bit is interpreted in two ways as follows.
-     *   - all functions must set the bit to 1.
-     *     Example: Intel X53
-     *   - function 0 must set the bit, but the rest function (> 0)
-     *     is allowed to leave the bit to 0.
-     *     Example: PIIX3(also in qemu), PIIX4(also in qemu), ICH10,
-     *
-     * So OS (at least Linux) checks the bit of only function 0,
-     * and doesn't see the bit of function > 0.
-     *
-     * The below check allows both interpretation.
-     */
-    if (PCI_FUNC(dev->devfn)) {
-        PCIDevice *f0 = bus->devices[PCI_DEVFN(slot, 0)];
-        if (f0 && !(f0->cap_present & QEMU_PCI_CAP_MULTIFUNCTION)) {
-            /* function 0 should set multifunction bit */
-            error_report("PCI: single function device can't be populated "
-                         "in function %x.%x", slot, PCI_FUNC(dev->devfn));
-            return -1;
-        }
-        return 0;
-    }
-
-    if (dev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
-        return 0;
-    }
-    /* function 0 indicates single function, so function > 0 must be NULL */
-    for (func = 1; func < PCI_FUNC_MAX; ++func) {
-        if (bus->devices[PCI_DEVFN(slot, func)]) {
-            error_report("PCI: %x.0 indicates single function, "
-                         "but %x.%x is already populated.",
-                         slot, slot, func);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-static void pci_config_alloc(PCIDevice *pci_dev)
-{
-    int config_size = pci_config_size(pci_dev);
-
-    pci_dev->config = g_malloc0(config_size);
-    pci_dev->cmask = g_malloc0(config_size);
-    pci_dev->wmask = g_malloc0(config_size);
-    pci_dev->w1cmask = g_malloc0(config_size);
-    pci_dev->used = g_malloc0(config_size);
-}
-
-static void pci_config_free(PCIDevice *pci_dev)
-{
-    g_free(pci_dev->config);
-    g_free(pci_dev->cmask);
-    g_free(pci_dev->wmask);
-    g_free(pci_dev->w1cmask);
-    g_free(pci_dev->used);
-}
-
-/* -1 for devfn means auto assign */
-static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
-                                         const char *name, int devfn)
-{
-    PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
-    PCIConfigReadFunc *config_read = pc->config_read;
-    PCIConfigWriteFunc *config_write = pc->config_write;
-
-    if (devfn < 0) {
-        for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
-            devfn += PCI_FUNC_MAX) {
-            if (!bus->devices[devfn])
-                goto found;
-        }
-        error_report("PCI: no slot/function available for %s, all in use", name);
-        return NULL;
-    found: ;
-    } else if (bus->devices[devfn]) {
-        error_report("PCI: slot %d function %d not available for %s, in use by %s",
-                     PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name);
-        return NULL;
-    }
-    pci_dev->bus = bus;
-    if (bus->dma_context_fn) {
-        pci_dev->dma = bus->dma_context_fn(bus, bus->dma_context_opaque, devfn);
-    } else {
-        /* FIXME: Make dma_context_fn use MemoryRegions instead, so this path is
-         * taken unconditionally */
-        /* FIXME: inherit memory region from bus creator */
-        memory_region_init_alias(&pci_dev->bus_master_enable_region, "bus master",
-                                 get_system_memory(), 0,
-                                 memory_region_size(get_system_memory()));
-        memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
-        address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region);
-        pci_dev->dma = g_new(DMAContext, 1);
-        dma_context_init(pci_dev->dma, &pci_dev->bus_master_as, NULL, NULL, NULL);
-    }
-    pci_dev->devfn = devfn;
-    pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
-    pci_dev->irq_state = 0;
-    pci_config_alloc(pci_dev);
-
-    pci_config_set_vendor_id(pci_dev->config, pc->vendor_id);
-    pci_config_set_device_id(pci_dev->config, pc->device_id);
-    pci_config_set_revision(pci_dev->config, pc->revision);
-    pci_config_set_class(pci_dev->config, pc->class_id);
-
-    if (!pc->is_bridge) {
-        if (pc->subsystem_vendor_id || pc->subsystem_id) {
-            pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID,
-                         pc->subsystem_vendor_id);
-            pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID,
-                         pc->subsystem_id);
-        } else {
-            pci_set_default_subsystem_id(pci_dev);
-        }
-    } else {
-        /* subsystem_vendor_id/subsystem_id are only for header type 0 */
-        assert(!pc->subsystem_vendor_id);
-        assert(!pc->subsystem_id);
-    }
-    pci_init_cmask(pci_dev);
-    pci_init_wmask(pci_dev);
-    pci_init_w1cmask(pci_dev);
-    if (pc->is_bridge) {
-        pci_init_mask_bridge(pci_dev);
-    }
-    if (pci_init_multifunction(bus, pci_dev)) {
-        pci_config_free(pci_dev);
-        return NULL;
-    }
-
-    if (!config_read)
-        config_read = pci_default_read_config;
-    if (!config_write)
-        config_write = pci_default_write_config;
-    pci_dev->config_read = config_read;
-    pci_dev->config_write = config_write;
-    bus->devices[devfn] = pci_dev;
-    pci_dev->irq = qemu_allocate_irqs(pci_set_irq, pci_dev, PCI_NUM_PINS);
-    pci_dev->version_id = 2; /* Current pci device vmstate version */
-    return pci_dev;
-}
-
-static void do_pci_unregister_device(PCIDevice *pci_dev)
-{
-    qemu_free_irqs(pci_dev->irq);
-    pci_dev->bus->devices[pci_dev->devfn] = NULL;
-    pci_config_free(pci_dev);
-
-    if (!pci_dev->bus->dma_context_fn) {
-        address_space_destroy(&pci_dev->bus_master_as);
-        memory_region_destroy(&pci_dev->bus_master_enable_region);
-        g_free(pci_dev->dma);
-        pci_dev->dma = NULL;
-    }
-}
-
-static void pci_unregister_io_regions(PCIDevice *pci_dev)
-{
-    PCIIORegion *r;
-    int i;
-
-    for(i = 0; i < PCI_NUM_REGIONS; i++) {
-        r = &pci_dev->io_regions[i];
-        if (!r->size || r->addr == PCI_BAR_UNMAPPED)
-            continue;
-        memory_region_del_subregion(r->address_space, r->memory);
-    }
-}
-
-static int pci_unregister_device(DeviceState *dev)
-{
-    PCIDevice *pci_dev = PCI_DEVICE(dev);
-    PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
-
-    pci_unregister_io_regions(pci_dev);
-    pci_del_option_rom(pci_dev);
-
-    if (pc->exit) {
-        pc->exit(pci_dev);
-    }
-
-    do_pci_unregister_device(pci_dev);
-    return 0;
-}
-
-void pci_register_bar(PCIDevice *pci_dev, int region_num,
-                      uint8_t type, MemoryRegion *memory)
-{
-    PCIIORegion *r;
-    uint32_t addr;
-    uint64_t wmask;
-    pcibus_t size = memory_region_size(memory);
-
-    assert(region_num >= 0);
-    assert(region_num < PCI_NUM_REGIONS);
-    if (size & (size-1)) {
-        fprintf(stderr, "ERROR: PCI region size must be pow2 "
-                    "type=0x%x, size=0x%"FMT_PCIBUS"\n", type, size);
-        exit(1);
-    }
-
-    r = &pci_dev->io_regions[region_num];
-    r->addr = PCI_BAR_UNMAPPED;
-    r->size = size;
-    r->type = type;
-    r->memory = NULL;
-
-    wmask = ~(size - 1);
-    addr = pci_bar(pci_dev, region_num);
-    if (region_num == PCI_ROM_SLOT) {
-        /* ROM enable bit is writable */
-        wmask |= PCI_ROM_ADDRESS_ENABLE;
-    }
-    pci_set_long(pci_dev->config + addr, type);
-    if (!(r->type & PCI_BASE_ADDRESS_SPACE_IO) &&
-        r->type & PCI_BASE_ADDRESS_MEM_TYPE_64) {
-        pci_set_quad(pci_dev->wmask + addr, wmask);
-        pci_set_quad(pci_dev->cmask + addr, ~0ULL);
-    } else {
-        pci_set_long(pci_dev->wmask + addr, wmask & 0xffffffff);
-        pci_set_long(pci_dev->cmask + addr, 0xffffffff);
-    }
-    pci_dev->io_regions[region_num].memory = memory;
-    pci_dev->io_regions[region_num].address_space
-        = type & PCI_BASE_ADDRESS_SPACE_IO
-        ? pci_dev->bus->address_space_io
-        : pci_dev->bus->address_space_mem;
-}
-
-pcibus_t pci_get_bar_addr(PCIDevice *pci_dev, int region_num)
-{
-    return pci_dev->io_regions[region_num].addr;
-}
-
-static pcibus_t pci_bar_address(PCIDevice *d,
-                               int reg, uint8_t type, pcibus_t size)
-{
-    pcibus_t new_addr, last_addr;
-    int bar = pci_bar(d, reg);
-    uint16_t cmd = pci_get_word(d->config + PCI_COMMAND);
-
-    if (type & PCI_BASE_ADDRESS_SPACE_IO) {
-        if (!(cmd & PCI_COMMAND_IO)) {
-            return PCI_BAR_UNMAPPED;
-        }
-        new_addr = pci_get_long(d->config + bar) & ~(size - 1);
-        last_addr = new_addr + size - 1;
-        /* NOTE: we have only 64K ioports on PC */
-        if (last_addr <= new_addr || new_addr == 0 || last_addr > UINT16_MAX) {
-            return PCI_BAR_UNMAPPED;
-        }
-        return new_addr;
-    }
-
-    if (!(cmd & PCI_COMMAND_MEMORY)) {
-        return PCI_BAR_UNMAPPED;
-    }
-    if (type & PCI_BASE_ADDRESS_MEM_TYPE_64) {
-        new_addr = pci_get_quad(d->config + bar);
-    } else {
-        new_addr = pci_get_long(d->config + bar);
-    }
-    /* the ROM slot has a specific enable bit */
-    if (reg == PCI_ROM_SLOT && !(new_addr & PCI_ROM_ADDRESS_ENABLE)) {
-        return PCI_BAR_UNMAPPED;
-    }
-    new_addr &= ~(size - 1);
-    last_addr = new_addr + size - 1;
-    /* NOTE: we do not support wrapping */
-    /* XXX: as we cannot support really dynamic
-       mappings, we handle specific values as invalid
-       mappings. */
-    if (last_addr <= new_addr || new_addr == 0 ||
-        last_addr == PCI_BAR_UNMAPPED) {
-        return PCI_BAR_UNMAPPED;
-    }
-
-    /* Now pcibus_t is 64bit.
-     * Check if 32 bit BAR wraps around explicitly.
-     * Without this, PC ide doesn't work well.
-     * TODO: remove this work around.
-     */
-    if  (!(type & PCI_BASE_ADDRESS_MEM_TYPE_64) && last_addr >= UINT32_MAX) {
-        return PCI_BAR_UNMAPPED;
-    }
-
-    /*
-     * OS is allowed to set BAR beyond its addressable
-     * bits. For example, 32 bit OS can set 64bit bar
-     * to >4G. Check it. TODO: we might need to support
-     * it in the future for e.g. PAE.
-     */
-    if (last_addr >= HWADDR_MAX) {
-        return PCI_BAR_UNMAPPED;
-    }
-
-    return new_addr;
-}
-
-static void pci_update_mappings(PCIDevice *d)
-{
-    PCIIORegion *r;
-    int i;
-    pcibus_t new_addr;
-
-    for(i = 0; i < PCI_NUM_REGIONS; i++) {
-        r = &d->io_regions[i];
-
-        /* this region isn't registered */
-        if (!r->size)
-            continue;
-
-        new_addr = pci_bar_address(d, i, r->type, r->size);
-
-        /* This bar isn't changed */
-        if (new_addr == r->addr)
-            continue;
-
-        /* now do the real mapping */
-        if (r->addr != PCI_BAR_UNMAPPED) {
-            memory_region_del_subregion(r->address_space, r->memory);
-        }
-        r->addr = new_addr;
-        if (r->addr != PCI_BAR_UNMAPPED) {
-            memory_region_add_subregion_overlap(r->address_space,
-                                                r->addr, r->memory, 1);
-        }
-    }
-}
-
-static inline int pci_irq_disabled(PCIDevice *d)
-{
-    return pci_get_word(d->config + PCI_COMMAND) & PCI_COMMAND_INTX_DISABLE;
-}
-
-/* Called after interrupt disabled field update in config space,
- * assert/deassert interrupts if necessary.
- * Gets original interrupt disable bit value (before update). */
-static void pci_update_irq_disabled(PCIDevice *d, int was_irq_disabled)
-{
-    int i, disabled = pci_irq_disabled(d);
-    if (disabled == was_irq_disabled)
-        return;
-    for (i = 0; i < PCI_NUM_PINS; ++i) {
-        int state = pci_irq_state(d, i);
-        pci_change_irq_level(d, i, disabled ? -state : state);
-    }
-}
-
-uint32_t pci_default_read_config(PCIDevice *d,
-                                 uint32_t address, int len)
-{
-    uint32_t val = 0;
-
-    memcpy(&val, d->config + address, len);
-    return le32_to_cpu(val);
-}
-
-void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l)
-{
-    int i, was_irq_disabled = pci_irq_disabled(d);
-
-    for (i = 0; i < l; val >>= 8, ++i) {
-        uint8_t wmask = d->wmask[addr + i];
-        uint8_t w1cmask = d->w1cmask[addr + i];
-        assert(!(wmask & w1cmask));
-        d->config[addr + i] = (d->config[addr + i] & ~wmask) | (val & wmask);
-        d->config[addr + i] &= ~(val & w1cmask); /* W1C: Write 1 to Clear */
-    }
-    if (ranges_overlap(addr, l, PCI_BASE_ADDRESS_0, 24) ||
-        ranges_overlap(addr, l, PCI_ROM_ADDRESS, 4) ||
-        ranges_overlap(addr, l, PCI_ROM_ADDRESS1, 4) ||
-        range_covers_byte(addr, l, PCI_COMMAND))
-        pci_update_mappings(d);
-
-    if (range_covers_byte(addr, l, PCI_COMMAND)) {
-        pci_update_irq_disabled(d, was_irq_disabled);
-        memory_region_set_enabled(&d->bus_master_enable_region,
-                                  pci_get_word(d->config + PCI_COMMAND)
-                                    & PCI_COMMAND_MASTER);
-    }
-
-    msi_write_config(d, addr, val, l);
-    msix_write_config(d, addr, val, l);
-}
-
-/***********************************************************/
-/* generic PCI irq support */
-
-/* 0 <= irq_num <= 3. level must be 0 or 1 */
-static void pci_set_irq(void *opaque, int irq_num, int level)
-{
-    PCIDevice *pci_dev = opaque;
-    int change;
-
-    change = level - pci_irq_state(pci_dev, irq_num);
-    if (!change)
-        return;
-
-    pci_set_irq_state(pci_dev, irq_num, level);
-    pci_update_irq_status(pci_dev);
-    if (pci_irq_disabled(pci_dev))
-        return;
-    pci_change_irq_level(pci_dev, irq_num, change);
-}
-
-/* Special hooks used by device assignment */
-void pci_bus_set_route_irq_fn(PCIBus *bus, pci_route_irq_fn route_intx_to_irq)
-{
-    assert(!bus->parent_dev);
-    bus->route_intx_to_irq = route_intx_to_irq;
-}
-
-PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin)
-{
-    PCIBus *bus;
-
-    do {
-         bus = dev->bus;
-         pin = bus->map_irq(dev, pin);
-         dev = bus->parent_dev;
-    } while (dev);
-
-    if (!bus->route_intx_to_irq) {
-        error_report("PCI: Bug - unimplemented PCI INTx routing (%s)\n",
-                     object_get_typename(OBJECT(bus->qbus.parent)));
-        return (PCIINTxRoute) { PCI_INTX_DISABLED, -1 };
-    }
-
-    return bus->route_intx_to_irq(bus->irq_opaque, pin);
-}
-
-bool pci_intx_route_changed(PCIINTxRoute *old, PCIINTxRoute *new)
-{
-    return old->mode != new->mode || old->irq != new->irq;
-}
-
-void pci_bus_fire_intx_routing_notifier(PCIBus *bus)
-{
-    PCIDevice *dev;
-    PCIBus *sec;
-    int i;
-
-    for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
-        dev = bus->devices[i];
-        if (dev && dev->intx_routing_notifier) {
-            dev->intx_routing_notifier(dev);
-        }
-        QLIST_FOREACH(sec, &bus->child, sibling) {
-            pci_bus_fire_intx_routing_notifier(sec);
-        }
-    }
-}
-
-void pci_device_set_intx_routing_notifier(PCIDevice *dev,
-                                          PCIINTxRoutingNotifier notifier)
-{
-    dev->intx_routing_notifier = notifier;
-}
-
-/*
- * PCI-to-PCI bridge specification
- * 9.1: Interrupt routing. Table 9-1
- *
- * the PCI Express Base Specification, Revision 2.1
- * 2.2.8.1: INTx interrutp signaling - Rules
- *          the Implementation Note
- *          Table 2-20
- */
-/*
- * 0 <= pin <= 3 0 = INTA, 1 = INTB, 2 = INTC, 3 = INTD
- * 0-origin unlike PCI interrupt pin register.
- */
-int pci_swizzle_map_irq_fn(PCIDevice *pci_dev, int pin)
-{
-    return (pin + PCI_SLOT(pci_dev->devfn)) % PCI_NUM_PINS;
-}
-
-/***********************************************************/
-/* monitor info on PCI */
-
-typedef struct {
-    uint16_t class;
-    const char *desc;
-    const char *fw_name;
-    uint16_t fw_ign_bits;
-} pci_class_desc;
-
-static const pci_class_desc pci_class_descriptions[] =
-{
-    { 0x0001, "VGA controller", "display"},
-    { 0x0100, "SCSI controller", "scsi"},
-    { 0x0101, "IDE controller", "ide"},
-    { 0x0102, "Floppy controller", "fdc"},
-    { 0x0103, "IPI controller", "ipi"},
-    { 0x0104, "RAID controller", "raid"},
-    { 0x0106, "SATA controller"},
-    { 0x0107, "SAS controller"},
-    { 0x0180, "Storage controller"},
-    { 0x0200, "Ethernet controller", "ethernet"},
-    { 0x0201, "Token Ring controller", "token-ring"},
-    { 0x0202, "FDDI controller", "fddi"},
-    { 0x0203, "ATM controller", "atm"},
-    { 0x0280, "Network controller"},
-    { 0x0300, "VGA controller", "display", 0x00ff},
-    { 0x0301, "XGA controller"},
-    { 0x0302, "3D controller"},
-    { 0x0380, "Display controller"},
-    { 0x0400, "Video controller", "video"},
-    { 0x0401, "Audio controller", "sound"},
-    { 0x0402, "Phone"},
-    { 0x0403, "Audio controller", "sound"},
-    { 0x0480, "Multimedia controller"},
-    { 0x0500, "RAM controller", "memory"},
-    { 0x0501, "Flash controller", "flash"},
-    { 0x0580, "Memory controller"},
-    { 0x0600, "Host bridge", "host"},
-    { 0x0601, "ISA bridge", "isa"},
-    { 0x0602, "EISA bridge", "eisa"},
-    { 0x0603, "MC bridge", "mca"},
-    { 0x0604, "PCI bridge", "pci"},
-    { 0x0605, "PCMCIA bridge", "pcmcia"},
-    { 0x0606, "NUBUS bridge", "nubus"},
-    { 0x0607, "CARDBUS bridge", "cardbus"},
-    { 0x0608, "RACEWAY bridge"},
-    { 0x0680, "Bridge"},
-    { 0x0700, "Serial port", "serial"},
-    { 0x0701, "Parallel port", "parallel"},
-    { 0x0800, "Interrupt controller", "interrupt-controller"},
-    { 0x0801, "DMA controller", "dma-controller"},
-    { 0x0802, "Timer", "timer"},
-    { 0x0803, "RTC", "rtc"},
-    { 0x0900, "Keyboard", "keyboard"},
-    { 0x0901, "Pen", "pen"},
-    { 0x0902, "Mouse", "mouse"},
-    { 0x0A00, "Dock station", "dock", 0x00ff},
-    { 0x0B00, "i386 cpu", "cpu", 0x00ff},
-    { 0x0c00, "Fireware contorller", "fireware"},
-    { 0x0c01, "Access bus controller", "access-bus"},
-    { 0x0c02, "SSA controller", "ssa"},
-    { 0x0c03, "USB controller", "usb"},
-    { 0x0c04, "Fibre channel controller", "fibre-channel"},
-    { 0x0c05, "SMBus"},
-    { 0, NULL}
-};
-
-static void pci_for_each_device_under_bus(PCIBus *bus,
-                                          void (*fn)(PCIBus *b, PCIDevice *d,
-                                                     void *opaque),
-                                          void *opaque)
-{
-    PCIDevice *d;
-    int devfn;
-
-    for(devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
-        d = bus->devices[devfn];
-        if (d) {
-            fn(bus, d, opaque);
-        }
-    }
-}
-
-void pci_for_each_device(PCIBus *bus, int bus_num,
-                         void (*fn)(PCIBus *b, PCIDevice *d, void *opaque),
-                         void *opaque)
-{
-    bus = pci_find_bus_nr(bus, bus_num);
-
-    if (bus) {
-        pci_for_each_device_under_bus(bus, fn, opaque);
-    }
-}
-
-static const pci_class_desc *get_class_desc(int class)
-{
-    const pci_class_desc *desc;
-
-    desc = pci_class_descriptions;
-    while (desc->desc && class != desc->class) {
-        desc++;
-    }
-
-    return desc;
-}
-
-static PciDeviceInfoList *qmp_query_pci_devices(PCIBus *bus, int bus_num);
-
-static PciMemoryRegionList *qmp_query_pci_regions(const PCIDevice *dev)
-{
-    PciMemoryRegionList *head = NULL, *cur_item = NULL;
-    int i;
-
-    for (i = 0; i < PCI_NUM_REGIONS; i++) {
-        const PCIIORegion *r = &dev->io_regions[i];
-        PciMemoryRegionList *region;
-
-        if (!r->size) {
-            continue;
-        }
-
-        region = g_malloc0(sizeof(*region));
-        region->value = g_malloc0(sizeof(*region->value));
-
-        if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
-            region->value->type = g_strdup("io");
-        } else {
-            region->value->type = g_strdup("memory");
-            region->value->has_prefetch = true;
-            region->value->prefetch = !!(r->type & PCI_BASE_ADDRESS_MEM_PREFETCH);
-            region->value->has_mem_type_64 = true;
-            region->value->mem_type_64 = !!(r->type & PCI_BASE_ADDRESS_MEM_TYPE_64);
-        }
-
-        region->value->bar = i;
-        region->value->address = r->addr;
-        region->value->size = r->size;
-
-        /* XXX: waiting for the qapi to support GSList */
-        if (!cur_item) {
-            head = cur_item = region;
-        } else {
-            cur_item->next = region;
-            cur_item = region;
-        }
-    }
-
-    return head;
-}
-
-static PciBridgeInfo *qmp_query_pci_bridge(PCIDevice *dev, PCIBus *bus,
-                                           int bus_num)
-{
-    PciBridgeInfo *info;
-
-    info = g_malloc0(sizeof(*info));
-
-    info->bus.number = dev->config[PCI_PRIMARY_BUS];
-    info->bus.secondary = dev->config[PCI_SECONDARY_BUS];
-    info->bus.subordinate = dev->config[PCI_SUBORDINATE_BUS];
-
-    info->bus.io_range = g_malloc0(sizeof(*info->bus.io_range));
-    info->bus.io_range->base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_IO);
-    info->bus.io_range->limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_IO);
-
-    info->bus.memory_range = g_malloc0(sizeof(*info->bus.memory_range));
-    info->bus.memory_range->base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);
-    info->bus.memory_range->limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);
-
-    info->bus.prefetchable_range = g_malloc0(sizeof(*info->bus.prefetchable_range));
-    info->bus.prefetchable_range->base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
-    info->bus.prefetchable_range->limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
-
-    if (dev->config[PCI_SECONDARY_BUS] != 0) {
-        PCIBus *child_bus = pci_find_bus_nr(bus, dev->config[PCI_SECONDARY_BUS]);
-        if (child_bus) {
-            info->has_devices = true;
-            info->devices = qmp_query_pci_devices(child_bus, dev->config[PCI_SECONDARY_BUS]);
-        }
-    }
-
-    return info;
-}
-
-static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus,
-                                           int bus_num)
-{
-    const pci_class_desc *desc;
-    PciDeviceInfo *info;
-    uint8_t type;
-    int class;
-
-    info = g_malloc0(sizeof(*info));
-    info->bus = bus_num;
-    info->slot = PCI_SLOT(dev->devfn);
-    info->function = PCI_FUNC(dev->devfn);
-
-    class = pci_get_word(dev->config + PCI_CLASS_DEVICE);
-    info->class_info.class = class;
-    desc = get_class_desc(class);
-    if (desc->desc) {
-        info->class_info.has_desc = true;
-        info->class_info.desc = g_strdup(desc->desc);
-    }
-
-    info->id.vendor = pci_get_word(dev->config + PCI_VENDOR_ID);
-    info->id.device = pci_get_word(dev->config + PCI_DEVICE_ID);
-    info->regions = qmp_query_pci_regions(dev);
-    info->qdev_id = g_strdup(dev->qdev.id ? dev->qdev.id : "");
-
-    if (dev->config[PCI_INTERRUPT_PIN] != 0) {
-        info->has_irq = true;
-        info->irq = dev->config[PCI_INTERRUPT_LINE];
-    }
-
-    type = dev->config[PCI_HEADER_TYPE] & ~PCI_HEADER_TYPE_MULTI_FUNCTION;
-    if (type == PCI_HEADER_TYPE_BRIDGE) {
-        info->has_pci_bridge = true;
-        info->pci_bridge = qmp_query_pci_bridge(dev, bus, bus_num);
-    }
-
-    return info;
-}
-
-static PciDeviceInfoList *qmp_query_pci_devices(PCIBus *bus, int bus_num)
-{
-    PciDeviceInfoList *info, *head = NULL, *cur_item = NULL;
-    PCIDevice *dev;
-    int devfn;
-
-    for (devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
-        dev = bus->devices[devfn];
-        if (dev) {
-            info = g_malloc0(sizeof(*info));
-            info->value = qmp_query_pci_device(dev, bus, bus_num);
-
-            /* XXX: waiting for the qapi to support GSList */
-            if (!cur_item) {
-                head = cur_item = info;
-            } else {
-                cur_item->next = info;
-                cur_item = info;
-            }
-        }
-    }
-
-    return head;
-}
-
-static PciInfo *qmp_query_pci_bus(PCIBus *bus, int bus_num)
-{
-    PciInfo *info = NULL;
-
-    bus = pci_find_bus_nr(bus, bus_num);
-    if (bus) {
-        info = g_malloc0(sizeof(*info));
-        info->bus = bus_num;
-        info->devices = qmp_query_pci_devices(bus, bus_num);
-    }
-
-    return info;
-}
-
-PciInfoList *qmp_query_pci(Error **errp)
-{
-    PciInfoList *info, *head = NULL, *cur_item = NULL;
-    struct PCIHostBus *host;
-
-    QLIST_FOREACH(host, &host_buses, next) {
-        info = g_malloc0(sizeof(*info));
-        info->value = qmp_query_pci_bus(host->bus, 0);
-
-        /* XXX: waiting for the qapi to support GSList */
-        if (!cur_item) {
-            head = cur_item = info;
-        } else {
-            cur_item->next = info;
-            cur_item = info;
-        }
-    }
-
-    return head;
-}
-
-static const char * const pci_nic_models[] = {
-    "ne2k_pci",
-    "i82551",
-    "i82557b",
-    "i82559er",
-    "rtl8139",
-    "e1000",
-    "pcnet",
-    "virtio",
-    NULL
-};
-
-static const char * const pci_nic_names[] = {
-    "ne2k_pci",
-    "i82551",
-    "i82557b",
-    "i82559er",
-    "rtl8139",
-    "e1000",
-    "pcnet",
-    "virtio-net-pci",
-    NULL
-};
-
-/* Initialize a PCI NIC.  */
-/* FIXME callers should check for failure, but don't */
-PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
-                        const char *default_devaddr)
-{
-    const char *devaddr = nd->devaddr ? nd->devaddr : default_devaddr;
-    PCIBus *bus;
-    int devfn;
-    PCIDevice *pci_dev;
-    DeviceState *dev;
-    int i;
-
-    i = qemu_find_nic_model(nd, pci_nic_models, default_model);
-    if (i < 0)
-        return NULL;
-
-    bus = pci_get_bus_devfn(&devfn, devaddr);
-    if (!bus) {
-        error_report("Invalid PCI device address %s for device %s",
-                     devaddr, pci_nic_names[i]);
-        return NULL;
-    }
-
-    pci_dev = pci_create(bus, devfn, pci_nic_names[i]);
-    dev = &pci_dev->qdev;
-    qdev_set_nic_properties(dev, nd);
-    if (qdev_init(dev) < 0)
-        return NULL;
-    return pci_dev;
-}
-
-PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
-                               const char *default_devaddr)
-{
-    PCIDevice *res;
-
-    if (qemu_show_nic_models(nd->model, pci_nic_models))
-        exit(0);
-
-    res = pci_nic_init(nd, default_model, default_devaddr);
-    if (!res)
-        exit(1);
-    return res;
-}
-
-PCIDevice *pci_vga_init(PCIBus *bus)
-{
-    switch (vga_interface_type) {
-    case VGA_CIRRUS:
-        return pci_create_simple(bus, -1, "cirrus-vga");
-    case VGA_QXL:
-        return pci_create_simple(bus, -1, "qxl-vga");
-    case VGA_STD:
-        return pci_create_simple(bus, -1, "VGA");
-    case VGA_VMWARE:
-        return pci_create_simple(bus, -1, "vmware-svga");
-    case VGA_NONE:
-    default: /* Other non-PCI types. Checking for unsupported types is already
-                done in vl.c. */
-        return NULL;
-    }
-}
-
-/* Whether a given bus number is in range of the secondary
- * bus of the given bridge device. */
-static bool pci_secondary_bus_in_range(PCIDevice *dev, int bus_num)
-{
-    return !(pci_get_word(dev->config + PCI_BRIDGE_CONTROL) &
-             PCI_BRIDGE_CTL_BUS_RESET) /* Don't walk the bus if it's reset. */ &&
-        dev->config[PCI_SECONDARY_BUS] < bus_num &&
-        bus_num <= dev->config[PCI_SUBORDINATE_BUS];
-}
-
-static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num)
-{
-    PCIBus *sec;
-
-    if (!bus) {
-        return NULL;
-    }
-
-    if (pci_bus_num(bus) == bus_num) {
-        return bus;
-    }
-
-    /* Consider all bus numbers in range for the host pci bridge. */
-    if (bus->parent_dev &&
-        !pci_secondary_bus_in_range(bus->parent_dev, bus_num)) {
-        return NULL;
-    }
-
-    /* try child bus */
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

hw/pci.h deleted +0 -684
deleted file mode 100644
index 4da0c2a..0000000

Lines of this file are not shown. View the raw message.

hw/pci/Makefile.objs new file +6 -0
new file mode 100644
index 0000000..9d21952

Lines of this file are not shown. View the raw message.

hw/pci/msi.c new file +395 -0
new file mode 100644
index 0000000..33037a8

Lines of this file are not shown. View the raw message.

hw/pci/msi.h new file +50 -0
new file mode 100644
index 0000000..150b09a

Lines of this file are not shown. View the raw message.

hw/pci/msix.c new file +562 -0
new file mode 100644
index 0000000..136ef09

Lines of this file are not shown. View the raw message.

hw/pci/msix.h new file +41 -0
new file mode 100644
index 0000000..15211cb

Lines of this file are not shown. View the raw message.

hw/pci/pci-hotplug.c new file +293 -0
new file mode 100644
index 0000000..0ca5546

Lines of this file are not shown. View the raw message.

hw/pci/pci-stub.c new file +47 -0
new file mode 100644
index 0000000..134c448

Lines of this file are not shown. View the raw message.

hw/pci/pci.c new file +2168 -0
new file mode 100644
index 0000000..97a0cd7

Lines of this file are not shown. View the raw message.

hw/pci/pci.h new file +684 -0
new file mode 100644
index 0000000..4da0c2a

Lines of this file are not shown. View the raw message.

hw/pci/pci_bridge.c new file +363 -0
new file mode 100644
index 0000000..4680501

Lines of this file are not shown. View the raw message.

hw/pci/pci_bridge.h new file +66 -0
new file mode 100644
index 0000000..a00accc

Lines of this file are not shown. View the raw message.

hw/pci/pci_host.c new file +180 -0
new file mode 100644
index 0000000..68e328c

Lines of this file are not shown. View the raw message.

hw/pci/pci_host.h new file +62 -0
new file mode 100644
index 0000000..4b9c300

Lines of this file are not shown. View the raw message.

hw/pci/pci_ids.h new file +147 -0
new file mode 100644
index 0000000..5df7245

Lines of this file are not shown. View the raw message.

hw/pci/pci_internals.h new file +78 -0
new file mode 100644
index 0000000..21d0ce6

Lines of this file are not shown. View the raw message.

hw/pci/pci_regs.h new file +717 -0
new file mode 100644
index 0000000..56a404b

Lines of this file are not shown. View the raw message.

hw/pci/pcie.c new file +555 -0
new file mode 100644
index 0000000..7c92f19

Lines of this file are not shown. View the raw message.

hw/pci/pcie.h new file +142 -0
new file mode 100644
index 0000000..4889194

Lines of this file are not shown. View the raw message.

hw/pci/pcie_aer.c new file +1032 -0
new file mode 100644
index 0000000..b04c164

Lines of this file are not shown. View the raw message.

hw/pci/pcie_aer.h new file +106 -0
new file mode 100644
index 0000000..7539500

Lines of this file are not shown. View the raw message.

hw/pci/pcie_host.c new file +161 -0
new file mode 100644
index 0000000..c257fb4

Lines of this file are not shown. View the raw message.

hw/pci/pcie_host.h new file +54 -0
new file mode 100644
index 0000000..3921935

Lines of this file are not shown. View the raw message.

hw/pci/pcie_port.c new file +114 -0
new file mode 100644
index 0000000..d6350e5

Lines of this file are not shown. View the raw message.

hw/pci/pcie_port.h new file +51 -0
new file mode 100644
index 0000000..3709583

Lines of this file are not shown. View the raw message.

hw/pci/pcie_regs.h new file +156 -0
new file mode 100644
index 0000000..4d123d9

Lines of this file are not shown. View the raw message.

hw/pci/shpc.c new file +681 -0
new file mode 100644
index 0000000..4597bbd

Lines of this file are not shown. View the raw message.

hw/pci/shpc.h new file +48 -0
new file mode 100644
index 0000000..130b71d

Lines of this file are not shown. View the raw message.

hw/pci/slotid_cap.c new file +44 -0
new file mode 100644
index 0000000..0106452

Lines of this file are not shown. View the raw message.

hw/pci/slotid_cap.h new file +11 -0
new file mode 100644
index 0000000..70db047

Lines of this file are not shown. View the raw message.

hw/pci_bridge.c deleted +0 -363
deleted file mode 100644
index 4680501..0000000

Lines of this file are not shown. View the raw message.

hw/pci_bridge.h deleted +0 -66
deleted file mode 100644
index a00accc..0000000

Lines of this file are not shown. View the raw message.

hw/pci_host.c deleted +0 -180
deleted file mode 100644
index 68e328c..0000000

Lines of this file are not shown. View the raw message.

hw/pci_host.h deleted +0 -62
deleted file mode 100644
index 4b9c300..0000000

Lines of this file are not shown. View the raw message.

hw/pci_ids.h deleted +0 -147
deleted file mode 100644
index 5df7245..0000000

Lines of this file are not shown. View the raw message.

hw/pci_internals.h deleted +0 -78
deleted file mode 100644
index 21d0ce6..0000000

Lines of this file are not shown. View the raw message.

hw/pci_regs.h deleted +0 -717
deleted file mode 100644
index 56a404b..0000000

Lines of this file are not shown. View the raw message.

hw/pcie.c deleted +0 -555
deleted file mode 100644
index 7c92f19..0000000

Lines of this file are not shown. View the raw message.

hw/pcie.h deleted +0 -142
deleted file mode 100644
index 4889194..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_aer.c deleted +0 -1032
deleted file mode 100644
index b04c164..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_aer.h deleted +0 -106
deleted file mode 100644
index 7539500..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_host.c deleted +0 -161
deleted file mode 100644
index c257fb4..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_host.h deleted +0 -54
deleted file mode 100644
index 3921935..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_port.c deleted +0 -114
deleted file mode 100644
index d6350e5..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_port.h deleted +0 -51
deleted file mode 100644
index 3709583..0000000

Lines of this file are not shown. View the raw message.

hw/pcie_regs.h deleted +0 -156
deleted file mode 100644
index 4d123d9..0000000

Lines of this file are not shown. View the raw message.

hw/ppc/Makefile.objs +1 -1
index 8fe2123..cb7cf8f 100644

Lines of this file are not shown. View the raw message.

hw/shpc.c deleted +0 -681
deleted file mode 100644
index 4597bbd..0000000

Lines of this file are not shown. View the raw message.

hw/shpc.h deleted +0 -48
deleted file mode 100644
index 130b71d..0000000

Lines of this file are not shown. View the raw message.

hw/slotid_cap.c deleted +0 -44
deleted file mode 100644
index 0106452..0000000

Lines of this file are not shown. View the raw message.

hw/slotid_cap.h deleted +0 -12
deleted file mode 100644
index 70db047..0000000

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

MST

Part of the diff is not shown here. View the raw message.