]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciHostBridgeDxe / PciHostBridge.h
1 /** @file
2
3 The Header file of the Pci Host Bridge Driver.
4
5 Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef _PCI_HOST_BRIDGE_H_
11 #define _PCI_HOST_BRIDGE_H_
12
13 #include <PiDxe.h>
14 #include <IndustryStandard/Acpi.h>
15 #include <Library/UefiDriverEntryPoint.h>
16 #include <Library/MemoryAllocationLib.h>
17 #include <Library/PciHostBridgeLib.h>
18 #include <Protocol/PciHostBridgeResourceAllocation.h>
19 #include <Protocol/IoMmu.h>
20
21 #include "PciRootBridge.h"
22
23 #define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32 ('p', 'h', 'b', 'g')
24 typedef struct {
25 UINTN Signature;
26 EFI_HANDLE Handle;
27 LIST_ENTRY RootBridges;
28 BOOLEAN CanRestarted;
29 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL ResAlloc;
30 } PCI_HOST_BRIDGE_INSTANCE;
31
32 #define PCI_HOST_BRIDGE_FROM_THIS(a) CR (a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)
33
34 //
35 // Macros to translate device address to host address and vice versa. According
36 // to UEFI 2.7, device address = host address + translation offset.
37 //
38 #define TO_HOST_ADDRESS(DeviceAddress, TranslationOffset) ((DeviceAddress) - (TranslationOffset))
39 #define TO_DEVICE_ADDRESS(HostAddress, TranslationOffset) ((HostAddress) + (TranslationOffset))
40
41 //
42 // Driver Entry Point
43 //
44
45 /**
46
47 Entry point of this driver.
48
49 @param ImageHandle - Image handle of this driver.
50 @param SystemTable - Pointer to standard EFI system table.
51
52 @retval EFI_SUCCESS - Succeed.
53 @retval EFI_DEVICE_ERROR - Fail to install PCI_ROOT_BRIDGE_IO protocol.
54
55 **/
56 EFI_STATUS
57 EFIAPI
58 InitializePciHostBridge (
59 IN EFI_HANDLE ImageHandle,
60 IN EFI_SYSTEM_TABLE *SystemTable
61 );
62
63 //
64 // HostBridge Resource Allocation interface
65 //
66
67 /**
68
69 Enter a certain phase of the PCI enumeration process.
70
71 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
72 @param Phase The phase during enumeration.
73
74 @retval EFI_SUCCESS Succeed.
75 @retval EFI_INVALID_PARAMETER Wrong phase parameter passed in.
76 @retval EFI_NOT_READY Resources have not been submitted yet.
77
78 **/
79 EFI_STATUS
80 EFIAPI
81 NotifyPhase (
82 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
83 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
84 );
85
86 /**
87
88 Return the device handle of the next PCI root bridge that is associated with
89 this Host Bridge.
90
91 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
92 @param RootBridgeHandle Returns the device handle of the next PCI Root Bridge.
93 On input, it holds the RootBridgeHandle returned by the most
94 recent call to GetNextRootBridge().The handle for the first
95 PCI Root Bridge is returned if RootBridgeHandle is NULL on input.
96
97 @retval EFI_SUCCESS Succeed.
98 @retval EFI_NOT_FOUND Next PCI root bridge not found.
99 @retval EFI_INVALID_PARAMETER Wrong parameter passed in.
100
101 **/
102 EFI_STATUS
103 EFIAPI
104 GetNextRootBridge (
105 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
106 IN OUT EFI_HANDLE *RootBridgeHandle
107 );
108
109 /**
110
111 Returns the attributes of a PCI Root Bridge.
112
113 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
114 @param RootBridgeHandle - The device handle of the PCI Root Bridge
115 that the caller is interested in
116 @param Attributes - The pointer to attributes of the PCI Root Bridge
117
118 @retval EFI_SUCCESS - Succeed.
119 @retval EFI_INVALID_PARAMETER - Attributes parameter passed in is NULL or
120 @retval RootBridgeHandle is not an EFI_HANDLE
121 @retval that was returned on a previous call to
122 @retval GetNextRootBridge().
123
124 **/
125 EFI_STATUS
126 EFIAPI
127 GetAttributes (
128 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
129 IN EFI_HANDLE RootBridgeHandle,
130 OUT UINT64 *Attributes
131 );
132
133 /**
134
135 This is the request from the PCI enumerator to set up
136 the specified PCI Root Bridge for bus enumeration process.
137
138 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
139 @param RootBridgeHandle - The PCI Root Bridge to be set up.
140 @param Configuration - Pointer to the pointer to the PCI bus resource descriptor.
141
142 @retval EFI_SUCCESS - Succeed.
143 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
144 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
145
146 **/
147 EFI_STATUS
148 EFIAPI
149 StartBusEnumeration (
150 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
151 IN EFI_HANDLE RootBridgeHandle,
152 OUT VOID **Configuration
153 );
154
155 /**
156
157 This function programs the PCI Root Bridge hardware so that
158 it decodes the specified PCI bus range.
159
160 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
161 @param RootBridgeHandle - The PCI Root Bridge whose bus range is to be programmed.
162 @param Configuration - The pointer to the PCI bus resource descriptor.
163
164 @retval EFI_SUCCESS - Succeed.
165 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
166
167 **/
168 EFI_STATUS
169 EFIAPI
170 SetBusNumbers (
171 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
172 IN EFI_HANDLE RootBridgeHandle,
173 IN VOID *Configuration
174 );
175
176 /**
177
178 Submits the I/O and memory resource requirements for the specified PCI Root Bridge.
179
180 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
181 @param RootBridgeHandle - The PCI Root Bridge whose I/O and memory resource requirements
182 are being submitted
183 @param Configuration - The pointer to the PCI I/O and PCI memory resource descriptor
184
185 @retval EFI_SUCCESS - Succeed.
186 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
187
188 **/
189 EFI_STATUS
190 EFIAPI
191 SubmitResources (
192 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
193 IN EFI_HANDLE RootBridgeHandle,
194 IN VOID *Configuration
195 );
196
197 /**
198
199 This function returns the proposed resource settings for the specified
200 PCI Root Bridge.
201
202 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
203 @param RootBridgeHandle - The PCI Root Bridge handle.
204 @param Configuration - The pointer to the pointer to the PCI I/O
205 and memory resource descriptor.
206
207 @retval EFI_SUCCESS - Succeed.
208 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
209 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
210
211 **/
212 EFI_STATUS
213 EFIAPI
214 GetProposedResources (
215 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
216 IN EFI_HANDLE RootBridgeHandle,
217 OUT VOID **Configuration
218 );
219
220 /**
221
222 This function is called for all the PCI controllers that the PCI
223 bus driver finds. Can be used to Preprogram the controller.
224
225 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
226 @param RootBridgeHandle - The PCI Root Bridge handle.
227 @param PciAddress - Address of the controller on the PCI bus.
228 @param Phase - The Phase during resource allocation.
229
230 @retval EFI_SUCCESS - Succeed.
231 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
232
233 **/
234 EFI_STATUS
235 EFIAPI
236 PreprocessController (
237 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
238 IN EFI_HANDLE RootBridgeHandle,
239 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,
240 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
241 );
242
243 /**
244 This routine constructs the resource descriptors for all root bridges and call PciHostBridgeResourceConflict().
245
246 @param HostBridge The Host Bridge Instance where the resource adjustment happens.
247 **/
248 VOID
249 ResourceConflict (
250 IN PCI_HOST_BRIDGE_INSTANCE *HostBridge
251 );
252
253 /**
254 This routine gets translation offset from a root bridge instance by resource type.
255
256 @param RootBridge The Root Bridge Instance for the resources.
257 @param ResourceType The Resource Type of the translation offset.
258
259 @retval The Translation Offset of the specified resource.
260 **/
261 UINT64
262 GetTranslationByResourceType (
263 IN PCI_ROOT_BRIDGE_INSTANCE *RootBridge,
264 IN PCI_RESOURCE_TYPE ResourceType
265 );
266
267 extern EFI_CPU_IO2_PROTOCOL *mCpuIo;
268 extern EDKII_IOMMU_PROTOCOL *mIoMmu;
269
270 #endif