]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
1. Correct File header to ## @file
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciBus.h
CommitLineData
9060e3ec 1/** @file\r
2 Header files and data structures needed by PCI Bus module.\r
3\r
4Copyright (c) 2006 - 2009, Intel Corporation\r
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
12\r
13**/\r
14\r
15\r
16#ifndef _EFI_PCI_BUS_H_\r
17#define _EFI_PCI_BUS_H_\r
18\r
19#include <PiDxe.h>\r
20\r
21#include <Protocol/LoadedImage.h>\r
22#include <Protocol/PciHostBridgeResourceAllocation.h>\r
23#include <Protocol/PciIo.h>\r
24#include <Protocol/LoadFile2.h>\r
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
31#include <Protocol/BusSpecificDriverOverride.h>\r
32#include <Protocol/IncompatiblePciDeviceSupport.h>\r
33#include <Protocol/PciOverride.h>\r
34#include <Protocol/PciEnumerationComplete.h>\r
35\r
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/PeCoffLib.h>\r
47\r
48#include <IndustryStandard/Pci.h>\r
49#include <IndustryStandard/PeImage.h>\r
50#include <IndustryStandard/Acpi.h>\r
51\r
52typedef struct _PCI_IO_DEVICE PCI_IO_DEVICE;\r
53typedef struct _PCI_BAR PCI_BAR;\r
54\r
55#define EFI_PCI_RID(Bus, Device, Function) (((UINT32)Bus << 8) + ((UINT32)Device << 3) + (UINT32)Function)\r
56#define EFI_PCI_BUS_OF_RID(RID) ((UINT32)RID >> 8)\r
57\r
58#define EFI_PCI_IOV_POLICY_ARI 0x0001\r
59#define EFI_PCI_IOV_POLICY_SRIOV 0x0002\r
60#define EFI_PCI_IOV_POLICY_MRIOV 0x0004\r
61\r
62typedef enum {\r
63 PciBarTypeUnknown = 0,\r
64 PciBarTypeIo16,\r
65 PciBarTypeIo32,\r
66 PciBarTypeMem32,\r
67 PciBarTypePMem32,\r
68 PciBarTypeMem64,\r
69 PciBarTypePMem64,\r
70 PciBarTypeIo,\r
71 PciBarTypeMem,\r
72 PciBarTypeMaxType\r
73} PCI_BAR_TYPE;\r
74\r
75#include "ComponentName.h"\r
76#include "PciIo.h"\r
77#include "PciCommand.h"\r
78#include "PciDeviceSupport.h"\r
79#include "PciEnumerator.h"\r
80#include "PciEnumeratorSupport.h"\r
81#include "PciDriverOverride.h"\r
82#include "PciRomTable.h"\r
83#include "PciOptionRomSupport.h"\r
84#include "PciPowerManagement.h"\r
85#include "PciHotPlugSupport.h"\r
86#include "PciLib.h"\r
87\r
88#define VGABASE1 0x3B0\r
89#define VGALIMIT1 0x3BB\r
90\r
91#define VGABASE2 0x3C0\r
92#define VGALIMIT2 0x3DF\r
93\r
94#define ISABASE 0x100\r
95#define ISALIMIT 0x3FF\r
96\r
97//\r
98// PCI BAR parameters\r
99//\r
100struct _PCI_BAR {\r
101 UINT64 BaseAddress;\r
102 UINT64 Length;\r
103 UINT64 Alignment;\r
104 PCI_BAR_TYPE BarType;\r
105 BOOLEAN Prefetchable;\r
106 UINT8 MemType;\r
107 UINT8 Offset;\r
108};\r
109\r
110//\r
111// defined in PCI Card Specification, 8.0\r
112//\r
113#define PCI_CARD_MEMORY_BASE_0 0x1C\r
114#define PCI_CARD_MEMORY_LIMIT_0 0x20\r
115#define PCI_CARD_MEMORY_BASE_1 0x24\r
116#define PCI_CARD_MEMORY_LIMIT_1 0x28\r
117#define PCI_CARD_IO_BASE_0_LOWER 0x2C\r
118#define PCI_CARD_IO_BASE_0_UPPER 0x2E\r
119#define PCI_CARD_IO_LIMIT_0_LOWER 0x30\r
120#define PCI_CARD_IO_LIMIT_0_UPPER 0x32\r
121#define PCI_CARD_IO_BASE_1_LOWER 0x34\r
122#define PCI_CARD_IO_BASE_1_UPPER 0x36\r
123#define PCI_CARD_IO_LIMIT_1_LOWER 0x38\r
124#define PCI_CARD_IO_LIMIT_1_UPPER 0x3A\r
125#define PCI_CARD_BRIDGE_CONTROL 0x3E\r
126\r
127#define PCI_CARD_PREFETCHABLE_MEMORY_0_ENABLE BIT8\r
128#define PCI_CARD_PREFETCHABLE_MEMORY_1_ENABLE BIT9\r
129\r
130#define PPB_BAR_0 0\r
131#define PPB_BAR_1 1\r
132#define PPB_IO_RANGE 2\r
133#define PPB_MEM32_RANGE 3\r
134#define PPB_PMEM32_RANGE 4\r
135#define PPB_PMEM64_RANGE 5\r
136#define PPB_MEM64_RANGE 0xFF\r
137\r
138#define P2C_BAR_0 0\r
139#define P2C_MEM_1 1\r
140#define P2C_MEM_2 2\r
141#define P2C_IO_1 3\r
142#define P2C_IO_2 4\r
143\r
144#define EFI_BRIDGE_IO32_DECODE_SUPPORTED 0x0001\r
145#define EFI_BRIDGE_PMEM32_DECODE_SUPPORTED 0x0002\r
146#define EFI_BRIDGE_PMEM64_DECODE_SUPPORTED 0x0004\r
147#define EFI_BRIDGE_IO16_DECODE_SUPPORTED 0x0008\r
148#define EFI_BRIDGE_PMEM_MEM_COMBINE_SUPPORTED 0x0010\r
149#define EFI_BRIDGE_MEM64_DECODE_SUPPORTED 0x0020\r
150#define EFI_BRIDGE_MEM32_DECODE_SUPPORTED 0x0040\r
151\r
152#define PCI_MAX_HOST_BRIDGE_NUM 0x0010\r
153\r
154//\r
155// Define option for attribute\r
156//\r
157#define EFI_SET_SUPPORTS 0\r
158#define EFI_SET_ATTRIBUTES 1\r
159\r
160#define PCI_IO_DEVICE_SIGNATURE SIGNATURE_32 ('p', 'c', 'i', 'o')\r
161\r
162struct _PCI_IO_DEVICE {\r
163 UINT32 Signature;\r
164 EFI_HANDLE Handle;\r
165 EFI_PCI_IO_PROTOCOL PciIo;\r
166 LIST_ENTRY Link;\r
167\r
168 EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL PciDriverOverride;\r
169 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
170 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;\r
171 EFI_LOAD_FILE2_PROTOCOL LoadFile2;\r
172\r
173 //\r
174 // PCI configuration space header type\r
175 //\r
176 PCI_TYPE00 Pci;\r
177\r
178 //\r
179 // Bus number, Device number, Function number\r
180 //\r
181 UINT8 BusNumber;\r
182 UINT8 DeviceNumber;\r
183 UINT8 FunctionNumber;\r
184\r
185 //\r
186 // BAR for this PCI Device\r
187 //\r
188 PCI_BAR PciBar[PCI_MAX_BAR];\r
189\r
190 //\r
191 // The bridge device this pci device is subject to\r
192 //\r
193 PCI_IO_DEVICE *Parent;\r
194\r
195 //\r
196 // A linked list for children Pci Device if it is bridge device\r
197 //\r
198 LIST_ENTRY ChildList;\r
199\r
200 //\r
201 // TURE if the PCI bus driver creates the handle for this PCI device\r
202 //\r
203 BOOLEAN Registered;\r
204\r
205 //\r
206 // TRUE if the PCI bus driver successfully allocates the resource required by\r
207 // this PCI device\r
208 //\r
209 BOOLEAN Allocated;\r
210\r
211 //\r
212 // The attribute this PCI device currently set\r
213 //\r
214 UINT64 Attributes;\r
215\r
216 //\r
217 // The attributes this PCI device actually supports\r
218 //\r
219 UINT64 Supports;\r
220\r
221 //\r
222 // The resource decode the bridge supports\r
223 //\r
224 UINT32 Decodes;\r
225\r
226 //\r
227 // The OptionRom Size\r
228 //\r
229 UINT64 RomSize;\r
230\r
231 //\r
232 // The OptionRom Size\r
233 //\r
234 UINT64 RomBase;\r
235\r
236 //\r
237 // TRUE if all OpROM (in device or in platform specific position) have been processed\r
238 //\r
239 BOOLEAN AllOpRomProcessed;\r
240\r
241 //\r
242 // TRUE if there is any EFI driver in the OptionRom\r
243 //\r
244 BOOLEAN BusOverride;\r
245\r
246 //\r
247 // A list tracking reserved resource on a bridge device\r
248 //\r
249 LIST_ENTRY ReservedResourceList;\r
250\r
251 //\r
252 // A list tracking image handle of platform specific overriding driver\r
253 //\r
254 LIST_ENTRY OptionRomDriverList;\r
255\r
256 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *ResourcePaddingDescriptors;\r
257 EFI_HPC_PADDING_ATTRIBUTES PaddingAttributes;\r
258\r
259 BOOLEAN IsPciExp;\r
260 //\r
261 // For SR-IOV\r
262 //\r
263 UINT8 PciExpressCapabilityOffset;\r
264 UINT32 AriCapabilityOffset;\r
265 UINT32 SrIovCapabilityOffset;\r
266 UINT32 MrIovCapabilityOffset;\r
267 PCI_BAR VfPciBar[PCI_MAX_BAR];\r
268 UINT32 SystemPageSize;\r
269 UINT16 InitialVFs;\r
270 UINT16 ReservedBusNum;\r
1ef26783 271 //\r
272 // Per PCI to PCI Bridge spec, I/O window is 4K aligned,\r
273 // but some chipsets support non-stardard I/O window aligments less than 4K.\r
274 // This field is used to support this case.\r
275 //\r
276 UINT16 BridgeIoAlignment;\r
9060e3ec 277};\r
278\r
279#define PCI_IO_DEVICE_FROM_PCI_IO_THIS(a) \\r
280 CR (a, PCI_IO_DEVICE, PciIo, PCI_IO_DEVICE_SIGNATURE)\r
281\r
282#define PCI_IO_DEVICE_FROM_PCI_DRIVER_OVERRIDE_THIS(a) \\r
283 CR (a, PCI_IO_DEVICE, PciDriverOverride, PCI_IO_DEVICE_SIGNATURE)\r
284\r
285#define PCI_IO_DEVICE_FROM_LINK(a) \\r
286 CR (a, PCI_IO_DEVICE, Link, PCI_IO_DEVICE_SIGNATURE)\r
287\r
288#define PCI_IO_DEVICE_FROM_LOAD_FILE2_THIS(a) \\r
289 CR (a, PCI_IO_DEVICE, LoadFile2, PCI_IO_DEVICE_SIGNATURE)\r
290\r
291\r
292\r
293//\r
294// Global Variables\r
295//\r
296extern EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL *gEfiIncompatiblePciDeviceSupport;\r
297extern EFI_DRIVER_BINDING_PROTOCOL gPciBusDriverBinding;\r
298extern EFI_COMPONENT_NAME_PROTOCOL gPciBusComponentName;\r
299extern EFI_COMPONENT_NAME2_PROTOCOL gPciBusComponentName2;\r
300extern BOOLEAN gFullEnumeration;\r
301extern UINTN gPciHostBridgeNumber;\r
302extern EFI_HANDLE gPciHostBrigeHandles[PCI_MAX_HOST_BRIDGE_NUM];\r
303extern UINT64 gAllOne;\r
304extern UINT64 gAllZero;\r
305extern EFI_PCI_PLATFORM_PROTOCOL *gPciPlatformProtocol;\r
306extern EFI_PCI_OVERRIDE_PROTOCOL *gPciOverrideProtocol;\r
307\r
308\r
309\r
310/**\r
311 Macro that checks whether device is a GFX device.\r
312\r
313 @param _p Specified device.\r
314\r
315 @retval TRUE Device is a a GFX device.\r
316 @retval FALSE Device is not a a GFX device.\r
317\r
318**/\r
319#define IS_PCI_GFX(_p) IS_CLASS2 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_OTHER)\r
320\r
321/**\r
322 Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
323 than contains a gEfiPciRootBridgeIoProtocolGuid protocol can be supported.\r
324\r
325 @param This Protocol instance pointer.\r
326 @param Controller Handle of device to test.\r
327 @param RemainingDevicePath Optional parameter use to pick a specific child.\r
328 device to start.\r
329\r
330 @retval EFI_SUCCESS This driver supports this device.\r
331 @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
332 @retval other This driver does not support this device.\r
333\r
334**/\r
335EFI_STATUS\r
336EFIAPI\r
337PciBusDriverBindingSupported (\r
338 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
339 IN EFI_HANDLE Controller,\r
340 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
341 );\r
342\r
343/**\r
344 Start this driver on ControllerHandle and enumerate Pci bus and start\r
345 all device under PCI bus.\r
346\r
347 @param This Protocol instance pointer.\r
348 @param Controller Handle of device to bind driver to.\r
349 @param RemainingDevicePath Optional parameter use to pick a specific child.\r
350 device to start.\r
351\r
352 @retval EFI_SUCCESS This driver is added to ControllerHandle.\r
353 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.\r
354 @retval other This driver does not support this device.\r
355\r
356**/\r
357EFI_STATUS\r
358EFIAPI\r
359PciBusDriverBindingStart (\r
360 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
361 IN EFI_HANDLE Controller,\r
362 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
363 );\r
364\r
365/**\r
366 Stop this driver on ControllerHandle. Support stoping any child handles\r
367 created by this driver.\r
368\r
369 @param This Protocol instance pointer.\r
370 @param Controller Handle of device to stop driver on.\r
371 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
372 children is zero stop the entire bus driver.\r
373 @param ChildHandleBuffer List of Child Handles to Stop.\r
374\r
375 @retval EFI_SUCCESS This driver is removed ControllerHandle.\r
376 @retval other This driver was not removed from this device.\r
377\r
378**/\r
379EFI_STATUS\r
380EFIAPI\r
381PciBusDriverBindingStop (\r
382 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
383 IN EFI_HANDLE Controller,\r
384 IN UINTN NumberOfChildren,\r
385 IN EFI_HANDLE *ChildHandleBuffer\r
386 );\r
387\r
388#endif\r