summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--MAINTAINERS1
-rw-r--r--Makefile.objs2
-rw-r--r--arch_init.c2
-rw-r--r--hw/Makefile.objs13
-rw-r--r--hw/ac97.c2
-rw-r--r--hw/acpi_ich9.c15
-rw-r--r--hw/acpi_piix4.c2
-rw-r--r--hw/alpha_sys.h4
-rw-r--r--hw/apb_pci.c8
-rw-r--r--hw/apic.c2
-rw-r--r--hw/apm.c2
-rw-r--r--hw/bonito.c4
-rw-r--r--hw/cirrus_vga.c2
-rw-r--r--hw/dec_pci.c8
-rw-r--r--hw/e1000.c2
-rw-r--r--hw/eepro100.c2
-rw-r--r--hw/es1370.c2
-rw-r--r--hw/esp-pci.c2
-rw-r--r--hw/grackle_pci.c4
-rw-r--r--hw/gt64xxx.c4
-rw-r--r--hw/hda-audio.c2
-rw-r--r--hw/i386/Makefile.objs2
-rw-r--r--hw/i82378.c2
-rw-r--r--hw/i82801b11.c2
-rw-r--r--hw/ich9.h8
-rw-r--r--hw/ide.h2
-rw-r--r--hw/ide/ahci.c4
-rw-r--r--hw/ide/cmd646.c2
-rw-r--r--hw/ide/core.c2
-rw-r--r--hw/ide/ich.c4
-rw-r--r--hw/ide/pci.c2
-rw-r--r--hw/ide/piix.c2
-rw-r--r--hw/ide/via.c2
-rw-r--r--hw/intel-hda.c4
-rw-r--r--hw/ioh3420.c6
-rw-r--r--hw/ioh3420.h2
-rw-r--r--hw/ivshmem.c4
-rw-r--r--hw/kvm/apic.c2
-rw-r--r--hw/kvm/pci-assign.c4
-rw-r--r--hw/lpc_ich9.c40
-rw-r--r--hw/lsi53c895a.c2
-rw-r--r--hw/macio.c2
-rw-r--r--hw/megasas.c4
-rw-r--r--hw/mips_fulong2e.c2
-rw-r--r--hw/mips_malta.c2
-rw-r--r--hw/ne2000.c2
-rw-r--r--hw/openpic.c4
-rw-r--r--hw/pc.c4
-rw-r--r--hw/pc_piix.c4
-rw-r--r--hw/pci/Makefile.objs9
-rw-r--r--hw/pci/msi.c (renamed from hw/msi.c)2
-rw-r--r--hw/pci/msi.h (renamed from hw/msi.h)2
-rw-r--r--hw/pci/msix.c (renamed from hw/msix.c)8
-rw-r--r--hw/pci/msix.h (renamed from hw/msix.h)2
-rw-r--r--hw/pci/pci-hotplug.c (renamed from hw/pci-hotplug.c)12
-rw-r--r--hw/pci/pci-stub.c (renamed from hw/pci-stub.c)2
-rw-r--r--hw/pci/pci.c (renamed from hw/pci.c)14
-rw-r--r--hw/pci/pci.h (renamed from hw/pci.h)10
-rw-r--r--hw/pci/pci_bridge.c (renamed from hw/pci_bridge.c)4
-rw-r--r--hw/pci/pci_bridge.h (renamed from hw/pci_bridge.h)2
-rw-r--r--hw/pci/pci_bus.h (renamed from hw/pci_internals.h)16
-rw-r--r--hw/pci/pci_host.c (renamed from hw/pci_host.c)4
-rw-r--r--hw/pci/pci_host.h (renamed from hw/pci_host.h)2
-rw-r--r--hw/pci/pci_ids.h (renamed from hw/pci_ids.h)0
-rw-r--r--hw/pci/pci_regs.h (renamed from hw/pci_regs.h)0
-rw-r--r--hw/pci/pcie.c (renamed from hw/pcie.c)12
-rw-r--r--hw/pci/pcie.h (renamed from hw/pcie.h)8
-rw-r--r--hw/pci/pcie_aer.c (renamed from hw/pcie_aer.c)12
-rw-r--r--hw/pci/pcie_aer.h (renamed from hw/pcie_aer.h)2
-rw-r--r--hw/pci/pcie_host.c (renamed from hw/pcie_host.c)6
-rw-r--r--hw/pci/pcie_host.h (renamed from hw/pcie_host.h)2
-rw-r--r--hw/pci/pcie_port.c (renamed from hw/pcie_port.c)2
-rw-r--r--hw/pci/pcie_port.h (renamed from hw/pcie_port.h)4
-rw-r--r--hw/pci/pcie_regs.h (renamed from hw/pcie_regs.h)0
-rw-r--r--hw/pci/shpc.c (renamed from hw/shpc.c)8
-rw-r--r--hw/pci/shpc.h (renamed from hw/shpc.h)0
-rw-r--r--hw/pci/slotid_cap.c (renamed from hw/slotid_cap.c)4
-rw-r--r--hw/pci/slotid_cap.h (renamed from hw/slotid_cap.h)0
-rw-r--r--hw/pci_bridge_dev.c12
-rw-r--r--hw/pcnet-pci.c2
-rw-r--r--hw/piix4.c2
-rw-r--r--hw/piix_pci.c4
-rw-r--r--hw/ppc/Makefile.objs2
-rw-r--r--hw/ppc/e500.c2
-rw-r--r--hw/ppc440_bamboo.c2
-rw-r--r--hw/ppc4xx.h2
-rw-r--r--hw/ppc4xx_pci.c4
-rw-r--r--hw/ppc_newworld.c2
-rw-r--r--hw/ppc_oldworld.c2
-rw-r--r--hw/ppc_prep.c4
-rw-r--r--hw/ppce500_pci.c4
-rw-r--r--hw/prep_pci.c4
-rw-r--r--hw/q35.h4
-rw-r--r--hw/qxl.h2
-rw-r--r--hw/r2d.c2
-rw-r--r--hw/realview.c2
-rw-r--r--hw/rtl8139.c2
-rw-r--r--hw/serial-pci.c2
-rw-r--r--hw/sga.c2
-rw-r--r--hw/sh_pci.c4
-rw-r--r--hw/smbus_ich9.c16
-rw-r--r--hw/spapr.c4
-rw-r--r--hw/spapr_pci.c10
-rw-r--r--hw/spapr_pci.h4
-rw-r--r--hw/sun4u.c2
-rw-r--r--hw/unin_pci.c4
-rw-r--r--hw/usb/hcd-ehci-pci.c2
-rw-r--r--hw/usb/hcd-ohci.c2
-rw-r--r--hw/usb/hcd-uhci.c2
-rw-r--r--hw/usb/hcd-xhci.c6
-rw-r--r--hw/versatile_pci.c4
-rw-r--r--hw/versatilepb.c2
-rw-r--r--hw/vfio_pci.c6
-rw-r--r--hw/vga-pci.c2
-rw-r--r--hw/vga.c2
-rw-r--r--hw/virtio-balloon.h2
-rw-r--r--hw/virtio-net.h2
-rw-r--r--hw/virtio-pci.c6
-rw-r--r--hw/virtio-scsi.h2
-rw-r--r--hw/vmware_vga.c2
-rw-r--r--hw/vt82c686.c4
-rw-r--r--hw/wdt_i6300esb.c2
-rw-r--r--hw/xen-host-pci-device.h2
-rw-r--r--hw/xen_apic.c2
-rw-r--r--hw/xen_platform.c2
-rw-r--r--hw/xen_pt.c2
-rw-r--r--hw/xen_pt.h2
-rw-r--r--hw/xio3130_downstream.c6
-rw-r--r--hw/xio3130_downstream.h2
-rw-r--r--hw/xio3130_upstream.c6
-rw-r--r--hw/xio3130_upstream.h2
-rw-r--r--kvm-all.c4
-rw-r--r--kvm-stub.c2
-rw-r--r--monitor.c2
-rw-r--r--net/tap-linux.c8
-rwxr-xr-xscripts/get_maintainer.pl25
-rw-r--r--target-i386/kvm.c2
-rw-r--r--xen-all.c2
138 files changed, 293 insertions, 290 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 2ede20d60b..c1b16c5fe4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -490,6 +490,7 @@ F: hw/omap*
 PCI
 M: Michael S. Tsirkin <mst@redhat.com>
 S: Supported
+F: hw/pci/*
 F: hw/pci*
 F: hw/piix*
 
diff --git a/Makefile.objs b/Makefile.objs
index 3c7abca433..20fb2c54f0 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -92,6 +92,8 @@ common-obj-$(CONFIG_SPICE) += spice-qemu-char.o
 
 common-obj-y += audio/
 common-obj-y += hw/
+extra-obj-y += hw/
+
 common-obj-y += ui/
 common-obj-y += bt-host.o bt-vhci.o
 
diff --git a/arch_init.c b/arch_init.c
index 83dcc53ff5..1645f3079a 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -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"
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index d581d8d6d6..bcf278d4ec 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -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
@@ -41,6 +37,8 @@ common-obj-$(CONFIG_I8259) += i8259_common.o i8259.o
 common-obj-y += fifo.o
 common-obj-y += pam.o
 
+extra-obj-y += pci/
+
 # PPC devices
 common-obj-$(CONFIG_PREP_PCI) += prep_pci.o
 common-obj-$(CONFIG_I82378) += i82378.o
@@ -102,8 +100,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
@@ -199,7 +195,6 @@ obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o virtio-scsi.o
 obj-$(CONFIG_SOFTMMU) += vhost_net.o
 obj-$(CONFIG_VHOST_NET) += vhost.o
 obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/
-obj-$(CONFIG_NO_PCI) += pci-stub.o
 obj-$(CONFIG_VGA) += vga.o
 obj-$(CONFIG_SOFTMMU) += device-hotplug.o
 obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
diff --git a/hw/ac97.c b/hw/ac97.c
index ce6a1dc609..3e659b38df 100644
--- a/hw/ac97.c
+++ b/hw/ac97.c
@@ -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 {
diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c
index c5978d33cc..755fa050f7 100644
--- a/hw/acpi_ich9.c
+++ b/hw/acpi_ich9.c
@@ -2,6 +2,11 @@
  * ACPI implementation
  *
  * Copyright (c) 2006 Fabrice Bellard
+ * Copyright (c) 2009 Isaku Yamahata <yamahata at valinux co jp>
+ *                    VA Linux Systems Japan K.K.
+ * Copyright (C) 2012 Jason Baron <jbaron@redhat.com>
+ *
+ * This is based on acpi.c.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -14,17 +19,13 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>
- */
-/*
- *  Copyright (c) 2009 Isaku Yamahata <yamahata at valinux co jp>
- *                     VA Linux Systems Japan K.K.
- *  Copyright (C) 2012 Jason Baron <jbaron@redhat.com>
  *
- *  This is based on acpi.c.
+ * 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 "pc.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "qemu-timer.h"
 #include "sysemu.h"
 #include "acpi.h"
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 0b5b0d3d3e..46f9843891 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -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"
diff --git a/hw/alpha_sys.h b/hw/alpha_sys.h
index 7604d09c80..b1e52585b3 100644
--- a/hw/alpha_sys.h
+++ b/hw/alpha_sys.h
@@ -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"
diff --git a/hw/apb_pci.c b/hw/apb_pci.c
index 054814fd4b..fb7a07de37 100644
--- a/hw/apb_pci.c
+++ b/hw/apb_pci.c
@@ -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_bus.h"
 #include "apb_pci.h"
 #include "sysemu.h"
 #include "exec-memory.h"
diff --git a/hw/apic.c b/hw/apic.c
index f73fc877aa..d66a476aac 100644
--- a/hw/apic.c
+++ b/hw/apic.c
@@ -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"
diff --git a/hw/apm.c b/hw/apm.c
index e988ad9939..2e1b1372d2 100644
--- a/hw/apm.c
+++ b/hw/apm.c
@@ -22,7 +22,7 @@
 
 #include "apm.h"
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 
 //#define DEBUG
 
diff --git a/hw/bonito.c b/hw/bonito.c
index 0bf6d4aa5f..a1fc38c784 100644
--- a/hw/bonito.c
+++ b/hw/bonito.c
@@ -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"
 
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 40efa8a523..7d021f2e1d 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -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"
diff --git a/hw/dec_pci.c b/hw/dec_pci.c
index c30ade38bd..ee3f4ca834 100644
--- a/hw/dec_pci.c
+++ b/hw/dec_pci.c
@@ -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_bus.h"
 
 /* debug DEC */
 //#define DEBUG_DEC
diff --git a/hw/e1000.c b/hw/e1000.c
index 5537ad2fc4..c89c8d22ab 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -26,7 +26,7 @@
 
 
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "net.h"
 #include "net/checksum.h"
 #include "loader.h"
diff --git a/hw/eepro100.c b/hw/eepro100.c
index a189474d31..992f03ace7 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -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"
diff --git a/hw/es1370.c b/hw/es1370.c
index e0c9729dc9..65365788e1 100644
--- a/hw/es1370.c
+++ b/hw/es1370.c
@@ -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:
diff --git a/hw/esp-pci.c b/hw/esp-pci.c
index d9a8e59c98..d433473d6a 100644
--- a/hw/esp-pci.c
+++ b/hw/esp-pci.c
@@ -23,7 +23,7 @@
  * THE SOFTWARE.
  */
 
-#include "pci.h"
+#include "pci/pci.h"
 #include "eeprom93xx.h"
 #include "esp.h"
 #include "trace.h"
diff --git a/hw/grackle_pci.c b/hw/grackle_pci.c
index 67da307284..948416632a 100644
--- a/hw/grackle_pci.c
+++ b/hw/grackle_pci.c
@@ -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
diff --git a/hw/gt64xxx.c b/hw/gt64xxx.c
index 95d491d932..5aa49c6148 100644
--- a/hw/gt64xxx.c
+++ b/hw/gt64xxx.c
@@ -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"
 
diff --git a/hw/hda-audio.c b/hw/hda-audio.c
index 36761dd2de..92a91b5ab1 100644
--- a/hw/hda-audio.c
+++ b/hw/hda-audio.c
@@ -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"
diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index 0d3f6a8e84..257f3c1a91 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -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
diff --git a/hw/i82378.c b/hw/i82378.c
index 99f35d41ef..c6b0b5ec55 100644
--- a/hw/i82378.c
+++ b/hw/i82378.c
@@ -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"
diff --git a/hw/i82801b11.c b/hw/i82801b11.c
index 3d1f996b2f..3dc10000a4 100644
--- a/hw/i82801b11.c
+++ b/hw/i82801b11.c
@@ -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"
 
 
diff --git a/hw/ich9.h b/hw/ich9.h
index 34e216f142..5c73f94caf 100644
--- a/hw/ich9.h
+++ b/hw/ich9.h
@@ -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_bus.h"
 
 void ich9_lpc_set_irq(void *opaque, int irq_num, int level);
 int ich9_lpc_map_irq(PCIDevice *pci_dev, int intx);
diff --git a/hw/ide.h b/hw/ide.h
index add742c4a8..081c710d56 100644
--- a/hw/ide.h
+++ b/hw/ide.h
@@ -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
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 67562db041..2ea64bd316 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -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"
diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index 804db60ffe..88210eabc8 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -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"
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 1235612d95..0e5bc7fe3b 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -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"
diff --git a/hw/ide/ich.c b/hw/ide/ich.c
index 272b7734b5..8e1a48e257 100644
--- a/hw/ide/ich.c
+++ b/hw/ide/ich.c
@@ -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"
diff --git a/hw/ide/pci.c b/hw/ide/pci.c
index bcdd70e450..23a0e237fb 100644
--- a/hw/ide/pci.c
+++ b/hw/ide/pci.c
@@ -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"
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index 9431badadf..5cf39cf8f0 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -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"
diff --git a/hw/ide/via.c b/hw/ide/via.c
index efda1733d9..8b4a24e5c2 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -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"
diff --git a/hw/intel-hda.c b/hw/intel-hda.c
index a68c3685e3..c21bf7204a 100644
--- a/hw/intel-hda.c
+++ b/hw/intel-hda.c
@@ -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"
diff --git a/hw/ioh3420.c b/hw/ioh3420.c
index 4d314733b9..d706e195df 100644
--- a/hw/ioh3420.c
+++ b/hw/ioh3420.c
@@ -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 */
diff --git a/hw/ioh3420.h b/hw/ioh3420.h
index 68c523ab46..046cf2c281 100644
--- a/hw/ioh3420.h
+++ b/hw/ioh3420.h
@@ -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,
diff --git a/hw/ivshmem.c b/hw/ivshmem.c
index f6dbb212f2..cf64f32ac0 100644
--- a/hw/ivshmem.c
+++ b/hw/ivshmem.c
@@ -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"
diff --git a/hw/kvm/apic.c b/hw/kvm/apic.c
index 8b65d513db..beb418de8d 100644
--- a/hw/kvm/apic.c
+++ b/hw/kvm/apic.c
@@ -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,
diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c
index e80dad009c..42291592e3 100644
--- a/hw/kvm/pci-assign.c
+++ b/hw/kvm/pci-assign.c
@@ -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
diff --git a/hw/lpc_ich9.c b/hw/lpc_ich9.c
index 878a43e92c..30505789f8 100644
--- a/hw/lpc_ich9.c
+++ b/hw/lpc_ich9.c
@@ -1,5 +1,13 @@
 /*
+ * QEMU ICH9 Emulation
+ *
  * Copyright (c) 2006 Fabrice Bellard
+ * Copyright (c) 2009, 2010, 2011
+ *               Isaku Yamahata <yamahata at valinux co jp>
+ *               VA Linux Systems Japan K.K.
+ * Copyright (C) 2012 Jason Baron <jbaron@redhat.com>
+ *
+ * This is based on piix_pci.c, but heavily modified.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -19,30 +27,6 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-/*
- * QEMU ICH9 Emulation
- *
- *  Copyright (c) 2009, 2010, 2011
- *                Isaku Yamahata <yamahata at valinux co jp>
- *                VA Linux Systems Japan K.K.
- *  Copyright (C) 2012 Jason Baron <jbaron@redhat.com>
- *
- *  This is based on piix_pci.c, but heavily modified.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>
- */
-
 #include "qemu-common.h"
 #include "hw.h"
 #include "range.h"
@@ -51,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_bus.h"
 #include "exec-memory.h"
 #include "sysemu.h"
 
diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index 04f2faef42..4aac9a0cff 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -13,7 +13,7 @@
 #include <assert.h>
 
 #include "hw.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "scsi.h"
 #include "dma.h"
 
diff --git a/hw/macio.c b/hw/macio.c
index eb15b890b1..362afdc7ec 100644
--- a/hw/macio.c
+++ b/hw/macio.c
@@ -24,7 +24,7 @@
  */
 #include "hw.h"
 #include "ppc_mac.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "escc.h"
 
 typedef struct MacIOState
diff --git a/hw/megasas.c b/hw/megasas.c
index 61b6527928..f4fbe9790a 100644
--- a/hw/megasas.c
+++ b/hw/megasas.c
@@ -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"
diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index 5fcf900e04..d5cf33b4b6 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -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"
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 4d2464a02c..571903dfc5 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -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"
diff --git a/hw/ne2000.c b/hw/ne2000.c
index d3dd9a6f26..fb78e5b252 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -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"
diff --git a/hw/openpic.c b/hw/openpic.c
index 3cbcea8eb3..9c956b9dcc 100644
--- a/hw/openpic.c
+++ b/hw/openpic.c
@@ -35,10 +35,10 @@
  */
 #include "hw.h"
 #include "ppc_mac.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "openpic.h"
 #include "sysbus.h"
-#include "msi.h"
+#include "pci/msi.h"
 
 //#define DEBUG_OPENPIC
 
diff --git a/hw/pc.c b/hw/pc.c
index b11e7c4adc..d1b102c879 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -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"
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 19e342aeb4..c2b4cb07e5 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -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"
diff --git a/hw/pci/Makefile.objs b/hw/pci/Makefile.objs
new file mode 100644
index 0000000000..fe965fe2f6
--- /dev/null
+++ b/hw/pci/Makefile.objs
@@ -0,0 +1,9 @@
+common-obj-$(CONFIG_PCI) += pci.o pci_bridge.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) += pcie.o pcie_aer.o pcie_port.o
+common-obj-$(CONFIG_NO_PCI) += pci-stub.o
+
+extra-obj-y += pci-stub.o
diff --git a/hw/msi.c b/hw/pci/msi.c
index 33037a80e9..680e4637d7 100644
--- a/hw/msi.c
+++ b/hw/pci/msi.c
@@ -18,7 +18,7 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "msi.h"
+#include "hw/pci/msi.h"
 #include "range.h"
 
 /* Eventually those constants should go to Linux pci_regs.h */
diff --git a/hw/msi.h b/hw/pci/msi.h
index 150b09a19d..81a3848a31 100644
--- a/hw/msi.h
+++ b/hw/pci/msi.h
@@ -22,7 +22,7 @@
 #define QEMU_MSI_H
 
 #include "qemu-common.h"
-#include "pci.h"
+#include "hw/pci/pci.h"
 
 struct MSIMessage {
     uint64_t address;
diff --git a/hw/msix.c b/hw/pci/msix.c
index b57ae60491..a6a401e286 100644
--- a/hw/msix.c
+++ b/hw/pci/msix.c
@@ -14,10 +14,10 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw.h"
-#include "msi.h"
-#include "msix.h"
-#include "pci.h"
+#include "hw/hw.h"
+#include "hw/pci/msi.h"
+#include "hw/pci/msix.h"
+#include "hw/pci/pci.h"
 #include "range.h"
 
 #define MSIX_CAP_LENGTH 12
diff --git a/hw/msix.h b/hw/pci/msix.h
index 15211cb592..ff07ae2e8f 100644
--- a/hw/msix.h
+++ b/hw/pci/msix.h
@@ -2,7 +2,7 @@
 #define QEMU_MSIX_H
 
 #include "qemu-common.h"
-#include "pci.h"
+#include "hw/pci/pci.h"
 
 void msix_set_message(PCIDevice *dev, int vector, MSIMessage msg);
 int msix_init(PCIDevice *dev, unsigned short nentries,
diff --git a/hw/pci-hotplug.c b/hw/pci/pci-hotplug.c
index 3bcfdcc1a6..4b4c931c74 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci/pci-hotplug.c
@@ -22,14 +22,14 @@
  * THE SOFTWARE.
  */
 
-#include "hw.h"
-#include "boards.h"
-#include "pci.h"
+#include "hw/hw.h"
+#include "hw/boards.h"
+#include "hw/pci/pci.h"
 #include "net.h"
-#include "pc.h"
+#include "hw/pc.h"
 #include "monitor.h"
-#include "scsi.h"
-#include "virtio-blk.h"
+#include "hw/scsi.h"
+#include "hw/virtio-blk.h"
 #include "qemu-config.h"
 #include "blockdev.h"
 #include "error.h"
diff --git a/hw/pci-stub.c b/hw/pci/pci-stub.c
index 134c4484b6..b5c43a935b 100644
--- a/hw/pci-stub.c
+++ b/hw/pci/pci-stub.c
@@ -20,7 +20,7 @@
 
 #include "sysemu.h"
 #include "monitor.h"
-#include "pci.h"
+#include "hw/pci/pci.h"
 #include "qmp-commands.h"
 
 PciInfoList *qmp_query_pci(Error **errp)
diff --git a/hw/pci.c b/hw/pci/pci.c
index 97a0cd77c1..2e455e22d2 100644
--- a/hw/pci.c
+++ b/hw/pci/pci.c
@@ -21,18 +21,18 @@
  * 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 "hw/hw.h"
+#include "hw/pci/pci.h"
+#include "hw/pci/pci_bridge.h"
+#include "hw/pci/pci_bus.h"
 #include "monitor.h"
 #include "net.h"
 #include "sysemu.h"
-#include "loader.h"
+#include "hw/loader.h"
 #include "range.h"
 #include "qmp-commands.h"
-#include "msi.h"
-#include "msix.h"
+#include "hw/pci/msi.h"
+#include "hw/pci/msix.h"
 #include "exec-memory.h"
 
 //#define DEBUG_PCI
diff --git a/hw/pci.h b/hw/pci/pci.h
index 4da0c2a4c9..41e5ddd1c4 100644
--- a/hw/pci.h
+++ b/hw/pci/pci.h
@@ -3,14 +3,14 @@
 
 #include "qemu-common.h"
 
-#include "qdev.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"
+#include "hw/pci/pcie.h"
 
 /* PCI bus */
 
@@ -21,7 +21,7 @@
 #define PCI_FUNC_MAX            8
 
 /* Class, Vendor and Device IDs from Linux's pci_ids.h */
-#include "pci_ids.h"
+#include "hw/pci/pci_ids.h"
 
 /* QEMU-specific Vendor and Device ID definitions */
 
@@ -100,7 +100,7 @@ typedef struct PCIIORegion {
 #define PCI_ROM_SLOT 6
 #define PCI_NUM_REGIONS 7
 
-#include "pci_regs.h"
+#include "hw/pci/pci_regs.h"
 
 /* PCI HEADER_TYPE */
 #define  PCI_HEADER_TYPE_MULTI_FUNCTION 0x80
diff --git a/hw/pci_bridge.c b/hw/pci/pci_bridge.c
index 4680501e4e..131091408d 100644
--- a/hw/pci_bridge.c
+++ b/hw/pci/pci_bridge.c
@@ -29,8 +29,8 @@
  *                    VA Linux Systems Japan K.K.
  */
 
-#include "pci_bridge.h"
-#include "pci_internals.h"
+#include "hw/pci/pci_bridge.h"
+#include "hw/pci/pci_bus.h"
 #include "range.h"
 
 /* PCI bridge subsystem vendor ID helper functions */
diff --git a/hw/pci_bridge.h b/hw/pci/pci_bridge.h
index a00accc172..455cb6677a 100644
--- a/hw/pci_bridge.h
+++ b/hw/pci/pci_bridge.h
@@ -26,7 +26,7 @@
 #ifndef QEMU_PCI_BRIDGE_H
 #define QEMU_PCI_BRIDGE_H
 
-#include "pci.h"
+#include "hw/pci/pci.h"
 
 int pci_bridge_ssvid_init(PCIDevice *dev, uint8_t offset,
                           uint16_t svid, uint16_t ssid);
diff --git a/hw/pci_internals.h b/hw/pci/pci_bus.h
index 21d0ce6973..f905b9e11e 100644
--- a/hw/pci_internals.h
+++ b/hw/pci/pci_bus.h
@@ -1,15 +1,11 @@
-#ifndef QEMU_PCI_INTERNALS_H
-#define QEMU_PCI_INTERNALS_H
+#ifndef QEMU_PCI_BUS_H
+#define QEMU_PCI_BUS_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"
@@ -75,4 +71,4 @@ struct PCIBridge {
     const char *bus_name;
 };
 
-#endif /* QEMU_PCI_INTERNALS_H */
+#endif /* QEMU_PCI_BUS_H */
diff --git a/hw/pci_host.c b/hw/pci/pci_host.c
index 68e328cd23..daca1c1ea0 100644
--- a/hw/pci_host.c
+++ b/hw/pci/pci_host.c
@@ -18,8 +18,8 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pci.h"
-#include "pci_host.h"
+#include "hw/pci/pci.h"
+#include "hw/pci/pci_host.h"
 
 /* debug PCI */
 //#define DEBUG_PCI
diff --git a/hw/pci_host.h b/hw/pci/pci_host.h
index 4b9c300fcf..1845d4dfd5 100644
--- a/hw/pci_host.h
+++ b/hw/pci/pci_host.h
@@ -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) \
diff --git a/hw/pci_ids.h b/hw/pci/pci_ids.h
index 5df7245349..5df7245349 100644
--- a/hw/pci_ids.h
+++ b/hw/pci/pci_ids.h
diff --git a/hw/pci_regs.h b/hw/pci/pci_regs.h
index 56a404be6e..56a404be6e 100644
--- a/hw/pci_regs.h
+++ b/hw/pci/pci_regs.h
diff --git a/hw/pcie.c b/hw/pci/pcie.c
index 7c92f193e7..b60a6faaf3 100644
--- a/hw/pcie.c
+++ b/hw/pci/pcie.c
@@ -19,12 +19,12 @@
  */
 
 #include "qemu-common.h"
-#include "pci_bridge.h"
-#include "pcie.h"
-#include "msix.h"
-#include "msi.h"
-#include "pci_internals.h"
-#include "pcie_regs.h"
+#include "hw/pci/pci_bridge.h"
+#include "hw/pci/pcie.h"
+#include "hw/pci/msix.h"
+#include "hw/pci/msi.h"
+#include "hw/pci/pci_bus.h"
+#include "hw/pci/pcie_regs.h"
 #include "range.h"
 
 //#define DEBUG_PCIE
diff --git a/hw/pcie.h b/hw/pci/pcie.h
index 4889194ae6..31604e2742 100644
--- a/hw/pcie.h
+++ b/hw/pci/pcie.h
@@ -21,10 +21,10 @@
 #ifndef QEMU_PCIE_H
 #define QEMU_PCIE_H
 
-#include "hw.h"
-#include "pci_regs.h"
-#include "pcie_regs.h"
-#include "pcie_aer.h"
+#include "hw/hw.h"
+#include "hw/pci/pci_regs.h"
+#include "hw/pci/pcie_regs.h"
+#include "hw/pci/pcie_aer.h"
 
 typedef enum {
     /* for attention and power indicator */
diff --git a/hw/pcie_aer.c b/hw/pci/pcie_aer.c
index b04c164e22..8a2032ca49 100644
--- a/hw/pcie_aer.c
+++ b/hw/pci/pcie_aer.c
@@ -21,12 +21,12 @@
 #include "sysemu.h"
 #include "qemu-objects.h"
 #include "monitor.h"
-#include "pci_bridge.h"
-#include "pcie.h"
-#include "msix.h"
-#include "msi.h"
-#include "pci_internals.h"
-#include "pcie_regs.h"
+#include "hw/pci/pci_bridge.h"
+#include "hw/pci/pcie.h"
+#include "hw/pci/msix.h"
+#include "hw/pci/msi.h"
+#include "hw/pci/pci_bus.h"
+#include "hw/pci/pcie_regs.h"
 
 //#define DEBUG_PCIE
 #ifdef DEBUG_PCIE
diff --git a/hw/pcie_aer.h b/hw/pci/pcie_aer.h
index 7539500cd8..bcac80a7b0 100644
--- a/hw/pcie_aer.h
+++ b/hw/pci/pcie_aer.h
@@ -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 */
 
diff --git a/hw/pcie_host.c b/hw/pci/pcie_host.c
index c257fb43ca..ab8d251de6 100644
--- a/hw/pcie_host.c
+++ b/hw/pci/pcie_host.c
@@ -19,9 +19,9 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "hw.h"
-#include "pci.h"
-#include "pcie_host.h"
+#include "hw/hw.h"
+#include "hw/pci/pci.h"
+#include "hw/pci/pcie_host.h"
 #include "exec-memory.h"
 
 /*
diff --git a/hw/pcie_host.h b/hw/pci/pcie_host.h
index 392193530d..150bef9736 100644
--- a/hw/pcie_host.h
+++ b/hw/pci/pcie_host.h
@@ -21,7 +21,7 @@
 #ifndef PCIE_HOST_H
 #define PCIE_HOST_H
 
-#include "pci_host.h"
+#include "hw/pci/pci_host.h"
 #include "memory.h"
 
 #define TYPE_PCIE_HOST_BRIDGE "pcie-host-bridge"
diff --git a/hw/pcie_port.c b/hw/pci/pcie_port.c
index d6350e5e73..33a6b0a08a 100644
--- a/hw/pcie_port.c
+++ b/hw/pci/pcie_port.c
@@ -18,7 +18,7 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pcie_port.h"
+#include "hw/pci/pcie_port.h"
 
 void pcie_port_init_reg(PCIDevice *d)
 {
diff --git a/hw/pcie_port.h b/hw/pci/pcie_port.h
index 3709583cc0..d89aa615c5 100644
--- a/hw/pcie_port.h
+++ b/hw/pci/pcie_port.h
@@ -21,8 +21,8 @@
 #ifndef QEMU_PCIE_PORT_H
 #define QEMU_PCIE_PORT_H
 
-#include "pci_bridge.h"
-#include "pci_internals.h"
+#include "hw/pci/pci_bridge.h"
+#include "hw/pci/pci_bus.h"
 
 struct PCIEPort {
     PCIBridge   br;
diff --git a/hw/pcie_regs.h b/hw/pci/pcie_regs.h
index 4d123d9fcc..4d123d9fcc 100644
--- a/hw/pcie_regs.h
+++ b/hw/pci/pcie_regs.h
diff --git a/hw/shpc.c b/hw/pci/shpc.c
index 4597bbde75..18b1512b43 100644
--- a/hw/shpc.c
+++ b/hw/pci/shpc.c
@@ -2,10 +2,10 @@
 #include <stdint.h>
 #include "range.h"
 #include "range.h"
-#include "shpc.h"
-#include "pci.h"
-#include "pci_internals.h"
-#include "msi.h"
+#include "hw/pci/shpc.h"
+#include "hw/pci/pci.h"
+#include "hw/pci/pci_bus.h"
+#include "hw/pci/msi.h"
 
 /* TODO: model power only and disabled slot states. */
 /* TODO: handle SERR and wakeups */
diff --git a/hw/shpc.h b/hw/pci/shpc.h
index 130b71df30..130b71df30 100644
--- a/hw/shpc.h
+++ b/hw/pci/shpc.h
diff --git a/hw/slotid_cap.c b/hw/pci/slotid_cap.c
index 01064521a9..99a30f429d 100644
--- a/hw/slotid_cap.c
+++ b/hw/pci/slotid_cap.c
@@ -1,5 +1,5 @@
-#include "slotid_cap.h"
-#include "pci.h"
+#include "hw/pci/slotid_cap.h"
+#include "hw/pci/pci.h"
 
 #define SLOTID_CAP_LENGTH 4
 #define SLOTID_NSLOTS_SHIFT (ffs(PCI_SID_ESR_NSLOTS) - 1)
diff --git a/hw/slotid_cap.h b/hw/pci/slotid_cap.h
index 70db0470b0..70db0470b0 100644
--- a/hw/slotid_cap.h
+++ b/hw/pci/slotid_cap.h
diff --git a/hw/pci_bridge_dev.c b/hw/pci_bridge_dev.c
index f7063961a0..dbb4b3b433 100644
--- a/hw/pci_bridge_dev.c
+++ b/hw/pci_bridge_dev.c
@@ -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_bus.h"
 
 #define REDHAT_PCI_VENDOR_ID 0x1b36
 #define PCI_BRIDGE_DEV_VENDOR_ID REDHAT_PCI_VENDOR_ID
diff --git a/hw/pcnet-pci.c b/hw/pcnet-pci.c
index 0bf438ffee..c1abbf8d0d 100644
--- a/hw/pcnet-pci.c
+++ b/hw/pcnet-pci.c
@@ -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"
diff --git a/hw/piix4.c b/hw/piix4.c
index ce4eb0d1ae..799ed1729c 100644
--- a/hw/piix4.c
+++ b/hw/piix4.c
@@ -24,7 +24,7 @@
 
 #include "hw.h"
 #include "pc.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "isa.h"
 #include "sysbus.h"
 
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index ba1b3de749..b5ea68bc61 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -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"
diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index 44921273c3..afdcc0e531 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -10,7 +10,7 @@ obj-y += ppc_newworld.o
 # IBM pSeries (sPAPR)
 obj-$(CONFIG_PSERIES) += spapr.o spapr_hcall.o spapr_rtas.o spapr_vio.o
 obj-$(CONFIG_PSERIES) += xics.o spapr_vty.o spapr_llan.o spapr_vscsi.o
-obj-$(CONFIG_PSERIES) += spapr_pci.o pci-hotplug.o spapr_iommu.o
+obj-$(CONFIG_PSERIES) += spapr_pci.o pci/pci-hotplug.o spapr_iommu.o
 obj-$(CONFIG_PSERIES) += spapr_events.o spapr_nvram.o
 # PowerPC 4xx boards
 obj-y += ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index af6b67143a..8fab508c07 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -21,7 +21,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"
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index cc85607cb7..0b39a81ec5 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -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"
diff --git a/hw/ppc4xx.h b/hw/ppc4xx.h
index d795ced57e..2b96d47f36 100644
--- a/hw/ppc4xx.h
+++ b/hw/ppc4xx.h
@@ -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,
diff --git a/hw/ppc4xx_pci.c b/hw/ppc4xx_pci.c
index d3ad6a0b79..3e8af11f08 100644
--- a/hw/ppc4xx_pci.c
+++ b/hw/ppc4xx_pci.c
@@ -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
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index 8c2114e26f..2bf3094e9f 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -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"
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index e8138c091e..3bc29c619c 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -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"
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index bf15730d8b..f6ffb593b7 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -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"
diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c
index 09e3507994..9bffbb9f87 100644
--- a/hw/ppce500_pci.c
+++ b/hw/ppce500_pci.c
@@ -16,8 +16,8 @@
 
 #include "hw.h"
 #include "hw/ppc/e500-ccsr.h"
-#include "pci.h"
-#include "pci_host.h"
+#include "pci/pci.h"
+#include "pci/pci_host.h"
 #include "bswap.h"
 #include "ppce500_pci.h"
 
diff --git a/hw/prep_pci.c b/hw/prep_pci.c
index 0bc479cd1f..5f22de647a 100644
--- a/hw/prep_pci.c
+++ b/hw/prep_pci.c
@@ -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"
 
diff --git a/hw/q35.h b/hw/q35.h
index e34f7c165f..2f951c8a94 100644
--- a/hw/q35.h
+++ b/hw/q35.h
@@ -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"
diff --git a/hw/qxl.h b/hw/qxl.h
index e583cfb750..41246c7554 100644
--- a/hw/qxl.h
+++ b/hw/qxl.h
@@ -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"
 
diff --git a/hw/r2d.c b/hw/r2d.c
index 66212e9cda..e18c23b28b 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -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"
diff --git a/hw/realview.c b/hw/realview.c
index 8ea4ad7423..5fbdcbf2b0 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -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"
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index e3aa8bfb11..e294a2a5e3 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -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"
diff --git a/hw/serial-pci.c b/hw/serial-pci.c
index 95dc5c8d2f..6a2548a515 100644
--- a/hw/serial-pci.c
+++ b/hw/serial-pci.c
@@ -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
 
diff --git a/hw/sga.c b/hw/sga.c
index a666349f82..5d80efd0c2 100644
--- a/hw/sga.c
+++ b/hw/sga.c
@@ -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"
diff --git a/hw/sh_pci.c b/hw/sh_pci.c
index fdec71b9e8..9ea08c8f8e 100644
--- a/hw/sh_pci.c
+++ b/hw/sh_pci.c
@@ -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"
 
diff --git a/hw/smbus_ich9.c b/hw/smbus_ich9.c
index 4194785d71..b7bddc80d3 100644
--- a/hw/smbus_ich9.c
+++ b/hw/smbus_ich9.c
@@ -2,6 +2,11 @@
  * ACPI implementation
  *
  * Copyright (c) 2006 Fabrice Bellard
+ * Copyright (c) 2009 Isaku Yamahata <yamahata at valinux co jp>
+ *               VA Linux Systems Japan K.K.
+ * Copyright (C) 2012 Jason Baron <jbaron@redhat.com>
+ *
+ * This is based on acpi.c, but heavily rewritten.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -14,18 +19,15 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>
- */
-/*
- *  Copyright (c) 2009 Isaku Yamahata <yamahata at valinux co jp>
- *                     VA Linux Systems Japan K.K.
- *  Copyright (C) 2012 Jason Baron <jbaron@redhat.com>
  *
- *  This is based on acpi.c, but heavily rewritten.
+ * 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 "pc.h"
 #include "pm_smbus.h"
-#include "pci.h"
+#include "pci/pci.h"
 #include "sysemu.h"
 #include "i2c.h"
 #include "smbus.h"
diff --git a/hw/spapr.c b/hw/spapr.c
index 504d0fca5e..9bd2fd5c8c 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -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"
diff --git a/hw/spapr_pci.c b/hw/spapr_pci.c
index 3c5b855bc0..786f6f4222 100644
--- a/hw/spapr_pci.c
+++ b/hw/spapr_pci.c
@@ -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_bus.h"
 
 /* Copied from the kernel arch/powerpc/platforms/pseries/msi.c */
 #define RTAS_QUERY_FN           0
diff --git a/hw/spapr_pci.h b/hw/spapr_pci.h
index e307ac8035..7b26ba1561 100644
--- a/hw/spapr_pci.h
+++ b/hw/spapr_pci.h
@@ -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
diff --git a/hw/sun4u.c b/hw/sun4u.c
index b2b51e30c2..47bcf9382d 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -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"
diff --git a/hw/unin_pci.c b/hw/unin_pci.c
index 9981d949d2..46757924b6 100644
--- a/hw/unin_pci.c
+++ b/hw/unin_pci.c
@@ -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
diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index 41dbb539f2..8b043966f6 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -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 {
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index e16a2ecab4..4faf8e1aed 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -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"
 
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index d053791de0..04c944613c 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -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"
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index efb509e423..220c3b536a 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -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
diff --git a/hw/versatile_pci.c b/hw/versatile_pci.c
index e0c3ee36a5..7a543b47d0 100644
--- a/hw/versatile_pci.c
+++ b/hw/versatile_pci.c
@@ -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 {
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 4892c1d27a..f5a742b37f 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -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"
diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c
index fbfe670078..264e58a68b 100644
--- a/hw/vfio_pci.c
+++ b/hw/vfio_pci.c
@@ -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"
diff --git a/hw/vga-pci.c b/hw/vga-pci.c
index 947e35c76f..0cb318eab6 100644
--- a/hw/vga-pci.c
+++ b/hw/vga-pci.c
@@ -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"
diff --git a/hw/vga.c b/hw/vga.c
index c2661610e3..ab40d73100 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -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"
diff --git a/hw/virtio-balloon.h b/hw/virtio-balloon.h
index 73300ddc86..b1828f4a48 100644
--- a/hw/virtio-balloon.h
+++ b/hw/virtio-balloon.h
@@ -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 */
 
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index 36aa463812..b13be7ccb5 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -16,7 +16,7 @@
 
 #include "virtio.h"
 #include "net.h"
-#include "pci.h"
+#include "pci/pci.h"
 
 #define ETH_ALEN    6
 
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 7684ac9a70..d0d6a5e816 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -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"
diff --git a/hw/virtio-scsi.h b/hw/virtio-scsi.h
index 91924f6dfc..7d7cba752d 100644
--- a/hw/virtio-scsi.h
+++ b/hw/virtio-scsi.h
@@ -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
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 834588daf6..333ec8cebe 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -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
diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index 57d16c0134..f963912112 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -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"
@@ -27,7 +27,7 @@
 #include "exec-memory.h"
 
 typedef uint32_t pci_addr_t;
-#include "pci_host.h"
+#include "pci/pci_host.h"
 //#define DEBUG_VT82C686B
 
 #ifdef DEBUG_VT82C686B
diff --git a/hw/wdt_i6300esb.c b/hw/wdt_i6300esb.c
index da15c73918..181774220d 100644
--- a/hw/wdt_i6300esb.c
+++ b/hw/wdt_i6300esb.c
@@ -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*/
 
diff --git a/hw/xen-host-pci-device.h b/hw/xen-host-pci-device.h
index 0079daca51..942b24dccc 100644
--- a/hw/xen-host-pci-device.h
+++ b/hw/xen-host-pci-device.h
@@ -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,
diff --git a/hw/xen_apic.c b/hw/xen_apic.c
index fc4536651a..a6632fe798 100644
--- a/hw/xen_apic.c
+++ b/hw/xen_apic.c
@@ -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,
diff --git a/hw/xen_platform.c b/hw/xen_platform.c
index a54e7a2cdb..10bb560073 100644
--- a/hw/xen_platform.c
+++ b/hw/xen_platform.c
@@ -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"
diff --git a/hw/xen_pt.c b/hw/xen_pt.c
index 7a3846e649..c782cdb283 100644
--- a/hw/xen_pt.c
+++ b/hw/xen_pt.c
@@ -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"
diff --git a/hw/xen_pt.h b/hw/xen_pt.h
index f15e69a290..e3497302cf 100644
--- a/hw/xen_pt.h
+++ b/hw/xen_pt.h
@@ -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);
diff --git a/hw/xio3130_downstream.c b/hw/xio3130_downstream.c
index 0d8a5e7020..2dcd46bff1 100644
--- a/hw/xio3130_downstream.c
+++ b/hw/xio3130_downstream.c
@@ -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 */
diff --git a/hw/xio3130_downstream.h b/hw/xio3130_downstream.h
index 010487f2d9..559dff6565 100644
--- a/hw/xio3130_downstream.h
+++ b/hw/xio3130_downstream.h
@@ -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,
diff --git a/hw/xio3130_upstream.c b/hw/xio3130_upstream.c
index d46b86c74d..713caf2dda 100644
--- a/hw/xio3130_upstream.c
+++ b/hw/xio3130_upstream.c
@@ -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 */
diff --git a/hw/xio3130_upstream.h b/hw/xio3130_upstream.h
index e9969975ff..fa09656b35 100644
--- a/hw/xio3130_upstream.h
+++ b/hw/xio3130_upstream.h
@@ -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,
diff --git a/kvm-all.c b/kvm-all.c
index 8e9a8d8fd2..759ef17ab0 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -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"
@@ -991,8 +991,6 @@ void kvm_irqchip_release_virq(KVMState *s, int virq)
         }
     }
     clear_gsi(s, virq);
-
-    kvm_irqchip_commit_routes(s);
 }
 
 static unsigned int kvm_hash_msi(uint32_t data)
diff --git a/kvm-stub.c b/kvm-stub.c
index a3455e2203..d65fd04507 100644
--- a/kvm-stub.c
+++ b/kvm-stub.c
@@ -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"
diff --git a/monitor.c b/monitor.c
index c0e32d60c3..a92ab44384 100644
--- a/monitor.c
+++ b/monitor.c
@@ -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"
diff --git a/net/tap-linux.c b/net/tap-linux.c
index c6521bec34..3eaedc40ad 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -39,6 +39,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
 {
     struct ifreq ifr;
     int fd, ret;
+    int len = sizeof(struct virtio_net_hdr);
 
     TFR(fd = open(PATH_NET_TUN, O_RDWR));
     if (fd < 0) {
@@ -65,6 +66,13 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
             close(fd);
             return -1;
         }
+        /*
+         * Make sure vnet header size has the default value: for a persistent
+         * tap it might have been modified e.g. by another instance of qemu.
+         * Ignore errors since old kernels do not support this ioctl: in this
+         * case the header size implicitly has the correct value.
+         */
+        ioctl(fd, TUNSETVNETHDRSZ, &len);
     }
 
     if (ifname[0] != '\0')
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index d9c48e0982..bf5342a08d 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -83,6 +83,8 @@ push(@signature_tags, "Signed-off-by:");
 push(@signature_tags, "Reviewed-by:");
 push(@signature_tags, "Acked-by:");
 
+my $signature_pattern = "\(" . join("|", @signature_tags) . "\)";
+
 # rfc822 email address - preloaded methods go here.
 my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])";
 my $rfc822_char = '[\\000-\\377]';
@@ -95,7 +97,7 @@ my %VCS_cmds_git = (
     "execute_cmd" => \&git_execute_cmd,
     "available" => '(which("git") ne "") && (-d ".git")',
     "find_signers_cmd" =>
-	"git log --no-color --since=\$email_git_since " .
+	"git log --no-color --follow --since=\$email_git_since " .
 	    '--format="GitCommit: %H%n' .
 		      'GitAuthor: %an <%ae>%n' .
 		      'GitDate: %aD%n' .
@@ -328,7 +330,8 @@ sub read_mailmap {
 	# name1 <mail1> <mail2>
 	# name1 <mail1> name2 <mail2>
 	# (see man git-shortlog)
-	if (/^(.+)<(.+)>$/) {
+
+	if (/^([^<]+)<([^>]+)>$/) {
 	    my $real_name = $1;
 	    my $address = $2;
 
@@ -336,13 +339,13 @@ sub read_mailmap {
 	    ($real_name, $address) = parse_email("$real_name <$address>");
 	    $mailmap->{names}->{$address} = $real_name;
 
-	} elsif (/^<([^\s]+)>\s*<([^\s]+)>$/) {
+	} elsif (/^<([^>]+)>\s*<([^>]+)>$/) {
 	    my $real_address = $1;
 	    my $wrong_address = $2;
 
 	    $mailmap->{addresses}->{$wrong_address} = $real_address;
 
-	} elsif (/^(.+)<([^\s]+)>\s*<([^\s]+)>$/) {
+	} elsif (/^(.+)<([^>]+)>\s*<([^>]+)>$/) {
 	    my $real_name = $1;
 	    my $real_address = $2;
 	    my $wrong_address = $3;
@@ -353,7 +356,7 @@ sub read_mailmap {
 	    $mailmap->{names}->{$wrong_address} = $real_name;
 	    $mailmap->{addresses}->{$wrong_address} = $real_address;
 
-	} elsif (/^(.+)<([^\s]+)>\s*([^\s].*)<([^\s]+)>$/) {
+	} elsif (/^(.+)<([^>]+)>\s*(.+)\s*<([^>]+)>$/) {
 	    my $real_name = $1;
 	    my $real_address = $2;
 	    my $wrong_name = $3;
@@ -472,7 +475,6 @@ my @subsystem = ();
 my @status = ();
 my %deduplicate_name_hash = ();
 my %deduplicate_address_hash = ();
-my $signature_pattern;
 
 my @maintainers = get_maintainers();
 
@@ -920,7 +922,7 @@ sub get_maintainer_role {
     my $start = find_starting_index($index);
     my $end = find_ending_index($index);
 
-    my $role;
+    my $role = "unknown";
     my $subsystem = $typevalue[$start];
     if (length($subsystem) > 20) {
 	$subsystem = substr($subsystem, 0, 17);
@@ -1016,8 +1018,13 @@ sub add_categories {
 		    if ($email_list) {
 			if (!$hash_list_to{lc($list_address)}) {
 			    $hash_list_to{lc($list_address)} = 1;
-			    push(@list_to, [$list_address,
-					    "open list${list_role}"]);
+			    if ($list_additional =~ m/moderated/) {
+				push(@list_to, [$list_address,
+						"moderated list${list_role}"]);
+			    } else {
+				push(@list_to, [$list_address,
+						"open list${list_role}"]);
+			    }
 			}
 		    }
 		}
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index f669281e13..0901589a88 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -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
 
diff --git a/xen-all.c b/xen-all.c
index 046cc2ac37..e3a51ccc81 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -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"