1 /** @file 2 Internal library declaration for PCI Bus module. 3 4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR> 5 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_LIB_H_ 16 #define _EFI_PCI_LIB_H_ 17 18 19 typedef struct { 20 EFI_HANDLE Handle; 21 } EFI_DEVICE_HANDLE_EXTENDED_DATA_PAYLOAD; 22 23 typedef struct { 24 UINT32 Bar; 25 UINT16 DevicePathSize; 26 UINT16 ReqResSize; 27 UINT16 AllocResSize; 28 UINT8 *DevicePath; 29 UINT8 *ReqRes; 30 UINT8 *AllocRes; 31 } EFI_RESOURCE_ALLOC_FAILURE_ERROR_DATA_PAYLOAD; 32 33 34 /** 35 Retrieve the PCI Card device BAR information via PciIo interface. 36 37 @param PciIoDevice PCI Card device instance. 38 39 **/ 40 VOID 41 GetBackPcCardBar ( 42 IN PCI_IO_DEVICE *PciIoDevice 43 ); 44 45 /** 46 Remove rejected pci device from specific root bridge 47 handle. 48 49 @param RootBridgeHandle Specific parent root bridge handle. 50 @param Bridge Bridge device instance. 51 52 **/ 53 VOID 54 RemoveRejectedPciDevices ( 55 IN EFI_HANDLE RootBridgeHandle, 56 IN PCI_IO_DEVICE *Bridge 57 ); 58 59 /** 60 Submits the I/O and memory resource requirements for the specified PCI Host Bridge. 61 62 @param PciResAlloc Point to protocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL. 63 64 @retval EFI_SUCCESS Successfully finished resource allocation. 65 @retval EFI_NOT_FOUND Cannot get root bridge instance. 66 @retval EFI_OUT_OF_RESOURCES Platform failed to program the resources if no hot plug supported. 67 @retval other Some error occurred when allocating resources for the PCI Host Bridge. 68 69 @note Feature flag PcdPciBusHotplugDeviceSupport determine whether need support hotplug. 70 71 **/ 72 EFI_STATUS 73 PciHostBridgeResourceAllocator ( 74 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc 75 ); 76 77 /** 78 Allocate NumberOfBuses buses and return the next available PCI bus number. 79 80 @param Bridge Bridge device instance. 81 @param StartBusNumber Current available PCI bus number. 82 @param NumberOfBuses Number of buses enumerated below the StartBusNumber. 83 @param NextBusNumber Next available PCI bus number. 84 85 @retval EFI_SUCCESS Available bus number resource is enough. Next available PCI bus number 86 is returned in NextBusNumber. 87 @retval EFI_OUT_OF_RESOURCES Available bus number resource is not enough for allocation. 88 89 **/ 90 EFI_STATUS 91 PciAllocateBusNumber ( 92 IN PCI_IO_DEVICE *Bridge, 93 IN UINT8 StartBusNumber, 94 IN UINT8 NumberOfBuses, 95 OUT UINT8 *NextBusNumber 96 ); 97 98 /** 99 Scan pci bus and assign bus number to the given PCI bus system. 100 101 @param Bridge Bridge device instance. 102 @param StartBusNumber start point. 103 @param SubBusNumber Point to sub bus number. 104 @param PaddedBusRange Customized bus number. 105 106 @retval EFI_SUCCESS Successfully scanned and assigned bus number. 107 @retval other Some error occurred when scanning pci bus. 108 109 @note Feature flag PcdPciBusHotplugDeviceSupport determine whether need support hotplug. 110 111 **/ 112 EFI_STATUS 113 PciScanBus ( 114 IN PCI_IO_DEVICE *Bridge, 115 IN UINT8 StartBusNumber, 116 OUT UINT8 *SubBusNumber, 117 OUT UINT8 *PaddedBusRange 118 ); 119 120 /** 121 Process Option Rom on the specified root bridge. 122 123 @param Bridge Pci root bridge device instance. 124 125 @retval EFI_SUCCESS Success process. 126 @retval other Some error occurred when processing Option Rom on the root bridge. 127 128 **/ 129 EFI_STATUS 130 PciRootBridgeP2CProcess ( 131 IN PCI_IO_DEVICE *Bridge 132 ); 133 134 /** 135 Process Option Rom on the specified host bridge. 136 137 @param PciResAlloc Pointer to instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL. 138 139 @retval EFI_SUCCESS Success process. 140 @retval EFI_NOT_FOUND Can not find the root bridge instance. 141 @retval other Some error occurred when processing Option Rom on the host bridge. 142 143 **/ 144 EFI_STATUS 145 PciHostBridgeP2CProcess ( 146 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc 147 ); 148 149 /** 150 This function is used to enumerate the entire host bridge 151 in a given platform. 152 153 @param PciResAlloc A pointer to the PCI Host Resource Allocation protocol. 154 155 @retval EFI_SUCCESS Successfully enumerated the host bridge. 156 @retval EFI_OUT_OF_RESOURCES No enough memory available. 157 @retval other Some error occurred when enumerating the host bridge. 158 159 **/ 160 EFI_STATUS 161 PciHostBridgeEnumerator ( 162 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc 163 ); 164 165 #endif 166