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
;
53 Install protocol gEfiPciHotPlugRequestProtocolGuid
54 @param Status return status of protocol installation.
57 InstallHotPlugRequestProtocol (
62 Retrieve the BAR information via PciIo interface.
64 @param PciIoDevice Pci device instance.
68 IN PCI_IO_DEVICE
*PciIoDevice
72 Remove rejected pci device from specific root bridge
75 @param RootBridgeHandle specific parent root bridge handle.
76 @param Bridge Bridge device instance.
78 @retval EFI_SUCCESS Success operation.
81 RemoveRejectedPciDevices (
82 EFI_HANDLE RootBridgeHandle
,
83 IN PCI_IO_DEVICE
*Bridge
87 Wrapper function for allocating resource for pci host bridge.
89 @param PciResAlloc Point to protocol instance EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
93 PciHostBridgeResourceAllocator (
94 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
98 Wrapper function for allocating resource for pci host bridge without hotplug device support.
100 @param PciResAlloc Point to protocol instance EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
104 PciHostBridgeResourceAllocator_WithoutHotPlugDeviceSupport (
105 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
109 Wrapper function for allocating resource for pci host bridge with hotplug device support.
111 @param PciResAlloc Point to protocol instance EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
115 PciHostBridgeResourceAllocator_WithHotPlugDeviceSupport (
116 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
120 Wapper function of scanning pci bus and assign bus number to the given PCI bus system
121 Feature flag PcdPciBusHotplugDeviceSupport determine whether need support hotplug.
123 @param Bridge Bridge device instance.
124 @param StartBusNumber start point.
125 @param SubBusNumber Point to sub bus number.
126 @param PaddedBusRange Customized bus number.
128 @retval EFI_SUCCESS Success.
129 @retval EFI_DEVICE_ERROR Fail to scan bus.
133 IN PCI_IO_DEVICE
*Bridge
,
134 IN UINT8 StartBusNumber
,
135 OUT UINT8
*SubBusNumber
,
136 OUT UINT8
*PaddedBusRange
140 Wapper function of scanning pci bus and assign bus number to the given PCI bus system
141 Feature flag PcdPciBusHotplugDeviceSupport determine whether need support hotplug.
143 @param Bridge Bridge device instance.
144 @param StartBusNumber start point.
145 @param SubBusNumber Point to sub bus number.
146 @param PaddedBusRange Customized bus number.
148 @retval EFI_SUCCESS Success.
149 @retval EFI_DEVICE_ERROR Fail to scan bus.
152 PciScanBus_WithHotPlugDeviceSupport (
153 IN PCI_IO_DEVICE
*Bridge
,
154 IN UINT8 StartBusNumber
,
155 OUT UINT8
*SubBusNumber
,
156 OUT UINT8
*PaddedBusRange
160 Wapper function of scanning pci bus and assign bus number to the given PCI bus system
161 Feature flag PcdPciBusHotplugDeviceSupport determine whether need support hotplug.
163 @param Bridge Bridge device instance.
164 @param StartBusNumber start point.
165 @param SubBusNumber Point to sub bus number.
166 @param PaddedBusRange Customized bus number.
168 @retval EFI_SUCCESS Success.
169 @retval EFI_DEVICE_ERROR Fail to scan bus.
172 PciScanBus_WithoutHotPlugDeviceSupport (
173 IN PCI_IO_DEVICE
*Bridge
,
174 IN UINT8 StartBusNumber
,
175 OUT UINT8
*SubBusNumber
,
176 OUT UINT8
*PaddedBusRange
180 Process Option Rom on this host bridge.
182 @param Bridge Pci bridge device instance.
184 @retval EFI_SUCCESS Success.
187 PciRootBridgeP2CProcess (
188 IN PCI_IO_DEVICE
*Bridge
192 Process Option Rom on this host bridge.
194 @param PciResAlloc Pointer to instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
196 @retval EFI_NOT_FOUND Can not find the root bridge instance.
197 @retval EFI_SUCCESS Success process.
200 PciHostBridgeP2CProcess (
201 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
205 This function is used to enumerate the entire host bridge
208 @param PciResAlloc A pointer to the resource allocate protocol.
210 @retval EFI_OUT_OF_RESOURCES no enough resource.
211 @retval EFI_SUCCESS Success.
215 PciHostBridgeEnumerator (
216 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
220 Read PCI configuration space through EFI_PCI_IO_PROTOCOL.
222 @param PciIo A pointer to the EFI_PCI_O_PROTOCOL.
223 @param Width Signifies the width of the memory operations.
224 @param Address The address within the PCI configuration space for the PCI controller.
225 @param Count The number of unit to be read.
226 @param Buffer For read operations, the destination buffer to store the results. For
227 write operations, the source buffer to write data from.
229 @retval EFI_SUCCESS The data was read from or written to the PCI root bridge.
230 @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
231 @retval EFI_INVALID_PARAMETER Buffer is NULL.
232 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
237 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
238 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
245 Write PCI configuration space through EFI_PCI_IO_PROTOCOL.
247 @param PciIo A pointer to the EFI_PCI_O_PROTOCOL.
248 @param Width Signifies the width of the memory operations.
249 @param Address The address within the PCI configuration space for the PCI controller.
250 @param Count The number of unit to be write.
251 @param Buffer For read operations, the destination buffer to store the results. For
252 write operations, the source buffer to write data from.
254 @retval EFI_SUCCESS The data was read from or written to the PCI root bridge.
255 @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
256 @retval EFI_INVALID_PARAMETER Buffer is NULL.
257 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
262 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
263 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
270 Write PCI configuration space through EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
272 @param PciRootBridgeIo A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
273 @param Pci A pointer to PCI_TYPE00.
274 @param Width Signifies the width of the memory operations.
275 @param Address The address within the PCI configuration space for the PCI controller.
276 @param Count The number of unit to be write.
277 @param Buffer For read operations, the destination buffer to store the results. For
278 write operations, the source buffer to write data from.
280 @retval EFI_SUCCESS The data was read from or written to the PCI root bridge.
281 @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
282 @retval EFI_INVALID_PARAMETER Buffer is NULL.
283 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
287 PciRootBridgeIoWrite (
288 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
,
290 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
297 Read PCI configuration space through EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
299 @param PciRootBridgeIo A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
300 @param Pci A pointer to PCI_TYPE00.
301 @param Width Signifies the width of the memory operations.
302 @param Address The address within the PCI configuration space for the PCI controller.
303 @param Count The number of unit to be read.
304 @param Buffer For read operations, the destination buffer to store the results. For
305 write operations, the source buffer to write data from.
307 @retval EFI_SUCCESS The data was read from or written to the PCI root bridge.
308 @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
309 @retval EFI_INVALID_PARAMETER Buffer is NULL.
310 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
314 PciRootBridgeIoRead (
315 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
,
316 IN PCI_TYPE00
*Pci
, OPTIONAL
317 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,