2 * QEMU PowerPC PowerNV (POWER8) PHB3 model
4 * Copyright (c) 2014-2020, IBM Corporation.
6 * This code is licensed under the GPL version 2 or later. See the
7 * COPYING file in the top-level directory.
10 #ifndef PCI_HOST_PNV_PHB3_H
11 #define PCI_HOST_PNV_PHB3_H
13 #include "hw/pci/pcie_host.h"
14 #include "hw/pci/pcie_port.h"
15 #include "hw/ppc/xics.h"
16 #include "qom/object.h"
18 typedef struct PnvPHB3 PnvPHB3
;
21 * PHB3 XICS Source for MSIs
23 #define TYPE_PHB3_MSI "phb3-msi"
24 typedef struct Phb3MsiState Phb3MsiState
;
25 DECLARE_INSTANCE_CHECKER(Phb3MsiState
, PHB3_MSI
,
28 #define PHB3_MAX_MSI 2048
35 uint64_t rba
[PHB3_MAX_MSI
/ 64];
39 void pnv_phb3_msi_update_config(Phb3MsiState
*msis
, uint32_t base
,
41 void pnv_phb3_msi_send(Phb3MsiState
*msis
, uint64_t addr
, uint16_t data
,
43 void pnv_phb3_msi_ffi(Phb3MsiState
*msis
, uint64_t val
);
44 void pnv_phb3_msi_pic_print_info(Phb3MsiState
*msis
, Monitor
*mon
);
48 * We have one such address space wrapper per possible device under
49 * the PHB since they need to be assigned statically at qemu device
50 * creation time. The relationship to a PE is done later dynamically.
51 * This means we can potentially create a lot of these guys. Q35
52 * stores them as some kind of radix tree but we never really need to
53 * do fast lookups so instead we simply keep a QLIST of them for now,
54 * we can add the radix if needed later on.
56 * We do cache the PE number to speed things up a bit though.
58 typedef struct PnvPhb3DMASpace
{
61 int pe_num
; /* Cached PE number */
62 #define PHB_INVALID_PE (-1)
65 IOMMUMemoryRegion dma_mr
;
66 MemoryRegion msi32_mr
;
67 MemoryRegion msi64_mr
;
68 QLIST_ENTRY(PnvPhb3DMASpace
) list
;
72 * PHB3 Power Bus Common Queue
74 #define TYPE_PNV_PBCQ "pnv-pbcq"
75 OBJECT_DECLARE_SIMPLE_TYPE(PnvPBCQState
, PNV_PBCQ
)
83 #define PBCQ_NEST_REGS_COUNT 0x46
84 #define PBCQ_PCI_REGS_COUNT 0x15
85 #define PBCQ_SPCI_REGS_COUNT 0x5
87 uint64_t nest_regs
[PBCQ_NEST_REGS_COUNT
];
88 uint64_t spci_regs
[PBCQ_SPCI_REGS_COUNT
];
89 uint64_t pci_regs
[PBCQ_PCI_REGS_COUNT
];
99 MemoryRegion xscom_nest_regs
;
100 MemoryRegion xscom_pci_regs
;
101 MemoryRegion xscom_spci_regs
;
105 * PHB3 PCIe Root port
107 #define TYPE_PNV_PHB3_ROOT_BUS "pnv-phb3-root-bus"
109 #define TYPE_PNV_PHB3_ROOT_PORT "pnv-phb3-root-port"
111 typedef struct PnvPHB3RootPort
{
116 * PHB3 PCIe Host Bridge for PowerNV machines (POWER8)
118 #define TYPE_PNV_PHB3 "pnv-phb3"
119 OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB3
, PNV_PHB3
)
121 #define PNV_PHB3_NUM_M64 16
122 #define PNV_PHB3_NUM_REGS (0x1000 >> 3)
123 #define PNV_PHB3_NUM_LSI 8
124 #define PNV_PHB3_NUM_PE 256
126 #define PCI_MMIO_TOTAL_SIZE (0x1ull << 60)
129 PCIExpressHost parent_obj
;
135 uint64_t regs
[PNV_PHB3_NUM_REGS
];
136 MemoryRegion mr_regs
;
139 MemoryRegion mr_m64
[PNV_PHB3_NUM_M64
];
140 MemoryRegion pci_mmio
;
143 uint64_t ioda_LIST
[8];
144 uint64_t ioda_LXIVT
[8];
145 uint64_t ioda_TVT
[512];
146 uint64_t ioda_M64BT
[16];
147 uint64_t ioda_MDT
[256];
148 uint64_t ioda_PEEV
[4];
157 PnvPHB3RootPort root
;
159 QLIST_HEAD(, PnvPhb3DMASpace
) dma_spaces
;
162 uint64_t pnv_phb3_reg_read(void *opaque
, hwaddr off
, unsigned size
);
163 void pnv_phb3_reg_write(void *opaque
, hwaddr off
, uint64_t val
, unsigned size
);
164 void pnv_phb3_update_regions(PnvPHB3
*phb
);
165 void pnv_phb3_remap_irqs(PnvPHB3
*phb
);
167 #endif /* PCI_HOST_PNV_PHB3_H */