pci_bus.h 1.7 KB
Newer Older
1 2
#ifndef QEMU_PCI_BUS_H
#define QEMU_PCI_BUS_H
3

4 5
#include "hw/pci/pci.h"

6
/*
7
 * PCI Bus datastructures.
8
 *
M
Michael S. Tsirkin 已提交
9
 * Do not access the following members directly;
10
 * use accessor functions in pci.h
11 12
 */

13 14 15 16 17
typedef struct PCIBusClass {
    /*< private >*/
    BusClass parent_class;
    /*< public >*/

18
    int (*bus_num)(PCIBus *bus);
19
    uint16_t (*numa_node)(PCIBus *bus);
20 21
} PCIBusClass;

D
David Gibson 已提交
22 23 24
enum PCIBusFlags {
    /* This bus is the root of a PCI domain */
    PCI_BUS_IS_ROOT                                         = 0x0001,
25 26
    /* PCIe extended configuration space is accessible on this bus */
    PCI_BUS_EXTENDED_CONFIG_SPACE                           = 0x0002,
D
David Gibson 已提交
27 28
};

29 30
struct PCIBus {
    BusState qbus;
D
David Gibson 已提交
31
    enum PCIBusFlags flags;
32 33
    PCIIOMMUFunc iommu_fn;
    void *iommu_opaque;
I
Isaku Yamahata 已提交
34
    uint8_t devfn_min;
35
    uint32_t slot_reserved_mask;
36 37
    pci_set_irq_fn set_irq;
    pci_map_irq_fn map_irq;
38
    pci_route_irq_fn route_intx_to_irq;
39
    void *irq_opaque;
40
    PCIDevice *devices[PCI_SLOT_MAX * PCI_FUNC_MAX];
41
    PCIDevice *parent_dev;
42 43
    MemoryRegion *address_space_mem;
    MemoryRegion *address_space_io;
44 45 46 47 48 49 50 51

    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;
52 53

    Notifier machine_done;
54 55
};

D
David Gibson 已提交
56 57 58 59 60
static inline bool pci_bus_is_root(PCIBus *bus)
{
    return !!(bus->flags & PCI_BUS_IS_ROOT);
}

61 62 63 64 65
static inline bool pci_bus_allows_extended_config_space(PCIBus *bus)
{
    return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
}

66
#endif /* QEMU_PCI_BUS_H */