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