3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 PCI Bus Driver Lib header file.
19 Please use PCD feature flag PcdPciBusHotplugDeviceSupport to enable
26 #ifndef _EFI_PCI_LIB_H_
27 #define _EFI_PCI_LIB_H_
30 // Mask definistions for PCD PcdPciIncompatibleDeviceSupportMask
32 #define PCI_INCOMPATIBLE_ACPI_RESOURCE_SUPPORT 0x01
33 #define PCI_INCOMPATIBLE_READ_SUPPORT 0x02
34 #define PCI_INCOMPATIBLE_WRITE_SUPPORT 0x04
35 #define PCI_INCOMPATIBLE_REGISTER_UPDATE_SUPPORT 0x08
36 #define PCI_INCOMPATIBLE_ACCESS_WIDTH_SUPPORT 0x0a
40 } EFI_DEVICE_HANDLE_EXTENDED_DATA_PAYLOAD
;
44 UINT16 DevicePathSize
;
50 } EFI_RESOURCE_ALLOC_FAILURE_ERROR_DATA_PAYLOAD
;
54 Retrieve the BAR information via PciIo interface.
56 @param PciIoDevice Pci device instance.
60 IN PCI_IO_DEVICE
*PciIoDevice
64 Remove rejected pci device from specific root bridge
67 @param RootBridgeHandle specific parent root bridge handle.
68 @param Bridge Bridge device instance.
70 @retval EFI_SUCCESS Success operation.
73 RemoveRejectedPciDevices (
74 EFI_HANDLE RootBridgeHandle
,
75 IN PCI_IO_DEVICE
*Bridge
79 Wrapper function for allocating resource for pci host bridge.
81 @param PciResAlloc Point to protocol instance EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
85 PciHostBridgeResourceAllocator (
86 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
90 Wrapper function for allocating resource for pci host bridge without hotplug device support.
92 @param PciResAlloc Point to protocol instance EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
96 PciHostBridgeResourceAllocator_WithoutHotPlugDeviceSupport (
97 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
101 Wrapper function for allocating resource for pci host bridge with hotplug device support.
103 @param PciResAlloc Point to protocol instance EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
107 PciHostBridgeResourceAllocator_WithHotPlugDeviceSupport (
108 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
112 Wapper function of scanning pci bus and assign bus number to the given PCI bus system
113 Feature flag PcdPciBusHotplugDeviceSupport determine whether need support hotplug.
115 @param Bridge Bridge device instance.
116 @param StartBusNumber start point.
117 @param SubBusNumber Point to sub bus number.
118 @param PaddedBusRange Customized bus number.
120 @retval EFI_SUCCESS Success.
121 @retval EFI_DEVICE_ERROR Fail to scan bus.
125 IN PCI_IO_DEVICE
*Bridge
,
126 IN UINT8 StartBusNumber
,
127 OUT UINT8
*SubBusNumber
,
128 OUT UINT8
*PaddedBusRange
132 Wapper function of scanning pci bus and assign bus number to the given PCI bus system
133 Feature flag PcdPciBusHotplugDeviceSupport determine whether need support hotplug.
135 @param Bridge Bridge device instance.
136 @param StartBusNumber start point.
137 @param SubBusNumber Point to sub bus number.
138 @param PaddedBusRange Customized bus number.
140 @retval EFI_SUCCESS Success.
141 @retval EFI_DEVICE_ERROR Fail to scan bus.
144 PciScanBus_WithHotPlugDeviceSupport (
145 IN PCI_IO_DEVICE
*Bridge
,
146 IN UINT8 StartBusNumber
,
147 OUT UINT8
*SubBusNumber
,
148 OUT UINT8
*PaddedBusRange
152 Wapper function of scanning pci bus and assign bus number to the given PCI bus system
153 Feature flag PcdPciBusHotplugDeviceSupport determine whether need support hotplug.
155 @param Bridge Bridge device instance.
156 @param StartBusNumber start point.
157 @param SubBusNumber Point to sub bus number.
158 @param PaddedBusRange Customized bus number.
160 @retval EFI_SUCCESS Success.
161 @retval EFI_DEVICE_ERROR Fail to scan bus.
164 PciScanBus_WithoutHotPlugDeviceSupport (
165 IN PCI_IO_DEVICE
*Bridge
,
166 IN UINT8 StartBusNumber
,
167 OUT UINT8
*SubBusNumber
,
168 OUT UINT8
*PaddedBusRange
172 Process Option Rom on this host bridge.
174 @param Bridge Pci bridge device instance.
176 @retval EFI_SUCCESS Success.
179 PciRootBridgeP2CProcess (
180 IN PCI_IO_DEVICE
*Bridge
184 Process Option Rom on this host bridge.
186 @param PciResAlloc Pointer to instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
188 @retval EFI_NOT_FOUND Can not find the root bridge instance.
189 @retval EFI_SUCCESS Success process.
192 PciHostBridgeP2CProcess (
193 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
197 This function is used to enumerate the entire host bridge
200 @param PciResAlloc A pointer to the resource allocate protocol.
202 @retval EFI_OUT_OF_RESOURCES no enough resource.
203 @retval EFI_SUCCESS Success.
207 PciHostBridgeEnumerator (
208 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
212 Read PCI configuration space through EFI_PCI_IO_PROTOCOL.
214 @param PciIo A pointer to the EFI_PCI_O_PROTOCOL.
215 @param Width Signifies the width of the memory operations.
216 @param Address The address within the PCI configuration space for the PCI controller.
217 @param Count The number of unit to be read.
218 @param Buffer For read operations, the destination buffer to store the results. For
219 write operations, the source buffer to write data from.
221 @retval EFI_SUCCESS The data was read from or written to the PCI root bridge.
222 @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
223 @retval EFI_INVALID_PARAMETER Buffer is NULL.
224 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
229 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
230 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
237 Write PCI configuration space through EFI_PCI_IO_PROTOCOL.
239 @param PciIo A pointer to the EFI_PCI_O_PROTOCOL.
240 @param Width Signifies the width of the memory operations.
241 @param Address The address within the PCI configuration space for the PCI controller.
242 @param Count The number of unit to be write.
243 @param Buffer For read operations, the destination buffer to store the results. For
244 write operations, the source buffer to write data from.
246 @retval EFI_SUCCESS The data was read from or written to the PCI root bridge.
247 @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
248 @retval EFI_INVALID_PARAMETER Buffer is NULL.
249 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
254 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
255 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
262 Write PCI configuration space through EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
264 @param PciRootBridgeIo A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
265 @param Pci A pointer to PCI_TYPE00.
266 @param Width Signifies the width of the memory operations.
267 @param Address The address within the PCI configuration space for the PCI controller.
268 @param Count The number of unit to be write.
269 @param Buffer For read operations, the destination buffer to store the results. For
270 write operations, the source buffer to write data from.
272 @retval EFI_SUCCESS The data was read from or written to the PCI root bridge.
273 @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
274 @retval EFI_INVALID_PARAMETER Buffer is NULL.
275 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
279 PciRootBridgeIoWrite (
280 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
,
282 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
289 Read PCI configuration space through EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
291 @param PciRootBridgeIo A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
292 @param Pci A pointer to PCI_TYPE00.
293 @param Width Signifies the width of the memory operations.
294 @param Address The address within the PCI configuration space for the PCI controller.
295 @param Count The number of unit to be read.
296 @param Buffer For read operations, the destination buffer to store the results. For
297 write operations, the source buffer to write data from.
299 @retval EFI_SUCCESS The data was read from or written to the PCI root bridge.
300 @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
301 @retval EFI_INVALID_PARAMETER Buffer is NULL.
302 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
306 PciRootBridgeIoRead (
307 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
,
308 IN PCI_TYPE00
*Pci
, OPTIONAL
309 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,