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