pci core reorg
Quoted 6 lines · Blue Swirl
Quoted 5 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.his renamed as it's used externally a lot.
Quoted 6 lines
Quoted 4 lines
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.
I haven't seen anything besides the nack, and a suggestion to fix coding style of existing files which should be done separately.
Quoted 239 lines
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: renamepci_internals.hpci_bus.h
pci_bus: update commentMAINTAINERS | 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
Re: [Qemu-devel] [PATCH 7/8] pci: rename pci_internals.h pci_bus.h
In reply to Blue SwirlQuoted 102 lines · Blue Swirl
Quoted 101 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.Signed-off-by Michael S. Tsirkin <[email protected]>--- 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.hhw/apb_pci.c +1
-1@@ -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@@ -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@@ -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@@ -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@@ -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@@ -30,7 +30,7 @@*/ #include "pci_bridge.h" -#include "pci_internals.h" +#include "pci_bus.h" #include "range.h"
Quoted 11 lines
hw/pci/pci_bus.h line 2
Quoted 9 lines
hw/pci/pci_bridge.c +0
-0/* PCI bridge subsystem vendor ID helper functions */ 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_Hor something similar.
Good catch, thanks! Will fix in a separate patch though - rename detection works better if file is moved without changes.
Quoted 242 lines
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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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_IDhw/spapr_pci.c +1
-2@@ -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