1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef QEMU_PCIE_H
22#define QEMU_PCIE_H
23
24#include "hw.h"
25#include "pci_regs.h"
26#include "pcie_regs.h"
27#include "pcie_aer.h"
28
29typedef enum {
30
31 PCI_EXP_HP_IND_RESERVED = PCI_EXP_SLTCTL_IND_RESERVED,
32 PCI_EXP_HP_IND_ON = PCI_EXP_SLTCTL_IND_ON,
33 PCI_EXP_HP_IND_BLINK = PCI_EXP_SLTCTL_IND_BLINK,
34 PCI_EXP_HP_IND_OFF = PCI_EXP_SLTCTL_IND_OFF,
35} PCIExpressIndicator;
36
37typedef enum {
38
39
40
41
42
43
44
45
46
47 PCI_EXP_HP_EV_ABP = PCI_EXP_SLTCTL_ABPE,
48
49 PCI_EXP_HP_EV_PDC = PCI_EXP_SLTCTL_PDCE,
50
51 PCI_EXP_HP_EV_CCI = PCI_EXP_SLTCTL_CCIE,
52
53
54 PCI_EXP_HP_EV_SUPPORTED = PCI_EXP_HP_EV_ABP |
55 PCI_EXP_HP_EV_PDC |
56 PCI_EXP_HP_EV_CCI,
57
58
59
60} PCIExpressHotPlugEvent;
61
62struct PCIExpressDevice {
63
64 uint8_t exp_cap;
65
66
67 unsigned int hpev_intx;
68
69
70
71
72
73
74
75
76 bool hpev_notified;
77
78
79
80
81
82
83 uint16_t aer_cap;
84 PCIEAERLog aer_log;
85 unsigned int aer_intx;
86
87
88
89
90
91
92
93
94};
95
96
97int pcie_cap_init(PCIDevice *dev, uint8_t offset, uint8_t type, uint8_t port);
98void pcie_cap_exit(PCIDevice *dev);
99uint8_t pcie_cap_get_type(const PCIDevice *dev);
100void pcie_cap_flags_set_vector(PCIDevice *dev, uint8_t vector);
101uint8_t pcie_cap_flags_get_vector(PCIDevice *dev);
102
103void pcie_cap_deverr_init(PCIDevice *dev);
104void pcie_cap_deverr_reset(PCIDevice *dev);
105
106void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot);
107void pcie_cap_slot_reset(PCIDevice *dev);
108void pcie_cap_slot_write_config(PCIDevice *dev,
109 uint32_t addr, uint32_t val, int len);
110int pcie_cap_slot_post_load(void *opaque, int version_id);
111void pcie_cap_slot_push_attention_button(PCIDevice *dev);
112
113void pcie_cap_root_init(PCIDevice *dev);
114void pcie_cap_root_reset(PCIDevice *dev);
115
116void pcie_cap_flr_init(PCIDevice *dev);
117void pcie_cap_flr_write_config(PCIDevice *dev,
118 uint32_t addr, uint32_t val, int len);
119
120void pcie_cap_ari_init(PCIDevice *dev);
121void pcie_cap_ari_reset(PCIDevice *dev);
122bool pcie_cap_is_ari_enabled(const PCIDevice *dev);
123
124
125uint16_t pcie_find_capability(PCIDevice *dev, uint16_t cap_id);
126void pcie_add_capability(PCIDevice *dev,
127 uint16_t cap_id, uint8_t cap_ver,
128 uint16_t offset, uint16_t size);
129
130void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);
131
132#endif
133