add SR-IOV support in EDK II.
[edk2.git] / IntelFrameworkModulePkg / Bus / Pci / PciBusDxe / PciEnumeratorSupport.h
blob31238b45cf5b22172b6e35d5a4440a094781531b
1 /** @file
2 PCI emumeration support functions declaration for PCI Bus module.
4 Copyright (c) 2006 - 2009, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 **/
15 #ifndef _EFI_PCI_ENUMERATOR_SUPPORT_H_
16 #define _EFI_PCI_ENUMERATOR_SUPPORT_H_
18 /**
19 This routine is used to check whether the pci device is present.
21 @param PciRootBridgeIo Pointer to instance of EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
22 @param Pci Output buffer for PCI device configuration space.
23 @param Bus PCI bus NO.
24 @param Device PCI device NO.
25 @param Func PCI Func NO.
27 @retval EFI_NOT_FOUND PCI device not present.
28 @retval EFI_SUCCESS PCI device is found.
30 **/
31 EFI_STATUS
32 PciDevicePresent (
33 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
34 OUT PCI_TYPE00 *Pci,
35 IN UINT8 Bus,
36 IN UINT8 Device,
37 IN UINT8 Func
40 /**
41 Collect all the resource information under this root bridge.
43 A database that records all the information about pci device subject to this
44 root bridge will then be created.
46 @param Bridge Parent bridge instance.
47 @param StartBusNumber Bus number of begining.
49 @retval EFI_SUCCESS PCI device is found.
50 @retval other Some error occurred when reading PCI bridge information.
52 **/
53 EFI_STATUS
54 PciPciDeviceInfoCollector (
55 IN PCI_IO_DEVICE *Bridge,
56 IN UINT8 StartBusNumber
59 /**
60 Seach required device and create PCI device instance.
62 @param Bridge Parent bridge instance.
63 @param Pci Input PCI device information block.
64 @param Bus PCI bus NO.
65 @param Device PCI device NO.
66 @param Func PCI func NO.
67 @param PciDevice Output of searched PCI device instance.
69 @retval EFI_SUCCESS Successfully created PCI device instance.
70 @retval EFI_OUT_OF_RESOURCES Cannot get PCI device information.
72 **/
73 EFI_STATUS
74 PciSearchDevice (
75 IN PCI_IO_DEVICE *Bridge,
76 IN PCI_TYPE00 *Pci,
77 IN UINT8 Bus,
78 IN UINT8 Device,
79 IN UINT8 Func,
80 OUT PCI_IO_DEVICE **PciDevice
83 /**
84 Create PCI device instance for PCI device.
86 @param Bridge Parent bridge instance.
87 @param Pci Input PCI device information block.
88 @param Bus PCI device Bus NO.
89 @param Device PCI device Device NO.
90 @param Func PCI device's func NO.
92 @return Created PCI device instance.
94 **/
95 PCI_IO_DEVICE *
96 GatherDeviceInfo (
97 IN PCI_IO_DEVICE *Bridge,
98 IN PCI_TYPE00 *Pci,
99 IN UINT8 Bus,
100 IN UINT8 Device,
101 IN UINT8 Func
105 Create PCI device instance for PCI-PCI bridge.
107 @param Bridge Parent bridge instance.
108 @param Pci Input PCI device information block.
109 @param Bus PCI device Bus NO.
110 @param Device PCI device Device NO.
111 @param Func PCI device's func NO.
113 @return Created PCI device instance.
116 PCI_IO_DEVICE *
117 GatherPpbInfo (
118 IN PCI_IO_DEVICE *Bridge,
119 IN PCI_TYPE00 *Pci,
120 IN UINT8 Bus,
121 IN UINT8 Device,
122 IN UINT8 Func
126 Create PCI device instance for PCI Card bridge device.
128 @param Bridge Parent bridge instance.
129 @param Pci Input PCI device information block.
130 @param Bus PCI device Bus NO.
131 @param Device PCI device Device NO.
132 @param Func PCI device's func NO.
134 @return Created PCI device instance.
137 PCI_IO_DEVICE *
138 GatherP2CInfo (
139 IN PCI_IO_DEVICE *Bridge,
140 IN PCI_TYPE00 *Pci,
141 IN UINT8 Bus,
142 IN UINT8 Device,
143 IN UINT8 Func
147 Create device path for pci deivce.
149 @param ParentDevicePath Parent bridge's path.
150 @param PciIoDevice Pci device instance.
152 @return device path protocol instance for specific pci device.
155 EFI_DEVICE_PATH_PROTOCOL *
156 CreatePciDevicePath (
157 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
158 IN PCI_IO_DEVICE *PciIoDevice
162 Check whether the PCI IOV VF bar is existed or not.
164 @param PciIoDevice A pointer to the PCI_IO_DEVICE.
165 @param Offset The offset.
166 @param BarLengthValue The bar length value returned.
167 @param OriginalBarValue The original bar value returned.
169 @retval EFI_NOT_FOUND The bar doesn't exist.
170 @retval EFI_SUCCESS The bar exist.
173 EFI_STATUS
174 VfBarExisted (
175 IN PCI_IO_DEVICE *PciIoDevice,
176 IN UINTN Offset,
177 OUT UINT32 *BarLengthValue,
178 OUT UINT32 *OriginalBarValue
182 Check whether the bar is existed or not.
184 @param PciIoDevice A pointer to the PCI_IO_DEVICE.
185 @param Offset The offset.
186 @param BarLengthValue The bar length value returned.
187 @param OriginalBarValue The original bar value returned.
189 @retval EFI_NOT_FOUND The bar doesn't exist.
190 @retval EFI_SUCCESS The bar exist.
193 EFI_STATUS
194 BarExisted (
195 IN PCI_IO_DEVICE *PciIoDevice,
196 IN UINTN Offset,
197 OUT UINT32 *BarLengthValue,
198 OUT UINT32 *OriginalBarValue
202 Test whether the device can support given attributes.
204 @param PciIoDevice Pci device instance.
205 @param Command Input command register value, and
206 returned supported register value.
207 @param BridgeControl Inout bridge control value for PPB or P2C, and
208 returned supported bridge control value.
209 @param OldCommand Returned and stored old command register offset.
210 @param OldBridgeControl Returned and stored old Bridge control value for PPB or P2C.
213 VOID
214 PciTestSupportedAttribute (
215 IN PCI_IO_DEVICE *PciIoDevice,
216 IN OUT UINT16 *Command,
217 IN OUT UINT16 *BridgeControl,
218 OUT UINT16 *OldCommand,
219 OUT UINT16 *OldBridgeControl
223 Set the supported or current attributes of a PCI device.
225 @param PciIoDevice Structure pointer for PCI device.
226 @param Command Command register value.
227 @param BridgeControl Bridge control value for PPB or P2C.
228 @param Option Make a choice of EFI_SET_SUPPORTS or EFI_SET_ATTRIBUTES.
231 VOID
232 PciSetDeviceAttribute (
233 IN PCI_IO_DEVICE *PciIoDevice,
234 IN UINT16 Command,
235 IN UINT16 BridgeControl,
236 IN UINTN Option
240 Determine if the device can support Fast Back to Back attribute.
242 @param PciIoDevice Pci device instance.
243 @param StatusIndex Status register value.
245 @retval EFI_SUCCESS This device support Fast Back to Back attribute.
246 @retval EFI_UNSUPPORTED This device doesn't support Fast Back to Back attribute.
249 EFI_STATUS
250 GetFastBackToBackSupport (
251 IN PCI_IO_DEVICE *PciIoDevice,
252 IN UINT8 StatusIndex
256 Determine the related attributes of all devices under a Root Bridge.
258 @param PciIoDevice PCI device instance.
261 EFI_STATUS
262 DetermineDeviceAttribute (
263 IN PCI_IO_DEVICE *PciIoDevice
267 This routine is used to update the bar information for those incompatible PCI device.
269 @param PciIoDevice Input Pci device instance. Output Pci device instance with updated
270 Bar information.
272 @retval EFI_SUCCESS Successfully updated bar information.
273 @retval EFI_UNSUPPORTED Given PCI device doesn't belong to incompatible PCI device list.
276 EFI_STATUS
277 UpdatePciInfo (
278 IN OUT PCI_IO_DEVICE *PciIoDevice
282 This routine will update the alignment with the new alignment.
284 @param Alignment Input Old alignment. Output updated alignment.
285 @param NewAlignment New alignment.
288 VOID
289 SetNewAlign (
290 IN OUT UINT64 *Alignment,
291 IN UINT64 NewAlignment
295 Parse PCI bar information and fill them into PCI device instance.
297 @param PciIoDevice Pci device instance.
298 @param Offset Bar offset.
299 @param BarIndex Bar index.
301 @return Next bar offset.
304 UINTN
305 PciParseBar (
306 IN PCI_IO_DEVICE *PciIoDevice,
307 IN UINTN Offset,
308 IN UINTN BarIndex
312 Parse PCI IOV VF bar information and fill them into PCI device instance.
314 @param PciIoDevice Pci device instance.
315 @param Offset Bar offset.
316 @param BarIndex Bar index.
318 @return Next bar offset.
321 UINTN
322 PciIovParseVfBar (
323 IN PCI_IO_DEVICE *PciIoDevice,
324 IN UINTN Offset,
325 IN UINTN BarIndex
329 This routine is used to initialize the bar of a PCI device.
331 @param PciIoDevice Pci device instance.
333 @note It can be called typically when a device is going to be rejected.
336 VOID
337 InitializePciDevice (
338 IN PCI_IO_DEVICE *PciIoDevice
342 This routine is used to initialize the bar of a PCI-PCI Bridge device.
344 @param PciIoDevice PCI-PCI bridge device instance.
347 VOID
348 InitializePpb (
349 IN PCI_IO_DEVICE *PciIoDevice
353 This routine is used to initialize the bar of a PCI Card Bridge device.
355 @param PciIoDevice PCI Card bridge device.
358 VOID
359 InitializeP2C (
360 IN PCI_IO_DEVICE *PciIoDevice
364 Create and initiliaze general PCI I/O device instance for
365 PCI device/bridge device/hotplug bridge device.
367 @param PciRootBridgeIo Pointer to instance of EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
368 @param Pci Input Pci information block.
369 @param Bus Device Bus NO.
370 @param Device Device device NO.
371 @param Func Device func NO.
373 @return Instance of PCI device. NULL means no instance created.
376 PCI_IO_DEVICE *
377 CreatePciIoDevice (
378 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
379 IN PCI_TYPE00 *Pci,
380 IN UINT8 Bus,
381 IN UINT8 Device,
382 IN UINT8 Func
386 This routine is used to enumerate entire pci bus system
387 in a given platform.
389 It is only called on the second start on the same Root Bridge.
391 @param Controller Parent bridge handler.
393 @retval EFI_SUCCESS PCI enumeration finished successfully.
394 @retval other Some error occurred when enumerating the pci bus system.
397 EFI_STATUS
398 PciEnumeratorLight (
399 IN EFI_HANDLE Controller
403 Get bus range from PCI resource descriptor list.
405 @param Descriptors A pointer to the address space descriptor.
406 @param MinBus The min bus returned.
407 @param MaxBus The max bus returned.
408 @param BusRange The bus range returned.
410 @retval EFI_SUCCESS Successfully got bus range.
411 @retval EFI_NOT_FOUND Can not find the specific bus.
414 EFI_STATUS
415 PciGetBusRange (
416 IN EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors,
417 OUT UINT16 *MinBus,
418 OUT UINT16 *MaxBus,
419 OUT UINT16 *BusRange
423 This routine can be used to start the root bridge.
425 @param RootBridgeDev Pci device instance.
427 @retval EFI_SUCCESS This device started.
428 @retval other Failed to get PCI Root Bridge I/O protocol.
431 EFI_STATUS
432 StartManagingRootBridge (
433 IN PCI_IO_DEVICE *RootBridgeDev
437 This routine can be used to check whether a PCI device should be rejected when light enumeration.
439 @param PciIoDevice Pci device instance.
441 @retval TRUE This device should be rejected.
442 @retval FALSE This device shouldn't be rejected.
445 BOOLEAN
446 IsPciDeviceRejected (
447 IN PCI_IO_DEVICE *PciIoDevice
451 Reset all bus number from specific bridge.
453 @param Bridge Parent specific bridge.
454 @param StartBusNumber Start bus number.
457 VOID
458 ResetAllPpbBusNumber (
459 IN PCI_IO_DEVICE *Bridge,
460 IN UINT8 StartBusNumber
463 #endif