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