]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | The driver binding and service binding protocol for HttpDxe driver.\r | |
3 | \r | |
4 | Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php.\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "HttpDriver.h"\r | |
17 | \r | |
18 | EFI_HTTP_UTILITIES_PROTOCOL *mHttpUtilities = NULL;\r | |
19 | \r | |
20 | ///\r | |
21 | /// Driver Binding Protocol instance\r | |
22 | ///\r | |
23 | EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp4DriverBinding = {\r | |
24 | HttpDxeIp4DriverBindingSupported,\r | |
25 | HttpDxeIp4DriverBindingStart,\r | |
26 | HttpDxeIp4DriverBindingStop,\r | |
27 | HTTP_DRIVER_VERSION,\r | |
28 | NULL,\r | |
29 | NULL\r | |
30 | };\r | |
31 | \r | |
32 | EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp6DriverBinding = {\r | |
33 | HttpDxeIp6DriverBindingSupported,\r | |
34 | HttpDxeIp6DriverBindingStart,\r | |
35 | HttpDxeIp6DriverBindingStop,\r | |
36 | HTTP_DRIVER_VERSION,\r | |
37 | NULL,\r | |
38 | NULL\r | |
39 | };\r | |
40 | \r | |
41 | \r | |
42 | /**\r | |
43 | Create a HTTP driver service binding private instance.\r | |
44 | \r | |
45 | @param[in] Controller The controller that has TCP4 service binding\r | |
46 | installed.\r | |
47 | @param[in] ImageHandle The HTTP driver's image handle.\r | |
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 | |
57 | IN EFI_HANDLE ImageHandle,\r | |
58 | OUT HTTP_SERVICE **ServiceData\r | |
59 | )\r | |
60 | {\r | |
61 | HTTP_SERVICE *HttpService;\r | |
62 | \r | |
63 | ASSERT (ServiceData != NULL);\r | |
64 | *ServiceData = NULL;\r | |
65 | \r | |
66 | HttpService = AllocateZeroPool (sizeof (HTTP_SERVICE));\r | |
67 | if (HttpService == NULL) {\r | |
68 | return EFI_OUT_OF_RESOURCES;\r | |
69 | }\r | |
70 | \r | |
71 | HttpService->Signature = HTTP_SERVICE_SIGNATURE;\r | |
72 | HttpService->ServiceBinding.CreateChild = HttpServiceBindingCreateChild;\r | |
73 | HttpService->ServiceBinding.DestroyChild = HttpServiceBindingDestroyChild;\r | |
74 | HttpService->ImageHandle = ImageHandle;\r | |
75 | HttpService->ControllerHandle = Controller;\r | |
76 | HttpService->ChildrenNumber = 0;\r | |
77 | InitializeListHead (&HttpService->ChildrenList);\r | |
78 | \r | |
79 | *ServiceData = HttpService;\r | |
80 | return EFI_SUCCESS;\r | |
81 | }\r | |
82 | \r | |
83 | /**\r | |
84 | Release all the resource used the HTTP service binding instance.\r | |
85 | \r | |
86 | @param[in] HttpService The HTTP private instance.\r | |
87 | @param[in] UsingIpv6 Indicate use TCP4 protocol or TCP6 protocol.\r | |
88 | if TRUE, use Tcp6 protocol.\r | |
89 | if FALSE, use Tcp4 protocl.\r | |
90 | **/\r | |
91 | VOID\r | |
92 | HttpCleanService (\r | |
93 | IN HTTP_SERVICE *HttpService,\r | |
94 | IN BOOLEAN UsingIpv6\r | |
95 | )\r | |
96 | { \r | |
97 | \r | |
98 | if (HttpService == NULL) {\r | |
99 | return ;\r | |
100 | }\r | |
101 | if (!UsingIpv6) {\r | |
102 | if (HttpService->Tcp4ChildHandle != NULL) {\r | |
103 | gBS->CloseProtocol (\r | |
104 | HttpService->Tcp4ChildHandle,\r | |
105 | &gEfiTcp4ProtocolGuid,\r | |
106 | HttpService->ImageHandle,\r | |
107 | HttpService->ControllerHandle\r | |
108 | );\r | |
109 | \r | |
110 | NetLibDestroyServiceChild (\r | |
111 | HttpService->ControllerHandle,\r | |
112 | HttpService->ImageHandle,\r | |
113 | &gEfiTcp4ServiceBindingProtocolGuid,\r | |
114 | HttpService->Tcp4ChildHandle\r | |
115 | );\r | |
116 | \r | |
117 | HttpService->Tcp4ChildHandle = NULL;\r | |
118 | }\r | |
119 | } else {\r | |
120 | if (HttpService->Tcp6ChildHandle != NULL) {\r | |
121 | gBS->CloseProtocol (\r | |
122 | HttpService->Tcp6ChildHandle,\r | |
123 | &gEfiTcp6ProtocolGuid,\r | |
124 | HttpService->ImageHandle,\r | |
125 | HttpService->ControllerHandle\r | |
126 | );\r | |
127 | \r | |
128 | NetLibDestroyServiceChild (\r | |
129 | HttpService->ControllerHandle,\r | |
130 | HttpService->ImageHandle,\r | |
131 | &gEfiTcp6ServiceBindingProtocolGuid,\r | |
132 | HttpService->Tcp6ChildHandle\r | |
133 | );\r | |
134 | \r | |
135 | HttpService->Tcp6ChildHandle = NULL;\r | |
136 | }\r | |
137 | }\r | |
138 | \r | |
139 | }\r | |
140 | \r | |
141 | /**\r | |
142 | The event process routine when the http utilities protocol is installed\r | |
143 | in the system.\r | |
144 | \r | |
145 | @param[in] Event Not used.\r | |
146 | @param[in] Context The pointer to the IP4 config2 instance data or IP6 Config instance data.\r | |
147 | \r | |
148 | **/\r | |
149 | VOID\r | |
150 | EFIAPI\r | |
151 | HttpUtilitiesInstalledCallback (\r | |
152 | IN EFI_EVENT Event,\r | |
153 | IN VOID *Context\r | |
154 | )\r | |
155 | {\r | |
156 | gBS->LocateProtocol (\r | |
157 | &gEfiHttpUtilitiesProtocolGuid, \r | |
158 | NULL, \r | |
159 | (VOID **) &mHttpUtilities\r | |
160 | );\r | |
161 | \r | |
162 | //\r | |
163 | // Close the event if Http utilities protocol is loacted.\r | |
164 | //\r | |
165 | if (mHttpUtilities != NULL && Event != NULL) {\r | |
166 | gBS->CloseEvent (Event);\r | |
167 | }\r | |
168 | }\r | |
169 | \r | |
170 | /**\r | |
171 | This is the declaration of an EFI image entry point. This entry point is\r | |
172 | the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including\r | |
173 | both device drivers and bus drivers.\r | |
174 | \r | |
175 | @param ImageHandle The firmware allocated handle for the UEFI image.\r | |
176 | @param SystemTable A pointer to the EFI System Table.\r | |
177 | \r | |
178 | @retval EFI_SUCCESS The operation completed successfully.\r | |
179 | @retval Others An unexpected error occurred.\r | |
180 | \r | |
181 | **/\r | |
182 | EFI_STATUS\r | |
183 | EFIAPI\r | |
184 | HttpDxeDriverEntryPoint (\r | |
185 | IN EFI_HANDLE ImageHandle,\r | |
186 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
187 | )\r | |
188 | { \r | |
189 | EFI_STATUS Status;\r | |
190 | VOID *Registration;\r | |
191 | \r | |
192 | gBS->LocateProtocol (\r | |
193 | &gEfiHttpUtilitiesProtocolGuid, \r | |
194 | NULL, \r | |
195 | (VOID **) &mHttpUtilities\r | |
196 | );\r | |
197 | \r | |
198 | if (mHttpUtilities == NULL) {\r | |
199 | //\r | |
200 | // No Http utilities protocol, register a notify.\r | |
201 | //\r | |
202 | EfiCreateProtocolNotifyEvent (\r | |
203 | &gEfiHttpUtilitiesProtocolGuid,\r | |
204 | TPL_CALLBACK,\r | |
205 | HttpUtilitiesInstalledCallback,\r | |
206 | NULL,\r | |
207 | &Registration\r | |
208 | );\r | |
209 | }\r | |
210 | \r | |
211 | //\r | |
212 | // Install UEFI Driver Model protocol(s).\r | |
213 | //\r | |
214 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
215 | ImageHandle,\r | |
216 | SystemTable,\r | |
217 | &gHttpDxeIp4DriverBinding,\r | |
218 | ImageHandle,\r | |
219 | &gHttpDxeComponentName,\r | |
220 | &gHttpDxeComponentName2\r | |
221 | );\r | |
222 | if (EFI_ERROR (Status)) {\r | |
223 | return Status;\r | |
224 | }\r | |
225 | \r | |
226 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
227 | ImageHandle,\r | |
228 | SystemTable,\r | |
229 | &gHttpDxeIp6DriverBinding,\r | |
230 | NULL,\r | |
231 | &gHttpDxeComponentName,\r | |
232 | &gHttpDxeComponentName2\r | |
233 | );\r | |
234 | if (EFI_ERROR (Status)) {\r | |
235 | gBS->UninstallMultipleProtocolInterfaces (\r | |
236 | ImageHandle,\r | |
237 | &gEfiDriverBindingProtocolGuid,\r | |
238 | &gHttpDxeIp4DriverBinding,\r | |
239 | &gEfiComponentName2ProtocolGuid,\r | |
240 | &gHttpDxeComponentName2,\r | |
241 | &gEfiComponentNameProtocolGuid,\r | |
242 | &gHttpDxeComponentName,\r | |
243 | NULL\r | |
244 | );\r | |
245 | }\r | |
246 | return Status;\r | |
247 | }\r | |
248 | \r | |
249 | /**\r | |
250 | Callback function which provided by user to remove one node in NetDestroyLinkList process.\r | |
251 | \r | |
252 | @param[in] Entry The entry to be removed.\r | |
253 | @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.\r | |
254 | \r | |
255 | @retval EFI_INVALID_PARAMETER Any input parameter is NULL.\r | |
256 | @retval EFI_SUCCESS The entry has been removed successfully.\r | |
257 | @retval Others Fail to remove the entry.\r | |
258 | \r | |
259 | **/\r | |
260 | EFI_STATUS\r | |
261 | EFIAPI\r | |
262 | HttpDestroyChildEntryInHandleBuffer (\r | |
263 | IN LIST_ENTRY *Entry,\r | |
264 | IN VOID *Context\r | |
265 | )\r | |
266 | {\r | |
267 | HTTP_PROTOCOL *HttpInstance;\r | |
268 | EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r | |
269 | UINTN NumberOfChildren;\r | |
270 | EFI_HANDLE *ChildHandleBuffer;\r | |
271 | \r | |
272 | if (Entry == NULL || Context == NULL) {\r | |
273 | return EFI_INVALID_PARAMETER;\r | |
274 | }\r | |
275 | \r | |
276 | HttpInstance = NET_LIST_USER_STRUCT_S (Entry, HTTP_PROTOCOL, Link, HTTP_PROTOCOL_SIGNATURE);\r | |
277 | ServiceBinding = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;\r | |
278 | NumberOfChildren = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;\r | |
279 | ChildHandleBuffer = ((HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;\r | |
280 | \r | |
281 | if (!NetIsInHandleBuffer (HttpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) {\r | |
282 | return EFI_SUCCESS;\r | |
283 | }\r | |
284 | \r | |
285 | return ServiceBinding->DestroyChild (ServiceBinding, HttpInstance->Handle);\r | |
286 | }\r | |
287 | \r | |
288 | /**\r | |
289 | Test to see if this driver supports ControllerHandle. This is the worker function for\r | |
290 | HttpDxeIp4(6)DriverBindingSupported.\r | |
291 | \r | |
292 | @param[in] This The pointer to the driver binding protocol.\r | |
293 | @param[in] ControllerHandle The handle of device to be tested.\r | |
294 | @param[in] RemainingDevicePath Optional parameter used to pick a specific child\r | |
295 | device to be started.\r | |
296 | @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r | |
297 | \r | |
298 | @retval EFI_SUCCESS This driver supports this device.\r | |
299 | @retval EFI_UNSUPPORTED This driver does not support this device.\r | |
300 | \r | |
301 | **/\r | |
302 | EFI_STATUS\r | |
303 | EFIAPI\r | |
304 | HttpDxeSupported (\r | |
305 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
306 | IN EFI_HANDLE ControllerHandle,\r | |
307 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,\r | |
308 | IN UINT8 IpVersion\r | |
309 | )\r | |
310 | {\r | |
311 | EFI_STATUS Status;\r | |
312 | EFI_GUID *TcpServiceBindingProtocolGuid;\r | |
313 | \r | |
314 | if (IpVersion == IP_VERSION_4) {\r | |
315 | TcpServiceBindingProtocolGuid = &gEfiTcp4ServiceBindingProtocolGuid;\r | |
316 | } else {\r | |
317 | TcpServiceBindingProtocolGuid = &gEfiTcp6ServiceBindingProtocolGuid;\r | |
318 | }\r | |
319 | \r | |
320 | Status = gBS->OpenProtocol (\r | |
321 | ControllerHandle,\r | |
322 | TcpServiceBindingProtocolGuid,\r | |
323 | NULL,\r | |
324 | This->DriverBindingHandle,\r | |
325 | ControllerHandle,\r | |
326 | EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r | |
327 | );\r | |
328 | \r | |
329 | if (EFI_ERROR (Status)) {\r | |
330 | return EFI_UNSUPPORTED;\r | |
331 | }\r | |
332 | \r | |
333 | return EFI_SUCCESS;\r | |
334 | }\r | |
335 | \r | |
336 | /**\r | |
337 | Start this driver on ControllerHandle. This is the worker function for\r | |
338 | HttpDxeIp4(6)DriverBindingStart.\r | |
339 | \r | |
340 | @param[in] This The pointer to the driver binding protocol.\r | |
341 | @param[in] ControllerHandle The handle of device to be started.\r | |
342 | @param[in] RemainingDevicePath Optional parameter used to pick a specific child\r | |
343 | device to be started.\r | |
344 | @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r | |
345 | \r | |
346 | \r | |
347 | @retval EFI_SUCCESS This driver is installed to ControllerHandle.\r | |
348 | @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.\r | |
349 | @retval other This driver does not support this device.\r | |
350 | \r | |
351 | **/\r | |
352 | EFI_STATUS\r | |
353 | EFIAPI\r | |
354 | HttpDxeStart (\r | |
355 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
356 | IN EFI_HANDLE ControllerHandle,\r | |
357 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,\r | |
358 | IN UINT8 IpVersion\r | |
359 | )\r | |
360 | {\r | |
361 | EFI_STATUS Status;\r | |
362 | EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r | |
363 | HTTP_SERVICE *HttpService;\r | |
364 | VOID *Interface;\r | |
365 | BOOLEAN UsingIpv6;\r | |
366 | \r | |
367 | UsingIpv6 = FALSE;\r | |
368 | \r | |
369 | //\r | |
370 | // Test for the Http service binding protocol\r | |
371 | //\r | |
372 | Status = gBS->OpenProtocol (\r | |
373 | ControllerHandle,\r | |
374 | &gEfiHttpServiceBindingProtocolGuid,\r | |
375 | (VOID **) &ServiceBinding,\r | |
376 | This->DriverBindingHandle,\r | |
377 | ControllerHandle,\r | |
378 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
379 | );\r | |
380 | \r | |
381 | if (!EFI_ERROR (Status)) {\r | |
382 | HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding);\r | |
383 | } else {\r | |
384 | Status = HttpCreateService (ControllerHandle, This->DriverBindingHandle, &HttpService);\r | |
385 | if (EFI_ERROR (Status)) {\r | |
386 | return Status;\r | |
387 | }\r | |
388 | \r | |
389 | ASSERT (HttpService != NULL);\r | |
390 | \r | |
391 | //\r | |
392 | // Install the HttpServiceBinding Protocol onto Controller\r | |
393 | //\r | |
394 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
395 | &ControllerHandle,\r | |
396 | &gEfiHttpServiceBindingProtocolGuid,\r | |
397 | &HttpService->ServiceBinding,\r | |
398 | NULL\r | |
399 | );\r | |
400 | \r | |
401 | if (EFI_ERROR (Status)) {\r | |
402 | goto ON_ERROR;\r | |
403 | }\r | |
404 | }\r | |
405 | \r | |
406 | if (IpVersion == IP_VERSION_4) {\r | |
407 | \r | |
408 | if (HttpService->Tcp4ChildHandle == NULL) {\r | |
409 | //\r | |
410 | // Create a TCP4 child instance, but do not configure it. This will establish the parent-child relationship.\r | |
411 | //\r | |
412 | Status = NetLibCreateServiceChild (\r | |
413 | ControllerHandle,\r | |
414 | This->DriverBindingHandle,\r | |
415 | &gEfiTcp4ServiceBindingProtocolGuid,\r | |
416 | &HttpService->Tcp4ChildHandle\r | |
417 | );\r | |
418 | \r | |
419 | if (EFI_ERROR (Status)) {\r | |
420 | goto ON_ERROR;\r | |
421 | }\r | |
422 | \r | |
423 | Status = gBS->OpenProtocol (\r | |
424 | HttpService->Tcp4ChildHandle,\r | |
425 | &gEfiTcp4ProtocolGuid,\r | |
426 | &Interface,\r | |
427 | This->DriverBindingHandle,\r | |
428 | ControllerHandle,\r | |
429 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
430 | );\r | |
431 | \r | |
432 | if (EFI_ERROR (Status)) {\r | |
433 | goto ON_ERROR;\r | |
434 | }\r | |
435 | \r | |
436 | } else {\r | |
437 | return EFI_ALREADY_STARTED;\r | |
438 | }\r | |
439 | \r | |
440 | } else {\r | |
441 | UsingIpv6 = TRUE;\r | |
442 | \r | |
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 | |
453 | \r | |
454 | if (EFI_ERROR (Status)) {\r | |
455 | goto ON_ERROR;\r | |
456 | }\r | |
457 | \r | |
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 | |
466 | \r | |
467 | if (EFI_ERROR (Status)) {\r | |
468 | goto ON_ERROR;\r | |
469 | }\r | |
470 | \r | |
471 | } else {\r | |
472 | return EFI_ALREADY_STARTED;\r | |
473 | }\r | |
474 | \r | |
475 | }\r | |
476 | \r | |
477 | return EFI_SUCCESS;\r | |
478 | \r | |
479 | ON_ERROR:\r | |
480 | \r | |
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 | |
487 | \r | |
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 | |
554 | \r | |
555 | HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding);\r | |
556 | \r | |
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 | |
572 | \r | |
573 | HttpCleanService (HttpService, UsingIpv6);\r | |
574 | \r | |
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 | |
584 | } \r | |
585 | }\r | |
586 | \r | |
587 | return Status;\r | |
588 | \r | |
589 | }\r | |
590 | \r | |
591 | /**\r | |
592 | Tests to see if this driver supports a given controller. If a child device is provided, \r | |
593 | it further tests to see if this driver supports creating a handle for the specified child device.\r | |
594 | \r | |
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 | |
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 | |
610 | @param[in] ControllerHandle The handle of the controller to test. This handle \r | |
611 | must support a protocol interface that supplies \r | |
612 | an I/O abstraction to the driver.\r | |
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 | |
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 | |
635 | HttpDxeIp4DriverBindingSupported (\r | |
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 | |
641 | return HttpDxeSupported (\r | |
642 | This,\r | |
643 | ControllerHandle,\r | |
644 | RemainingDevicePath,\r | |
645 | IP_VERSION_4\r | |
646 | );\r | |
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 | |
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 | |
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 | |
660 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. \r | |
661 | \r | |
662 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
663 | @param[in] ControllerHandle The handle of the controller to start. This handle \r | |
664 | must support a protocol interface that supplies \r | |
665 | an I/O abstraction to the driver.\r | |
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 | |
673 | RemainingDevicePath is created by this driver.\r | |
674 | If the first Device Path Node of RemainingDevicePath is \r | |
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 | |
687 | HttpDxeIp4DriverBindingStart (\r | |
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 | |
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 | |
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 | |
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 | |
714 | \r | |
715 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
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 | |
718 | to use to stop the device.\r | |
719 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
720 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL \r | |
721 | if NumberOfChildren is 0.\r | |
722 | \r | |
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 | |
725 | \r | |
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 | |
744 | \r | |
745 | /**\r | |
746 | Tests to see if this driver supports a given controller. If a child device is provided, \r | |
747 | it further tests to see if this driver supports creating a handle for the specified child device.\r | |
748 | \r | |
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 | |
761 | to guarantee the state of ControllerHandle is not modified by this function.\r | |
762 | \r | |
763 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
764 | @param[in] ControllerHandle The handle of the controller to test. This handle \r | |
765 | must support a protocol interface that supplies \r | |
766 | an I/O abstraction to the driver.\r | |
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 | |
773 | bus driver.\r | |
774 | \r | |
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 | |
794 | { \r | |
795 | return HttpDxeSupported (\r | |
796 | This,\r | |
797 | ControllerHandle,\r | |
798 | RemainingDevicePath,\r | |
799 | IP_VERSION_6\r | |
800 | );\r | |
801 | \r | |
802 | }\r | |
803 | \r | |
804 | /**\r | |
805 | Starts a device controller or a bus controller.\r | |
806 | \r | |
807 | The Start() function is designed to be invoked from the EFI boot service ConnectController().\r | |
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 | |
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 | |
815 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. \r | |
816 | \r | |
817 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
818 | @param[in] ControllerHandle The handle of the controller to start. This handle \r | |
819 | must support a protocol interface that supplies \r | |
820 | an I/O abstraction to the driver.\r | |
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 | |
828 | RemainingDevicePath is created by this driver.\r | |
829 | If the first Device Path Node of RemainingDevicePath is \r | |
830 | the End of Device Path Node, no child handle is created by this\r | |
831 | driver.\r | |
832 | \r | |
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 | |
854 | }\r | |
855 | \r | |
856 | /**\r | |
857 | Stops a device controller or a bus controller.\r | |
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 | |
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 | |
869 | \r | |
870 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
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 | |
873 | to use to stop the device.\r | |
874 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
875 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL \r | |
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 | |
884 | HttpDxeIp6DriverBindingStop (\r | |
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 | |
891 | return HttpDxeStop (\r | |
892 | This,\r | |
893 | ControllerHandle,\r | |
894 | NumberOfChildren,\r | |
895 | ChildHandleBuffer,\r | |
896 | IP_VERSION_6\r | |
897 | );\r | |
898 | }\r | |
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 | |
913 | @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create\r | |
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 | |
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 | |
939 | \r | |
940 | HttpInstance->Signature = HTTP_PROTOCOL_SIGNATURE;\r | |
941 | HttpInstance->Service = HttpService;\r | |
942 | CopyMem (&HttpInstance->Http, &mEfiHttpTemplate, sizeof (HttpInstance->Http));\r | |
943 | NetMapInit (&HttpInstance->TxTokens);\r | |
944 | NetMapInit (&HttpInstance->RxTokens);\r | |
945 | \r | |
946 | //\r | |
947 | // Install HTTP protocol onto ChildHandle\r | |
948 | //\r | |
949 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
950 | ChildHandle,\r | |
951 | &gEfiHttpProtocolGuid,\r | |
952 | &HttpInstance->Http,\r | |
953 | NULL\r | |
954 | );\r | |
955 | \r | |
956 | if (EFI_ERROR (Status)) {\r | |
957 | goto ON_ERROR;\r | |
958 | }\r | |
959 | \r | |
960 | HttpInstance->Handle = *ChildHandle;\r | |
961 | \r | |
962 | //\r | |
963 | // Add it to the HTTP service's child list.\r | |
964 | //\r | |
965 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
966 | \r | |
967 | InsertTailList (&HttpService->ChildrenList, &HttpInstance->Link);\r | |
968 | HttpService->ChildrenNumber++;\r | |
969 | \r | |
970 | gBS->RestoreTPL (OldTpl);\r | |
971 | \r | |
972 | return EFI_SUCCESS;\r | |
973 | \r | |
974 | ON_ERROR:\r | |
975 | \r | |
976 | NetMapClean (&HttpInstance->TxTokens);\r | |
977 | NetMapClean (&HttpInstance->RxTokens);\r | |
978 | FreePool (HttpInstance);\r | |
979 | \r | |
980 | return Status;\r | |
981 | }\r | |
982 | \r | |
983 | /**\r | |
984 | Destroys a child handle with a protocol installed on it.\r | |
985 | \r | |
986 | The DestroyChild() function does the opposite of CreateChild(). It removes a protocol\r | |
987 | that was installed by CreateChild() from ChildHandle. If the removed protocol is the\r | |
988 | last protocol on ChildHandle, then ChildHandle is destroyed.\r | |
989 | \r | |
990 | @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r | |
991 | @param ChildHandle Handle of the child to destroy\r | |
992 | \r | |
993 | @retval EFI_SUCCES The protocol was removed from ChildHandle.\r | |
994 | @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.\r | |
995 | @retval EFI_INVALID_PARAMETER Child handle is NULL.\r | |
996 | @retval other The child handle was not destroyed\r | |
997 | \r | |
998 | **/\r | |
999 | EFI_STATUS\r | |
1000 | EFIAPI\r | |
1001 | HttpServiceBindingDestroyChild (\r | |
1002 | IN EFI_SERVICE_BINDING_PROTOCOL *This,\r | |
1003 | IN EFI_HANDLE ChildHandle\r | |
1004 | )\r | |
1005 | {\r | |
1006 | HTTP_SERVICE *HttpService;\r | |
1007 | HTTP_PROTOCOL *HttpInstance;\r | |
1008 | EFI_HTTP_PROTOCOL *Http;\r | |
1009 | EFI_STATUS Status;\r | |
1010 | EFI_TPL OldTpl;\r | |
1011 | \r | |
1012 | if ((This == NULL) || (ChildHandle == NULL)) {\r | |
1013 | return EFI_INVALID_PARAMETER;\r | |
1014 | }\r | |
1015 | \r | |
1016 | HttpService = HTTP_SERVICE_FROM_PROTOCOL (This);\r | |
1017 | Status = gBS->OpenProtocol (\r | |
1018 | ChildHandle,\r | |
1019 | &gEfiHttpProtocolGuid,\r | |
1020 | (VOID **) &Http,\r | |
1021 | NULL,\r | |
1022 | NULL,\r | |
1023 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
1024 | );\r | |
1025 | if (EFI_ERROR (Status)) {\r | |
1026 | return EFI_UNSUPPORTED;\r | |
1027 | }\r | |
1028 | \r | |
1029 | HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (Http);\r | |
1030 | if (HttpInstance->Service != HttpService) {\r | |
1031 | return EFI_INVALID_PARAMETER;\r | |
1032 | }\r | |
1033 | \r | |
1034 | if (HttpInstance->InDestroy) {\r | |
1035 | return EFI_SUCCESS;\r | |
1036 | }\r | |
1037 | \r | |
1038 | HttpInstance->InDestroy = TRUE;\r | |
1039 | \r | |
1040 | //\r | |
1041 | // Uninstall the HTTP protocol.\r | |
1042 | //\r | |
1043 | Status = gBS->UninstallProtocolInterface (\r | |
1044 | ChildHandle,\r | |
1045 | &gEfiHttpProtocolGuid,\r | |
1046 | Http\r | |
1047 | );\r | |
1048 | \r | |
1049 | if (EFI_ERROR (Status)) {\r | |
1050 | HttpInstance->InDestroy = FALSE;\r | |
1051 | return Status;\r | |
1052 | }\r | |
1053 | \r | |
1054 | HttpCleanProtocol (HttpInstance);\r | |
1055 | \r | |
1056 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
1057 | \r | |
1058 | RemoveEntryList (&HttpInstance->Link);\r | |
1059 | HttpService->ChildrenNumber--;\r | |
1060 | \r | |
1061 | gBS->RestoreTPL (OldTpl);\r | |
1062 | \r | |
1063 | FreePool (HttpInstance);\r | |
1064 | return EFI_SUCCESS;\r | |
1065 | }\r |