]>
Commit | Line | Data |
---|---|---|
47f51a06 YT |
1 | /** @file\r |
2 | The driver binding and service binding protocol for HttpDxe driver.\r | |
3 | \r | |
f75a7f56 | 4 | Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r |
d8293d31 | 5 | (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r |
47f51a06 | 6 | \r |
ecf98fbc | 7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
47f51a06 YT |
8 | \r |
9 | **/\r | |
10 | \r | |
11 | #include "HttpDriver.h"\r | |
12 | \r | |
5ca29abe JW |
13 | EFI_HTTP_UTILITIES_PROTOCOL *mHttpUtilities = NULL;\r |
14 | \r | |
47f51a06 YT |
15 | ///\r |
16 | /// Driver Binding Protocol instance\r | |
17 | ///\r | |
b659408b ZL |
18 | EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp4DriverBinding = {\r |
19 | HttpDxeIp4DriverBindingSupported,\r | |
20 | HttpDxeIp4DriverBindingStart,\r | |
21 | HttpDxeIp4DriverBindingStop,\r | |
47f51a06 YT |
22 | HTTP_DRIVER_VERSION,\r |
23 | NULL,\r | |
24 | NULL\r | |
25 | };\r | |
26 | \r | |
b659408b ZL |
27 | EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp6DriverBinding = {\r |
28 | HttpDxeIp6DriverBindingSupported,\r | |
29 | HttpDxeIp6DriverBindingStart,\r | |
30 | HttpDxeIp6DriverBindingStop,\r | |
31 | HTTP_DRIVER_VERSION,\r | |
32 | NULL,\r | |
33 | NULL\r | |
34 | };\r | |
35 | \r | |
36 | \r | |
47f51a06 YT |
37 | /**\r |
38 | Create a HTTP driver service binding private instance.\r | |
39 | \r | |
40 | @param[in] Controller The controller that has TCP4 service binding\r | |
41 | installed.\r | |
47f51a06 YT |
42 | @param[out] ServiceData Point to HTTP driver private instance.\r |
43 | \r | |
44 | @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.\r | |
45 | @retval EFI_SUCCESS A new HTTP driver private instance is created.\r | |
46 | \r | |
47 | **/\r | |
48 | EFI_STATUS\r | |
49 | HttpCreateService (\r | |
50 | IN EFI_HANDLE Controller,\r | |
47f51a06 YT |
51 | OUT HTTP_SERVICE **ServiceData\r |
52 | )\r | |
53 | {\r | |
54 | HTTP_SERVICE *HttpService;\r | |
55 | \r | |
56 | ASSERT (ServiceData != NULL);\r | |
57 | *ServiceData = NULL;\r | |
58 | \r | |
59 | HttpService = AllocateZeroPool (sizeof (HTTP_SERVICE));\r | |
60 | if (HttpService == NULL) {\r | |
61 | return EFI_OUT_OF_RESOURCES;\r | |
62 | }\r | |
63 | \r | |
64 | HttpService->Signature = HTTP_SERVICE_SIGNATURE;\r | |
65 | HttpService->ServiceBinding.CreateChild = HttpServiceBindingCreateChild;\r | |
66 | HttpService->ServiceBinding.DestroyChild = HttpServiceBindingDestroyChild;\r | |
47f51a06 YT |
67 | HttpService->ControllerHandle = Controller;\r |
68 | HttpService->ChildrenNumber = 0;\r | |
69 | InitializeListHead (&HttpService->ChildrenList);\r | |
f75a7f56 | 70 | \r |
47f51a06 YT |
71 | *ServiceData = HttpService;\r |
72 | return EFI_SUCCESS;\r | |
73 | }\r | |
74 | \r | |
75 | /**\r | |
76 | Release all the resource used the HTTP service binding instance.\r | |
77 | \r | |
b659408b ZL |
78 | @param[in] HttpService The HTTP private instance.\r |
79 | @param[in] UsingIpv6 Indicate use TCP4 protocol or TCP6 protocol.\r | |
80 | if TRUE, use Tcp6 protocol.\r | |
ba3b642d | 81 | if FALSE, use Tcp4 protocol.\r |
47f51a06 YT |
82 | **/\r |
83 | VOID\r | |
84 | HttpCleanService (\r | |
b659408b ZL |
85 | IN HTTP_SERVICE *HttpService,\r |
86 | IN BOOLEAN UsingIpv6\r | |
47f51a06 | 87 | )\r |
f75a7f56 LG |
88 | {\r |
89 | \r | |
3fd7bd08 | 90 | if (HttpService == NULL) {\r |
47f51a06 YT |
91 | return ;\r |
92 | }\r | |
b659408b ZL |
93 | if (!UsingIpv6) {\r |
94 | if (HttpService->Tcp4ChildHandle != NULL) {\r | |
95 | gBS->CloseProtocol (\r | |
96 | HttpService->Tcp4ChildHandle,\r | |
97 | &gEfiTcp4ProtocolGuid,\r | |
7cf59c85 | 98 | HttpService->Ip4DriverBindingHandle,\r |
b659408b ZL |
99 | HttpService->ControllerHandle\r |
100 | );\r | |
f75a7f56 | 101 | \r |
b659408b ZL |
102 | NetLibDestroyServiceChild (\r |
103 | HttpService->ControllerHandle,\r | |
7cf59c85 | 104 | HttpService->Ip4DriverBindingHandle,\r |
b659408b ZL |
105 | &gEfiTcp4ServiceBindingProtocolGuid,\r |
106 | HttpService->Tcp4ChildHandle\r | |
107 | );\r | |
f75a7f56 | 108 | \r |
b659408b ZL |
109 | HttpService->Tcp4ChildHandle = NULL;\r |
110 | }\r | |
111 | } else {\r | |
112 | if (HttpService->Tcp6ChildHandle != NULL) {\r | |
113 | gBS->CloseProtocol (\r | |
114 | HttpService->Tcp6ChildHandle,\r | |
115 | &gEfiTcp6ProtocolGuid,\r | |
7cf59c85 | 116 | HttpService->Ip6DriverBindingHandle,\r |
b659408b ZL |
117 | HttpService->ControllerHandle\r |
118 | );\r | |
f75a7f56 | 119 | \r |
b659408b ZL |
120 | NetLibDestroyServiceChild (\r |
121 | HttpService->ControllerHandle,\r | |
7cf59c85 | 122 | HttpService->Ip6DriverBindingHandle,\r |
b659408b ZL |
123 | &gEfiTcp6ServiceBindingProtocolGuid,\r |
124 | HttpService->Tcp6ChildHandle\r | |
125 | );\r | |
f75a7f56 | 126 | \r |
b659408b ZL |
127 | HttpService->Tcp6ChildHandle = NULL;\r |
128 | }\r | |
47f51a06 | 129 | }\r |
f75a7f56 | 130 | \r |
47f51a06 YT |
131 | }\r |
132 | \r | |
5ca29abe JW |
133 | /**\r |
134 | The event process routine when the http utilities protocol is installed\r | |
135 | in the system.\r | |
136 | \r | |
137 | @param[in] Event Not used.\r | |
b659408b | 138 | @param[in] Context The pointer to the IP4 config2 instance data or IP6 Config instance data.\r |
5ca29abe JW |
139 | \r |
140 | **/\r | |
141 | VOID\r | |
142 | EFIAPI\r | |
143 | HttpUtilitiesInstalledCallback (\r | |
144 | IN EFI_EVENT Event,\r | |
145 | IN VOID *Context\r | |
146 | )\r | |
147 | {\r | |
148 | gBS->LocateProtocol (\r | |
f75a7f56 LG |
149 | &gEfiHttpUtilitiesProtocolGuid,\r |
150 | NULL,\r | |
5ca29abe JW |
151 | (VOID **) &mHttpUtilities\r |
152 | );\r | |
f75a7f56 | 153 | \r |
5ca29abe | 154 | //\r |
ba3b642d | 155 | // Close the event if Http utilities protocol is located.\r |
5ca29abe JW |
156 | //\r |
157 | if (mHttpUtilities != NULL && Event != NULL) {\r | |
158 | gBS->CloseEvent (Event);\r | |
159 | }\r | |
160 | }\r | |
161 | \r | |
47f51a06 YT |
162 | /**\r |
163 | This is the declaration of an EFI image entry point. This entry point is\r | |
164 | the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including\r | |
165 | both device drivers and bus drivers.\r | |
166 | \r | |
167 | @param ImageHandle The firmware allocated handle for the UEFI image.\r | |
168 | @param SystemTable A pointer to the EFI System Table.\r | |
169 | \r | |
170 | @retval EFI_SUCCESS The operation completed successfully.\r | |
171 | @retval Others An unexpected error occurred.\r | |
172 | \r | |
173 | **/\r | |
174 | EFI_STATUS\r | |
175 | EFIAPI\r | |
176 | HttpDxeDriverEntryPoint (\r | |
177 | IN EFI_HANDLE ImageHandle,\r | |
178 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
179 | )\r | |
f75a7f56 | 180 | {\r |
b659408b | 181 | EFI_STATUS Status;\r |
5ca29abe JW |
182 | VOID *Registration;\r |
183 | \r | |
184 | gBS->LocateProtocol (\r | |
f75a7f56 LG |
185 | &gEfiHttpUtilitiesProtocolGuid,\r |
186 | NULL,\r | |
5ca29abe JW |
187 | (VOID **) &mHttpUtilities\r |
188 | );\r | |
189 | \r | |
190 | if (mHttpUtilities == NULL) {\r | |
191 | //\r | |
192 | // No Http utilities protocol, register a notify.\r | |
193 | //\r | |
194 | EfiCreateProtocolNotifyEvent (\r | |
195 | &gEfiHttpUtilitiesProtocolGuid,\r | |
196 | TPL_CALLBACK,\r | |
197 | HttpUtilitiesInstalledCallback,\r | |
198 | NULL,\r | |
199 | &Registration\r | |
200 | );\r | |
201 | }\r | |
202 | \r | |
47f51a06 YT |
203 | //\r |
204 | // Install UEFI Driver Model protocol(s).\r | |
205 | //\r | |
b659408b ZL |
206 | Status = EfiLibInstallDriverBindingComponentName2 (\r |
207 | ImageHandle,\r | |
208 | SystemTable,\r | |
209 | &gHttpDxeIp4DriverBinding,\r | |
210 | ImageHandle,\r | |
211 | &gHttpDxeComponentName,\r | |
212 | &gHttpDxeComponentName2\r | |
213 | );\r | |
214 | if (EFI_ERROR (Status)) {\r | |
215 | return Status;\r | |
216 | }\r | |
217 | \r | |
218 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
219 | ImageHandle,\r | |
220 | SystemTable,\r | |
221 | &gHttpDxeIp6DriverBinding,\r | |
222 | NULL,\r | |
223 | &gHttpDxeComponentName,\r | |
224 | &gHttpDxeComponentName2\r | |
225 | );\r | |
226 | if (EFI_ERROR (Status)) {\r | |
22b35e8b AS |
227 | EfiLibUninstallDriverBindingComponentName2 (\r |
228 | &gHttpDxeIp4DriverBinding,\r | |
229 | &gHttpDxeComponentName,\r | |
230 | &gHttpDxeComponentName2\r | |
231 | );\r | |
b659408b ZL |
232 | }\r |
233 | return Status;\r | |
47f51a06 YT |
234 | }\r |
235 | \r | |
236 | /**\r | |
237 | Callback function which provided by user to remove one node in NetDestroyLinkList process.\r | |
f75a7f56 | 238 | \r |
47f51a06 YT |
239 | @param[in] Entry The entry to be removed.\r |
240 | @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.\r | |
241 | \r | |
242 | @retval EFI_INVALID_PARAMETER Any input parameter is NULL.\r | |
243 | @retval EFI_SUCCESS The entry has been removed successfully.\r | |
244 | @retval Others Fail to remove the entry.\r | |
245 | \r | |
246 | **/\r | |
247 | EFI_STATUS\r | |
248 | EFIAPI\r | |
249 | HttpDestroyChildEntryInHandleBuffer (\r | |
250 | IN LIST_ENTRY *Entry,\r | |
251 | IN VOID *Context\r | |
252 | )\r | |
253 | {\r | |
254 | HTTP_PROTOCOL *HttpInstance;\r | |
255 | EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r | |
256 | UINTN NumberOfChildren;\r | |
257 | EFI_HANDLE *ChildHandleBuffer;\r | |
258 | \r | |
259 | if (Entry == NULL || Context == NULL) {\r | |
260 | return EFI_INVALID_PARAMETER;\r | |
261 | }\r | |
262 | \r | |
263 | HttpInstance = NET_LIST_USER_STRUCT_S (Entry, HTTP_PROTOCOL, Link, HTTP_PROTOCOL_SIGNATURE);\r | |
264 | ServiceBinding = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;\r | |
265 | NumberOfChildren = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;\r | |
266 | ChildHandleBuffer = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;\r | |
267 | \r | |
268 | if (!NetIsInHandleBuffer (HttpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) {\r | |
269 | return EFI_SUCCESS;\r | |
270 | }\r | |
271 | \r | |
272 | return ServiceBinding->DestroyChild (ServiceBinding, HttpInstance->Handle);\r | |
273 | }\r | |
274 | \r | |
b659408b ZL |
275 | /**\r |
276 | Test to see if this driver supports ControllerHandle. This is the worker function for\r | |
277 | HttpDxeIp4(6)DriverBindingSupported.\r | |
278 | \r | |
279 | @param[in] This The pointer to the driver binding protocol.\r | |
280 | @param[in] ControllerHandle The handle of device to be tested.\r | |
281 | @param[in] RemainingDevicePath Optional parameter used to pick a specific child\r | |
282 | device to be started.\r | |
283 | @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r | |
f75a7f56 | 284 | \r |
b659408b ZL |
285 | @retval EFI_SUCCESS This driver supports this device.\r |
286 | @retval EFI_UNSUPPORTED This driver does not support this device.\r | |
287 | \r | |
288 | **/\r | |
289 | EFI_STATUS\r | |
290 | EFIAPI\r | |
291 | HttpDxeSupported (\r | |
292 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
293 | IN EFI_HANDLE ControllerHandle,\r | |
294 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,\r | |
295 | IN UINT8 IpVersion\r | |
296 | )\r | |
297 | {\r | |
298 | EFI_STATUS Status;\r | |
299 | EFI_GUID *TcpServiceBindingProtocolGuid;\r | |
300 | \r | |
301 | if (IpVersion == IP_VERSION_4) {\r | |
302 | TcpServiceBindingProtocolGuid = &gEfiTcp4ServiceBindingProtocolGuid;\r | |
303 | } else {\r | |
304 | TcpServiceBindingProtocolGuid = &gEfiTcp6ServiceBindingProtocolGuid;\r | |
305 | }\r | |
306 | \r | |
307 | Status = gBS->OpenProtocol (\r | |
308 | ControllerHandle,\r | |
309 | TcpServiceBindingProtocolGuid,\r | |
310 | NULL,\r | |
311 | This->DriverBindingHandle,\r | |
312 | ControllerHandle,\r | |
313 | EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r | |
314 | );\r | |
315 | \r | |
316 | if (EFI_ERROR (Status)) {\r | |
317 | return EFI_UNSUPPORTED;\r | |
318 | }\r | |
319 | \r | |
320 | return EFI_SUCCESS;\r | |
321 | }\r | |
322 | \r | |
323 | /**\r | |
324 | Start this driver on ControllerHandle. This is the worker function for\r | |
325 | HttpDxeIp4(6)DriverBindingStart.\r | |
326 | \r | |
327 | @param[in] This The pointer to the driver binding protocol.\r | |
328 | @param[in] ControllerHandle The handle of device to be started.\r | |
329 | @param[in] RemainingDevicePath Optional parameter used to pick a specific child\r | |
330 | device to be started.\r | |
331 | @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r | |
332 | \r | |
333 | \r | |
334 | @retval EFI_SUCCESS This driver is installed to ControllerHandle.\r | |
335 | @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.\r | |
336 | @retval other This driver does not support this device.\r | |
337 | \r | |
338 | **/\r | |
339 | EFI_STATUS\r | |
340 | EFIAPI\r | |
341 | HttpDxeStart (\r | |
342 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
343 | IN EFI_HANDLE ControllerHandle,\r | |
344 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,\r | |
345 | IN UINT8 IpVersion\r | |
346 | )\r | |
347 | {\r | |
348 | EFI_STATUS Status;\r | |
349 | EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r | |
350 | HTTP_SERVICE *HttpService;\r | |
351 | VOID *Interface;\r | |
352 | BOOLEAN UsingIpv6;\r | |
353 | \r | |
354 | UsingIpv6 = FALSE;\r | |
355 | \r | |
356 | //\r | |
357 | // Test for the Http service binding protocol\r | |
358 | //\r | |
359 | Status = gBS->OpenProtocol (\r | |
360 | ControllerHandle,\r | |
361 | &gEfiHttpServiceBindingProtocolGuid,\r | |
362 | (VOID **) &ServiceBinding,\r | |
363 | This->DriverBindingHandle,\r | |
364 | ControllerHandle,\r | |
365 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
366 | );\r | |
367 | \r | |
368 | if (!EFI_ERROR (Status)) {\r | |
369 | HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding);\r | |
370 | } else {\r | |
7cf59c85 | 371 | Status = HttpCreateService (ControllerHandle, &HttpService);\r |
b659408b ZL |
372 | if (EFI_ERROR (Status)) {\r |
373 | return Status;\r | |
374 | }\r | |
f75a7f56 | 375 | \r |
b659408b | 376 | ASSERT (HttpService != NULL);\r |
f75a7f56 | 377 | \r |
b659408b ZL |
378 | //\r |
379 | // Install the HttpServiceBinding Protocol onto Controller\r | |
380 | //\r | |
381 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
382 | &ControllerHandle,\r | |
383 | &gEfiHttpServiceBindingProtocolGuid,\r | |
384 | &HttpService->ServiceBinding,\r | |
385 | NULL\r | |
386 | );\r | |
f75a7f56 | 387 | \r |
b659408b ZL |
388 | if (EFI_ERROR (Status)) {\r |
389 | goto ON_ERROR;\r | |
390 | }\r | |
391 | }\r | |
392 | \r | |
393 | if (IpVersion == IP_VERSION_4) {\r | |
7cf59c85 ZL |
394 | HttpService->Ip4DriverBindingHandle = This->DriverBindingHandle;\r |
395 | \r | |
b659408b ZL |
396 | if (HttpService->Tcp4ChildHandle == NULL) {\r |
397 | //\r | |
398 | // Create a TCP4 child instance, but do not configure it. This will establish the parent-child relationship.\r | |
399 | //\r | |
400 | Status = NetLibCreateServiceChild (\r | |
401 | ControllerHandle,\r | |
402 | This->DriverBindingHandle,\r | |
403 | &gEfiTcp4ServiceBindingProtocolGuid,\r | |
404 | &HttpService->Tcp4ChildHandle\r | |
405 | );\r | |
f75a7f56 | 406 | \r |
b659408b ZL |
407 | if (EFI_ERROR (Status)) {\r |
408 | goto ON_ERROR;\r | |
409 | }\r | |
f75a7f56 | 410 | \r |
b659408b ZL |
411 | Status = gBS->OpenProtocol (\r |
412 | HttpService->Tcp4ChildHandle,\r | |
413 | &gEfiTcp4ProtocolGuid,\r | |
414 | &Interface,\r | |
415 | This->DriverBindingHandle,\r | |
416 | ControllerHandle,\r | |
417 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
418 | );\r | |
f75a7f56 | 419 | \r |
b659408b ZL |
420 | if (EFI_ERROR (Status)) {\r |
421 | goto ON_ERROR;\r | |
422 | }\r | |
f75a7f56 | 423 | \r |
b659408b ZL |
424 | } else {\r |
425 | return EFI_ALREADY_STARTED;\r | |
426 | }\r | |
427 | \r | |
428 | } else {\r | |
429 | UsingIpv6 = TRUE;\r | |
7cf59c85 ZL |
430 | HttpService->Ip6DriverBindingHandle = This->DriverBindingHandle;\r |
431 | \r | |
b659408b ZL |
432 | if (HttpService->Tcp6ChildHandle == NULL) {\r |
433 | //\r | |
434 | // Create a TCP6 child instance, but do not configure it. This will establish the parent-child relationship.\r | |
435 | //\r | |
436 | Status = NetLibCreateServiceChild (\r | |
437 | ControllerHandle,\r | |
438 | This->DriverBindingHandle,\r | |
439 | &gEfiTcp6ServiceBindingProtocolGuid,\r | |
440 | &HttpService->Tcp6ChildHandle\r | |
441 | );\r | |
f75a7f56 | 442 | \r |
b659408b ZL |
443 | if (EFI_ERROR (Status)) {\r |
444 | goto ON_ERROR;\r | |
445 | }\r | |
f75a7f56 | 446 | \r |
b659408b ZL |
447 | Status = gBS->OpenProtocol (\r |
448 | HttpService->Tcp6ChildHandle,\r | |
449 | &gEfiTcp6ProtocolGuid,\r | |
450 | &Interface,\r | |
451 | This->DriverBindingHandle,\r | |
452 | ControllerHandle,\r | |
453 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
454 | );\r | |
f75a7f56 | 455 | \r |
b659408b ZL |
456 | if (EFI_ERROR (Status)) {\r |
457 | goto ON_ERROR;\r | |
458 | }\r | |
f75a7f56 | 459 | \r |
b659408b ZL |
460 | } else {\r |
461 | return EFI_ALREADY_STARTED;\r | |
462 | }\r | |
463 | \r | |
464 | }\r | |
465 | \r | |
466 | return EFI_SUCCESS;\r | |
f75a7f56 | 467 | \r |
b659408b | 468 | ON_ERROR:\r |
f75a7f56 | 469 | \r |
b659408b ZL |
470 | if (HttpService != NULL) {\r |
471 | HttpCleanService (HttpService, UsingIpv6);\r | |
472 | if (HttpService->Tcp4ChildHandle == NULL && HttpService->Tcp6ChildHandle == NULL) {\r | |
473 | FreePool (HttpService);\r | |
474 | }\r | |
475 | }\r | |
f75a7f56 | 476 | \r |
b659408b ZL |
477 | return Status;\r |
478 | \r | |
479 | \r | |
480 | }\r | |
481 | \r | |
482 | /**\r | |
483 | Stop this driver on ControllerHandle. This is the worker function for\r | |
484 | HttpDxeIp4(6)DriverBindingStop.\r | |
485 | \r | |
486 | @param[in] This Protocol instance pointer.\r | |
487 | @param[in] ControllerHandle Handle of device to stop driver on.\r | |
488 | @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
489 | children is zero stop the entire bus driver.\r | |
490 | @param[in] ChildHandleBuffer List of Child Handles to Stop.\r | |
491 | @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r | |
492 | \r | |
493 | @retval EFI_SUCCESS This driver was removed ControllerHandle.\r | |
494 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r | |
495 | @retval Others This driver was not removed from this device\r | |
496 | \r | |
497 | **/\r | |
498 | EFI_STATUS\r | |
499 | EFIAPI\r | |
500 | HttpDxeStop (\r | |
501 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
502 | IN EFI_HANDLE ControllerHandle,\r | |
503 | IN UINTN NumberOfChildren,\r | |
504 | IN EFI_HANDLE *ChildHandleBuffer,\r | |
505 | IN UINT8 IpVersion\r | |
506 | )\r | |
507 | {\r | |
508 | EFI_HANDLE NicHandle;\r | |
509 | EFI_STATUS Status;\r | |
510 | EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r | |
511 | HTTP_SERVICE *HttpService;\r | |
512 | LIST_ENTRY *List;\r | |
513 | HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;\r | |
514 | BOOLEAN UsingIpv6;\r | |
515 | \r | |
516 | //\r | |
517 | // HTTP driver opens TCP4(6) child, So, Controller is a TCP4(6)\r | |
518 | // child handle. Locate the Nic handle first. Then get the\r | |
519 | // HTTP private data back.\r | |
520 | //\r | |
521 | if (IpVersion == IP_VERSION_4) {\r | |
522 | UsingIpv6 = FALSE;\r | |
523 | NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid);\r | |
524 | } else {\r | |
525 | UsingIpv6 = TRUE;\r | |
526 | NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiTcp6ProtocolGuid);\r | |
527 | }\r | |
528 | \r | |
529 | if (NicHandle == NULL) {\r | |
530 | return EFI_SUCCESS;\r | |
531 | }\r | |
532 | \r | |
533 | Status = gBS->OpenProtocol (\r | |
534 | NicHandle,\r | |
535 | &gEfiHttpServiceBindingProtocolGuid,\r | |
536 | (VOID **) &ServiceBinding,\r | |
537 | This->DriverBindingHandle,\r | |
538 | NicHandle,\r | |
539 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
540 | );\r | |
541 | \r | |
542 | if (!EFI_ERROR (Status)) {\r | |
f75a7f56 | 543 | \r |
b659408b | 544 | HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding);\r |
f75a7f56 | 545 | \r |
b659408b ZL |
546 | if (NumberOfChildren != 0) {\r |
547 | //\r | |
548 | // Destroy the HTTP child instance in ChildHandleBuffer.\r | |
549 | //\r | |
550 | List = &HttpService->ChildrenList;\r | |
551 | Context.ServiceBinding = ServiceBinding;\r | |
552 | Context.NumberOfChildren = NumberOfChildren;\r | |
553 | Context.ChildHandleBuffer = ChildHandleBuffer;\r | |
554 | Status = NetDestroyLinkList (\r | |
555 | List,\r | |
556 | HttpDestroyChildEntryInHandleBuffer,\r | |
557 | &Context,\r | |
558 | NULL\r | |
559 | );\r | |
560 | } else {\r | |
f75a7f56 | 561 | \r |
b659408b | 562 | HttpCleanService (HttpService, UsingIpv6);\r |
f75a7f56 | 563 | \r |
b659408b ZL |
564 | if (HttpService->Tcp4ChildHandle == NULL && HttpService->Tcp6ChildHandle == NULL) {\r |
565 | gBS->UninstallProtocolInterface (\r | |
566 | NicHandle,\r | |
567 | &gEfiHttpServiceBindingProtocolGuid,\r | |
568 | ServiceBinding\r | |
569 | );\r | |
570 | FreePool (HttpService);\r | |
571 | }\r | |
572 | Status = EFI_SUCCESS;\r | |
f75a7f56 | 573 | }\r |
b659408b | 574 | }\r |
f75a7f56 | 575 | \r |
b659408b ZL |
576 | return Status;\r |
577 | \r | |
578 | }\r | |
579 | \r | |
47f51a06 | 580 | /**\r |
f75a7f56 | 581 | Tests to see if this driver supports a given controller. If a child device is provided,\r |
47f51a06 YT |
582 | it further tests to see if this driver supports creating a handle for the specified child device.\r |
583 | \r | |
f75a7f56 LG |
584 | This function checks to see if the driver specified by This supports the device specified by\r |
585 | ControllerHandle. Drivers will typically use the device path attached to\r | |
586 | ControllerHandle and/or the services from the bus I/O abstraction attached to\r | |
587 | ControllerHandle to determine if the driver supports ControllerHandle. This function\r | |
588 | may be called many times during platform initialization. In order to reduce boot times, the tests\r | |
589 | performed by this function must be very small, and take as little time as possible to execute. This\r | |
590 | function must not change the state of any hardware devices, and this function must be aware that the\r | |
591 | device specified by ControllerHandle may already be managed by the same driver or a\r | |
592 | different driver. This function must match its calls to AllocatePages() with FreePages(),\r | |
593 | AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r | |
594 | Because ControllerHandle may have been previously started by the same driver, if a protocol is\r | |
595 | already in the opened state, then it must not be closed with CloseProtocol(). This is required\r | |
47f51a06 YT |
596 | to guarantee the state of ControllerHandle is not modified by this function.\r |
597 | \r | |
598 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
f75a7f56 LG |
599 | @param[in] ControllerHandle The handle of the controller to test. This handle\r |
600 | must support a protocol interface that supplies\r | |
47f51a06 | 601 | an I/O abstraction to the driver.\r |
f75a7f56 LG |
602 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r |
603 | parameter is ignored by device drivers, and is optional for bus\r | |
604 | drivers. For bus drivers, if this parameter is not NULL, then\r | |
605 | the bus driver must determine if the bus controller specified\r | |
606 | by ControllerHandle and the child controller specified\r | |
607 | by RemainingDevicePath are both supported by this\r | |
47f51a06 YT |
608 | bus driver.\r |
609 | \r | |
610 | @retval EFI_SUCCESS The device specified by ControllerHandle and\r | |
611 | RemainingDevicePath is supported by the driver specified by This.\r | |
612 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r | |
613 | RemainingDevicePath is already being managed by the driver\r | |
614 | specified by This.\r | |
615 | @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r | |
616 | RemainingDevicePath is already being managed by a different\r | |
617 | driver or an application that requires exclusive access.\r | |
618 | Currently not implemented.\r | |
619 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r | |
620 | RemainingDevicePath is not supported by the driver specified by This.\r | |
621 | **/\r | |
622 | EFI_STATUS\r | |
623 | EFIAPI\r | |
b659408b | 624 | HttpDxeIp4DriverBindingSupported (\r |
47f51a06 YT |
625 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
626 | IN EFI_HANDLE ControllerHandle,\r | |
627 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
628 | )\r | |
629 | {\r | |
b659408b ZL |
630 | return HttpDxeSupported (\r |
631 | This,\r | |
632 | ControllerHandle,\r | |
633 | RemainingDevicePath,\r | |
634 | IP_VERSION_4\r | |
635 | );\r | |
47f51a06 YT |
636 | }\r |
637 | \r | |
638 | /**\r | |
639 | Starts a device controller or a bus controller.\r | |
640 | \r | |
641 | The Start() function is designed to be invoked from the EFI boot service ConnectController().\r | |
f75a7f56 LG |
642 | As a result, much of the error checking on the parameters to Start() has been moved into this\r |
643 | common boot service. It is legal to call Start() from other locations,\r | |
47f51a06 YT |
644 | but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r |
645 | 1. ControllerHandle must be a valid EFI_HANDLE.\r | |
646 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r | |
647 | EFI_DEVICE_PATH_PROTOCOL.\r | |
648 | 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r | |
f75a7f56 | 649 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r |
47f51a06 YT |
650 | \r |
651 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
f75a7f56 LG |
652 | @param[in] ControllerHandle The handle of the controller to start. This handle\r |
653 | must support a protocol interface that supplies\r | |
47f51a06 | 654 | an I/O abstraction to the driver.\r |
f75a7f56 LG |
655 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r |
656 | parameter is ignored by device drivers, and is optional for bus\r | |
657 | drivers. For a bus driver, if this parameter is NULL, then handles\r | |
658 | for all the children of Controller are created by this driver.\r | |
659 | If this parameter is not NULL and the first Device Path Node is\r | |
660 | not the End of Device Path Node, then only the handle for the\r | |
661 | child device specified by the first Device Path Node of\r | |
47f51a06 | 662 | RemainingDevicePath is created by this driver.\r |
f75a7f56 | 663 | If the first Device Path Node of RemainingDevicePath is\r |
47f51a06 YT |
664 | the End of Device Path Node, no child handle is created by this\r |
665 | driver.\r | |
666 | \r | |
667 | @retval EFI_SUCCESS The device was started.\r | |
668 | @retval EFI_ALREADY_STARTED This device is already running on ControllerHandle.\r | |
669 | @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r | |
670 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
ba3b642d | 671 | @retval Others The driver failed to start the device.\r |
47f51a06 YT |
672 | \r |
673 | **/\r | |
674 | EFI_STATUS\r | |
675 | EFIAPI\r | |
b659408b | 676 | HttpDxeIp4DriverBindingStart (\r |
47f51a06 YT |
677 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
678 | IN EFI_HANDLE ControllerHandle,\r | |
679 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
680 | )\r | |
681 | {\r | |
b659408b ZL |
682 | return HttpDxeStart (\r |
683 | This,\r | |
684 | ControllerHandle,\r | |
685 | RemainingDevicePath,\r | |
686 | IP_VERSION_4\r | |
687 | );\r | |
688 | }\r | |
689 | \r | |
690 | /**\r | |
691 | Stops a device controller or a bus controller.\r | |
f75a7f56 LG |
692 | \r |
693 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r | |
694 | As a result, much of the error checking on the parameters to Stop() has been moved\r | |
695 | into this common boot service. It is legal to call Stop() from other locations,\r | |
b659408b ZL |
696 | but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r |
697 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r | |
698 | same driver's Start() function.\r | |
699 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r | |
700 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r | |
701 | Start() function, and the Start() function must have called OpenProtocol() on\r | |
702 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r | |
f75a7f56 | 703 | \r |
b659408b | 704 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r |
f75a7f56 LG |
705 | @param[in] ControllerHandle A handle to the device being stopped. The handle must\r |
706 | support a bus specific I/O protocol for the driver\r | |
b659408b ZL |
707 | to use to stop the device.\r |
708 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
f75a7f56 | 709 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r |
b659408b | 710 | if NumberOfChildren is 0.\r |
47f51a06 | 711 | \r |
b659408b ZL |
712 | @retval EFI_SUCCESS The device was stopped.\r |
713 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
47f51a06 | 714 | \r |
b659408b ZL |
715 | **/\r |
716 | EFI_STATUS\r | |
717 | EFIAPI\r | |
718 | HttpDxeIp4DriverBindingStop (\r | |
719 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
720 | IN EFI_HANDLE ControllerHandle,\r | |
721 | IN UINTN NumberOfChildren,\r | |
722 | IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r | |
723 | )\r | |
724 | {\r | |
725 | return HttpDxeStop (\r | |
726 | This,\r | |
727 | ControllerHandle,\r | |
728 | NumberOfChildren,\r | |
729 | ChildHandleBuffer,\r | |
730 | IP_VERSION_4\r | |
731 | );\r | |
732 | }\r | |
47f51a06 | 733 | \r |
b659408b | 734 | /**\r |
f75a7f56 | 735 | Tests to see if this driver supports a given controller. If a child device is provided,\r |
b659408b | 736 | it further tests to see if this driver supports creating a handle for the specified child device.\r |
47f51a06 | 737 | \r |
f75a7f56 LG |
738 | This function checks to see if the driver specified by This supports the device specified by\r |
739 | ControllerHandle. Drivers will typically use the device path attached to\r | |
740 | ControllerHandle and/or the services from the bus I/O abstraction attached to\r | |
741 | ControllerHandle to determine if the driver supports ControllerHandle. This function\r | |
742 | may be called many times during platform initialization. In order to reduce boot times, the tests\r | |
743 | performed by this function must be very small, and take as little time as possible to execute. This\r | |
744 | function must not change the state of any hardware devices, and this function must be aware that the\r | |
745 | device specified by ControllerHandle may already be managed by the same driver or a\r | |
746 | different driver. This function must match its calls to AllocatePages() with FreePages(),\r | |
747 | AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r | |
748 | Because ControllerHandle may have been previously started by the same driver, if a protocol is\r | |
749 | already in the opened state, then it must not be closed with CloseProtocol(). This is required\r | |
b659408b | 750 | to guarantee the state of ControllerHandle is not modified by this function.\r |
47f51a06 | 751 | \r |
b659408b | 752 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r |
f75a7f56 LG |
753 | @param[in] ControllerHandle The handle of the controller to test. This handle\r |
754 | must support a protocol interface that supplies\r | |
b659408b | 755 | an I/O abstraction to the driver.\r |
f75a7f56 LG |
756 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r |
757 | parameter is ignored by device drivers, and is optional for bus\r | |
758 | drivers. For bus drivers, if this parameter is not NULL, then\r | |
759 | the bus driver must determine if the bus controller specified\r | |
760 | by ControllerHandle and the child controller specified\r | |
761 | by RemainingDevicePath are both supported by this\r | |
b659408b | 762 | bus driver.\r |
47f51a06 | 763 | \r |
b659408b ZL |
764 | @retval EFI_SUCCESS The device specified by ControllerHandle and\r |
765 | RemainingDevicePath is supported by the driver specified by This.\r | |
766 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r | |
767 | RemainingDevicePath is already being managed by the driver\r | |
768 | specified by This.\r | |
769 | @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r | |
770 | RemainingDevicePath is already being managed by a different\r | |
771 | driver or an application that requires exclusive access.\r | |
772 | Currently not implemented.\r | |
773 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r | |
774 | RemainingDevicePath is not supported by the driver specified by This.\r | |
775 | **/\r | |
776 | EFI_STATUS\r | |
777 | EFIAPI\r | |
778 | HttpDxeIp6DriverBindingSupported (\r | |
779 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
780 | IN EFI_HANDLE ControllerHandle,\r | |
781 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
782 | )\r | |
f75a7f56 | 783 | {\r |
b659408b ZL |
784 | return HttpDxeSupported (\r |
785 | This,\r | |
786 | ControllerHandle,\r | |
787 | RemainingDevicePath,\r | |
788 | IP_VERSION_6\r | |
789 | );\r | |
47f51a06 | 790 | \r |
b659408b | 791 | }\r |
47f51a06 | 792 | \r |
b659408b ZL |
793 | /**\r |
794 | Starts a device controller or a bus controller.\r | |
47f51a06 | 795 | \r |
b659408b | 796 | The Start() function is designed to be invoked from the EFI boot service ConnectController().\r |
f75a7f56 LG |
797 | As a result, much of the error checking on the parameters to Start() has been moved into this\r |
798 | common boot service. It is legal to call Start() from other locations,\r | |
b659408b ZL |
799 | but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r |
800 | 1. ControllerHandle must be a valid EFI_HANDLE.\r | |
801 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r | |
802 | EFI_DEVICE_PATH_PROTOCOL.\r | |
803 | 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r | |
f75a7f56 | 804 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r |
47f51a06 | 805 | \r |
b659408b | 806 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r |
f75a7f56 LG |
807 | @param[in] ControllerHandle The handle of the controller to start. This handle\r |
808 | must support a protocol interface that supplies\r | |
b659408b | 809 | an I/O abstraction to the driver.\r |
f75a7f56 LG |
810 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r |
811 | parameter is ignored by device drivers, and is optional for bus\r | |
812 | drivers. For a bus driver, if this parameter is NULL, then handles\r | |
813 | for all the children of Controller are created by this driver.\r | |
814 | If this parameter is not NULL and the first Device Path Node is\r | |
815 | not the End of Device Path Node, then only the handle for the\r | |
816 | child device specified by the first Device Path Node of\r | |
b659408b | 817 | RemainingDevicePath is created by this driver.\r |
f75a7f56 | 818 | If the first Device Path Node of RemainingDevicePath is\r |
b659408b ZL |
819 | the End of Device Path Node, no child handle is created by this\r |
820 | driver.\r | |
47f51a06 | 821 | \r |
b659408b ZL |
822 | @retval EFI_SUCCESS The device was started.\r |
823 | @retval EFI_ALREADY_STARTED This device is already running on ControllerHandle.\r | |
824 | @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r | |
825 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
ba3b642d | 826 | @retval Others The driver failed to start the device.\r |
b659408b ZL |
827 | \r |
828 | **/\r | |
829 | EFI_STATUS\r | |
830 | EFIAPI\r | |
831 | HttpDxeIp6DriverBindingStart (\r | |
832 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
833 | IN EFI_HANDLE ControllerHandle,\r | |
834 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
835 | )\r | |
836 | {\r | |
837 | return HttpDxeStart (\r | |
838 | This,\r | |
839 | ControllerHandle,\r | |
840 | RemainingDevicePath,\r | |
841 | IP_VERSION_6\r | |
842 | );\r | |
47f51a06 YT |
843 | }\r |
844 | \r | |
845 | /**\r | |
846 | Stops a device controller or a bus controller.\r | |
f75a7f56 LG |
847 | \r |
848 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r | |
849 | As a result, much of the error checking on the parameters to Stop() has been moved\r | |
850 | into this common boot service. It is legal to call Stop() from other locations,\r | |
47f51a06 YT |
851 | but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r |
852 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r | |
853 | same driver's Start() function.\r | |
854 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r | |
855 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r | |
856 | Start() function, and the Start() function must have called OpenProtocol() on\r | |
857 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r | |
f75a7f56 | 858 | \r |
47f51a06 | 859 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r |
f75a7f56 LG |
860 | @param[in] ControllerHandle A handle to the device being stopped. The handle must\r |
861 | support a bus specific I/O protocol for the driver\r | |
47f51a06 YT |
862 | to use to stop the device.\r |
863 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
f75a7f56 | 864 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r |
47f51a06 YT |
865 | if NumberOfChildren is 0.\r |
866 | \r | |
867 | @retval EFI_SUCCESS The device was stopped.\r | |
868 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
869 | \r | |
870 | **/\r | |
871 | EFI_STATUS\r | |
872 | EFIAPI\r | |
b659408b | 873 | HttpDxeIp6DriverBindingStop (\r |
47f51a06 YT |
874 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
875 | IN EFI_HANDLE ControllerHandle,\r | |
876 | IN UINTN NumberOfChildren,\r | |
877 | IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r | |
878 | )\r | |
879 | {\r | |
b659408b ZL |
880 | return HttpDxeStop (\r |
881 | This,\r | |
882 | ControllerHandle,\r | |
883 | NumberOfChildren,\r | |
884 | ChildHandleBuffer,\r | |
885 | IP_VERSION_6\r | |
47f51a06 | 886 | );\r |
47f51a06 | 887 | }\r |
47f51a06 YT |
888 | /**\r |
889 | Creates a child handle and installs a protocol.\r | |
890 | \r | |
891 | The CreateChild() function installs a protocol on ChildHandle.\r | |
892 | If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.\r | |
893 | If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.\r | |
894 | \r | |
895 | @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r | |
896 | @param ChildHandle Pointer to the handle of the child to create. If it is NULL,\r | |
897 | then a new handle is created. If it is a pointer to an existing UEFI handle,\r | |
898 | then the protocol is added to the existing UEFI handle.\r | |
899 | \r | |
ba3b642d | 900 | @retval EFI_SUCCESS The protocol was added to ChildHandle.\r |
47f51a06 | 901 | @retval EFI_INVALID_PARAMETER This is NULL, or ChildHandle is NULL.\r |
c2adf51f | 902 | @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create\r |
47f51a06 YT |
903 | the child.\r |
904 | @retval other The child handle was not created.\r | |
905 | \r | |
906 | **/\r | |
907 | EFI_STATUS\r | |
908 | EFIAPI\r | |
909 | HttpServiceBindingCreateChild (\r | |
910 | IN EFI_SERVICE_BINDING_PROTOCOL *This,\r | |
911 | IN OUT EFI_HANDLE *ChildHandle\r | |
912 | )\r | |
913 | {\r | |
914 | HTTP_SERVICE *HttpService;\r | |
915 | HTTP_PROTOCOL *HttpInstance;\r | |
916 | EFI_STATUS Status;\r | |
47f51a06 YT |
917 | EFI_TPL OldTpl;\r |
918 | \r | |
919 | if ((This == NULL) || (ChildHandle == NULL)) {\r | |
920 | return EFI_INVALID_PARAMETER;\r | |
921 | }\r | |
922 | \r | |
923 | HttpService = HTTP_SERVICE_FROM_PROTOCOL (This);\r | |
924 | HttpInstance = AllocateZeroPool (sizeof (HTTP_PROTOCOL));\r | |
925 | if (HttpInstance == NULL) {\r | |
926 | return EFI_OUT_OF_RESOURCES;\r | |
927 | }\r | |
f75a7f56 | 928 | \r |
b659408b ZL |
929 | HttpInstance->Signature = HTTP_PROTOCOL_SIGNATURE;\r |
930 | HttpInstance->Service = HttpService;\r | |
d8293d31 NH |
931 | HttpInstance->Method = HttpMethodMax;\r |
932 | \r | |
b659408b ZL |
933 | CopyMem (&HttpInstance->Http, &mEfiHttpTemplate, sizeof (HttpInstance->Http));\r |
934 | NetMapInit (&HttpInstance->TxTokens);\r | |
935 | NetMapInit (&HttpInstance->RxTokens);\r | |
47f51a06 YT |
936 | \r |
937 | //\r | |
938 | // Install HTTP protocol onto ChildHandle\r | |
939 | //\r | |
940 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
941 | ChildHandle,\r | |
942 | &gEfiHttpProtocolGuid,\r | |
943 | &HttpInstance->Http,\r | |
944 | NULL\r | |
945 | );\r | |
946 | \r | |
947 | if (EFI_ERROR (Status)) {\r | |
948 | goto ON_ERROR;\r | |
949 | }\r | |
950 | \r | |
b659408b | 951 | HttpInstance->Handle = *ChildHandle;\r |
47f51a06 YT |
952 | \r |
953 | //\r | |
954 | // Add it to the HTTP service's child list.\r | |
955 | //\r | |
956 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
957 | \r | |
958 | InsertTailList (&HttpService->ChildrenList, &HttpInstance->Link);\r | |
959 | HttpService->ChildrenNumber++;\r | |
960 | \r | |
961 | gBS->RestoreTPL (OldTpl);\r | |
962 | \r | |
963 | return EFI_SUCCESS;\r | |
f75a7f56 | 964 | \r |
47f51a06 | 965 | ON_ERROR:\r |
f75a7f56 | 966 | \r |
b659408b ZL |
967 | NetMapClean (&HttpInstance->TxTokens);\r |
968 | NetMapClean (&HttpInstance->RxTokens);\r | |
47f51a06 YT |
969 | FreePool (HttpInstance);\r |
970 | \r | |
971 | return Status;\r | |
972 | }\r | |
973 | \r | |
974 | /**\r | |
975 | Destroys a child handle with a protocol installed on it.\r | |
976 | \r | |
977 | The DestroyChild() function does the opposite of CreateChild(). It removes a protocol\r | |
978 | that was installed by CreateChild() from ChildHandle. If the removed protocol is the\r | |
979 | last protocol on ChildHandle, then ChildHandle is destroyed.\r | |
980 | \r | |
981 | @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r | |
982 | @param ChildHandle Handle of the child to destroy\r | |
983 | \r | |
ba3b642d | 984 | @retval EFI_SUCCESS The protocol was removed from ChildHandle.\r |
47f51a06 YT |
985 | @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.\r |
986 | @retval EFI_INVALID_PARAMETER Child handle is NULL.\r | |
987 | @retval other The child handle was not destroyed\r | |
988 | \r | |
989 | **/\r | |
990 | EFI_STATUS\r | |
991 | EFIAPI\r | |
992 | HttpServiceBindingDestroyChild (\r | |
993 | IN EFI_SERVICE_BINDING_PROTOCOL *This,\r | |
994 | IN EFI_HANDLE ChildHandle\r | |
995 | )\r | |
996 | {\r | |
997 | HTTP_SERVICE *HttpService;\r | |
998 | HTTP_PROTOCOL *HttpInstance;\r | |
999 | EFI_HTTP_PROTOCOL *Http;\r | |
1000 | EFI_STATUS Status;\r | |
1001 | EFI_TPL OldTpl;\r | |
f75a7f56 | 1002 | \r |
47f51a06 YT |
1003 | if ((This == NULL) || (ChildHandle == NULL)) {\r |
1004 | return EFI_INVALID_PARAMETER;\r | |
1005 | }\r | |
1006 | \r | |
1007 | HttpService = HTTP_SERVICE_FROM_PROTOCOL (This);\r | |
1008 | Status = gBS->OpenProtocol (\r | |
1009 | ChildHandle,\r | |
1010 | &gEfiHttpProtocolGuid,\r | |
1011 | (VOID **) &Http,\r | |
b659408b ZL |
1012 | NULL,\r |
1013 | NULL,\r | |
47f51a06 YT |
1014 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r |
1015 | );\r | |
1016 | if (EFI_ERROR (Status)) {\r | |
1017 | return EFI_UNSUPPORTED;\r | |
1018 | }\r | |
f75a7f56 | 1019 | \r |
47f51a06 YT |
1020 | HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (Http);\r |
1021 | if (HttpInstance->Service != HttpService) {\r | |
1022 | return EFI_INVALID_PARAMETER;\r | |
1023 | }\r | |
1024 | \r | |
1025 | if (HttpInstance->InDestroy) {\r | |
1026 | return EFI_SUCCESS;\r | |
1027 | }\r | |
1028 | \r | |
47f51a06 YT |
1029 | HttpInstance->InDestroy = TRUE;\r |
1030 | \r | |
1031 | //\r | |
1032 | // Uninstall the HTTP protocol.\r | |
1033 | //\r | |
1034 | Status = gBS->UninstallProtocolInterface (\r | |
1035 | ChildHandle,\r | |
1036 | &gEfiHttpProtocolGuid,\r | |
1037 | Http\r | |
1038 | );\r | |
1039 | \r | |
1040 | if (EFI_ERROR (Status)) {\r | |
1041 | HttpInstance->InDestroy = FALSE;\r | |
1042 | return Status;\r | |
1043 | }\r | |
f75a7f56 | 1044 | \r |
47f51a06 | 1045 | HttpCleanProtocol (HttpInstance);\r |
f75a7f56 | 1046 | \r |
b659408b | 1047 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r |
f75a7f56 | 1048 | \r |
47f51a06 YT |
1049 | RemoveEntryList (&HttpInstance->Link);\r |
1050 | HttpService->ChildrenNumber--;\r | |
1051 | \r | |
1052 | gBS->RestoreTPL (OldTpl);\r | |
f75a7f56 | 1053 | \r |
47f51a06 YT |
1054 | FreePool (HttpInstance);\r |
1055 | return EFI_SUCCESS;\r | |
1056 | }\r |