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