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