]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.h
3bbd5431adfead42943aea4320db81aa6a630292
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / PciBusDxe / PciEnumeratorSupport.h
1 /** @file
2 PCI emumeration support functions declaration for PCI Bus module.
3
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
9
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.
12
13 **/
14
15 #ifndef _EFI_PCI_ENUMERATOR_SUPPORT_H_
16 #define _EFI_PCI_ENUMERATOR_SUPPORT_H_
17
18 /**
19 This routine is used to check whether the pci device is present.
20
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.
26
27 @retval EFI_NOT_FOUND PCI device not present.
28 @retval EFI_SUCCESS PCI device is found.
29
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
38 );
39
40 /**
41 Collect all the resource information under this root bridge.
42
43 A database that records all the information about pci device subject to this
44 root bridge will then be created.
45
46 @param Bridge Parent bridge instance.
47 @param StartBusNumber Bus number of begining.
48
49 @retval EFI_SUCCESS PCI device is found.
50 @retval other Some error occurred when reading PCI bridge information.
51
52 **/
53 EFI_STATUS
54 PciPciDeviceInfoCollector (
55 IN PCI_IO_DEVICE *Bridge,
56 IN UINT8 StartBusNumber
57 );
58
59 /**
60 Seach required device and create PCI device instance.
61
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.
68
69 @retval EFI_SUCCESS Successfully created PCI device instance.
70 @retval EFI_OUT_OF_RESOURCES Cannot get PCI device information.
71
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
81 );
82
83 /**
84 Create PCI device instance for PCI device.
85
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.
91
92 @return Created PCI device instance.
93
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
102 );
103
104 /**
105 Create PCI device instance for PCI-PCI bridge.
106
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.
112
113 @return Created PCI device instance.
114
115 **/
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
123 );
124
125 /**
126 Create PCI device instance for PCI Card bridge device.
127
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.
133
134 @return Created PCI device instance.
135
136 **/
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
144 );
145
146 /**
147 Create device path for pci deivce.
148
149 @param ParentDevicePath Parent bridge's path.
150 @param PciIoDevice Pci device instance.
151
152 @return device path protocol instance for specific pci device.
153
154 **/
155 EFI_DEVICE_PATH_PROTOCOL *
156 CreatePciDevicePath (
157 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
158 IN PCI_IO_DEVICE *PciIoDevice
159 );
160
161 /**
162 Check whether the bar is existed or not.
163
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.
168
169 @retval EFI_NOT_FOUND The bar doesn't exist.
170 @retval EFI_SUCCESS The bar exist.
171
172 **/
173 EFI_STATUS
174 BarExisted (
175 IN PCI_IO_DEVICE *PciIoDevice,
176 IN UINTN Offset,
177 OUT UINT32 *BarLengthValue,
178 OUT UINT32 *OriginalBarValue
179 );
180
181 /**
182 Test whether the device can support given attributes.
183
184 @param PciIoDevice Pci device instance.
185 @param Command Input command register value, and
186 returned supported register value.
187 @param BridgeControl Inout bridge control value for PPB or P2C, and
188 returned supported bridge control value.
189 @param OldCommand Returned and stored old command register offset.
190 @param OldBridgeControl Returned and stored old Bridge control value for PPB or P2C.
191
192 **/
193 VOID
194 PciTestSupportedAttribute (
195 IN PCI_IO_DEVICE *PciIoDevice,
196 IN OUT UINT16 *Command,
197 IN OUT UINT16 *BridgeControl,
198 OUT UINT16 *OldCommand,
199 OUT UINT16 *OldBridgeControl
200 );
201
202 /**
203 Set the supported or current attributes of a PCI device.
204
205 @param PciIoDevice Structure pointer for PCI device.
206 @param Command Command register value.
207 @param BridgeControl Bridge control value for PPB or P2C.
208 @param Option Make a choice of EFI_SET_SUPPORTS or EFI_SET_ATTRIBUTES.
209
210 **/
211 VOID
212 PciSetDeviceAttribute (
213 IN PCI_IO_DEVICE *PciIoDevice,
214 IN UINT16 Command,
215 IN UINT16 BridgeControl,
216 IN UINTN Option
217 );
218
219 /**
220 Determine if the device can support Fast Back to Back attribute.
221
222 @param PciIoDevice Pci device instance.
223 @param StatusIndex Status register value.
224
225 @retval EFI_SUCCESS This device support Fast Back to Back attribute.
226 @retval EFI_UNSUPPORTED This device doesn't support Fast Back to Back attribute.
227
228 **/
229 EFI_STATUS
230 GetFastBackToBackSupport (
231 IN PCI_IO_DEVICE *PciIoDevice,
232 IN UINT8 StatusIndex
233 );
234
235 /**
236 Determine the related attributes of all devices under a Root Bridge.
237
238 @param PciIoDevice PCI device instance.
239
240 **/
241 EFI_STATUS
242 DetermineDeviceAttribute (
243 IN PCI_IO_DEVICE *PciIoDevice
244 );
245
246 /**
247 This routine is used to update the bar information for those incompatible PCI device.
248
249 @param PciIoDevice Pci device instance.
250
251 @retval EFI_SUCCESS Successfully updated bar information.
252 @retval EFI_UNSUPPORTED Given PCI device doesn't belong to incompatible PCI device list.
253 @retval other Failed to check incompatibility device.
254
255 **/
256 EFI_STATUS
257 UpdatePciInfo (
258 IN PCI_IO_DEVICE *PciIoDevice
259 );
260
261 /**
262 This routine will update the alignment with the new alignment.
263
264 @param Alignment Old alignment.
265 @param NewAlignment New alignment.
266
267 **/
268 VOID
269 SetNewAlign (
270 IN UINT64 *Alignment,
271 IN UINT64 NewAlignment
272 );
273
274 /**
275 Parse PCI bar information and fill them into PCI device instance.
276
277 @param PciIoDevice Pci device instance.
278 @param Offset Bar offset.
279 @param BarIndex Bar index.
280
281 @return Next bar offset.
282
283 **/
284 UINTN
285 PciParseBar (
286 IN PCI_IO_DEVICE *PciIoDevice,
287 IN UINTN Offset,
288 IN UINTN BarIndex
289 );
290
291 /**
292 This routine is used to initialize the bar of a PCI device.
293
294 @param PciIoDevice Pci device instance.
295
296 @note It can be called typically when a device is going to be rejected.
297
298 **/
299 VOID
300 InitializePciDevice (
301 IN PCI_IO_DEVICE *PciIoDevice
302 );
303
304 /**
305 This routine is used to initialize the bar of a PCI-PCI Bridge device.
306
307 @param PciIoDevice PCI-PCI bridge device instance.
308
309 **/
310 VOID
311 InitializePpb (
312 IN PCI_IO_DEVICE *PciIoDevice
313 );
314
315 /**
316 This routine is used to initialize the bar of a PCI Card Bridge device.
317
318 @param PciIoDevice PCI Card bridge device.
319
320 **/
321 VOID
322 InitializeP2C (
323 IN PCI_IO_DEVICE *PciIoDevice
324 );
325
326 /**
327 Create and initiliaze general PCI I/O device instance for
328 PCI device/bridge device/hotplug bridge device.
329
330 @param PciRootBridgeIo Pointer to instance of EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
331 @param Pci Input Pci information block.
332 @param Bus Device Bus NO.
333 @param Device Device device NO.
334 @param Func Device func NO.
335
336 @return Instance of PCI device. NULL means no instance created.
337
338 **/
339 PCI_IO_DEVICE *
340 CreatePciIoDevice (
341 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
342 IN PCI_TYPE00 *Pci,
343 IN UINT8 Bus,
344 IN UINT8 Device,
345 IN UINT8 Func
346 );
347
348 /**
349 This routine is used to enumerate entire pci bus system
350 in a given platform.
351
352 It is only called on the second start on the same Root Bridge.
353
354 @param Controller Parent bridge handler.
355
356 @retval EFI_SUCCESS PCI enumeration finished successfully.
357 @retval other Some error occurred when enumerating the pci bus system.
358
359 **/
360 EFI_STATUS
361 PciEnumeratorLight (
362 IN EFI_HANDLE Controller
363 );
364
365 /**
366 Get bus range from PCI resource descriptor list.
367
368 @param Descriptors A pointer to the address space descriptor.
369 @param MinBus The min bus returned.
370 @param MaxBus The max bus returned.
371 @param BusRange The bus range returned.
372
373 @retval EFI_SUCCESS Successfully got bus range.
374 @retval EFI_NOT_FOUND Can not find the specific bus.
375
376 **/
377 EFI_STATUS
378 PciGetBusRange (
379 IN EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors,
380 OUT UINT16 *MinBus,
381 OUT UINT16 *MaxBus,
382 OUT UINT16 *BusRange
383 );
384
385 /**
386 This routine can be used to start the root bridge.
387
388 @param RootBridgeDev Pci device instance.
389
390 @retval EFI_SUCCESS This device started.
391 @retval other Failed to get PCI Root Bridge I/O protocol.
392
393 **/
394 EFI_STATUS
395 StartManagingRootBridge (
396 IN PCI_IO_DEVICE *RootBridgeDev
397 );
398
399 /**
400 This routine can be used to check whether a PCI device should be rejected when light enumeration.
401
402 @param PciIoDevice Pci device instance.
403
404 @retval TRUE This device should be rejected.
405 @retval FALSE This device shouldn't be rejected.
406
407 **/
408 BOOLEAN
409 IsPciDeviceRejected (
410 IN PCI_IO_DEVICE *PciIoDevice
411 );
412
413 /**
414 Reset all bus number from specific bridge.
415
416 @param Bridge Parent specific bridge.
417 @param StartBusNumber Start bus number.
418
419 **/
420 VOID
421 ResetAllPpbBusNumber (
422 IN PCI_IO_DEVICE *Bridge,
423 IN UINT8 StartBusNumber
424 );
425
426 #endif