]>
Commit | Line | Data |
---|---|---|
9060e3ec | 1 | /** @file\r |
2 | Supporting functions declaration for PCI devices management.\r | |
3 | \r | |
fcdfcdbf | 4 | Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
9060e3ec | 6 | \r |
7 | **/\r | |
8 | \r | |
9 | #ifndef _EFI_PCI_DEVICE_SUPPORT_H_\r | |
10 | #define _EFI_PCI_DEVICE_SUPPORT_H_\r | |
11 | \r | |
12 | /**\r | |
13 | Initialize the PCI devices pool.\r | |
14 | \r | |
15 | **/\r | |
16 | VOID\r | |
17 | InitializePciDevicePool (\r | |
18 | VOID\r | |
19 | );\r | |
20 | \r | |
21 | /**\r | |
22 | Insert a root bridge into PCI device pool.\r | |
23 | \r | |
24 | @param RootBridge A pointer to the PCI_IO_DEVICE.\r | |
25 | \r | |
26 | **/\r | |
27 | VOID\r | |
28 | InsertRootBridge (\r | |
29 | IN PCI_IO_DEVICE *RootBridge\r | |
30 | );\r | |
31 | \r | |
32 | /**\r | |
33 | This function is used to insert a PCI device node under\r | |
34 | a bridge.\r | |
35 | \r | |
36 | @param Bridge The PCI bridge.\r | |
37 | @param PciDeviceNode The PCI device needs inserting.\r | |
38 | \r | |
39 | **/\r | |
40 | VOID\r | |
41 | InsertPciDevice (\r | |
42 | IN PCI_IO_DEVICE *Bridge,\r | |
43 | IN PCI_IO_DEVICE *PciDeviceNode\r | |
44 | );\r | |
45 | \r | |
46 | /**\r | |
fcdfcdbf | 47 | Destroy root bridge and remove it from device tree.\r |
9060e3ec | 48 | \r |
49 | @param RootBridge The bridge want to be removed.\r | |
50 | \r | |
51 | **/\r | |
52 | VOID\r | |
53 | DestroyRootBridge (\r | |
54 | IN PCI_IO_DEVICE *RootBridge\r | |
55 | );\r | |
56 | \r | |
57 | /**\r | |
58 | Destroy all the pci device node under the bridge.\r | |
59 | Bridge itself is not included.\r | |
60 | \r | |
61 | @param Bridge A pointer to the PCI_IO_DEVICE.\r | |
62 | \r | |
63 | **/\r | |
64 | VOID\r | |
65 | DestroyPciDeviceTree (\r | |
66 | IN PCI_IO_DEVICE *Bridge\r | |
67 | );\r | |
68 | \r | |
69 | /**\r | |
70 | Destroy all device nodes under the root bridge\r | |
71 | specified by Controller.\r | |
72 | \r | |
73 | The root bridge itself is also included.\r | |
74 | \r | |
75 | @param Controller Root bridge handle.\r | |
76 | \r | |
fcdfcdbf | 77 | @retval EFI_SUCCESS Destroy all device nodes successfully.\r |
9060e3ec | 78 | @retval EFI_NOT_FOUND Cannot find any PCI device under specified\r |
79 | root bridge.\r | |
80 | \r | |
81 | **/\r | |
82 | EFI_STATUS\r | |
83 | DestroyRootBridgeByHandle (\r | |
84 | IN EFI_HANDLE Controller\r | |
85 | );\r | |
86 | \r | |
87 | /**\r | |
88 | This function registers the PCI IO device.\r | |
89 | \r | |
90 | It creates a handle for this PCI IO device (if the handle does not exist), attaches\r | |
91 | appropriate protocols onto the handle, does necessary initialization, and sets up\r | |
92 | parent/child relationship with its bus controller.\r | |
93 | \r | |
94 | @param Controller An EFI handle for the PCI bus controller.\r | |
95 | @param PciIoDevice A PCI_IO_DEVICE pointer to the PCI IO device to be registered.\r | |
96 | @param Handle A pointer to hold the returned EFI handle for the PCI IO device.\r | |
97 | \r | |
98 | @retval EFI_SUCCESS The PCI device is successfully registered.\r | |
99 | @retval other An error occurred when registering the PCI device.\r | |
100 | \r | |
101 | **/\r | |
102 | EFI_STATUS\r | |
103 | RegisterPciDevice (\r | |
104 | IN EFI_HANDLE Controller,\r | |
105 | IN PCI_IO_DEVICE *PciIoDevice,\r | |
106 | OUT EFI_HANDLE *Handle OPTIONAL\r | |
107 | );\r | |
108 | \r | |
109 | /**\r | |
110 | This function is used to remove the whole PCI devices on the specified bridge from\r | |
111 | the root bridge.\r | |
112 | \r | |
113 | @param RootBridgeHandle The root bridge device handle.\r | |
114 | @param Bridge The bridge device to be removed.\r | |
115 | \r | |
116 | **/\r | |
117 | VOID\r | |
118 | RemoveAllPciDeviceOnBridge (\r | |
119 | EFI_HANDLE RootBridgeHandle,\r | |
120 | PCI_IO_DEVICE *Bridge\r | |
121 | );\r | |
122 | \r | |
123 | /**\r | |
124 | This function is used to de-register the PCI IO device.\r | |
125 | \r | |
126 | That includes un-installing PciIo protocol from the specified PCI\r | |
127 | device handle.\r | |
128 | \r | |
129 | @param Controller An EFI handle for the PCI bus controller.\r | |
130 | @param Handle PCI device handle.\r | |
131 | \r | |
132 | @retval EFI_SUCCESS The PCI device is successfully de-registered.\r | |
133 | @retval other An error occurred when de-registering the PCI device.\r | |
134 | \r | |
135 | **/\r | |
136 | EFI_STATUS\r | |
137 | DeRegisterPciDevice (\r | |
138 | IN EFI_HANDLE Controller,\r | |
139 | IN EFI_HANDLE Handle\r | |
140 | );\r | |
141 | \r | |
142 | /**\r | |
143 | Start to manage the PCI device on the specified root bridge or PCI-PCI Bridge.\r | |
144 | \r | |
145 | @param Controller The root bridge handle.\r | |
146 | @param RootBridge A pointer to the PCI_IO_DEVICE.\r | |
147 | @param RemainingDevicePath A pointer to the EFI_DEVICE_PATH_PROTOCOL.\r | |
148 | @param NumberOfChildren Children number.\r | |
149 | @param ChildHandleBuffer A pointer to the child handle buffer.\r | |
150 | \r | |
151 | @retval EFI_NOT_READY Device is not allocated.\r | |
152 | @retval EFI_UNSUPPORTED Device only support PCI-PCI bridge.\r | |
153 | @retval EFI_NOT_FOUND Can not find the specific device.\r | |
154 | @retval EFI_SUCCESS Success to start Pci devices on bridge.\r | |
155 | \r | |
156 | **/\r | |
157 | EFI_STATUS\r | |
158 | StartPciDevicesOnBridge (\r | |
159 | IN EFI_HANDLE Controller,\r | |
160 | IN PCI_IO_DEVICE *RootBridge,\r | |
161 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath,\r | |
162 | IN OUT UINT8 *NumberOfChildren,\r | |
163 | IN OUT EFI_HANDLE *ChildHandleBuffer\r | |
164 | );\r | |
165 | \r | |
166 | /**\r | |
167 | Start to manage all the PCI devices it found previously under\r | |
168 | the entire host bridge.\r | |
169 | \r | |
170 | @param Controller The root bridge handle.\r | |
171 | \r | |
172 | @retval EFI_NOT_READY Device is not allocated.\r | |
173 | @retval EFI_SUCCESS Success to start Pci device on host bridge.\r | |
174 | \r | |
175 | **/\r | |
176 | EFI_STATUS\r | |
177 | StartPciDevices (\r | |
178 | IN EFI_HANDLE Controller\r | |
179 | );\r | |
180 | \r | |
181 | /**\r | |
182 | Create root bridge device.\r | |
183 | \r | |
fcdfcdbf | 184 | @param RootBridgeHandle Specified root bridge handle.\r |
9060e3ec | 185 | \r |
186 | @return The crated root bridge device instance, NULL means no\r | |
187 | root bridge device instance created.\r | |
188 | \r | |
189 | **/\r | |
190 | PCI_IO_DEVICE *\r | |
191 | CreateRootBridge (\r | |
192 | IN EFI_HANDLE RootBridgeHandle\r | |
193 | );\r | |
194 | \r | |
195 | /**\r | |
196 | Get root bridge device instance by specific root bridge handle.\r | |
197 | \r | |
198 | @param RootBridgeHandle Given root bridge handle.\r | |
199 | \r | |
200 | @return The root bridge device instance, NULL means no root bridge\r | |
201 | device instance found.\r | |
202 | \r | |
203 | **/\r | |
204 | PCI_IO_DEVICE *\r | |
205 | GetRootBridgeByHandle (\r | |
206 | EFI_HANDLE RootBridgeHandle\r | |
207 | );\r | |
208 | \r | |
209 | \r | |
210 | /**\r | |
fcdfcdbf | 211 | Judge whether Pci device existed.\r |
9060e3ec | 212 | \r |
fcdfcdbf | 213 | @param Bridge Parent bridge instance.\r |
9060e3ec | 214 | @param PciIoDevice Device instance.\r |
215 | \r | |
216 | @retval TRUE Pci device existed.\r | |
217 | @retval FALSE Pci device did not exist.\r | |
218 | \r | |
219 | **/\r | |
220 | BOOLEAN\r | |
221 | PciDeviceExisted (\r | |
222 | IN PCI_IO_DEVICE *Bridge,\r | |
223 | IN PCI_IO_DEVICE *PciIoDevice\r | |
224 | );\r | |
225 | \r | |
226 | /**\r | |
983f5abb | 227 | Get the active VGA device on the specified Host Bridge.\r |
9060e3ec | 228 | \r |
983f5abb | 229 | @param HostBridgeHandle Host Bridge handle.\r |
9060e3ec | 230 | \r |
983f5abb | 231 | @return The active VGA device on the specified Host Bridge.\r |
9060e3ec | 232 | \r |
233 | **/\r | |
234 | PCI_IO_DEVICE *\r | |
983f5abb RN |
235 | LocateVgaDeviceOnHostBridge (\r |
236 | IN EFI_HANDLE HostBridgeHandle\r | |
9060e3ec | 237 | );\r |
238 | \r | |
239 | /**\r | |
06da1e31 | 240 | Locate the active VGA device under the bridge.\r |
9060e3ec | 241 | \r |
06da1e31 | 242 | @param Bridge PCI IO instance for the bridge.\r |
9060e3ec | 243 | \r |
244 | @return The active VGA device.\r | |
245 | \r | |
246 | **/\r | |
247 | PCI_IO_DEVICE *\r | |
06da1e31 RN |
248 | LocateVgaDevice (\r |
249 | IN PCI_IO_DEVICE *Bridge\r | |
9060e3ec | 250 | );\r |
251 | \r | |
9060e3ec | 252 | \r |
253 | /**\r | |
254 | Destroy a pci device node.\r | |
255 | \r | |
256 | All direct or indirect allocated resource for this node will be freed.\r | |
257 | \r | |
fcdfcdbf | 258 | @param PciIoDevice A pointer to the PCI_IO_DEVICE to be destroyed.\r |
9060e3ec | 259 | \r |
260 | **/\r | |
261 | VOID\r | |
262 | FreePciDevice (\r | |
263 | IN PCI_IO_DEVICE *PciIoDevice\r | |
264 | );\r | |
265 | \r | |
266 | #endif\r |