]>
Commit | Line | Data |
---|---|---|
9060e3ec | 1 | /** @file\r |
fcdfcdbf | 2 | PCI enumeration support functions declaration for PCI Bus module.\r |
9060e3ec | 3 | \r |
0785c619 | 4 | Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
9060e3ec | 6 | \r |
7 | **/\r | |
8 | \r | |
9 | #ifndef _EFI_PCI_ENUMERATOR_SUPPORT_H_\r | |
10 | #define _EFI_PCI_ENUMERATOR_SUPPORT_H_\r | |
11 | \r | |
12 | /**\r | |
13 | This routine is used to check whether the pci device is present.\r | |
14 | \r | |
15 | @param PciRootBridgeIo Pointer to instance of EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r | |
16 | @param Pci Output buffer for PCI device configuration space.\r | |
17 | @param Bus PCI bus NO.\r | |
18 | @param Device PCI device NO.\r | |
19 | @param Func PCI Func NO.\r | |
20 | \r | |
21 | @retval EFI_NOT_FOUND PCI device not present.\r | |
22 | @retval EFI_SUCCESS PCI device is found.\r | |
23 | \r | |
24 | **/\r | |
25 | EFI_STATUS\r | |
26 | PciDevicePresent (\r | |
1436aea4 MK |
27 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,\r |
28 | OUT PCI_TYPE00 *Pci,\r | |
29 | IN UINT8 Bus,\r | |
30 | IN UINT8 Device,\r | |
31 | IN UINT8 Func\r | |
9060e3ec | 32 | );\r |
33 | \r | |
34 | /**\r | |
35 | Collect all the resource information under this root bridge.\r | |
36 | \r | |
37 | A database that records all the information about pci device subject to this\r | |
38 | root bridge will then be created.\r | |
39 | \r | |
40 | @param Bridge Parent bridge instance.\r | |
fcdfcdbf | 41 | @param StartBusNumber Bus number of beginning.\r |
9060e3ec | 42 | \r |
43 | @retval EFI_SUCCESS PCI device is found.\r | |
44 | @retval other Some error occurred when reading PCI bridge information.\r | |
45 | \r | |
46 | **/\r | |
47 | EFI_STATUS\r | |
48 | PciPciDeviceInfoCollector (\r | |
1436aea4 MK |
49 | IN PCI_IO_DEVICE *Bridge,\r |
50 | IN UINT8 StartBusNumber\r | |
9060e3ec | 51 | );\r |
52 | \r | |
53 | /**\r | |
fcdfcdbf | 54 | Search required device and create PCI device instance.\r |
9060e3ec | 55 | \r |
56 | @param Bridge Parent bridge instance.\r | |
57 | @param Pci Input PCI device information block.\r | |
58 | @param Bus PCI bus NO.\r | |
59 | @param Device PCI device NO.\r | |
60 | @param Func PCI func NO.\r | |
61 | @param PciDevice Output of searched PCI device instance.\r | |
62 | \r | |
63 | @retval EFI_SUCCESS Successfully created PCI device instance.\r | |
64 | @retval EFI_OUT_OF_RESOURCES Cannot get PCI device information.\r | |
65 | \r | |
66 | **/\r | |
67 | EFI_STATUS\r | |
68 | PciSearchDevice (\r | |
1436aea4 MK |
69 | IN PCI_IO_DEVICE *Bridge,\r |
70 | IN PCI_TYPE00 *Pci,\r | |
71 | IN UINT8 Bus,\r | |
72 | IN UINT8 Device,\r | |
73 | IN UINT8 Func,\r | |
74 | OUT PCI_IO_DEVICE **PciDevice\r | |
9060e3ec | 75 | );\r |
76 | \r | |
77 | /**\r | |
78 | Create PCI device instance for PCI device.\r | |
79 | \r | |
80 | @param Bridge Parent bridge instance.\r | |
81 | @param Pci Input PCI device information block.\r | |
82 | @param Bus PCI device Bus NO.\r | |
83 | @param Device PCI device Device NO.\r | |
84 | @param Func PCI device's func NO.\r | |
85 | \r | |
86 | @return Created PCI device instance.\r | |
87 | \r | |
88 | **/\r | |
89 | PCI_IO_DEVICE *\r | |
90 | GatherDeviceInfo (\r | |
1436aea4 MK |
91 | IN PCI_IO_DEVICE *Bridge,\r |
92 | IN PCI_TYPE00 *Pci,\r | |
93 | IN UINT8 Bus,\r | |
94 | IN UINT8 Device,\r | |
95 | IN UINT8 Func\r | |
9060e3ec | 96 | );\r |
97 | \r | |
98 | /**\r | |
99 | Create PCI device instance for PCI-PCI bridge.\r | |
100 | \r | |
101 | @param Bridge Parent bridge instance.\r | |
102 | @param Pci Input PCI device information block.\r | |
103 | @param Bus PCI device Bus NO.\r | |
104 | @param Device PCI device Device NO.\r | |
105 | @param Func PCI device's func NO.\r | |
106 | \r | |
107 | @return Created PCI device instance.\r | |
108 | \r | |
109 | **/\r | |
110 | PCI_IO_DEVICE *\r | |
111 | GatherPpbInfo (\r | |
1436aea4 MK |
112 | IN PCI_IO_DEVICE *Bridge,\r |
113 | IN PCI_TYPE00 *Pci,\r | |
114 | IN UINT8 Bus,\r | |
115 | IN UINT8 Device,\r | |
116 | IN UINT8 Func\r | |
9060e3ec | 117 | );\r |
118 | \r | |
119 | /**\r | |
120 | Create PCI device instance for PCI Card bridge device.\r | |
121 | \r | |
122 | @param Bridge Parent bridge instance.\r | |
123 | @param Pci Input PCI device information block.\r | |
124 | @param Bus PCI device Bus NO.\r | |
125 | @param Device PCI device Device NO.\r | |
126 | @param Func PCI device's func NO.\r | |
127 | \r | |
128 | @return Created PCI device instance.\r | |
129 | \r | |
130 | **/\r | |
131 | PCI_IO_DEVICE *\r | |
132 | GatherP2CInfo (\r | |
1436aea4 MK |
133 | IN PCI_IO_DEVICE *Bridge,\r |
134 | IN PCI_TYPE00 *Pci,\r | |
135 | IN UINT8 Bus,\r | |
136 | IN UINT8 Device,\r | |
137 | IN UINT8 Func\r | |
9060e3ec | 138 | );\r |
139 | \r | |
140 | /**\r | |
fcdfcdbf | 141 | Create device path for pci device.\r |
9060e3ec | 142 | \r |
143 | @param ParentDevicePath Parent bridge's path.\r | |
144 | @param PciIoDevice Pci device instance.\r | |
145 | \r | |
fcdfcdbf | 146 | @return Device path protocol instance for specific pci device.\r |
9060e3ec | 147 | \r |
148 | **/\r | |
149 | EFI_DEVICE_PATH_PROTOCOL *\r | |
150 | CreatePciDevicePath (\r | |
1436aea4 MK |
151 | IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r |
152 | IN PCI_IO_DEVICE *PciIoDevice\r | |
9060e3ec | 153 | );\r |
154 | \r | |
155 | /**\r | |
156 | Check whether the PCI IOV VF bar is existed or not.\r | |
157 | \r | |
158 | @param PciIoDevice A pointer to the PCI_IO_DEVICE.\r | |
159 | @param Offset The offset.\r | |
160 | @param BarLengthValue The bar length value returned.\r | |
161 | @param OriginalBarValue The original bar value returned.\r | |
162 | \r | |
163 | @retval EFI_NOT_FOUND The bar doesn't exist.\r | |
164 | @retval EFI_SUCCESS The bar exist.\r | |
165 | \r | |
166 | **/\r | |
167 | EFI_STATUS\r | |
168 | VfBarExisted (\r | |
1436aea4 MK |
169 | IN PCI_IO_DEVICE *PciIoDevice,\r |
170 | IN UINTN Offset,\r | |
171 | OUT UINT32 *BarLengthValue,\r | |
172 | OUT UINT32 *OriginalBarValue\r | |
9060e3ec | 173 | );\r |
174 | \r | |
175 | /**\r | |
176 | Check whether the bar is existed or not.\r | |
177 | \r | |
178 | @param PciIoDevice A pointer to the PCI_IO_DEVICE.\r | |
179 | @param Offset The offset.\r | |
180 | @param BarLengthValue The bar length value returned.\r | |
181 | @param OriginalBarValue The original bar value returned.\r | |
182 | \r | |
183 | @retval EFI_NOT_FOUND The bar doesn't exist.\r | |
184 | @retval EFI_SUCCESS The bar exist.\r | |
185 | \r | |
186 | **/\r | |
187 | EFI_STATUS\r | |
188 | BarExisted (\r | |
1436aea4 MK |
189 | IN PCI_IO_DEVICE *PciIoDevice,\r |
190 | IN UINTN Offset,\r | |
191 | OUT UINT32 *BarLengthValue,\r | |
192 | OUT UINT32 *OriginalBarValue\r | |
9060e3ec | 193 | );\r |
194 | \r | |
195 | /**\r | |
196 | Test whether the device can support given attributes.\r | |
197 | \r | |
198 | @param PciIoDevice Pci device instance.\r | |
199 | @param Command Input command register value, and\r | |
200 | returned supported register value.\r | |
fcdfcdbf | 201 | @param BridgeControl Input bridge control value for PPB or P2C, and\r |
9060e3ec | 202 | returned supported bridge control value.\r |
203 | @param OldCommand Returned and stored old command register offset.\r | |
204 | @param OldBridgeControl Returned and stored old Bridge control value for PPB or P2C.\r | |
205 | \r | |
206 | **/\r | |
207 | VOID\r | |
208 | PciTestSupportedAttribute (\r | |
1436aea4 MK |
209 | IN PCI_IO_DEVICE *PciIoDevice,\r |
210 | IN OUT UINT16 *Command,\r | |
211 | IN OUT UINT16 *BridgeControl,\r | |
212 | OUT UINT16 *OldCommand,\r | |
213 | OUT UINT16 *OldBridgeControl\r | |
9060e3ec | 214 | );\r |
215 | \r | |
216 | /**\r | |
217 | Set the supported or current attributes of a PCI device.\r | |
218 | \r | |
219 | @param PciIoDevice Structure pointer for PCI device.\r | |
220 | @param Command Command register value.\r | |
221 | @param BridgeControl Bridge control value for PPB or P2C.\r | |
222 | @param Option Make a choice of EFI_SET_SUPPORTS or EFI_SET_ATTRIBUTES.\r | |
223 | \r | |
224 | **/\r | |
225 | VOID\r | |
226 | PciSetDeviceAttribute (\r | |
1436aea4 MK |
227 | IN PCI_IO_DEVICE *PciIoDevice,\r |
228 | IN UINT16 Command,\r | |
229 | IN UINT16 BridgeControl,\r | |
230 | IN UINTN Option\r | |
9060e3ec | 231 | );\r |
232 | \r | |
233 | /**\r | |
234 | Determine if the device can support Fast Back to Back attribute.\r | |
235 | \r | |
236 | @param PciIoDevice Pci device instance.\r | |
237 | @param StatusIndex Status register value.\r | |
238 | \r | |
239 | @retval EFI_SUCCESS This device support Fast Back to Back attribute.\r | |
240 | @retval EFI_UNSUPPORTED This device doesn't support Fast Back to Back attribute.\r | |
241 | \r | |
242 | **/\r | |
243 | EFI_STATUS\r | |
244 | GetFastBackToBackSupport (\r | |
1436aea4 MK |
245 | IN PCI_IO_DEVICE *PciIoDevice,\r |
246 | IN UINT8 StatusIndex\r | |
9060e3ec | 247 | );\r |
248 | \r | |
249 | /**\r | |
250 | Determine the related attributes of all devices under a Root Bridge.\r | |
251 | \r | |
252 | @param PciIoDevice PCI device instance.\r | |
253 | \r | |
254 | **/\r | |
255 | EFI_STATUS\r | |
256 | DetermineDeviceAttribute (\r | |
1436aea4 | 257 | IN PCI_IO_DEVICE *PciIoDevice\r |
9060e3ec | 258 | );\r |
259 | \r | |
260 | /**\r | |
261 | This routine is used to update the bar information for those incompatible PCI device.\r | |
262 | \r | |
263 | @param PciIoDevice Input Pci device instance. Output Pci device instance with updated\r | |
264 | Bar information.\r | |
265 | \r | |
266 | @retval EFI_SUCCESS Successfully updated bar information.\r | |
267 | @retval EFI_UNSUPPORTED Given PCI device doesn't belong to incompatible PCI device list.\r | |
268 | \r | |
269 | **/\r | |
270 | EFI_STATUS\r | |
271 | UpdatePciInfo (\r | |
1436aea4 | 272 | IN OUT PCI_IO_DEVICE *PciIoDevice\r |
9060e3ec | 273 | );\r |
274 | \r | |
275 | /**\r | |
276 | This routine will update the alignment with the new alignment.\r | |
277 | \r | |
278 | @param Alignment Input Old alignment. Output updated alignment.\r | |
279 | @param NewAlignment New alignment.\r | |
280 | \r | |
281 | **/\r | |
282 | VOID\r | |
283 | SetNewAlign (\r | |
1436aea4 MK |
284 | IN OUT UINT64 *Alignment,\r |
285 | IN UINT64 NewAlignment\r | |
9060e3ec | 286 | );\r |
287 | \r | |
288 | /**\r | |
289 | Parse PCI bar information and fill them into PCI device instance.\r | |
290 | \r | |
291 | @param PciIoDevice Pci device instance.\r | |
292 | @param Offset Bar offset.\r | |
293 | @param BarIndex Bar index.\r | |
294 | \r | |
295 | @return Next bar offset.\r | |
296 | \r | |
297 | **/\r | |
298 | UINTN\r | |
299 | PciParseBar (\r | |
300 | IN PCI_IO_DEVICE *PciIoDevice,\r | |
301 | IN UINTN Offset,\r | |
302 | IN UINTN BarIndex\r | |
303 | );\r | |
304 | \r | |
305 | /**\r | |
306 | Parse PCI IOV VF bar information and fill them into PCI device instance.\r | |
307 | \r | |
308 | @param PciIoDevice Pci device instance.\r | |
309 | @param Offset Bar offset.\r | |
310 | @param BarIndex Bar index.\r | |
311 | \r | |
312 | @return Next bar offset.\r | |
313 | \r | |
314 | **/\r | |
315 | UINTN\r | |
316 | PciIovParseVfBar (\r | |
317 | IN PCI_IO_DEVICE *PciIoDevice,\r | |
318 | IN UINTN Offset,\r | |
319 | IN UINTN BarIndex\r | |
320 | );\r | |
321 | \r | |
322 | /**\r | |
323 | This routine is used to initialize the bar of a PCI device.\r | |
324 | \r | |
325 | @param PciIoDevice Pci device instance.\r | |
326 | \r | |
327 | @note It can be called typically when a device is going to be rejected.\r | |
328 | \r | |
329 | **/\r | |
330 | VOID\r | |
331 | InitializePciDevice (\r | |
1436aea4 | 332 | IN PCI_IO_DEVICE *PciIoDevice\r |
9060e3ec | 333 | );\r |
334 | \r | |
335 | /**\r | |
336 | This routine is used to initialize the bar of a PCI-PCI Bridge device.\r | |
337 | \r | |
338 | @param PciIoDevice PCI-PCI bridge device instance.\r | |
339 | \r | |
340 | **/\r | |
341 | VOID\r | |
342 | InitializePpb (\r | |
1436aea4 | 343 | IN PCI_IO_DEVICE *PciIoDevice\r |
9060e3ec | 344 | );\r |
345 | \r | |
346 | /**\r | |
347 | This routine is used to initialize the bar of a PCI Card Bridge device.\r | |
348 | \r | |
349 | @param PciIoDevice PCI Card bridge device.\r | |
350 | \r | |
351 | **/\r | |
352 | VOID\r | |
353 | InitializeP2C (\r | |
1436aea4 | 354 | IN PCI_IO_DEVICE *PciIoDevice\r |
9060e3ec | 355 | );\r |
356 | \r | |
357 | /**\r | |
fcdfcdbf | 358 | Create and initialize general PCI I/O device instance for\r |
9060e3ec | 359 | PCI device/bridge device/hotplug bridge device.\r |
360 | \r | |
d4048391 | 361 | @param Bridge Parent bridge instance.\r |
9060e3ec | 362 | @param Pci Input Pci information block.\r |
363 | @param Bus Device Bus NO.\r | |
364 | @param Device Device device NO.\r | |
365 | @param Func Device func NO.\r | |
366 | \r | |
367 | @return Instance of PCI device. NULL means no instance created.\r | |
368 | \r | |
369 | **/\r | |
370 | PCI_IO_DEVICE *\r | |
371 | CreatePciIoDevice (\r | |
1436aea4 MK |
372 | IN PCI_IO_DEVICE *Bridge,\r |
373 | IN PCI_TYPE00 *Pci,\r | |
374 | IN UINT8 Bus,\r | |
375 | IN UINT8 Device,\r | |
376 | IN UINT8 Func\r | |
9060e3ec | 377 | );\r |
378 | \r | |
379 | /**\r | |
380 | This routine is used to enumerate entire pci bus system\r | |
381 | in a given platform.\r | |
382 | \r | |
383 | It is only called on the second start on the same Root Bridge.\r | |
384 | \r | |
385 | @param Controller Parent bridge handler.\r | |
386 | \r | |
387 | @retval EFI_SUCCESS PCI enumeration finished successfully.\r | |
388 | @retval other Some error occurred when enumerating the pci bus system.\r | |
389 | \r | |
390 | **/\r | |
391 | EFI_STATUS\r | |
392 | PciEnumeratorLight (\r | |
1436aea4 | 393 | IN EFI_HANDLE Controller\r |
9060e3ec | 394 | );\r |
395 | \r | |
396 | /**\r | |
397 | Get bus range from PCI resource descriptor list.\r | |
398 | \r | |
399 | @param Descriptors A pointer to the address space descriptor.\r | |
400 | @param MinBus The min bus returned.\r | |
401 | @param MaxBus The max bus returned.\r | |
402 | @param BusRange The bus range returned.\r | |
403 | \r | |
404 | @retval EFI_SUCCESS Successfully got bus range.\r | |
405 | @retval EFI_NOT_FOUND Can not find the specific bus.\r | |
406 | \r | |
407 | **/\r | |
408 | EFI_STATUS\r | |
409 | PciGetBusRange (\r | |
410 | IN EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors,\r | |
411 | OUT UINT16 *MinBus,\r | |
412 | OUT UINT16 *MaxBus,\r | |
413 | OUT UINT16 *BusRange\r | |
414 | );\r | |
415 | \r | |
416 | /**\r | |
417 | This routine can be used to start the root bridge.\r | |
418 | \r | |
419 | @param RootBridgeDev Pci device instance.\r | |
420 | \r | |
421 | @retval EFI_SUCCESS This device started.\r | |
422 | @retval other Failed to get PCI Root Bridge I/O protocol.\r | |
423 | \r | |
424 | **/\r | |
425 | EFI_STATUS\r | |
426 | StartManagingRootBridge (\r | |
1436aea4 | 427 | IN PCI_IO_DEVICE *RootBridgeDev\r |
9060e3ec | 428 | );\r |
429 | \r | |
430 | /**\r | |
431 | This routine can be used to check whether a PCI device should be rejected when light enumeration.\r | |
432 | \r | |
433 | @param PciIoDevice Pci device instance.\r | |
434 | \r | |
435 | @retval TRUE This device should be rejected.\r | |
436 | @retval FALSE This device shouldn't be rejected.\r | |
437 | \r | |
438 | **/\r | |
439 | BOOLEAN\r | |
440 | IsPciDeviceRejected (\r | |
1436aea4 | 441 | IN PCI_IO_DEVICE *PciIoDevice\r |
9060e3ec | 442 | );\r |
443 | \r | |
444 | /**\r | |
445 | Reset all bus number from specific bridge.\r | |
446 | \r | |
447 | @param Bridge Parent specific bridge.\r | |
448 | @param StartBusNumber Start bus number.\r | |
449 | \r | |
450 | **/\r | |
451 | VOID\r | |
452 | ResetAllPpbBusNumber (\r | |
1436aea4 MK |
453 | IN PCI_IO_DEVICE *Bridge,\r |
454 | IN UINT8 StartBusNumber\r | |
9060e3ec | 455 | );\r |
456 | \r | |
f67bd32d RN |
457 | /**\r |
458 | Dump the PPB padding resource information.\r | |
459 | \r | |
460 | @param PciIoDevice PCI IO instance.\r | |
461 | @param ResourceType The desired resource type to dump.\r | |
462 | PciBarTypeUnknown means to dump all types of resources.\r | |
463 | **/\r | |
464 | VOID\r | |
465 | DumpPpbPaddingResource (\r | |
1436aea4 MK |
466 | IN PCI_IO_DEVICE *PciIoDevice,\r |
467 | IN PCI_BAR_TYPE ResourceType\r | |
f67bd32d RN |
468 | );\r |
469 | \r | |
0785c619 LH |
470 | /**\r |
471 | Dump the PCI BAR information.\r | |
472 | \r | |
473 | @param PciIoDevice PCI IO instance.\r | |
474 | **/\r | |
475 | VOID\r | |
476 | DumpPciBars (\r | |
1436aea4 | 477 | IN PCI_IO_DEVICE *PciIoDevice\r |
0785c619 LH |
478 | );\r |
479 | \r | |
9060e3ec | 480 | #endif\r |