]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/HttpBootDxe/HttpBootDxe.c
NetworkPkg:Enable Http Boot over Ipv6 stack
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootDxe.c
CommitLineData
d933e70a
JW
1/** @file\r
2 Driver Binding functions implementation for UEFI HTTP boot.\r
3\r
4Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials are licensed and made available under \r
6the terms and conditions of the BSD License that accompanies this distribution. \r
7The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php. \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
13**/\r
14\r
15#include "HttpBootDxe.h"\r
16\r
17///\r
18/// Driver Binding Protocol instance\r
19///\r
20EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp4DxeDriverBinding = {\r
21 HttpBootIp4DxeDriverBindingSupported,\r
22 HttpBootIp4DxeDriverBindingStart,\r
23 HttpBootIp4DxeDriverBindingStop,\r
24 HTTP_BOOT_DXE_VERSION,\r
25 NULL,\r
26 NULL\r
27};\r
28\r
b659408b
ZL
29EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp6DxeDriverBinding = {\r
30 HttpBootIp6DxeDriverBindingSupported,\r
31 HttpBootIp6DxeDriverBindingStart,\r
32 HttpBootIp6DxeDriverBindingStop,\r
33 HTTP_BOOT_DXE_VERSION,\r
34 NULL,\r
35 NULL\r
36};\r
37\r
d933e70a
JW
38/**\r
39 Destroy the HTTP child based on IPv4 stack.\r
40\r
41 @param[in] This Pointer to the EFI_DRIVER_BINDING_PROTOCOL.\r
42 @param[in] Private Pointer to HTTP_BOOT_PRIVATE_DATA.\r
43\r
44**/\r
45VOID\r
46HttpBootDestroyIp4Children (\r
47 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
48 IN HTTP_BOOT_PRIVATE_DATA *Private\r
49 )\r
50{\r
51 ASSERT (This != NULL);\r
52 ASSERT (Private != NULL);\r
53 ASSERT (Private->UsingIpv6 == FALSE);\r
54\r
55 if (Private->Dhcp4Child != NULL) {\r
56 gBS->CloseProtocol (\r
b659408b
ZL
57 Private->Dhcp4Child,\r
58 &gEfiDhcp4ProtocolGuid,\r
59 This->DriverBindingHandle,\r
60 Private->Controller\r
61 );\r
d933e70a
JW
62\r
63 NetLibDestroyServiceChild (\r
64 Private->Controller,\r
65 This->DriverBindingHandle,\r
66 &gEfiDhcp4ServiceBindingProtocolGuid,\r
67 Private->Dhcp4Child\r
68 );\r
69 }\r
70\r
71 if (Private->HttpCreated) {\r
72 HttpIoDestroyIo (&Private->HttpIo);\r
73 Private->HttpCreated = FALSE;\r
74 }\r
75\r
b659408b
ZL
76 if (Private->Ip4Nic != NULL) {\r
77 \r
78 gBS->CloseProtocol (\r
79 Private->Controller,\r
80 &gEfiCallerIdGuid,\r
81 This->DriverBindingHandle,\r
82 Private->Ip4Nic->Controller\r
83 );\r
84 \r
85 gBS->UninstallMultipleProtocolInterfaces (\r
86 Private->Ip4Nic->Controller,\r
87 &gEfiLoadFileProtocolGuid,\r
88 &Private->Ip4Nic->LoadFile,\r
89 &gEfiDevicePathProtocolGuid,\r
90 Private->Ip4Nic->DevicePath,\r
91 NULL\r
92 );\r
93 FreePool (Private->Ip4Nic);\r
94 Private->Ip4Nic = NULL;\r
95 }\r
96\r
97}\r
98\r
99/**\r
100 Destroy the HTTP child based on IPv6 stack.\r
101\r
102 @param[in] This Pointer to the EFI_DRIVER_BINDING_PROTOCOL.\r
103 @param[in] Private Pointer to HTTP_BOOT_PRIVATE_DATA.\r
104\r
105**/\r
106VOID\r
107HttpBootDestroyIp6Children (\r
108 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
109 IN HTTP_BOOT_PRIVATE_DATA *Private\r
110 )\r
111{\r
112 ASSERT (This != NULL);\r
113 ASSERT (Private != NULL);\r
114 ASSERT (Private->UsingIpv6 == TRUE);\r
115 \r
116 if (Private->Ip6Child != NULL) {\r
117 gBS->CloseProtocol (\r
118 Private->Ip6Child,\r
119 &gEfiIp6ProtocolGuid,\r
120 This->DriverBindingHandle,\r
121 Private->Controller\r
122 );\r
123\r
124 NetLibDestroyServiceChild (\r
125 Private->Controller,\r
126 This->DriverBindingHandle,\r
127 &gEfiIp6ServiceBindingProtocolGuid,\r
128 Private->Ip6Child\r
129 );\r
130 }\r
131\r
132 if (Private->Dhcp6Child != NULL) {\r
133 gBS->CloseProtocol (\r
134 Private->Dhcp6Child,\r
135 &gEfiDhcp6ProtocolGuid,\r
136 This->DriverBindingHandle,\r
137 Private->Controller\r
138 );\r
d933e70a 139\r
b659408b
ZL
140 NetLibDestroyServiceChild (\r
141 Private->Controller,\r
142 This->DriverBindingHandle,\r
143 &gEfiDhcp6ServiceBindingProtocolGuid,\r
144 Private->Dhcp6Child\r
145 );\r
146 }\r
d933e70a 147\r
b659408b
ZL
148 if (Private->HttpCreated) {\r
149 HttpIoDestroyIo(&Private->HttpIo);\r
150 Private->HttpCreated = FALSE;\r
151 }\r
152 \r
153 if (Private->Ip6Nic != NULL) {\r
154 \r
155 gBS->CloseProtocol (\r
156 Private->Controller,\r
157 &gEfiCallerIdGuid,\r
158 This->DriverBindingHandle,\r
159 Private->Ip6Nic->Controller\r
160 );\r
161 \r
162 gBS->UninstallMultipleProtocolInterfaces (\r
163 Private->Ip6Nic->Controller,\r
164 &gEfiLoadFileProtocolGuid,\r
165 &Private->Ip6Nic->LoadFile,\r
166 &gEfiDevicePathProtocolGuid,\r
167 Private->Ip6Nic->DevicePath,\r
168 NULL\r
169 );\r
170 FreePool (Private->Ip6Nic);\r
171 Private->Ip6Nic = NULL;\r
d933e70a
JW
172 }\r
173}\r
174\r
175/**\r
176 Tests to see if this driver supports a given controller. If a child device is provided, \r
177 it further tests to see if this driver supports creating a handle for the specified child device.\r
178\r
179 This function checks to see if the driver specified by This supports the device specified by \r
180 ControllerHandle. Drivers will typically use the device path attached to \r
181 ControllerHandle and/or the services from the bus I/O abstraction attached to \r
182 ControllerHandle to determine if the driver supports ControllerHandle. This function \r
183 may be called many times during platform initialization. In order to reduce boot times, the tests \r
184 performed by this function must be very small, and take as little time as possible to execute. This \r
185 function must not change the state of any hardware devices, and this function must be aware that the \r
186 device specified by ControllerHandle may already be managed by the same driver or a \r
187 different driver. This function must match its calls to AllocatePages() with FreePages(), \r
188 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). \r
189 Because ControllerHandle may have been previously started by the same driver, if a protocol is \r
190 already in the opened state, then it must not be closed with CloseProtocol(). This is required \r
191 to guarantee the state of ControllerHandle is not modified by this function.\r
192\r
193 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
194 @param[in] ControllerHandle The handle of the controller to test. This handle \r
195 must support a protocol interface that supplies \r
196 an I/O abstraction to the driver.\r
197 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This \r
198 parameter is ignored by device drivers, and is optional for bus \r
199 drivers. For bus drivers, if this parameter is not NULL, then \r
200 the bus driver must determine if the bus controller specified \r
201 by ControllerHandle and the child controller specified \r
202 by RemainingDevicePath are both supported by this \r
203 bus driver.\r
204\r
205 @retval EFI_SUCCESS The device specified by ControllerHandle and\r
206 RemainingDevicePath is supported by the driver specified by This.\r
207 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r
208 RemainingDevicePath is already being managed by the driver\r
209 specified by This.\r
210 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r
211 RemainingDevicePath is already being managed by a different\r
212 driver or an application that requires exclusive access.\r
213 Currently not implemented.\r
214 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r
215 RemainingDevicePath is not supported by the driver specified by This.\r
216**/\r
217EFI_STATUS\r
218EFIAPI\r
219HttpBootIp4DxeDriverBindingSupported (\r
220 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
221 IN EFI_HANDLE ControllerHandle,\r
222 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
223 )\r
224{\r
225 EFI_STATUS Status;\r
226 \r
227 //\r
228 // Try to open the DHCP4, HTTP4 and Device Path protocol.\r
229 //\r
230 Status = gBS->OpenProtocol (\r
b659408b
ZL
231 ControllerHandle,\r
232 &gEfiDhcp4ServiceBindingProtocolGuid,\r
233 NULL,\r
234 This->DriverBindingHandle,\r
235 ControllerHandle,\r
236 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
237 );\r
d933e70a
JW
238 if (EFI_ERROR (Status)) {\r
239 return Status;\r
240 }\r
241\r
242 Status = gBS->OpenProtocol (\r
b659408b
ZL
243 ControllerHandle,\r
244 &gEfiHttpServiceBindingProtocolGuid,\r
245 NULL,\r
246 This->DriverBindingHandle,\r
247 ControllerHandle,\r
248 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
249 );\r
d933e70a
JW
250 if (EFI_ERROR (Status)) {\r
251 return Status;\r
252 }\r
253\r
254 Status = gBS->OpenProtocol (\r
b659408b
ZL
255 ControllerHandle,\r
256 &gEfiDevicePathProtocolGuid,\r
257 NULL,\r
258 This->DriverBindingHandle,\r
259 ControllerHandle,\r
260 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
261 );\r
d933e70a
JW
262\r
263 return Status;\r
264}\r
265\r
266\r
267/**\r
268 Starts a device controller or a bus controller.\r
269\r
270 The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
271 As a result, much of the error checking on the parameters to Start() has been moved into this \r
272 common boot service. It is legal to call Start() from other locations, \r
273 but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
274 1. ControllerHandle must be a valid EFI_HANDLE.\r
275 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
276 EFI_DEVICE_PATH_PROTOCOL.\r
277 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
278 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. \r
279\r
280 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
281 @param[in] ControllerHandle The handle of the controller to start. This handle \r
282 must support a protocol interface that supplies \r
283 an I/O abstraction to the driver.\r
284 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This \r
285 parameter is ignored by device drivers, and is optional for bus \r
286 drivers. For a bus driver, if this parameter is NULL, then handles \r
287 for all the children of Controller are created by this driver. \r
288 If this parameter is not NULL and the first Device Path Node is \r
289 not the End of Device Path Node, then only the handle for the \r
290 child device specified by the first Device Path Node of \r
291 RemainingDevicePath is created by this driver.\r
292 If the first Device Path Node of RemainingDevicePath is \r
293 the End of Device Path Node, no child handle is created by this\r
294 driver.\r
295\r
296 @retval EFI_SUCCESS The device was started.\r
297 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r
298 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
299 @retval Others The driver failded to start the device.\r
300\r
301**/\r
302EFI_STATUS\r
303EFIAPI\r
304HttpBootIp4DxeDriverBindingStart (\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 )\r
309{\r
310 EFI_STATUS Status;\r
311 HTTP_BOOT_PRIVATE_DATA *Private;\r
312 EFI_DEV_PATH *Node;\r
313 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
314 UINT32 *Id;\r
315\r
316 Status = gBS->OpenProtocol (\r
317 ControllerHandle,\r
318 &gEfiCallerIdGuid,\r
319 (VOID **) &Id,\r
320 This->DriverBindingHandle,\r
321 ControllerHandle,\r
322 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
323 );\r
b659408b 324\r
d933e70a 325 if (!EFI_ERROR (Status)) {\r
b659408b
ZL
326 Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id);\r
327 } else {\r
328 //\r
329 // Initialize the private data structure.\r
330 //\r
331 Private = AllocateZeroPool (sizeof (HTTP_BOOT_PRIVATE_DATA));\r
332 if (Private == NULL) {\r
333 return EFI_OUT_OF_RESOURCES;\r
334 }\r
335 Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;\r
336 Private->Controller = ControllerHandle;\r
337 Private->Image = This->ImageHandle;\r
338 InitializeListHead (&Private->CacheList);\r
339 //\r
340 // Get the NII interface if it exists, it's not required.\r
341 //\r
342 Status = gBS->OpenProtocol (\r
343 ControllerHandle,\r
344 &gEfiNetworkInterfaceIdentifierProtocolGuid_31,\r
345 (VOID **) &Private->Nii,\r
346 This->DriverBindingHandle,\r
347 ControllerHandle,\r
348 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
349 );\r
350 if (EFI_ERROR (Status)) {\r
351 Private->Nii = NULL;\r
352 }\r
d933e70a 353\r
b659408b
ZL
354 //\r
355 // Open Device Path Protocol to prepare for appending IP and URI node.\r
356 //\r
357 Status = gBS->OpenProtocol (\r
358 ControllerHandle,\r
359 &gEfiDevicePathProtocolGuid,\r
360 (VOID **) &Private->ParentDevicePath,\r
361 This->DriverBindingHandle,\r
362 ControllerHandle,\r
363 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
364 );\r
365 if (EFI_ERROR (Status)) {\r
366 goto ON_ERROR;\r
367 }\r
368\r
369 //\r
370 // Install a protocol with Caller Id Guid to the NIC, this is just to build the relationship between\r
371 // NIC handle and the private data.\r
372 //\r
373 Status = gBS->InstallProtocolInterface (\r
374 &ControllerHandle,\r
375 &gEfiCallerIdGuid,\r
376 EFI_NATIVE_INTERFACE,\r
377 &Private->Id\r
378 );\r
379 if (EFI_ERROR (Status)) {\r
380 goto ON_ERROR;\r
381 }\r
382 \r
383 }\r
384 \r
385 if (Private->Ip4Nic != NULL) {\r
386 //\r
387 // Already created before\r
388 //\r
389 return EFI_SUCCESS;\r
390 }\r
391 \r
392 Private->Ip4Nic = AllocateZeroPool (sizeof (HTTP_BOOT_VIRTUAL_NIC));\r
393 if (Private->Ip4Nic == NULL) {\r
d933e70a
JW
394 return EFI_OUT_OF_RESOURCES;\r
395 }\r
b659408b
ZL
396 Private->Ip4Nic->Private = Private;\r
397 Private->Ip4Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE;\r
398 \r
d933e70a 399 //\r
b659408b 400 // Create DHCP4 child instance.\r
d933e70a
JW
401 //\r
402 Status = NetLibCreateServiceChild (\r
403 ControllerHandle,\r
404 This->DriverBindingHandle,\r
405 &gEfiDhcp4ServiceBindingProtocolGuid,\r
406 &Private->Dhcp4Child\r
407 );\r
408 if (EFI_ERROR (Status)) {\r
409 goto ON_ERROR;\r
410 }\r
b659408b 411 \r
d933e70a
JW
412 Status = gBS->OpenProtocol (\r
413 Private->Dhcp4Child,\r
414 &gEfiDhcp4ProtocolGuid,\r
415 (VOID **) &Private->Dhcp4,\r
416 This->DriverBindingHandle,\r
417 ControllerHandle,\r
418 EFI_OPEN_PROTOCOL_BY_DRIVER\r
419 );\r
420 if (EFI_ERROR (Status)) {\r
421 goto ON_ERROR;\r
422 }\r
b659408b 423 \r
d933e70a
JW
424 //\r
425 // Get the Ip4Config2 protocol, it's required to configure the default gateway address.\r
426 //\r
427 Status = gBS->OpenProtocol (\r
428 ControllerHandle,\r
429 &gEfiIp4Config2ProtocolGuid,\r
430 (VOID **) &Private->Ip4Config2,\r
431 This->DriverBindingHandle,\r
432 ControllerHandle,\r
433 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
434 );\r
435 if (EFI_ERROR (Status)) {\r
436 goto ON_ERROR;\r
437 }\r
b659408b 438 \r
d933e70a
JW
439 //\r
440 // Append IPv4 device path node.\r
441 //\r
442 Node = AllocateZeroPool (sizeof (IPv4_DEVICE_PATH));\r
443 if (Node == NULL) {\r
444 Status = EFI_OUT_OF_RESOURCES;\r
445 goto ON_ERROR;\r
446 }\r
447 Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;\r
448 Node->Ipv4.Header.SubType = MSG_IPv4_DP;\r
449 SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));\r
450 Node->Ipv4.StaticIpAddress = FALSE;\r
451 DevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);\r
452 FreePool (Node);\r
453 if (DevicePath == NULL) {\r
454 Status = EFI_OUT_OF_RESOURCES;\r
455 goto ON_ERROR;\r
456 }\r
b659408b 457 \r
d933e70a
JW
458 //\r
459 // Append URI device path node.\r
460 //\r
461 Node = AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
462 if (Node == NULL) {\r
463 Status = EFI_OUT_OF_RESOURCES;\r
464 goto ON_ERROR;\r
465 }\r
466 Node->DevPath.Type = MESSAGING_DEVICE_PATH;\r
467 Node->DevPath.SubType = MSG_URI_DP;\r
468 SetDevicePathNodeLength (Node, sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
b659408b 469 Private->Ip4Nic->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);\r
d933e70a
JW
470 FreePool (Node);\r
471 FreePool (DevicePath);\r
b659408b 472 if (Private->Ip4Nic->DevicePath == NULL) {\r
d933e70a
JW
473 Status = EFI_OUT_OF_RESOURCES;\r
474 goto ON_ERROR;\r
475 }\r
b659408b 476 \r
d933e70a
JW
477 //\r
478 // Create a child handle for the HTTP boot and install DevPath and Load file protocol on it.\r
479 //\r
b659408b 480 CopyMem (&Private->Ip4Nic->LoadFile, &gHttpBootDxeLoadFile, sizeof (EFI_LOAD_FILE_PROTOCOL));\r
d933e70a 481 Status = gBS->InstallMultipleProtocolInterfaces (\r
b659408b 482 &Private->Ip4Nic->Controller,\r
d933e70a 483 &gEfiLoadFileProtocolGuid,\r
b659408b 484 &Private->Ip4Nic->LoadFile,\r
d933e70a 485 &gEfiDevicePathProtocolGuid,\r
b659408b 486 Private->Ip4Nic->DevicePath,\r
d933e70a
JW
487 NULL\r
488 );\r
489 if (EFI_ERROR (Status)) {\r
490 goto ON_ERROR;\r
491 }\r
b659408b 492 \r
d933e70a
JW
493 //\r
494 // Open the Caller Id child to setup a parent-child relationship between\r
b659408b 495 // real NIC handle and the HTTP boot Ipv4 NIC handle.\r
d933e70a
JW
496 //\r
497 Status = gBS->OpenProtocol (\r
498 ControllerHandle,\r
499 &gEfiCallerIdGuid,\r
500 (VOID **) &Id,\r
501 This->DriverBindingHandle,\r
b659408b 502 Private->Ip4Nic->Controller,\r
d933e70a
JW
503 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
504 );\r
505 if (EFI_ERROR (Status)) {\r
506 goto ON_ERROR;\r
507 }\r
b659408b 508 \r
d933e70a
JW
509 return EFI_SUCCESS;\r
510\r
b659408b 511 \r
d933e70a
JW
512ON_ERROR:\r
513 \r
514 HttpBootDestroyIp4Children (This, Private);\r
515 FreePool (Private);\r
516\r
517 return Status;\r
518}\r
519\r
b659408b 520\r
d933e70a
JW
521/**\r
522 Stops a device controller or a bus controller.\r
523 \r
524 The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
525 As a result, much of the error checking on the parameters to Stop() has been moved \r
526 into this common boot service. It is legal to call Stop() from other locations, \r
527 but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
528 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
529 same driver's Start() function.\r
530 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
531 EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
532 Start() function, and the Start() function must have called OpenProtocol() on\r
533 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
534 \r
535 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
536 @param[in] ControllerHandle A handle to the device being stopped. The handle must \r
537 support a bus specific I/O protocol for the driver \r
538 to use to stop the device.\r
539 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
540 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL \r
541 if NumberOfChildren is 0.\r
542\r
543 @retval EFI_SUCCESS The device was stopped.\r
544 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
545\r
546**/\r
547EFI_STATUS\r
548EFIAPI\r
549HttpBootIp4DxeDriverBindingStop (\r
550 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
551 IN EFI_HANDLE ControllerHandle,\r
552 IN UINTN NumberOfChildren,\r
553 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
554 )\r
555{\r
556 EFI_STATUS Status;\r
557 EFI_LOAD_FILE_PROTOCOL *LoadFile;\r
558 HTTP_BOOT_PRIVATE_DATA *Private;\r
559 EFI_HANDLE NicHandle;\r
560 UINT32 *Id;\r
561\r
562 //\r
563 // Try to get the Load File Protocol from the controller handle.\r
564 //\r
565 Status = gBS->OpenProtocol (\r
566 ControllerHandle,\r
567 &gEfiLoadFileProtocolGuid,\r
568 (VOID **) &LoadFile,\r
569 This->DriverBindingHandle,\r
570 ControllerHandle,\r
571 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
572 );\r
573 if (EFI_ERROR (Status)) {\r
574 //\r
575 // If failed, try to find the NIC handle for this controller.\r
576 //\r
577 NicHandle = HttpBootGetNicByIp4Children (ControllerHandle);\r
578 if (NicHandle == NULL) {\r
579 return EFI_SUCCESS;\r
580 }\r
581\r
582 //\r
583 // Try to retrieve the private data by the Caller Id Guid.\r
584 //\r
585 Status = gBS->OpenProtocol (\r
586 NicHandle,\r
587 &gEfiCallerIdGuid,\r
588 (VOID **) &Id,\r
589 This->DriverBindingHandle,\r
590 ControllerHandle,\r
591 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
592 );\r
593 if (EFI_ERROR (Status)) {\r
594 return Status;\r
595 }\r
596 Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);\r
597 } else {\r
598 Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);\r
599 NicHandle = Private->Controller;\r
600 }\r
601\r
602 //\r
603 // Disable the HTTP boot function.\r
604 //\r
605 Status = HttpBootStop (Private);\r
606 if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {\r
607 return Status;\r
608 }\r
609\r
610 //\r
611 // Destory all child instance and uninstall protocol interface.\r
612 //\r
613 HttpBootDestroyIp4Children (This, Private);\r
b659408b
ZL
614 \r
615 if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) {\r
616 //\r
617 // Release the cached data.\r
618 //\r
619 HttpBootFreeCacheList (Private);\r
620 \r
621 gBS->UninstallProtocolInterface (\r
622 NicHandle,\r
623 &gEfiCallerIdGuid,\r
624 &Private->Id\r
625 );\r
626 FreePool (Private);\r
d933e70a 627\r
b659408b 628 }\r
d933e70a
JW
629\r
630 return EFI_SUCCESS;\r
631}\r
632\r
633/**\r
b659408b
ZL
634 Tests to see if this driver supports a given controller. If a child device is provided, \r
635 it further tests to see if this driver supports creating a handle for the specified child device.\r
d933e70a 636\r
b659408b
ZL
637 This function checks to see if the driver specified by This supports the device specified by \r
638 ControllerHandle. Drivers will typically use the device path attached to \r
639 ControllerHandle and/or the services from the bus I/O abstraction attached to \r
640 ControllerHandle to determine if the driver supports ControllerHandle. This function \r
641 may be called many times during platform initialization. In order to reduce boot times, the tests \r
642 performed by this function must be very small, and take as little time as possible to execute. This \r
643 function must not change the state of any hardware devices, and this function must be aware that the \r
644 device specified by ControllerHandle may already be managed by the same driver or a \r
645 different driver. This function must match its calls to AllocatePages() with FreePages(), \r
646 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). \r
647 Because ControllerHandle may have been previously started by the same driver, if a protocol is \r
648 already in the opened state, then it must not be closed with CloseProtocol(). This is required \r
649 to guarantee the state of ControllerHandle is not modified by this function.\r
d933e70a 650\r
b659408b
ZL
651 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
652 @param[in] ControllerHandle The handle of the controller to test. This handle \r
653 must support a protocol interface that supplies \r
654 an I/O abstraction to the driver.\r
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 bus drivers, if this parameter is not NULL, then \r
658 the bus driver must determine if the bus controller specified \r
659 by ControllerHandle and the child controller specified \r
660 by RemainingDevicePath are both supported by this \r
661 bus driver.\r
d933e70a 662\r
b659408b
ZL
663 @retval EFI_SUCCESS The device specified by ControllerHandle and\r
664 RemainingDevicePath is supported by the driver specified by This.\r
665 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r
666 RemainingDevicePath is already being managed by the driver\r
667 specified by This.\r
668 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r
669 RemainingDevicePath is already being managed by a different\r
670 driver or an application that requires exclusive access.\r
671 Currently not implemented.\r
672 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r
673 RemainingDevicePath is not supported by the driver specified by This.\r
d933e70a
JW
674**/\r
675EFI_STATUS\r
676EFIAPI\r
b659408b
ZL
677HttpBootIp6DxeDriverBindingSupported (\r
678 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
679 IN EFI_HANDLE ControllerHandle,\r
680 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
d933e70a
JW
681 )\r
682{\r
b659408b
ZL
683 EFI_STATUS Status;\r
684 \r
d933e70a 685 //\r
b659408b 686 // Try to open the DHCP6, HTTP and Device Path protocol.\r
d933e70a 687 //\r
b659408b
ZL
688 Status = gBS->OpenProtocol (\r
689 ControllerHandle,\r
690 &gEfiDhcp6ServiceBindingProtocolGuid,\r
691 NULL,\r
692 This->DriverBindingHandle,\r
693 ControllerHandle,\r
694 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
695 );\r
696 if (EFI_ERROR (Status)) {\r
697 return Status;\r
698 }\r
699\r
700 Status = gBS->OpenProtocol (\r
701 ControllerHandle,\r
702 &gEfiHttpServiceBindingProtocolGuid,\r
703 NULL,\r
704 This->DriverBindingHandle,\r
705 ControllerHandle,\r
706 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
707 );\r
708 if (EFI_ERROR (Status)) {\r
709 return Status;\r
710 }\r
711\r
712 Status = gBS->OpenProtocol (\r
713 ControllerHandle,\r
714 &gEfiDevicePathProtocolGuid,\r
715 NULL,\r
716 This->DriverBindingHandle,\r
717 ControllerHandle,\r
718 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
719 );\r
720\r
721 return Status;\r
722\r
723}\r
724\r
725/**\r
726 Starts a device controller or a bus controller.\r
727\r
728 The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
729 As a result, much of the error checking on the parameters to Start() has been moved into this \r
730 common boot service. It is legal to call Start() from other locations, \r
731 but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
732 1. ControllerHandle must be a valid EFI_HANDLE.\r
733 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
734 EFI_DEVICE_PATH_PROTOCOL.\r
735 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
736 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. \r
737\r
738 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
739 @param[in] ControllerHandle The handle of the controller to start. This handle \r
740 must support a protocol interface that supplies \r
741 an I/O abstraction to the driver.\r
742 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This \r
743 parameter is ignored by device drivers, and is optional for bus \r
744 drivers. For a bus driver, if this parameter is NULL, then handles \r
745 for all the children of Controller are created by this driver. \r
746 If this parameter is not NULL and the first Device Path Node is \r
747 not the End of Device Path Node, then only the handle for the \r
748 child device specified by the first Device Path Node of \r
749 RemainingDevicePath is created by this driver.\r
750 If the first Device Path Node of RemainingDevicePath is \r
751 the End of Device Path Node, no child handle is created by this\r
752 driver.\r
753\r
754 @retval EFI_SUCCESS The device was started.\r
755 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r
756 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
757 @retval Others The driver failded to start the device.\r
758\r
759**/\r
760EFI_STATUS\r
761EFIAPI\r
762HttpBootIp6DxeDriverBindingStart (\r
763 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
764 IN EFI_HANDLE ControllerHandle,\r
765 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
766 )\r
767{\r
768 EFI_STATUS Status;\r
769 HTTP_BOOT_PRIVATE_DATA *Private;\r
770 EFI_DEV_PATH *Node;\r
771 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
772 UINT32 *Id;\r
773 \r
774 Status = gBS->OpenProtocol (\r
775 ControllerHandle,\r
776 &gEfiCallerIdGuid,\r
777 (VOID **) &Id,\r
778 This->DriverBindingHandle,\r
779 ControllerHandle,\r
780 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
781 );\r
782 \r
783 if (!EFI_ERROR (Status)) {\r
784 Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id);\r
785 } else {\r
786 //\r
787 // Initialize the private data structure.\r
788 //\r
789 Private = AllocateZeroPool (sizeof (HTTP_BOOT_PRIVATE_DATA));\r
790 if (Private == NULL) {\r
791 return EFI_OUT_OF_RESOURCES;\r
792 }\r
793 Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;\r
794 Private->Controller = ControllerHandle;\r
795 Private->Image = This->ImageHandle;\r
796 InitializeListHead (&Private->CacheList);\r
797 //\r
798 // Get the NII interface if it exists, it's not required.\r
799 //\r
800 Status = gBS->OpenProtocol (\r
801 ControllerHandle,\r
802 &gEfiNetworkInterfaceIdentifierProtocolGuid_31,\r
803 (VOID **) &Private->Nii,\r
804 This->DriverBindingHandle,\r
805 ControllerHandle,\r
806 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
807 );\r
808 if (EFI_ERROR (Status)) {\r
809 Private->Nii = NULL;\r
810 }\r
811\r
812 //\r
813 // Open Device Path Protocol to prepare for appending IP and URI node.\r
814 //\r
815 Status = gBS->OpenProtocol (\r
816 ControllerHandle,\r
817 &gEfiDevicePathProtocolGuid,\r
818 (VOID **) &Private->ParentDevicePath,\r
819 This->DriverBindingHandle,\r
820 ControllerHandle,\r
821 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
822 );\r
823 if (EFI_ERROR (Status)) {\r
824 goto ON_ERROR;\r
825 }\r
826\r
827 //\r
828 // Install a protocol with Caller Id Guid to the NIC, this is just to build the relationship between\r
829 // NIC handle and the private data.\r
830 //\r
831 Status = gBS->InstallProtocolInterface (\r
832 &ControllerHandle,\r
833 &gEfiCallerIdGuid,\r
834 EFI_NATIVE_INTERFACE,\r
835 &Private->Id\r
836 );\r
837 if (EFI_ERROR (Status)) {\r
838 goto ON_ERROR;\r
839 }\r
840 \r
841 }\r
842 \r
843 if (Private->Ip6Nic != NULL) {\r
844 //\r
845 // Already created before\r
846 //\r
847 return EFI_SUCCESS;\r
848 }\r
849 \r
850 Private->Ip6Nic = AllocateZeroPool (sizeof (HTTP_BOOT_VIRTUAL_NIC));\r
851 if (Private->Ip6Nic == NULL) {\r
852 return EFI_OUT_OF_RESOURCES;\r
853 }\r
854 Private->Ip6Nic->Private = Private;\r
855 Private->Ip6Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE;\r
856\r
857 //\r
858 // Create Dhcp6 child and open Dhcp6 protocol\r
859 Status = NetLibCreateServiceChild (\r
860 ControllerHandle,\r
861 This->DriverBindingHandle,\r
862 &gEfiDhcp6ServiceBindingProtocolGuid,\r
863 &Private->Dhcp6Child\r
864 );\r
865 if (EFI_ERROR (Status)) {\r
866 goto ON_ERROR;\r
867 }\r
868\r
869 Status = gBS->OpenProtocol (\r
870 Private->Dhcp6Child,\r
871 &gEfiDhcp6ProtocolGuid,\r
872 (VOID **) &Private->Dhcp6,\r
873 This->DriverBindingHandle,\r
874 ControllerHandle,\r
875 EFI_OPEN_PROTOCOL_BY_DRIVER\r
876 );\r
877 if (EFI_ERROR (Status)) {\r
878 goto ON_ERROR;\r
879 }\r
880\r
881 //\r
882 // Create Ip6 child and open Ip6 protocol for background ICMP packets.\r
883 //\r
884 Status = NetLibCreateServiceChild (\r
885 ControllerHandle,\r
886 This->DriverBindingHandle,\r
887 &gEfiIp6ServiceBindingProtocolGuid,\r
888 &Private->Ip6Child\r
889 );\r
890 if (EFI_ERROR (Status)) {\r
891 goto ON_ERROR;\r
892 }\r
893\r
894 Status = gBS->OpenProtocol (\r
895 Private->Ip6Child,\r
896 &gEfiIp6ProtocolGuid,\r
897 (VOID **) &Private->Ip6,\r
898 This->DriverBindingHandle,\r
899 ControllerHandle,\r
900 EFI_OPEN_PROTOCOL_BY_DRIVER\r
901 );\r
902 if (EFI_ERROR (Status)) {\r
903 goto ON_ERROR;\r
904 }\r
905\r
906 //\r
907 // Locate Ip6Config protocol, it's required to configure the default gateway address.\r
908 //\r
909 Status = gBS->OpenProtocol (\r
910 ControllerHandle,\r
911 &gEfiIp6ConfigProtocolGuid,\r
912 (VOID **) &Private->Ip6Config,\r
913 This->DriverBindingHandle,\r
914 ControllerHandle,\r
915 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
916 );\r
917 if (EFI_ERROR (Status)) {\r
918 goto ON_ERROR;\r
919 }\r
920\r
921 //\r
922 // Append IPv6 device path node.\r
923 //\r
924 Node = AllocateZeroPool (sizeof (IPv6_DEVICE_PATH));\r
925 if (Node == NULL) {\r
926 Status = EFI_OUT_OF_RESOURCES;\r
927 goto ON_ERROR;\r
928 }\r
929 Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;\r
930 Node->Ipv6.Header.SubType = MSG_IPv6_DP;\r
931 Node->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;\r
932 SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));\r
933 DevicePath = AppendDevicePathNode(Private->ParentDevicePath, (EFI_DEVICE_PATH*) Node);\r
934 FreePool(Node);\r
935 if (DevicePath == NULL) {\r
936 Status = EFI_OUT_OF_RESOURCES;\r
937 goto ON_ERROR;\r
938 }\r
939\r
940 //\r
941 // Append URI device path node.\r
942 //\r
943 Node = AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
944 if (Node == NULL) {\r
945 Status = EFI_OUT_OF_RESOURCES;\r
946 goto ON_ERROR;\r
947 }\r
948 Node->DevPath.Type = MESSAGING_DEVICE_PATH;\r
949 Node->DevPath.SubType = MSG_URI_DP;\r
950 SetDevicePathNodeLength (Node, sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
951 Private->Ip6Nic->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);\r
952 FreePool (Node);\r
953 FreePool (DevicePath);\r
954 if (Private->Ip6Nic->DevicePath == NULL) {\r
955 Status = EFI_OUT_OF_RESOURCES;\r
956 goto ON_ERROR;\r
957 }\r
958\r
959 //\r
960 // Create a child handle for the HTTP boot and install DevPath and Load file protocol on it.\r
961 //\r
962 CopyMem (&Private->Ip6Nic->LoadFile, &gHttpBootDxeLoadFile, sizeof (Private->LoadFile));\r
963 Status = gBS->InstallMultipleProtocolInterfaces (\r
964 &Private->Ip6Nic->Controller,\r
965 &gEfiLoadFileProtocolGuid,\r
966 &Private->Ip6Nic->LoadFile,\r
967 &gEfiDevicePathProtocolGuid,\r
968 Private->Ip6Nic->DevicePath,\r
969 NULL\r
970 );\r
971 if (EFI_ERROR (Status)) {\r
972 goto ON_ERROR;\r
973 }\r
974\r
975 //\r
976 // Open the Caller Id child to setup a parent-child relationship between\r
977 // real NIC handle and the HTTP boot child handle.\r
978 //\r
979 Status = gBS->OpenProtocol (\r
980 ControllerHandle,\r
981 &gEfiCallerIdGuid,\r
982 (VOID **) &Id,\r
983 This->DriverBindingHandle,\r
984 Private->Ip6Nic->Controller,\r
985 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
986 );\r
987 if (EFI_ERROR (Status)) {\r
988 goto ON_ERROR;\r
989 }\r
990\r
991 return EFI_SUCCESS;\r
992 \r
993ON_ERROR:\r
994 \r
995 HttpBootDestroyIp6Children(This, Private);\r
996 FreePool (Private);\r
997\r
998 return Status;\r
999 \r
1000}\r
1001\r
1002/**\r
1003 Stops a device controller or a bus controller.\r
1004 \r
1005 The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
1006 As a result, much of the error checking on the parameters to Stop() has been moved \r
1007 into this common boot service. It is legal to call Stop() from other locations, \r
1008 but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
1009 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
1010 same driver's Start() function.\r
1011 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
1012 EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
1013 Start() function, and the Start() function must have called OpenProtocol() on\r
1014 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
1015 \r
1016 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
1017 @param[in] ControllerHandle A handle to the device being stopped. The handle must \r
1018 support a bus specific I/O protocol for the driver \r
1019 to use to stop the device.\r
1020 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
1021 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL \r
1022 if NumberOfChildren is 0.\r
1023\r
1024 @retval EFI_SUCCESS The device was stopped.\r
1025 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
1026\r
1027**/\r
1028EFI_STATUS\r
1029EFIAPI\r
1030HttpBootIp6DxeDriverBindingStop (\r
1031 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
1032 IN EFI_HANDLE ControllerHandle,\r
1033 IN UINTN NumberOfChildren,\r
1034 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
1035 )\r
1036{\r
1037 EFI_STATUS Status;\r
1038 EFI_LOAD_FILE_PROTOCOL *LoadFile;\r
1039 HTTP_BOOT_PRIVATE_DATA *Private;\r
1040 EFI_HANDLE NicHandle;\r
1041 UINT32 *Id;\r
1042\r
1043 //\r
1044 // Try to get the Load File Protocol from the controller handle.\r
1045 //\r
1046 Status = gBS->OpenProtocol (\r
1047 ControllerHandle,\r
1048 &gEfiLoadFileProtocolGuid,\r
1049 (VOID **) &LoadFile,\r
1050 This->DriverBindingHandle,\r
1051 ControllerHandle,\r
1052 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
1053 );\r
1054 if (EFI_ERROR (Status)) {\r
1055 //\r
1056 // If failed, try to find the NIC handle for this controller.\r
1057 //\r
1058 NicHandle = HttpBootGetNicByIp6Children (ControllerHandle);\r
1059 if (NicHandle == NULL) {\r
1060 return EFI_SUCCESS;\r
1061 }\r
1062\r
1063 //\r
1064 // Try to retrieve the private data by the Caller Id Guid.\r
1065 //\r
1066 Status = gBS->OpenProtocol (\r
1067 NicHandle,\r
1068 &gEfiCallerIdGuid,\r
1069 (VOID **) &Id,\r
1070 This->DriverBindingHandle,\r
1071 ControllerHandle,\r
1072 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
1073 );\r
1074 if (EFI_ERROR (Status)) {\r
1075 return Status;\r
1076 }\r
1077 Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);\r
1078 } else {\r
1079 Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);\r
1080 NicHandle = Private->Controller;\r
1081 }\r
1082\r
1083 //\r
1084 // Disable the HTTP boot function.\r
1085 //\r
1086 Status = HttpBootStop (Private);\r
1087 if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {\r
1088 return Status;\r
1089 }\r
1090\r
1091 //\r
1092 // Destory all child instance and uninstall protocol interface.\r
1093 //\r
1094 HttpBootDestroyIp6Children (This, Private);\r
1095\r
1096 if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) {\r
1097 //\r
1098 // Release the cached data.\r
1099 //\r
1100 HttpBootFreeCacheList (Private);\r
1101 \r
1102 gBS->UninstallProtocolInterface (\r
1103 NicHandle,\r
1104 &gEfiCallerIdGuid,\r
1105 &Private->Id\r
1106 );\r
1107 FreePool (Private);\r
1108\r
1109 }\r
1110\r
1111 return EFI_SUCCESS;\r
1112}\r
1113/**\r
1114 This is the declaration of an EFI image entry point. This entry point is\r
1115 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including\r
1116 both device drivers and bus drivers.\r
1117\r
1118 @param[in] ImageHandle The firmware allocated handle for the UEFI image.\r
1119 @param[in] SystemTable A pointer to the EFI System Table.\r
1120\r
1121 @retval EFI_SUCCESS The operation completed successfully.\r
1122 @retval Others An unexpected error occurred.\r
1123\r
1124**/\r
1125EFI_STATUS\r
1126EFIAPI\r
1127HttpBootDxeDriverEntryPoint (\r
1128 IN EFI_HANDLE ImageHandle,\r
1129 IN EFI_SYSTEM_TABLE *SystemTable\r
1130 )\r
1131{\r
1132 EFI_STATUS Status;\r
1133 //\r
1134 // Install UEFI Driver Model protocol(s).\r
1135 //\r
1136 Status = EfiLibInstallDriverBindingComponentName2 (\r
1137 ImageHandle,\r
1138 SystemTable,\r
1139 &gHttpBootIp4DxeDriverBinding,\r
1140 ImageHandle,\r
1141 &gHttpBootDxeComponentName,\r
1142 &gHttpBootDxeComponentName2\r
1143 );\r
1144 if (EFI_ERROR (Status)) {\r
1145 return Status;\r
1146 }\r
1147 \r
1148 Status = EfiLibInstallDriverBindingComponentName2 (\r
1149 ImageHandle,\r
1150 SystemTable,\r
1151 &gHttpBootIp6DxeDriverBinding,\r
1152 NULL,\r
1153 &gHttpBootDxeComponentName,\r
1154 &gHttpBootDxeComponentName2\r
1155 );\r
1156 if (EFI_ERROR (Status)) {\r
1157 gBS->UninstallMultipleProtocolInterfaces(\r
1158 ImageHandle,\r
1159 &gEfiDriverBindingProtocolGuid,\r
1160 &gHttpBootIp4DxeDriverBinding,\r
1161 &gEfiComponentName2ProtocolGuid,\r
1162 &gHttpBootDxeComponentName2,\r
1163 &gEfiComponentNameProtocolGuid,\r
1164 &gHttpBootDxeComponentName,\r
1165 NULL\r
1166 );\r
1167 }\r
1168 return Status;\r
d933e70a
JW
1169}\r
1170\r