root / hw / pcie.h @ e590ecbe
History | View | Annotate | Download (5.9 kB)
1 | 0428527c | Isaku Yamahata | /*
|
---|---|---|---|
2 | 0428527c | Isaku Yamahata | * pcie.h
|
3 | 0428527c | Isaku Yamahata | *
|
4 | 0428527c | Isaku Yamahata | * Copyright (c) 2010 Isaku Yamahata <yamahata at valinux co jp>
|
5 | 0428527c | Isaku Yamahata | * VA Linux Systems Japan K.K.
|
6 | 0428527c | Isaku Yamahata | *
|
7 | 0428527c | Isaku Yamahata | * This program is free software; you can redistribute it and/or modify
|
8 | 0428527c | Isaku Yamahata | * it under the terms of the GNU General Public License as published by
|
9 | 0428527c | Isaku Yamahata | * the Free Software Foundation; either version 2 of the License, or
|
10 | 0428527c | Isaku Yamahata | * (at your option) any later version.
|
11 | 0428527c | Isaku Yamahata | *
|
12 | 0428527c | Isaku Yamahata | * This program is distributed in the hope that it will be useful,
|
13 | 0428527c | Isaku Yamahata | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 | 0428527c | Isaku Yamahata | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 | 0428527c | Isaku Yamahata | * GNU General Public License for more details.
|
16 | 0428527c | Isaku Yamahata | *
|
17 | 0428527c | Isaku Yamahata | * You should have received a copy of the GNU General Public License along
|
18 | 0428527c | Isaku Yamahata | * with this program; if not, see <http://www.gnu.org/licenses/>.
|
19 | 0428527c | Isaku Yamahata | */
|
20 | 0428527c | Isaku Yamahata | |
21 | 0428527c | Isaku Yamahata | #ifndef QEMU_PCIE_H
|
22 | 0428527c | Isaku Yamahata | #define QEMU_PCIE_H
|
23 | 0428527c | Isaku Yamahata | |
24 | 0428527c | Isaku Yamahata | #include "hw.h" |
25 | 0428527c | Isaku Yamahata | #include "pci_regs.h" |
26 | 0428527c | Isaku Yamahata | #include "pcie_regs.h" |
27 | 34e65944 | Isaku Yamahata | #include "pcie_aer.h" |
28 | 0428527c | Isaku Yamahata | |
29 | 0428527c | Isaku Yamahata | typedef enum { |
30 | 0428527c | Isaku Yamahata | /* for attention and power indicator */
|
31 | 0428527c | Isaku Yamahata | PCI_EXP_HP_IND_RESERVED = PCI_EXP_SLTCTL_IND_RESERVED, |
32 | 0428527c | Isaku Yamahata | PCI_EXP_HP_IND_ON = PCI_EXP_SLTCTL_IND_ON, |
33 | 0428527c | Isaku Yamahata | PCI_EXP_HP_IND_BLINK = PCI_EXP_SLTCTL_IND_BLINK, |
34 | 0428527c | Isaku Yamahata | PCI_EXP_HP_IND_OFF = PCI_EXP_SLTCTL_IND_OFF, |
35 | 0428527c | Isaku Yamahata | } PCIExpressIndicator; |
36 | 0428527c | Isaku Yamahata | |
37 | 0428527c | Isaku Yamahata | typedef enum { |
38 | 0428527c | Isaku Yamahata | /* these bits must match the bits in Slot Control/Status registers.
|
39 | 0428527c | Isaku Yamahata | * PCI_EXP_HP_EV_xxx = PCI_EXP_SLTCTL_xxxE = PCI_EXP_SLTSTA_xxx
|
40 | 0428527c | Isaku Yamahata | *
|
41 | 0428527c | Isaku Yamahata | * Not all the bits of slot control register match with the ones of
|
42 | 0428527c | Isaku Yamahata | * slot status. Not some bits of slot status register is used to
|
43 | a1c7273b | Stefan Weil | * show status, not to report event occurrence.
|
44 | 0428527c | Isaku Yamahata | * So such bits must be masked out when checking the software
|
45 | 0428527c | Isaku Yamahata | * notification condition.
|
46 | 0428527c | Isaku Yamahata | */
|
47 | 0428527c | Isaku Yamahata | PCI_EXP_HP_EV_ABP = PCI_EXP_SLTCTL_ABPE, |
48 | 0428527c | Isaku Yamahata | /* attention button pressed */
|
49 | 0428527c | Isaku Yamahata | PCI_EXP_HP_EV_PDC = PCI_EXP_SLTCTL_PDCE, |
50 | 0428527c | Isaku Yamahata | /* presence detect changed */
|
51 | 0428527c | Isaku Yamahata | PCI_EXP_HP_EV_CCI = PCI_EXP_SLTCTL_CCIE, |
52 | 0428527c | Isaku Yamahata | /* command completed */
|
53 | 0428527c | Isaku Yamahata | |
54 | 0428527c | Isaku Yamahata | PCI_EXP_HP_EV_SUPPORTED = PCI_EXP_HP_EV_ABP | |
55 | 0428527c | Isaku Yamahata | PCI_EXP_HP_EV_PDC | |
56 | 0428527c | Isaku Yamahata | PCI_EXP_HP_EV_CCI, |
57 | 0428527c | Isaku Yamahata | /* supported event mask */
|
58 | 0428527c | Isaku Yamahata | |
59 | 0428527c | Isaku Yamahata | /* events not listed aren't supported */
|
60 | 0428527c | Isaku Yamahata | } PCIExpressHotPlugEvent; |
61 | 0428527c | Isaku Yamahata | |
62 | 0428527c | Isaku Yamahata | struct PCIExpressDevice {
|
63 | 0428527c | Isaku Yamahata | /* Offset of express capability in config space */
|
64 | 0428527c | Isaku Yamahata | uint8_t exp_cap; |
65 | 0428527c | Isaku Yamahata | |
66 | 0428527c | Isaku Yamahata | /* SLOT */
|
67 | 6da6d29f | Isaku Yamahata | unsigned int hpev_intx; /* INTx for hot plug event (0-3:INT[A-D]#) |
68 | 6da6d29f | Isaku Yamahata | * default is 0 = INTA#
|
69 | 6da6d29f | Isaku Yamahata | * If the chip wants to use other interrupt
|
70 | 6da6d29f | Isaku Yamahata | * line, initialize this member with the
|
71 | 6da6d29f | Isaku Yamahata | * desired number.
|
72 | 6da6d29f | Isaku Yamahata | * If the chip dynamically changes this member,
|
73 | 6da6d29f | Isaku Yamahata | * also initialize it when loaded as
|
74 | 6da6d29f | Isaku Yamahata | * appropreately.
|
75 | 6da6d29f | Isaku Yamahata | */
|
76 | 6bde6aaa | Michael S. Tsirkin | bool hpev_notified; /* Logical AND of conditions for hot plug event. |
77 | 6bde6aaa | Michael S. Tsirkin | Following 6.7.3.4:
|
78 | 6bde6aaa | Michael S. Tsirkin | Software Notification of Hot-Plug Events, an interrupt
|
79 | 6bde6aaa | Michael S. Tsirkin | is sent whenever the logical and of these conditions
|
80 | 6bde6aaa | Michael S. Tsirkin | transitions from false to true. */
|
81 | 34e65944 | Isaku Yamahata | |
82 | 34e65944 | Isaku Yamahata | /* AER */
|
83 | 34e65944 | Isaku Yamahata | uint16_t aer_cap; |
84 | 34e65944 | Isaku Yamahata | PCIEAERLog aer_log; |
85 | 34e65944 | Isaku Yamahata | unsigned int aer_intx; /* INTx for error reporting |
86 | 34e65944 | Isaku Yamahata | * default is 0 = INTA#
|
87 | 34e65944 | Isaku Yamahata | * If the chip wants to use other interrupt
|
88 | 34e65944 | Isaku Yamahata | * line, initialize this member with the
|
89 | 34e65944 | Isaku Yamahata | * desired number.
|
90 | 34e65944 | Isaku Yamahata | * If the chip dynamically changes this member,
|
91 | 34e65944 | Isaku Yamahata | * also initialize it when loaded as
|
92 | 34e65944 | Isaku Yamahata | * appropreately.
|
93 | 34e65944 | Isaku Yamahata | */
|
94 | 0428527c | Isaku Yamahata | }; |
95 | 0428527c | Isaku Yamahata | |
96 | 0428527c | Isaku Yamahata | /* PCI express capability helper functions */
|
97 | 0428527c | Isaku Yamahata | int pcie_cap_init(PCIDevice *dev, uint8_t offset, uint8_t type, uint8_t port);
|
98 | 0428527c | Isaku Yamahata | void pcie_cap_exit(PCIDevice *dev);
|
99 | 0428527c | Isaku Yamahata | uint8_t pcie_cap_get_type(const PCIDevice *dev);
|
100 | 0428527c | Isaku Yamahata | void pcie_cap_flags_set_vector(PCIDevice *dev, uint8_t vector);
|
101 | 0428527c | Isaku Yamahata | uint8_t pcie_cap_flags_get_vector(PCIDevice *dev); |
102 | 0428527c | Isaku Yamahata | |
103 | 0428527c | Isaku Yamahata | void pcie_cap_deverr_init(PCIDevice *dev);
|
104 | 0428527c | Isaku Yamahata | void pcie_cap_deverr_reset(PCIDevice *dev);
|
105 | 0428527c | Isaku Yamahata | |
106 | 0428527c | Isaku Yamahata | void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot);
|
107 | 0428527c | Isaku Yamahata | void pcie_cap_slot_reset(PCIDevice *dev);
|
108 | 0428527c | Isaku Yamahata | void pcie_cap_slot_write_config(PCIDevice *dev,
|
109 | 6bde6aaa | Michael S. Tsirkin | uint32_t addr, uint32_t val, int len);
|
110 | 6bde6aaa | Michael S. Tsirkin | int pcie_cap_slot_post_load(void *opaque, int version_id); |
111 | 0428527c | Isaku Yamahata | void pcie_cap_slot_push_attention_button(PCIDevice *dev);
|
112 | 0428527c | Isaku Yamahata | |
113 | 0428527c | Isaku Yamahata | void pcie_cap_root_init(PCIDevice *dev);
|
114 | 0428527c | Isaku Yamahata | void pcie_cap_root_reset(PCIDevice *dev);
|
115 | 0428527c | Isaku Yamahata | |
116 | 0428527c | Isaku Yamahata | void pcie_cap_flr_init(PCIDevice *dev);
|
117 | 0428527c | Isaku Yamahata | void pcie_cap_flr_write_config(PCIDevice *dev,
|
118 | 0428527c | Isaku Yamahata | uint32_t addr, uint32_t val, int len);
|
119 | 0428527c | Isaku Yamahata | |
120 | 0428527c | Isaku Yamahata | void pcie_cap_ari_init(PCIDevice *dev);
|
121 | 0428527c | Isaku Yamahata | void pcie_cap_ari_reset(PCIDevice *dev);
|
122 | 0428527c | Isaku Yamahata | bool pcie_cap_is_ari_enabled(const PCIDevice *dev); |
123 | 0428527c | Isaku Yamahata | |
124 | 0428527c | Isaku Yamahata | /* PCI express extended capability helper functions */
|
125 | 0428527c | Isaku Yamahata | uint16_t pcie_find_capability(PCIDevice *dev, uint16_t cap_id); |
126 | 0428527c | Isaku Yamahata | void pcie_add_capability(PCIDevice *dev,
|
127 | 0428527c | Isaku Yamahata | uint16_t cap_id, uint8_t cap_ver, |
128 | 0428527c | Isaku Yamahata | uint16_t offset, uint16_t size); |
129 | 0428527c | Isaku Yamahata | |
130 | 0428527c | Isaku Yamahata | void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);
|
131 | 0428527c | Isaku Yamahata | |
132 | 701a8f76 | Paolo Bonzini | extern const VMStateDescription vmstate_pcie_device; |
133 | 701a8f76 | Paolo Bonzini | |
134 | 701a8f76 | Paolo Bonzini | #define VMSTATE_PCIE_DEVICE(_field, _state) { \
|
135 | 701a8f76 | Paolo Bonzini | .name = (stringify(_field)), \ |
136 | 701a8f76 | Paolo Bonzini | .version_id = 2, \
|
137 | 701a8f76 | Paolo Bonzini | .size = sizeof(PCIDevice), \
|
138 | 701a8f76 | Paolo Bonzini | .vmsd = &vmstate_pcie_device, \ |
139 | 701a8f76 | Paolo Bonzini | .flags = VMS_STRUCT, \ |
140 | 701a8f76 | Paolo Bonzini | .offset = vmstate_offset_value(_state, _field, PCIDevice), \ |
141 | 701a8f76 | Paolo Bonzini | } |
142 | 701a8f76 | Paolo Bonzini | |
143 | 0428527c | Isaku Yamahata | #endif /* QEMU_PCIE_H */ |