]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBus.h
Move gEfiPciOptionRomTableGuid from IntelFrameworkModulePkg to the DuetPkg
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / PciBusDxe / PciBus.h
CommitLineData
eeefcb9d 1/** @file\r
ead42efc 2\r
ea5632e5 3Copyright (c) 2006, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
ead42efc 11\r
3db51098 12**/\r
ead42efc 13\r
ead42efc 14\r
eeefcb9d 15#ifndef _EFI_PCI_BUS_H_\r
16#define _EFI_PCI_BUS_H_\r
ead42efc 17\r
ed7748fe 18\r
694b922c 19#include <FrameworkDxe.h>\r
20\r
ed7748fe 21\r
ead42efc 22#include <Protocol/LoadedImage.h>\r
23#include <Protocol/PciHostBridgeResourceAllocation.h>\r
24#include <Protocol/PciIo.h>\r
8e6b0dcb 25#include <Protocol/LoadFile2.h>\r
ead42efc 26#include <Protocol/PciRootBridgeIo.h>\r
27#include <Protocol/PciHotPlugRequest.h>\r
28#include <Protocol/DevicePath.h>\r
29#include <Protocol/PciPlatform.h>\r
30#include <Protocol/PciHotPlugInit.h>\r
31#include <Protocol/Decompress.h>\r
ead42efc 32#include <Protocol/BusSpecificDriverOverride.h>\r
33#include <Protocol/UgaIo.h>\r
ea5632e5 34#include <Protocol/IncompatiblePciDeviceSupport.h>\r
ed7748fe 35\r
ead42efc 36#include <Library/DebugLib.h>\r
37#include <Library/UefiDriverEntryPoint.h>\r
38#include <Library/BaseLib.h>\r
39#include <Library/UefiLib.h>\r
40#include <Library/BaseMemoryLib.h>\r
41#include <Library/ReportStatusCodeLib.h>\r
42#include <Library/MemoryAllocationLib.h>\r
43#include <Library/UefiBootServicesTableLib.h>\r
44#include <Library/DevicePathLib.h>\r
45#include <Library/PcdLib.h>\r
46#include <Library/PciIncompatibleDeviceSupportLib.h>\r
2fb718b0 47#include <Library/PeCoffLib.h>\r
ead42efc 48\r
bc14bdb3 49#include <IndustryStandard/Pci.h>\r
b1ef4015 50#include <IndustryStandard/PeImage.h>\r
ead42efc 51#include <IndustryStandard/Acpi.h>\r
52#include "ComponentName.h"\r
53\r
9f6531d1 54\r
55//\r
56// Global Variables\r
57//\r
58extern EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL *gEfiIncompatiblePciDeviceSupport;\r
59extern EFI_DRIVER_BINDING_PROTOCOL gPciBusDriverBinding;\r
60extern EFI_COMPONENT_NAME_PROTOCOL gPciBusComponentName;\r
61extern EFI_COMPONENT_NAME2_PROTOCOL gPciBusComponentName2;\r
62\r
ead42efc 63//\r
64// Driver Produced Protocol Prototypes\r
65//\r
66\r
67#define VGABASE1 0x3B0\r
68#define VGALIMIT1 0x3BB\r
69\r
70#define VGABASE2 0x3C0\r
71#define VGALIMIT2 0x3DF\r
72\r
73#define ISABASE 0x100\r
74#define ISALIMIT 0x3FF\r
75\r
76typedef enum {\r
77 PciBarTypeUnknown = 0,\r
78 PciBarTypeIo16,\r
79 PciBarTypeIo32,\r
80 PciBarTypeMem32,\r
81 PciBarTypePMem32,\r
82 PciBarTypeMem64,\r
83 PciBarTypePMem64,\r
84 PciBarTypeIo,\r
85 PciBarTypeMem,\r
86 PciBarTypeMaxType\r
87} PCI_BAR_TYPE;\r
88\r
89typedef struct {\r
90 UINT64 BaseAddress;\r
91 UINT64 Length;\r
92 UINT64 Alignment;\r
93 PCI_BAR_TYPE BarType;\r
94 BOOLEAN Prefetchable;\r
95 UINT8 MemType;\r
96 UINT8 Offset;\r
97} PCI_BAR;\r
98\r
99#define PPB_BAR_0 0\r
100#define PPB_BAR_1 1\r
101#define PPB_IO_RANGE 2\r
102#define PPB_MEM32_RANGE 3\r
103#define PPB_PMEM32_RANGE 4\r
104#define PPB_PMEM64_RANGE 5\r
105#define PPB_MEM64_RANGE 0xFF\r
106\r
107#define P2C_BAR_0 0\r
108#define P2C_MEM_1 1\r
109#define P2C_MEM_2 2\r
110#define P2C_IO_1 3\r
111#define P2C_IO_2 4\r
112\r
f02bd376 113#define PCI_IO_DEVICE_SIGNATURE SIGNATURE_32 ('p', 'c', 'i', 'o')\r
ead42efc 114\r
115#define EFI_BRIDGE_IO32_DECODE_SUPPORTED 0x0001\r
116#define EFI_BRIDGE_PMEM32_DECODE_SUPPORTED 0x0002\r
117#define EFI_BRIDGE_PMEM64_DECODE_SUPPORTED 0x0004\r
118#define EFI_BRIDGE_IO16_DECODE_SUPPORTED 0x0008\r
119#define EFI_BRIDGE_PMEM_MEM_COMBINE_SUPPORTED 0x0010\r
120#define EFI_BRIDGE_MEM64_DECODE_SUPPORTED 0x0020\r
121#define EFI_BRIDGE_MEM32_DECODE_SUPPORTED 0x0040\r
122\r
123#define PCI_MAX_HOST_BRIDGE_NUM 0x0010\r
ead42efc 124\r
125//\r
126// Define option for attribute\r
127//\r
128#define EFI_SET_SUPPORTS 0\r
129#define EFI_SET_ATTRIBUTES 1\r
130\r
131typedef struct _PCI_IO_DEVICE {\r
132 UINT32 Signature;\r
133 EFI_HANDLE Handle;\r
134 EFI_PCI_IO_PROTOCOL PciIo;\r
135 LIST_ENTRY Link;\r
136\r
137 EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL PciDriverOverride;\r
138 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
139 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;\r
8e6b0dcb 140 EFI_LOAD_FILE2_PROTOCOL LoadFile2;\r
ead42efc 141\r
142 //\r
143 // PCI configuration space header type\r
144 //\r
145 PCI_TYPE00 Pci;\r
146\r
147 //\r
148 // Bus number, Device number, Function number\r
149 //\r
150 UINT8 BusNumber;\r
151 UINT8 DeviceNumber;\r
152 UINT8 FunctionNumber;\r
153\r
154 //\r
155 // BAR for this PCI Device\r
156 //\r
157 PCI_BAR PciBar[PCI_MAX_BAR];\r
158\r
159 //\r
160 // The bridge device this pci device is subject to\r
161 //\r
162 struct _PCI_IO_DEVICE *Parent;\r
163\r
164 //\r
165 // A linked list for children Pci Device if it is bridge device\r
166 //\r
167 LIST_ENTRY ChildList;\r
168\r
169 //\r
170 // TURE if the PCI bus driver creates the handle for this PCI device\r
171 //\r
172 BOOLEAN Registered;\r
173\r
174 //\r
175 // TRUE if the PCI bus driver successfully allocates the resource required by\r
176 // this PCI device\r
177 //\r
178 BOOLEAN Allocated;\r
179\r
180 //\r
181 // The attribute this PCI device currently set\r
182 //\r
183 UINT64 Attributes;\r
184\r
185 //\r
186 // The attributes this PCI device actually supports\r
187 //\r
188 UINT64 Supports;\r
189\r
190 //\r
191 // The resource decode the bridge supports\r
192 //\r
193 UINT32 Decodes;\r
194\r
195 //\r
196 // The OptionRom Size\r
197 //\r
198 UINT64 RomSize;\r
199\r
200 //\r
201 // The OptionRom Size\r
202 //\r
203 UINT64 RomBase;\r
204\r
205 //\r
206 // TRUE if all OpROM (in device or in platform specific position) have been processed\r
207 //\r
208 BOOLEAN AllOpRomProcessed;\r
209\r
210 //\r
211 // TRUE if there is any EFI driver in the OptionRom\r
212 //\r
213 BOOLEAN BusOverride;\r
214\r
215 //\r
216 // A list tracking reserved resource on a bridge device\r
217 //\r
218 LIST_ENTRY ReservedResourceList;\r
219\r
220 //\r
221 // A list tracking image handle of platform specific overriding driver\r
222 //\r
223 LIST_ENTRY OptionRomDriverList;\r
224\r
225 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *ResourcePaddingDescriptors;\r
226 EFI_HPC_PADDING_ATTRIBUTES PaddingAttributes;\r
227\r
228 BOOLEAN IsPciExp;\r
229\r
230} PCI_IO_DEVICE;\r
231\r
232\r
233#define PCI_IO_DEVICE_FROM_PCI_IO_THIS(a) \\r
234 CR (a, PCI_IO_DEVICE, PciIo, PCI_IO_DEVICE_SIGNATURE)\r
235\r
236#define PCI_IO_DEVICE_FROM_PCI_DRIVER_OVERRIDE_THIS(a) \\r
237 CR (a, PCI_IO_DEVICE, PciDriverOverride, PCI_IO_DEVICE_SIGNATURE)\r
238\r
239#define PCI_IO_DEVICE_FROM_LINK(a) \\r
240 CR (a, PCI_IO_DEVICE, Link, PCI_IO_DEVICE_SIGNATURE)\r
241\r
8e6b0dcb 242#define PCI_IO_DEVICE_FROM_LOAD_FILE2_THIS(a) \\r
243 CR (a, PCI_IO_DEVICE, LoadFile2, PCI_IO_DEVICE_SIGNATURE)\r
244\r
ead42efc 245//\r
246// Global Variables\r
247//\r
ead42efc 248extern LIST_ENTRY gPciDevicePool;\r
249extern BOOLEAN gFullEnumeration;\r
250extern UINTN gPciHostBridgeNumber;\r
251extern EFI_HANDLE gPciHostBrigeHandles[PCI_MAX_HOST_BRIDGE_NUM];\r
252extern UINT64 gAllOne;\r
253extern UINT64 gAllZero;\r
254\r
255extern EFI_PCI_PLATFORM_PROTOCOL *gPciPlatformProtocol;\r
256\r
257#include "PciIo.h"\r
258#include "PciCommand.h"\r
259#include "PciDeviceSupport.h"\r
260#include "PciEnumerator.h"\r
261#include "PciEnumeratorSupport.h"\r
262#include "PciDriverOverride.h"\r
263#include "PciRomTable.h"\r
264#include "PciOptionRomSupport.h"\r
265#include "PciPowerManagement.h"\r
266#include "PciHotPlugSupport.h"\r
267#include "PciLib.h"\r
268\r
269//\r
270// PCI Bus Support Function Prototypes\r
271//\r
eeefcb9d 272/**\r
273 Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
274 than contains a gEfiPciRootBridgeIoProtocolGuid protocol can be supported.\r
275\r
276 @param This Protocol instance pointer.\r
277 @param ControllerHandle Handle of device to test.\r
278 @param RemainingDevicePath Optional parameter use to pick a specific child.\r
279 device to start.\r
280\r
281 @retval EFI_SUCCESS This driver supports this device.\r
282 @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
283 @retval other This driver does not support this device.\r
284\r
285**/\r
ead42efc 286EFI_STATUS\r
287EFIAPI\r
288PciBusDriverBindingSupported (\r
289 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
290 IN EFI_HANDLE Controller,\r
291 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
292 );\r
293\r
eeefcb9d 294/**\r
295 Start this driver on ControllerHandle and enumerate Pci bus and start\r
296 all device under PCI bus.\r
297\r
298 @param This Protocol instance pointer.\r
299 @param ControllerHandle Handle of device to bind driver to.\r
300 @param RemainingDevicePath Optional parameter use to pick a specific child.\r
301 device to start.\r
302\r
303 @retval EFI_SUCCESS This driver is added to ControllerHandle.\r
304 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.\r
305 @retval other This driver does not support this device.\r
306\r
307**/\r
ead42efc 308EFI_STATUS\r
309EFIAPI\r
310PciBusDriverBindingStart (\r
311 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
312 IN EFI_HANDLE Controller,\r
313 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
314 );\r
315\r
eeefcb9d 316/**\r
317 Stop this driver on ControllerHandle. Support stoping any child handles\r
318 created by this driver.\r
319\r
320 @param This Protocol instance pointer.\r
321 @param ControllerHandle Handle of device to stop driver on.\r
322 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
323 children is zero stop the entire bus driver.\r
324 @param ChildHandleBuffer List of Child Handles to Stop.\r
325\r
326 @retval EFI_SUCCESS This driver is removed ControllerHandle.\r
327 @retval other This driver was not removed from this device.\r
328\r
329**/\r
ead42efc 330EFI_STATUS\r
331EFIAPI\r
332PciBusDriverBindingStop (\r
333 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
334 IN EFI_HANDLE Controller,\r
335 IN UINTN NumberOfChildren,\r
336 IN EFI_HANDLE *ChildHandleBuffer\r
337 );\r
338\r
1833218d 339#define IS_PCI_GFX(_p) IS_CLASS2 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_OTHER)\r
340\r
ead42efc 341#endif\r