]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciEnumeratorSupport.h
CommitLineData
9060e3ec 1/** @file\r
fcdfcdbf 2 PCI enumeration support functions declaration for PCI Bus module.\r
9060e3ec 3\r
0785c619 4Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5SPDX-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
25EFI_STATUS\r
26PciDevicePresent (\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
47EFI_STATUS\r
48PciPciDeviceInfoCollector (\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
67EFI_STATUS\r
68PciSearchDevice (\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
89PCI_IO_DEVICE *\r
90GatherDeviceInfo (\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
110PCI_IO_DEVICE *\r
111GatherPpbInfo (\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
131PCI_IO_DEVICE *\r
132GatherP2CInfo (\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
149EFI_DEVICE_PATH_PROTOCOL *\r
150CreatePciDevicePath (\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
167EFI_STATUS\r
168VfBarExisted (\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
187EFI_STATUS\r
188BarExisted (\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
207VOID\r
208PciTestSupportedAttribute (\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
225VOID\r
226PciSetDeviceAttribute (\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
243EFI_STATUS\r
244GetFastBackToBackSupport (\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
255EFI_STATUS\r
256DetermineDeviceAttribute (\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
cb8349f0 265 @param IgnoreOptionRom Output If the option rom of incompatible device need to be ignored.\r
9060e3ec 266\r
267 @retval EFI_SUCCESS Successfully updated bar information.\r
268 @retval EFI_UNSUPPORTED Given PCI device doesn't belong to incompatible PCI device list.\r
269\r
270**/\r
271EFI_STATUS\r
272UpdatePciInfo (\r
cb8349f0
MX
273 IN OUT PCI_IO_DEVICE *PciIoDevice,\r
274 OUT BOOLEAN *IgnoreOptionRom\r
9060e3ec 275 );\r
276\r
277/**\r
278 This routine will update the alignment with the new alignment.\r
279\r
280 @param Alignment Input Old alignment. Output updated alignment.\r
281 @param NewAlignment New alignment.\r
282\r
283**/\r
284VOID\r
285SetNewAlign (\r
1436aea4
MK
286 IN OUT UINT64 *Alignment,\r
287 IN UINT64 NewAlignment\r
9060e3ec 288 );\r
289\r
290/**\r
291 Parse PCI bar information and fill them into PCI device instance.\r
292\r
293 @param PciIoDevice Pci device instance.\r
294 @param Offset Bar offset.\r
295 @param BarIndex Bar index.\r
296\r
297 @return Next bar offset.\r
298\r
299**/\r
300UINTN\r
301PciParseBar (\r
302 IN PCI_IO_DEVICE *PciIoDevice,\r
303 IN UINTN Offset,\r
304 IN UINTN BarIndex\r
305 );\r
306\r
307/**\r
308 Parse PCI IOV VF bar information and fill them into PCI device instance.\r
309\r
310 @param PciIoDevice Pci device instance.\r
311 @param Offset Bar offset.\r
312 @param BarIndex Bar index.\r
313\r
314 @return Next bar offset.\r
315\r
316**/\r
317UINTN\r
318PciIovParseVfBar (\r
319 IN PCI_IO_DEVICE *PciIoDevice,\r
320 IN UINTN Offset,\r
321 IN UINTN BarIndex\r
322 );\r
323\r
324/**\r
325 This routine is used to initialize the bar of a PCI device.\r
326\r
327 @param PciIoDevice Pci device instance.\r
328\r
329 @note It can be called typically when a device is going to be rejected.\r
330\r
331**/\r
332VOID\r
333InitializePciDevice (\r
1436aea4 334 IN PCI_IO_DEVICE *PciIoDevice\r
9060e3ec 335 );\r
336\r
337/**\r
338 This routine is used to initialize the bar of a PCI-PCI Bridge device.\r
339\r
340 @param PciIoDevice PCI-PCI bridge device instance.\r
341\r
342**/\r
343VOID\r
344InitializePpb (\r
1436aea4 345 IN PCI_IO_DEVICE *PciIoDevice\r
9060e3ec 346 );\r
347\r
348/**\r
349 This routine is used to initialize the bar of a PCI Card Bridge device.\r
350\r
351 @param PciIoDevice PCI Card bridge device.\r
352\r
353**/\r
354VOID\r
355InitializeP2C (\r
1436aea4 356 IN PCI_IO_DEVICE *PciIoDevice\r
9060e3ec 357 );\r
358\r
359/**\r
fcdfcdbf 360 Create and initialize general PCI I/O device instance for\r
9060e3ec 361 PCI device/bridge device/hotplug bridge device.\r
362\r
d4048391 363 @param Bridge Parent bridge instance.\r
9060e3ec 364 @param Pci Input Pci information block.\r
365 @param Bus Device Bus NO.\r
366 @param Device Device device NO.\r
367 @param Func Device func NO.\r
368\r
369 @return Instance of PCI device. NULL means no instance created.\r
370\r
371**/\r
372PCI_IO_DEVICE *\r
373CreatePciIoDevice (\r
1436aea4
MK
374 IN PCI_IO_DEVICE *Bridge,\r
375 IN PCI_TYPE00 *Pci,\r
376 IN UINT8 Bus,\r
377 IN UINT8 Device,\r
378 IN UINT8 Func\r
9060e3ec 379 );\r
380\r
381/**\r
382 This routine is used to enumerate entire pci bus system\r
383 in a given platform.\r
384\r
385 It is only called on the second start on the same Root Bridge.\r
386\r
387 @param Controller Parent bridge handler.\r
388\r
389 @retval EFI_SUCCESS PCI enumeration finished successfully.\r
390 @retval other Some error occurred when enumerating the pci bus system.\r
391\r
392**/\r
393EFI_STATUS\r
394PciEnumeratorLight (\r
1436aea4 395 IN EFI_HANDLE Controller\r
9060e3ec 396 );\r
397\r
398/**\r
399 Get bus range from PCI resource descriptor list.\r
400\r
401 @param Descriptors A pointer to the address space descriptor.\r
402 @param MinBus The min bus returned.\r
403 @param MaxBus The max bus returned.\r
404 @param BusRange The bus range returned.\r
405\r
406 @retval EFI_SUCCESS Successfully got bus range.\r
407 @retval EFI_NOT_FOUND Can not find the specific bus.\r
408\r
409**/\r
410EFI_STATUS\r
411PciGetBusRange (\r
412 IN EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors,\r
413 OUT UINT16 *MinBus,\r
414 OUT UINT16 *MaxBus,\r
415 OUT UINT16 *BusRange\r
416 );\r
417\r
418/**\r
419 This routine can be used to start the root bridge.\r
420\r
421 @param RootBridgeDev Pci device instance.\r
422\r
423 @retval EFI_SUCCESS This device started.\r
424 @retval other Failed to get PCI Root Bridge I/O protocol.\r
425\r
426**/\r
427EFI_STATUS\r
428StartManagingRootBridge (\r
1436aea4 429 IN PCI_IO_DEVICE *RootBridgeDev\r
9060e3ec 430 );\r
431\r
432/**\r
433 This routine can be used to check whether a PCI device should be rejected when light enumeration.\r
434\r
435 @param PciIoDevice Pci device instance.\r
436\r
437 @retval TRUE This device should be rejected.\r
438 @retval FALSE This device shouldn't be rejected.\r
439\r
440**/\r
441BOOLEAN\r
442IsPciDeviceRejected (\r
1436aea4 443 IN PCI_IO_DEVICE *PciIoDevice\r
9060e3ec 444 );\r
445\r
446/**\r
447 Reset all bus number from specific bridge.\r
448\r
449 @param Bridge Parent specific bridge.\r
450 @param StartBusNumber Start bus number.\r
451\r
452**/\r
453VOID\r
454ResetAllPpbBusNumber (\r
1436aea4
MK
455 IN PCI_IO_DEVICE *Bridge,\r
456 IN UINT8 StartBusNumber\r
9060e3ec 457 );\r
458\r
f67bd32d
RN
459/**\r
460 Dump the PPB padding resource information.\r
461\r
462 @param PciIoDevice PCI IO instance.\r
463 @param ResourceType The desired resource type to dump.\r
464 PciBarTypeUnknown means to dump all types of resources.\r
465**/\r
466VOID\r
467DumpPpbPaddingResource (\r
1436aea4
MK
468 IN PCI_IO_DEVICE *PciIoDevice,\r
469 IN PCI_BAR_TYPE ResourceType\r
f67bd32d
RN
470 );\r
471\r
0785c619
LH
472/**\r
473 Dump the PCI BAR information.\r
474\r
475 @param PciIoDevice PCI IO instance.\r
476**/\r
477VOID\r
478DumpPciBars (\r
1436aea4 479 IN PCI_IO_DEVICE *PciIoDevice\r
0785c619
LH
480 );\r
481\r
9060e3ec 482#endif\r