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