]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | \r | |
3 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r | |
4 | \r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef _PCI_ROOT_BRIDGE_H_\r | |
16 | #define _PCI_ROOT_BRIDGE_H_\r | |
17 | \r | |
18 | #include <PiDxe.h>\r | |
19 | \r | |
20 | #include <TPS65950.h>\r | |
21 | \r | |
22 | #include <Library/BaseLib.h>\r | |
23 | #include <Library/BaseMemoryLib.h>\r | |
24 | #include <Library/DebugLib.h>\r | |
25 | #include <Library/DxeServicesTableLib.h>\r | |
26 | #include <Library/IoLib.h>\r | |
27 | #include <Library/MemoryAllocationLib.h>\r | |
28 | #include <Library/PciLib.h>\r | |
29 | #include <Library/UefiLib.h>\r | |
30 | #include <Library/UefiBootServicesTableLib.h>\r | |
31 | #include <Library/OmapDmaLib.h>\r | |
32 | #include <Library/DmaLib.h>\r | |
33 | \r | |
34 | #include <Protocol/EmbeddedExternalDevice.h>\r | |
35 | #include <Protocol/DevicePath.h>\r | |
36 | #include <Protocol/PciIo.h>\r | |
37 | #include <Protocol/PciRootBridgeIo.h>\r | |
38 | #include <Protocol/PciHostBridgeResourceAllocation.h>\r | |
39 | \r | |
40 | #include <IndustryStandard/Pci22.h>\r | |
41 | #include <IndustryStandard/Acpi.h>\r | |
42 | \r | |
43 | #include <Omap3530/Omap3530.h>\r | |
44 | \r | |
45 | \r | |
46 | \r | |
47 | #define EFI_RESOURCE_NONEXISTENT 0xFFFFFFFFFFFFFFFFULL\r | |
48 | #define EFI_RESOURCE_LESS 0xFFFFFFFFFFFFFFFEULL\r | |
49 | #define EFI_RESOURCE_SATISFIED 0x0000000000000000ULL\r | |
50 | \r | |
51 | \r | |
52 | typedef struct {\r | |
53 | ACPI_HID_DEVICE_PATH AcpiDevicePath;\r | |
54 | EFI_DEVICE_PATH_PROTOCOL EndDevicePath;\r | |
55 | } EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;\r | |
56 | \r | |
57 | \r | |
58 | #define ACPI_CONFIG_IO 0\r | |
59 | #define ACPI_CONFIG_MMIO 1\r | |
60 | #define ACPI_CONFIG_BUS 2\r | |
61 | \r | |
62 | typedef struct {\r | |
63 | EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR Desc[3];\r | |
64 | EFI_ACPI_END_TAG_DESCRIPTOR EndDesc;\r | |
65 | } ACPI_CONFIG_INFO;\r | |
66 | \r | |
67 | \r | |
68 | #define PCI_ROOT_BRIDGE_SIGNATURE SIGNATURE_32 ('P', 'c', 'i', 'F')\r | |
69 | \r | |
70 | typedef struct {\r | |
71 | UINT32 Signature;\r | |
72 | EFI_HANDLE Handle;\r | |
73 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL Io;\r | |
74 | EFI_PCI_ROOT_BRIDGE_DEVICE_PATH DevicePath;\r | |
75 | \r | |
76 | UINT8 StartBus;\r | |
77 | UINT8 EndBus;\r | |
78 | UINT16 Type;\r | |
79 | UINT32 MemoryStart;\r | |
80 | UINT32 MemorySize;\r | |
81 | UINTN IoOffset;\r | |
82 | UINT32 IoStart;\r | |
83 | UINT32 IoSize;\r | |
84 | UINT64 PciAttributes;\r | |
85 | \r | |
86 | ACPI_CONFIG_INFO *Config;\r | |
87 | \r | |
88 | } PCI_ROOT_BRIDGE;\r | |
89 | \r | |
90 | \r | |
91 | #define INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(a) CR (a, PCI_ROOT_BRIDGE, Io, PCI_ROOT_BRIDGE_SIGNATURE)\r | |
92 | \r | |
93 | \r | |
94 | typedef union {\r | |
95 | UINT8 volatile *buf;\r | |
96 | UINT8 volatile *ui8;\r | |
97 | UINT16 volatile *ui16;\r | |
98 | UINT32 volatile *ui32;\r | |
99 | UINT64 volatile *ui64;\r | |
100 | UINTN volatile ui;\r | |
101 | } PTR;\r | |
102 | \r | |
103 | \r | |
104 | \r | |
105 | EFI_STATUS\r | |
106 | EFIAPI\r | |
107 | PciRootBridgeIoPollMem (\r | |
108 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
109 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r | |
110 | IN UINT64 Address,\r | |
111 | IN UINT64 Mask,\r | |
112 | IN UINT64 Value,\r | |
113 | IN UINT64 Delay,\r | |
114 | OUT UINT64 *Result\r | |
115 | );\r | |
116 | \r | |
117 | EFI_STATUS\r | |
118 | EFIAPI\r | |
119 | PciRootBridgeIoPollIo (\r | |
120 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
121 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r | |
122 | IN UINT64 Address,\r | |
123 | IN UINT64 Mask,\r | |
124 | IN UINT64 Value,\r | |
125 | IN UINT64 Delay,\r | |
126 | OUT UINT64 *Result\r | |
127 | );\r | |
128 | \r | |
129 | EFI_STATUS\r | |
130 | EFIAPI\r | |
131 | PciRootBridgeIoMemRead (\r | |
132 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
133 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r | |
134 | IN UINT64 Address,\r | |
135 | IN UINTN Count,\r | |
136 | IN OUT VOID *Buffer\r | |
137 | );\r | |
138 | \r | |
139 | EFI_STATUS\r | |
140 | EFIAPI\r | |
141 | PciRootBridgeIoMemWrite (\r | |
142 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
143 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r | |
144 | IN UINT64 Address,\r | |
145 | IN UINTN Count,\r | |
146 | IN OUT VOID *Buffer\r | |
147 | );\r | |
148 | \r | |
149 | EFI_STATUS\r | |
150 | EFIAPI\r | |
151 | PciRootBridgeIoIoRead (\r | |
152 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
153 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r | |
154 | IN UINT64 UserAddress,\r | |
155 | IN UINTN Count,\r | |
156 | IN OUT VOID *UserBuffer\r | |
157 | );\r | |
158 | \r | |
159 | EFI_STATUS\r | |
160 | EFIAPI\r | |
161 | PciRootBridgeIoIoWrite (\r | |
162 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
163 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r | |
164 | IN UINT64 UserAddress,\r | |
165 | IN UINTN Count,\r | |
166 | IN OUT VOID *UserBuffer\r | |
167 | );\r | |
168 | \r | |
169 | EFI_STATUS\r | |
170 | EFIAPI\r | |
171 | PciRootBridgeIoCopyMem (\r | |
172 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
173 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r | |
174 | IN UINT64 DestAddress,\r | |
175 | IN UINT64 SrcAddress,\r | |
176 | IN UINTN Count\r | |
177 | );\r | |
178 | \r | |
179 | EFI_STATUS\r | |
180 | EFIAPI\r | |
181 | PciRootBridgeIoPciRead (\r | |
182 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
183 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r | |
184 | IN UINT64 Address,\r | |
185 | IN UINTN Count,\r | |
186 | IN OUT VOID *Buffer\r | |
187 | );\r | |
188 | \r | |
189 | EFI_STATUS\r | |
190 | EFIAPI\r | |
191 | PciRootBridgeIoPciWrite (\r | |
192 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
193 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r | |
194 | IN UINT64 Address,\r | |
195 | IN UINTN Count,\r | |
196 | IN OUT VOID *Buffer\r | |
197 | );\r | |
198 | \r | |
199 | EFI_STATUS\r | |
200 | EFIAPI\r | |
201 | PciRootBridgeIoMap (\r | |
202 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
203 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation,\r | |
204 | IN VOID *HostAddress,\r | |
205 | IN OUT UINTN *NumberOfBytes,\r | |
206 | OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r | |
207 | OUT VOID **Mapping\r | |
208 | );\r | |
209 | \r | |
210 | EFI_STATUS\r | |
211 | EFIAPI\r | |
212 | PciRootBridgeIoUnmap (\r | |
213 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
214 | IN VOID *Mapping\r | |
215 | );\r | |
216 | \r | |
217 | EFI_STATUS\r | |
218 | EFIAPI\r | |
219 | PciRootBridgeIoAllocateBuffer (\r | |
220 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
221 | IN EFI_ALLOCATE_TYPE Type,\r | |
222 | IN EFI_MEMORY_TYPE MemoryType,\r | |
223 | IN UINTN Pages,\r | |
224 | OUT VOID **HostAddress,\r | |
225 | IN UINT64 Attributes\r | |
226 | );\r | |
227 | \r | |
228 | EFI_STATUS\r | |
229 | EFIAPI\r | |
230 | PciRootBridgeIoFreeBuffer (\r | |
231 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
232 | IN UINTN Pages,\r | |
233 | OUT VOID *HostAddress\r | |
234 | );\r | |
235 | \r | |
236 | EFI_STATUS\r | |
237 | EFIAPI\r | |
238 | PciRootBridgeIoFlush (\r | |
239 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This\r | |
240 | );\r | |
241 | \r | |
242 | EFI_STATUS\r | |
243 | EFIAPI\r | |
244 | PciRootBridgeIoGetAttributes (\r | |
245 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
246 | OUT UINT64 *Supported,\r | |
247 | OUT UINT64 *Attributes\r | |
248 | );\r | |
249 | \r | |
250 | EFI_STATUS\r | |
251 | EFIAPI\r | |
252 | PciRootBridgeIoSetAttributes (\r | |
253 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
254 | IN UINT64 Attributes,\r | |
255 | IN OUT UINT64 *ResourceBase,\r | |
256 | IN OUT UINT64 *ResourceLength\r | |
257 | );\r | |
258 | \r | |
259 | EFI_STATUS\r | |
260 | EFIAPI\r | |
261 | PciRootBridgeIoConfiguration (\r | |
262 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r | |
263 | OUT VOID **Resources\r | |
264 | );\r | |
265 | \r | |
266 | //\r | |
267 | // Private Function Prototypes\r | |
268 | //\r | |
269 | EFI_STATUS\r | |
270 | EFIAPI\r | |
271 | PciRootBridgeIoMemRW (\r | |
272 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r | |
273 | IN UINTN Count,\r | |
274 | IN BOOLEAN InStrideFlag,\r | |
275 | IN PTR In,\r | |
276 | IN BOOLEAN OutStrideFlag,\r | |
277 | OUT PTR Out\r | |
278 | );\r | |
279 | \r | |
280 | BOOLEAN\r | |
281 | PciIoMemAddressValid (\r | |
282 | IN EFI_PCI_IO_PROTOCOL *This,\r | |
283 | IN UINT64 Address\r | |
284 | );\r | |
285 | \r | |
286 | EFI_STATUS\r | |
287 | EmulatePciIoForEhci (\r | |
288 | INTN MvPciIfMaxIf\r | |
289 | );\r | |
290 | \r | |
291 | #endif\r | |
292 | \r |