]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/PciBusDxe/PciHotPlugSupport.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciHotPlugSupport.h
CommitLineData
9060e3ec 1/** @file\r
2 PCI Hot Plug support functions declaration for PCI Bus module.\r
3\r
fcdfcdbf 4Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
9060e3ec 6\r
7**/\r
8\r
9#ifndef _EFI_PCI_HOT_PLUG_SUPPORT_H_\r
10#define _EFI_PCI_HOT_PLUG_SUPPORT_H_\r
11\r
12//\r
13// stall 1 second, its unit is 100ns\r
14//\r
1436aea4 15#define STALL_1_SECOND 1000000\r
9060e3ec 16\r
17//\r
18// PCI Hot Plug controller private data\r
19//\r
20typedef struct {\r
1436aea4
MK
21 EFI_EVENT Event;\r
22 BOOLEAN Found;\r
23 BOOLEAN Initialized;\r
24 VOID *Padding;\r
9060e3ec 25} ROOT_HPC_DATA;\r
26\r
27//\r
fcdfcdbf 28// Reference of some global variables\r
9060e3ec 29//\r
1436aea4
MK
30extern EFI_PCI_HOT_PLUG_INIT_PROTOCOL *gPciHotPlugInit;\r
31extern EFI_HPC_LOCATION *gPciRootHpcPool;\r
32extern ROOT_HPC_DATA *gPciRootHpcData;\r
9060e3ec 33\r
34/**\r
35 Event notification function to set Hot Plug controller status.\r
36\r
37 @param Event The event that invoke this function.\r
38 @param Context The calling context, pointer to ROOT_HPC_DATA.\r
39\r
40**/\r
41VOID\r
42EFIAPI\r
43PciHPCInitialized (\r
1436aea4
MK
44 IN EFI_EVENT Event,\r
45 IN VOID *Context\r
9060e3ec 46 );\r
47\r
48/**\r
fcdfcdbf 49 Compare two device paths to check if they are exactly same.\r
9060e3ec 50\r
51 @param DevicePath1 A pointer to the first device path data structure.\r
52 @param DevicePath2 A pointer to the second device path data structure.\r
53\r
54 @retval TRUE They are same.\r
55 @retval FALSE They are not same.\r
56\r
57**/\r
58BOOLEAN\r
59EfiCompareDevicePath (\r
1436aea4
MK
60 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath1,\r
61 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath2\r
9060e3ec 62 );\r
63\r
64/**\r
65 Check hot plug support and initialize root hot plug private data.\r
66\r
67 If Hot Plug is supported by the platform, call PCI Hot Plug Init protocol\r
68 to get PCI Hot Plug controller's information and constructor the root hot plug\r
69 private data structure.\r
70\r
71 @retval EFI_SUCCESS They are same.\r
fcdfcdbf 72 @retval EFI_UNSUPPORTED No PCI Hot Plug controller on the platform.\r
9060e3ec 73 @retval EFI_OUT_OF_RESOURCES No memory to constructor root hot plug private\r
74 data structure.\r
75\r
76**/\r
77EFI_STATUS\r
78InitializeHotPlugSupport (\r
79 VOID\r
80 );\r
81\r
82/**\r
83 Test whether PCI device is hot plug bus.\r
84\r
85 @param PciIoDevice PCI device instance.\r
86\r
87 @retval TRUE PCI device is a hot plug bus.\r
88 @retval FALSE PCI device is not a hot plug bus.\r
89\r
90**/\r
91BOOLEAN\r
92IsPciHotPlugBus (\r
1436aea4 93 PCI_IO_DEVICE *PciIoDevice\r
9060e3ec 94 );\r
95\r
96/**\r
97 Test whether device path is for root pci hot plug bus.\r
98\r
99 @param HpbDevicePath A pointer to device path data structure to be tested.\r
100 @param HpIndex If HpIndex is not NULL, return the index of root hot\r
fcdfcdbf 101 plug in global array when TRUE is returned.\r
9060e3ec 102\r
103 @retval TRUE The device path is for root pci hot plug bus.\r
104 @retval FALSE The device path is not for root pci hot plug bus.\r
105\r
106**/\r
107BOOLEAN\r
108IsRootPciHotPlugBus (\r
1436aea4
MK
109 IN EFI_DEVICE_PATH_PROTOCOL *HpbDevicePath,\r
110 OUT UINTN *HpIndex OPTIONAL\r
9060e3ec 111 );\r
112\r
113/**\r
114 Test whether device path is for root pci hot plug controller.\r
115\r
116 @param HpcDevicePath A pointer to device path data structure to be tested.\r
117 @param HpIndex If HpIndex is not NULL, return the index of root hot\r
fcdfcdbf 118 plug in global array when TRUE is returned.\r
9060e3ec 119\r
120 @retval TRUE The device path is for root pci hot plug controller.\r
121 @retval FALSE The device path is not for root pci hot plug controller.\r
122\r
123**/\r
124BOOLEAN\r
125IsRootPciHotPlugController (\r
1436aea4
MK
126 IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath,\r
127 OUT UINTN *HpIndex\r
9060e3ec 128 );\r
129\r
130/**\r
131 Creating event object for PCI Hot Plug controller.\r
132\r
133 @param HpIndex Index of hot plug device in global array.\r
fcdfcdbf 134 @param Event The returned event that invoke this function.\r
9060e3ec 135\r
fcdfcdbf 136 @return Status of create event.\r
9060e3ec 137\r
138**/\r
139EFI_STATUS\r
140CreateEventForHpc (\r
141 IN UINTN HpIndex,\r
142 OUT EFI_EVENT *Event\r
143 );\r
144\r
145/**\r
146 Wait for all root PCI Hot Plug controller finished initializing.\r
147\r
148 @param TimeoutInMicroSeconds Microseconds to wait for all root HPCs' initialization.\r
149\r
150 @retval EFI_SUCCESS All HPCs initialization finished.\r
151 @retval EFI_TIMEOUT Not ALL HPCs initialization finished in Microseconds.\r
152\r
153**/\r
154EFI_STATUS\r
155AllRootHPCInitialized (\r
1436aea4 156 IN UINTN TimeoutInMicroSeconds\r
9060e3ec 157 );\r
158\r
159/**\r
160 Check whether PCI-PCI bridge has PCI Hot Plug capability register block.\r
161\r
162 @param PciIoDevice A Pointer to the PCI-PCI bridge.\r
163\r
164 @retval TRUE PCI device is HPC.\r
165 @retval FALSE PCI device is not HPC.\r
166\r
167**/\r
168BOOLEAN\r
169IsSHPC (\r
1436aea4 170 IN PCI_IO_DEVICE *PciIoDevice\r
9060e3ec 171 );\r
172\r
ffdd3376
LE
173/**\r
174 Check whether PciIoDevice supports PCIe hotplug.\r
175\r
176 This is equivalent to the following condition:\r
177 - the device is either a PCIe switch downstream port or a root port,\r
178 - and the device has the SlotImplemented bit set in its PCIe capability\r
179 register,\r
180 - and the device has the HotPlugCapable bit set in its slot capabilities\r
181 register.\r
182\r
183 @param[in] PciIoDevice The device being checked.\r
184\r
fcdfcdbf 185 @retval TRUE PciIoDevice is a PCIe port that accepts a hot-plugged device.\r
ffdd3376
LE
186 @retval FALSE Otherwise.\r
187\r
188**/\r
189BOOLEAN\r
190SupportsPcieHotplug (\r
1436aea4 191 IN PCI_IO_DEVICE *PciIoDevice\r
ffdd3376
LE
192 );\r
193\r
9060e3ec 194/**\r
195 Get resource padding if the specified PCI bridge is a hot plug bus.\r
196\r
197 @param PciIoDevice PCI bridge instance.\r
198\r
199**/\r
200VOID\r
201GetResourcePaddingForHpb (\r
1436aea4 202 IN PCI_IO_DEVICE *PciIoDevice\r
9060e3ec 203 );\r
204\r
205#endif\r