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