diff options
author | Isaku Yamahata <yamahata@valinux.co.jp> | 2009-10-30 21:21:18 +0900 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-11-09 08:43:09 -0600 |
commit | a9f49946113262f9449890ed918ab99ef73dace8 (patch) | |
tree | 7c474a0a9bf245a4ba5fde38e4c9a3c94051cb5d /hw/pci.h | |
parent | 9cae69bd8d94ccb1e550d8d17a2142a4d36d8c49 (diff) |
pci: pcie host and mmcfg support.
This patch adds common routines for pcie host bridge and pcie mmcfg.
This will be used by q35 based chipset emulation.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/pci.h')
-rw-r--r-- | hw/pci.h | 27 |
1 files changed, 23 insertions, 4 deletions
@@ -163,28 +163,31 @@ typedef struct PCIIORegion { #define PCI_CONFIG_HEADER_SIZE 0x40 /* Size of the standard PCI config space */ #define PCI_CONFIG_SPACE_SIZE 0x100 +/* Size of the standart PCIe config space: 4KB */ +#define PCIE_CONFIG_SPACE_SIZE 0x1000 #define PCI_NUM_PINS 4 /* A-D */ /* Bits in cap_present field. */ enum { QEMU_PCI_CAP_MSIX = 0x1, + QEMU_PCI_CAP_EXPRESS = 0x2, }; struct PCIDevice { DeviceState qdev; /* PCI config space */ - uint8_t config[PCI_CONFIG_SPACE_SIZE]; + uint8_t *config; /* Used to enable config checks on load. Note that writeable bits are * never checked even if set in cmask. */ - uint8_t cmask[PCI_CONFIG_SPACE_SIZE]; + uint8_t *cmask; /* Used to implement R/W bytes */ - uint8_t wmask[PCI_CONFIG_SPACE_SIZE]; + uint8_t *wmask; /* Used to allocate config space for capabilities. */ - uint8_t used[PCI_CONFIG_SPACE_SIZE]; + uint8_t *used; /* the following fields are read only */ PCIBus *bus; @@ -354,6 +357,12 @@ typedef struct { PCIUnregisterFunc *exit; PCIConfigReadFunc *config_read; PCIConfigWriteFunc *config_write; + + /* pcie stuff */ + int is_express; /* is this device pci express? + * initialization code needs to know this before + * each specific device initialization. + */ } PCIDeviceInfo; void pci_qdev_register(PCIDeviceInfo *info); @@ -362,6 +371,16 @@ void pci_qdev_register_many(PCIDeviceInfo *info); PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name); PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name); +static inline int pci_is_express(PCIDevice *d) +{ + return d->cap_present & QEMU_PCI_CAP_EXPRESS; +} + +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 |