From 18e08a55292a57b988df7fa14af2b4dd282a6486 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 11 Nov 2009 14:59:56 +0200 Subject: pci: pci.h cleanup: move out stuff not in pci.c pci.h declares some functions which aren't defined in pci.h. Clean up moving things to appropriate headers, and update all users. Signed-off-by: Michael S. Tsirkin --- hw/pci.h | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'hw/pci.h') diff --git a/hw/pci.h b/hw/pci.h index 9a56d0df6e..560da5074e 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -413,31 +413,6 @@ static inline uint32_t pci_config_size(PCIDevice *d) return pci_is_express(d) ? PCIE_CONFIG_SPACE_SIZE : PCI_CONFIG_SPACE_SIZE; } -/* lsi53c895a.c */ -#define LSI_MAX_DEVS 7 - -/* vmware_vga.c */ -void pci_vmsvga_init(PCIBus *bus); - -/* usb-uhci.c */ -void usb_uhci_piix3_init(PCIBus *bus, int devfn); -void usb_uhci_piix4_init(PCIBus *bus, int devfn); - -/* usb-ohci.c */ -void usb_ohci_init_pci(struct PCIBus *bus, int devfn); - -/* prep_pci.c */ -PCIBus *pci_prep_init(qemu_irq *pic); - -/* apb_pci.c */ -PCIBus *pci_apb_init(target_phys_addr_t special_base, - target_phys_addr_t mem_base, - qemu_irq *pic, PCIBus **bus2, PCIBus **bus3); - -/* sh_pci.c */ -PCIBus *sh_pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, - void *pic, int devfn_min, int nirq); - /* These are not pci specific. Should move into a separate header. * Only pci.c uses them, so keep them here for now. */ -- cgit 1.4.1 From b6243d991a4d073b2c8c16737fec9ee74274bfeb Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Thu, 12 Nov 2009 14:58:30 +0900 Subject: pci: move pci_data_{read, write}() declaration from pci.h to pci_host.h Now pci host stuff has been moved from pci.[hc] to pci_host.[hc] so the declaration of pci_data_{read, write}() should be in pci_host.h This patch moves them from pci.h to pci_host.h for consistency. Signed-off-by: Isaku Yamahata Signed-off-by: Michael S. Tsirkin --- hw/pci.h | 2 -- hw/pci_host.h | 3 +++ hw/sh_pci.c | 1 + hw/versatile_pci.c | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) (limited to 'hw/pci.h') diff --git a/hw/pci.h b/hw/pci.h index 560da5074e..2f213524c5 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -293,8 +293,6 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, const char *default_devaddr); PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model, const char *default_devaddr); -void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len); -uint32_t pci_data_read(PCIBus *s, uint32_t addr, int len); int pci_bus_num(PCIBus *s); void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus, PCIDevice *d)); PCIBus *pci_find_host_bus(int domain); diff --git a/hw/pci_host.h b/hw/pci_host.h index e5e877f4cd..7cfa693563 100644 --- a/hw/pci_host.h +++ b/hw/pci_host.h @@ -36,6 +36,9 @@ typedef struct { PCIBus *bus; } PCIHostState; +void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len); +uint32_t pci_data_read(PCIBus *s, uint32_t addr, int len); + /* for mmio */ int pci_host_config_register_io_memory(PCIHostState *s); int pci_host_config_register_io_memory_noswap(PCIHostState *s); diff --git a/hw/sh_pci.c b/hw/sh_pci.c index 52dc02e1e7..abe4c7568b 100644 --- a/hw/sh_pci.c +++ b/hw/sh_pci.c @@ -24,6 +24,7 @@ #include "hw.h" #include "sh.h" #include "pci.h" +#include "pci_host.h" #include "sh_pci.h" #include "bswap.h" diff --git a/hw/versatile_pci.c b/hw/versatile_pci.c index a0d7d07ad2..153c6514f7 100644 --- a/hw/versatile_pci.c +++ b/hw/versatile_pci.c @@ -9,6 +9,7 @@ #include "sysbus.h" #include "pci.h" +#include "pci_host.h" typedef struct { SysBusDevice busdev; -- cgit 1.4.1 From c469e1dd6375c50bc61d995dde4714fc19f411ed Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Thu, 12 Nov 2009 14:58:36 +0900 Subject: pci: s/pci_find_host_bus/pci_find_root_bus/g This patch renames pci_find_host_bus() to pci_find_root_bus() as suggested by "Michael S. Tsirkin" . Signed-off-by: Isaku Yamahata Signed-off-by: Michael S. Tsirkin --- hw/pci-hotplug.c | 4 ++-- hw/pci.c | 8 ++++---- hw/pci.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'hw/pci.h') diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index a254498143..081d6d1ac9 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -113,7 +113,7 @@ void drive_hot_add(Monitor *mon, const QDict *qdict) if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) { goto err; } - dev = pci_find_device(pci_find_host_bus(0), pci_bus, slot, 0); + dev = pci_find_device(pci_find_root_bus(0), pci_bus, slot, 0); if (!dev) { monitor_printf(mon, "no pci device with address %s\n", pci_addr); goto err; @@ -257,7 +257,7 @@ void pci_device_hot_remove(Monitor *mon, const char *pci_addr) return; } - d = pci_find_device(pci_find_host_bus(0), bus, slot, 0); + d = pci_find_device(pci_find_root_bus(0), bus, slot, 0); if (!d) { monitor_printf(mon, "slot %d empty\n", slot); return; diff --git a/hw/pci.c b/hw/pci.c index aa677b2dbe..d8f5fa0ede 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -146,7 +146,7 @@ static void pci_host_bus_register(int domain, PCIBus *bus) QLIST_INSERT_HEAD(&host_buses, host, next); } -PCIBus *pci_find_host_bus(int domain) +PCIBus *pci_find_root_bus(int domain) { struct PCIHostBus *host; @@ -372,7 +372,7 @@ static int pci_parse_devaddr(const char *addr, int *domp, int *busp, unsigned *s return -1; /* Note: QEMU doesn't implement domains other than 0 */ - if (!pci_find_bus(pci_find_host_bus(dom), bus)) + if (!pci_find_bus(pci_find_root_bus(dom), bus)) return -1; *domp = dom; @@ -402,7 +402,7 @@ PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr) if (!devaddr) { *devfnp = -1; - return pci_find_bus(pci_find_host_bus(0), 0); + return pci_find_bus(pci_find_root_bus(0), 0); } if (pci_parse_devaddr(devaddr, &dom, &bus, &slot) < 0) { @@ -410,7 +410,7 @@ PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr) } *devfnp = slot << 3; - return pci_find_bus(pci_find_host_bus(0), bus); + return pci_find_bus(pci_find_root_bus(0), bus); } static void pci_init_cmask(PCIDevice *dev) diff --git a/hw/pci.h b/hw/pci.h index 2f213524c5..ff5f36ceeb 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -295,7 +295,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model, const char *default_devaddr); int pci_bus_num(PCIBus *s); void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus, PCIDevice *d)); -PCIBus *pci_find_host_bus(int domain); +PCIBus *pci_find_root_bus(int domain); PCIBus *pci_find_bus(PCIBus *bus, int bus_num); PCIDevice *pci_find_device(PCIBus *bus, int bus_num, int slot, int function); PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr); -- cgit 1.4.1 From 3c217c14f58c0146a0dbca01716cd850a63a0e81 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Thu, 12 Nov 2009 14:58:40 +0900 Subject: pci: remove some unnecessary comment in pci.h This patch removes some comment which should go into commit log in pci.h. Signed-off-by: Isaku Yamahata Signed-off-by: Michael S. Tsirkin --- hw/pci.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'hw/pci.h') diff --git a/hw/pci.h b/hw/pci.h index ff5f36ceeb..b2c2c92f2d 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -382,17 +382,10 @@ typedef struct { PCIConfigWriteFunc *config_write; /* pci config header type */ - uint8_t header_type; /* this is necessary for initialization - * code to know its header type before - * device specific code can initialize - * configuration space. - */ + uint8_t header_type; /* pcie stuff */ - int is_express; /* is this device pci express? - * initialization code needs to know this before - * each specific device initialization. - */ + int is_express; /* is this device pci express? */ } PCIDeviceInfo; void pci_qdev_register(PCIDeviceInfo *info); -- cgit 1.4.1 From 2c56b44b88d913c4f7acb444071052b55b37da34 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Thu, 12 Nov 2009 14:58:42 +0900 Subject: pci: remove unused constants This patch removes unused constants committed by fb23162885f7fd8cf7334bed22c25ac32c7d8b9d. Signed-off-by: Isaku Yamahata Signed-off-by: Michael S. Tsirkin --- hw/pci.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'hw/pci.h') diff --git a/hw/pci.h b/hw/pci.h index b2c2c92f2d..6a868f95de 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -101,14 +101,6 @@ typedef struct PCIIORegion { #define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ #define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ #define PCI_COMMAND_MASTER 0x4 /* Enable bus master */ -#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */ -#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ -#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ -#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ -#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ -#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ -#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ -#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ #define PCI_STATUS 0x06 /* 16 bits */ #define PCI_REVISION_ID 0x08 /* 8 bits */ #define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ @@ -128,7 +120,6 @@ typedef struct PCIIORegion { #define PCI_PRIMARY_BUS 0x18 /* Primary bus number */ #define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */ #define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */ -#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */ #define PCI_IO_BASE 0x1c /* I/O range behind the bridge */ #define PCI_IO_LIMIT 0x1d #define PCI_IO_RANGE_TYPE_32 0x01 -- cgit 1.4.1 From d46636b88339ecc2cb8d10113f45ada164817773 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Thu, 12 Nov 2009 14:58:47 +0900 Subject: pci: pci bridge related clean up. - fix bridge prefetchable memory accesser to check 64bit or not. - use pcibus_t consistently instead mixing pcibus_t and uint64_t. Signed-off-by: Isaku Yamahata Signed-off-by: Michael S. Tsirkin --- hw/pci.c | 18 +++++++++++------- hw/pci.h | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'hw/pci.h') diff --git a/hw/pci.c b/hw/pci.c index bc566e5945..e26b3d0341 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -635,19 +635,23 @@ static uint32_t pci_config_get_io_base(PCIDevice *d, return val; } -static uint64_t pci_config_get_memory_base(PCIDevice *d, uint32_t base) +static pcibus_t pci_config_get_memory_base(PCIDevice *d, uint32_t base) { - return ((uint64_t)pci_get_word(d->config + base) & PCI_MEMORY_RANGE_MASK) + return ((pcibus_t)pci_get_word(d->config + base) & PCI_MEMORY_RANGE_MASK) << 16; } -static uint64_t pci_config_get_pref_base(PCIDevice *d, +static pcibus_t pci_config_get_pref_base(PCIDevice *d, uint32_t base, uint32_t upper) { - uint64_t val; - val = ((uint64_t)pci_get_word(d->config + base) & - PCI_PREF_RANGE_MASK) << 16; - val |= (uint64_t)pci_get_long(d->config + upper) << 32; + pcibus_t tmp; + pcibus_t val; + + tmp = (pcibus_t)pci_get_word(d->config + base); + val = (tmp & PCI_PREF_RANGE_MASK) << 16; + if (tmp & PCI_PREF_RANGE_TYPE_64) { + val |= (pcibus_t)pci_get_long(d->config + upper) << 32; + } return val; } diff --git a/hw/pci.h b/hw/pci.h index 6a868f95de..0baf69bd5d 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -131,6 +131,7 @@ typedef struct PCIIORegion { #define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */ #define PCI_PREF_MEMORY_LIMIT 0x26 #define PCI_PREF_RANGE_MASK (~0x0fUL) +#define PCI_PREF_RANGE_TYPE_64 0x01 #define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */ #define PCI_PREF_LIMIT_UPPER32 0x2c #define PCI_SUBSYSTEM_VENDOR_ID 0x2c /* 16 bits */ -- cgit 1.4.1