Fix a bug about the iSCSI DHCP dependency issue.
[mirror_edk2.git] / NetworkPkg / Udp6Dxe / Udp6Driver.c
CommitLineData
a3bcde70
HT
1/** @file\r
2 Driver Binding functions and Service Binding functions for the Network driver module.\r
3\r
216f7970 4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
a3bcde70
HT
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 "Udp6Impl.h"\r
17\r
18EFI_DRIVER_BINDING_PROTOCOL gUdp6DriverBinding = {\r
19 Udp6DriverBindingSupported,\r
20 Udp6DriverBindingStart,\r
21 Udp6DriverBindingStop,\r
22 0xa,\r
23 NULL,\r
24 NULL\r
25};\r
26\r
27EFI_SERVICE_BINDING_PROTOCOL mUdp6ServiceBinding = {\r
28 Udp6ServiceBindingCreateChild,\r
29 Udp6ServiceBindingDestroyChild\r
30};\r
31\r
32/**\r
33 Tests to see if this driver supports a given controller. If a child device is provided,\r
34 it further tests to see if this driver supports creating a handle for the specified child device.\r
35\r
36 This function checks to see if the driver specified by This supports the device specified by\r
37 ControllerHandle. Drivers will typically use the device path attached to\r
38 ControllerHandle and/or the services from the bus I/O abstraction attached to\r
39 ControllerHandle to determine if the driver supports ControllerHandle. This function\r
40 may be called many times during platform initialization. In order to reduce boot times, the tests\r
41 performed by this function must be very small, and take as little time as possible to execute. This\r
42 function must not change the state of any hardware devices, and this function must be aware that the\r
43 device specified by ControllerHandle may already be managed by the same driver or a\r
44 different driver. This function must match its calls to AllocatePages() with FreePages(),\r
45 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r
46 Because ControllerHandle may have been previously started by the same driver, if a protocol is\r
47 already in the opened state, then it must not be closed with CloseProtocol(). This is required\r
48 to guarantee the state of ControllerHandle is not modified by this function.\r
49\r
50 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
51 @param[in] ControllerHandle The handle of the controller to test. This handle\r
52 must support a protocol interface that supplies\r
53 an I/O abstraction to the driver.\r
54 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r
55 parameter is ignored by device drivers, and is optional for bus\r
56 drivers. For bus drivers, if this parameter is not NULL, then\r
57 the bus driver must determine if the bus controller specified\r
58 by ControllerHandle and the child controller specified\r
59 by RemainingDevicePath are both supported by this\r
60 bus driver.\r
61\r
62 @retval EFI_SUCCESS The device specified by ControllerHandle and\r
63 RemainingDevicePath is supported by the driver specified by This.\r
64 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r
65 RemainingDevicePath is already being managed by the driver\r
66 specified by This.\r
67 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r
68 RemainingDevicePath is already being managed by a different\r
69 driver or an application that requires exclusive access.\r
70 Currently not implemented.\r
71 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r
72 RemainingDevicePath is not supported by the driver specified by This.\r
73**/\r
74EFI_STATUS\r
75EFIAPI\r
76Udp6DriverBindingSupported (\r
77 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
78 IN EFI_HANDLE ControllerHandle,\r
79 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
80 )\r
81{\r
82 EFI_STATUS Status;\r
83 //\r
84 // Test for the Udp6ServiceBinding Protocol\r
85 //\r
86 Status = gBS->OpenProtocol (\r
87 ControllerHandle,\r
88 &gEfiUdp6ServiceBindingProtocolGuid,\r
89 NULL,\r
90 This->DriverBindingHandle,\r
91 ControllerHandle,\r
92 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
93 );\r
94 if (!EFI_ERROR (Status)) {\r
95 return EFI_ALREADY_STARTED;\r
96 }\r
97 //\r
98 // Test for the Ip6ServiceBinding Protocol\r
99 //\r
100 Status = gBS->OpenProtocol (\r
101 ControllerHandle,\r
102 &gEfiIp6ServiceBindingProtocolGuid,\r
103 NULL,\r
104 This->DriverBindingHandle,\r
105 ControllerHandle,\r
106 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
107 );\r
108\r
109 return Status;\r
110}\r
111\r
112/**\r
113 Start this driver on ControllerHandle.\r
114\r
115 This service is called by the EFI boot service ConnectController(). In order to make\r
116 drivers as small as possible, there are a few calling restrictions for\r
117 this service. ConnectController() must follow these\r
118 calling restrictions. If any other agent wishes to call Start() it\r
119 must also follow these calling restrictions.\r
120\r
121 @param[in] This Protocol instance pointer.\r
122 @param[in] ControllerHandle Handle of device to bind the driver to.\r
123 @param[in] RemainingDevicePath Optional parameter use to pick a specific child\r
124 device to start.\r
125\r
126 @retval EFI_SUCCES This driver is added to ControllerHandle.\r
127 @retval EFI_OUT_OF_RESOURCES The required system resource can't be allocated.\r
128 @retval other This driver does not support this device.\r
129\r
130**/\r
131EFI_STATUS\r
132EFIAPI\r
133Udp6DriverBindingStart (\r
134 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
135 IN EFI_HANDLE ControllerHandle,\r
136 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
137 )\r
138{\r
139 EFI_STATUS Status;\r
140 UDP6_SERVICE_DATA *Udp6Service;\r
141\r
142 //\r
143 // Allocate Private Context Data Structure.\r
144 //\r
145 Udp6Service = AllocateZeroPool (sizeof (UDP6_SERVICE_DATA));\r
146 if (Udp6Service == NULL) {\r
147 Status = EFI_OUT_OF_RESOURCES;\r
148 goto EXIT;\r
149 }\r
150\r
151 Status = Udp6CreateService (Udp6Service, This->DriverBindingHandle, ControllerHandle);\r
152 if (EFI_ERROR (Status)) {\r
153 goto EXIT;\r
154 }\r
155\r
156 //\r
157 // Install the Udp6ServiceBindingProtocol on the ControllerHandle.\r
158 //\r
159 Status = gBS->InstallMultipleProtocolInterfaces (\r
160 &ControllerHandle,\r
161 &gEfiUdp6ServiceBindingProtocolGuid,\r
162 &Udp6Service->ServiceBinding,\r
163 NULL\r
164 );\r
165 if (EFI_ERROR (Status)) {\r
166 Udp6CleanService (Udp6Service);\r
167 goto EXIT;\r
168 } else {\r
169 Status = Udp6SetVariableData (Udp6Service);\r
170 }\r
171\r
172EXIT:\r
173 if (EFI_ERROR (Status)) {\r
174 if (Udp6Service != NULL) {\r
175 FreePool (Udp6Service);\r
176 }\r
177 }\r
178 return Status;\r
179}\r
180\r
216f7970 181/**\r
182 Callback function which provided by user to remove one node in NetDestroyLinkList process.\r
183 \r
184 @param[in] Entry The entry to be removed.\r
185 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.\r
186\r
187 @retval EFI_SUCCESS The entry has been removed successfully.\r
188 @retval Others Fail to remove the entry.\r
189\r
190**/\r
191EFI_STATUS\r
1f7eb561 192EFIAPI\r
216f7970 193Udp6DestroyChildEntryInHandleBuffer (\r
194 IN LIST_ENTRY *Entry,\r
195 IN VOID *Context\r
1f7eb561 196 )\r
216f7970 197{\r
198 UDP6_INSTANCE_DATA *Instance;\r
199 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
200 UINTN NumberOfChildren;\r
201 EFI_HANDLE *ChildHandleBuffer;\r
202\r
203 if (Entry == NULL || Context == NULL) {\r
204 return EFI_INVALID_PARAMETER;\r
205 }\r
206\r
207 Instance = NET_LIST_USER_STRUCT_S (Entry, UDP6_INSTANCE_DATA, Link, UDP6_INSTANCE_DATA_SIGNATURE);\r
208 ServiceBinding = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;\r
209 NumberOfChildren = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;\r
210 ChildHandleBuffer = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;\r
211\r
212 if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {\r
213 return EFI_SUCCESS;\r
214 }\r
215\r
216 return ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);\r
217}\r
218\r
a3bcde70
HT
219/**\r
220 Stop this driver on ControllerHandle.\r
221\r
222 This service is called by the EFI boot service DisconnectController(). In order to\r
223 make drivers as small as possible, there are a few calling\r
224 restrictions for this service. DisconnectController()\r
225 must follow these calling restrictions. If any other agent wishes\r
226 to call Stop(), it must also follow these calling restrictions.\r
227\r
228 @param[in] This Protocol instance pointer.\r
229 @param[in] ControllerHandle Handle of device to stop the driver on.\r
230 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If the number\r
231 of children is zero stop the entire bus driver.\r
232 @param[in] ChildHandleBuffer List of Child Handles to Stop. It is optional.\r
233\r
234 @retval EFI_SUCCES This driver is removed ControllerHandle.\r
235 @retval EFI_DEVICE_ERROR Can't find the NicHandle from the ControllerHandle and specified GUID.\r
236 @retval other This driver was not removed from this device.\r
237\r
238**/\r
239EFI_STATUS\r
240EFIAPI\r
241Udp6DriverBindingStop (\r
242 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
243 IN EFI_HANDLE ControllerHandle,\r
244 IN UINTN NumberOfChildren,\r
245 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
246 )\r
247{\r
248 EFI_STATUS Status;\r
249 EFI_HANDLE NicHandle;\r
250 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
251 UDP6_SERVICE_DATA *Udp6Service;\r
216f7970 252 LIST_ENTRY *List;\r
253 UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;\r
a3bcde70
HT
254\r
255 //\r
256 // Find the NicHandle where UDP6 ServiceBinding Protocol is installed.\r
257 //\r
258 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp6ProtocolGuid);\r
259 if (NicHandle == NULL) {\r
216f7970 260 return EFI_SUCCESS;\r
a3bcde70
HT
261 }\r
262\r
263 //\r
264 // Retrieve the UDP6 ServiceBinding Protocol.\r
265 //\r
266 Status = gBS->OpenProtocol (\r
267 NicHandle,\r
268 &gEfiUdp6ServiceBindingProtocolGuid,\r
269 (VOID **) &ServiceBinding,\r
270 This->DriverBindingHandle,\r
271 NicHandle,\r
272 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
273 );\r
274 if (EFI_ERROR (Status)) {\r
275 return EFI_DEVICE_ERROR;\r
276 }\r
277\r
278 Udp6Service = UDP6_SERVICE_DATA_FROM_THIS (ServiceBinding);\r
279\r
216f7970 280 if (NumberOfChildren != 0) {\r
281 //\r
282 // NumberOfChildren is not zero, destroy the children instances in ChildHandleBuffer.\r
283 //\r
284 List = &Udp6Service->ChildrenList;\r
285 Context.ServiceBinding = ServiceBinding;\r
286 Context.NumberOfChildren = NumberOfChildren;\r
287 Context.ChildHandleBuffer = ChildHandleBuffer;\r
288 Status = NetDestroyLinkList (\r
289 List,\r
290 Udp6DestroyChildEntryInHandleBuffer,\r
291 &Context,\r
292 NULL\r
293 );\r
294 } else if (IsListEmpty (&Udp6Service->ChildrenList)) {\r
a3bcde70
HT
295 gBS->UninstallMultipleProtocolInterfaces (\r
296 NicHandle,\r
297 &gEfiUdp6ServiceBindingProtocolGuid,\r
298 &Udp6Service->ServiceBinding,\r
299 NULL\r
300 );\r
301\r
302 Udp6ClearVariableData (Udp6Service);\r
303\r
304 Udp6CleanService (Udp6Service);\r
305\r
306 FreePool (Udp6Service);\r
a3bcde70 307\r
216f7970 308 Status = EFI_SUCCESS;\r
a3bcde70
HT
309 }\r
310\r
311 return Status;\r
312}\r
313\r
314/**\r
315 Creates a child handle and installs a protocol.\r
316\r
317 The CreateChild() function installs a protocol on ChildHandle.\r
318 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.\r
319 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.\r
320\r
321 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
322 @param[in, out] ChildHandle Pointer to the handle of the child to create. If it is NULL,\r
323 then a new handle is created. If it is a pointer to an existing UEFI handle,\r
324 then the protocol is added to the existing UEFI handle.\r
325\r
326 @retval EFI_SUCCES The protocol was added to ChildHandle.\r
327 @retval EFI_INVALID_PARAMETER This is NULL or ChildHandle is NULL.\r
328 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create\r
329 the child.\r
330 @retval other The child handle was not created.\r
331\r
332**/\r
333EFI_STATUS\r
334EFIAPI\r
335Udp6ServiceBindingCreateChild (\r
336 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
337 IN OUT EFI_HANDLE *ChildHandle\r
338 )\r
339{\r
340 EFI_STATUS Status;\r
341 UDP6_SERVICE_DATA *Udp6Service;\r
342 UDP6_INSTANCE_DATA *Instance;\r
343 EFI_TPL OldTpl;\r
344 VOID *Ip6;\r
345\r
346 if ((This == NULL) || (ChildHandle == NULL)) {\r
347 return EFI_INVALID_PARAMETER;\r
348 }\r
349\r
350 Udp6Service = UDP6_SERVICE_DATA_FROM_THIS (This);\r
351\r
352 //\r
353 // Allocate the instance private data structure.\r
354 //\r
355 Instance = AllocateZeroPool (sizeof (UDP6_INSTANCE_DATA));\r
356 if (Instance == NULL) {\r
357 return EFI_OUT_OF_RESOURCES;\r
358 }\r
359\r
360 Udp6InitInstance (Udp6Service, Instance);\r
361\r
362 //\r
363 // Add an IpInfo for this instance.\r
364 //\r
365 Instance->IpInfo = IpIoAddIp (Udp6Service->IpIo);\r
366 if (Instance->IpInfo == NULL) {\r
367 Status = EFI_OUT_OF_RESOURCES;\r
368 goto ON_ERROR;\r
369 }\r
370\r
371 //\r
372 // Install the Udp6Protocol for this instance.\r
373 //\r
374 Status = gBS->InstallMultipleProtocolInterfaces (\r
375 ChildHandle,\r
376 &gEfiUdp6ProtocolGuid,\r
377 &Instance->Udp6Proto,\r
378 NULL\r
379 );\r
380 if (EFI_ERROR (Status)) {\r
381 goto ON_ERROR;\r
382 }\r
383\r
384 Instance->ChildHandle = *ChildHandle;\r
385\r
386 //\r
387 // Open the default Ip6 protocol in the IP_IO BY_CHILD.\r
388 //\r
389 Status = gBS->OpenProtocol (\r
390 Udp6Service->IpIo->ChildHandle,\r
391 &gEfiIp6ProtocolGuid,\r
392 (VOID **) &Ip6,\r
393 gUdp6DriverBinding.DriverBindingHandle,\r
394 Instance->ChildHandle,\r
395 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
396 );\r
397 if (EFI_ERROR (Status)) {\r
398 goto ON_ERROR;\r
399 }\r
400\r
216f7970 401 //\r
402 // Open this instance's Ip6 protocol in the IpInfo BY_CHILD.\r
403 //\r
404 Status = gBS->OpenProtocol (\r
405 Instance->IpInfo->ChildHandle,\r
406 &gEfiIp6ProtocolGuid,\r
407 (VOID **) &Ip6,\r
408 gUdp6DriverBinding.DriverBindingHandle,\r
409 Instance->ChildHandle,\r
410 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
411 );\r
412 if (EFI_ERROR (Status)) {\r
413 goto ON_ERROR;\r
414 }\r
415 \r
a3bcde70
HT
416 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
417\r
418 //\r
419 // Link this instance into the service context data and increase the ChildrenNumber.\r
420 //\r
421 InsertTailList (&Udp6Service->ChildrenList, &Instance->Link);\r
422 Udp6Service->ChildrenNumber++;\r
423\r
424 gBS->RestoreTPL (OldTpl);\r
425\r
426 return EFI_SUCCESS;\r
427\r
428ON_ERROR:\r
429\r
430 if (Instance->ChildHandle != NULL) {\r
431 gBS->UninstallMultipleProtocolInterfaces (\r
432 Instance->ChildHandle,\r
433 &gEfiUdp6ProtocolGuid,\r
434 &Instance->Udp6Proto,\r
435 NULL\r
436 );\r
437 }\r
438\r
439 if (Instance->IpInfo != NULL) {\r
440 IpIoRemoveIp (Udp6Service->IpIo, Instance->IpInfo);\r
441 }\r
442\r
443 Udp6CleanInstance (Instance);\r
444\r
445 FreePool (Instance);\r
446\r
447 return Status;\r
448}\r
449\r
450/**\r
451 Destroys a child handle with a set of I/O services.\r
452 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol\r
453 that was installed by CreateChild() from ChildHandle. If the removed protocol is the\r
454 last protocol on ChildHandle, then ChildHandle is destroyed.\r
455\r
456 @param[in] This Protocol instance pointer.\r
457 @param[in] ChildHandle Handle of the child to destroy.\r
458\r
459 @retval EFI_SUCCES The I/O services were removed from the child\r
460 handle.\r
461 @retval EFI_UNSUPPORTED The child handle does not support the I/O services\r
462 that are being removed.\r
15ee13fc 463 @retval EFI_INVALID_PARAMETER Child handle is NULL.\r
a3bcde70
HT
464 @retval EFI_ACCESS_DENIED The child handle could not be destroyed because\r
465 its I/O services are being used.\r
466 @retval other The child handle was not destroyed.\r
467\r
468**/\r
469EFI_STATUS\r
470EFIAPI\r
471Udp6ServiceBindingDestroyChild (\r
472 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
473 IN EFI_HANDLE ChildHandle\r
474 )\r
475{\r
476 EFI_STATUS Status;\r
477 UDP6_SERVICE_DATA *Udp6Service;\r
478 EFI_UDP6_PROTOCOL *Udp6Proto;\r
479 UDP6_INSTANCE_DATA *Instance;\r
480 EFI_TPL OldTpl;\r
481\r
482 if ((This == NULL) || (ChildHandle == NULL)) {\r
483 return EFI_INVALID_PARAMETER;\r
484 }\r
485\r
486 Udp6Service = UDP6_SERVICE_DATA_FROM_THIS (This);\r
487\r
488 //\r
489 // Try to get the Udp6 protocol from the ChildHandle.\r
490 //\r
491 Status = gBS->OpenProtocol (\r
492 ChildHandle,\r
493 &gEfiUdp6ProtocolGuid,\r
494 (VOID **) &Udp6Proto,\r
495 gUdp6DriverBinding.DriverBindingHandle,\r
496 ChildHandle,\r
497 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
498 );\r
499 if (EFI_ERROR (Status)) {\r
500 return EFI_UNSUPPORTED;\r
501 }\r
502\r
503 Instance = UDP6_INSTANCE_DATA_FROM_THIS (Udp6Proto);\r
504\r
216f7970 505 if (Instance->InDestroy) {\r
a3bcde70
HT
506 return EFI_SUCCESS;\r
507 }\r
508\r
509 //\r
510 // Use the Destroyed flag to avoid the re-entering of the following code.\r
511 //\r
216f7970 512 Instance->InDestroy = TRUE;\r
a3bcde70
HT
513\r
514 //\r
216f7970 515 // Close the Ip6 protocol on the default IpIo.\r
a3bcde70
HT
516 //\r
517 gBS->CloseProtocol (\r
518 Udp6Service->IpIo->ChildHandle,\r
519 &gEfiIp6ProtocolGuid,\r
520 gUdp6DriverBinding.DriverBindingHandle,\r
521 Instance->ChildHandle\r
522 );\r
216f7970 523 //\r
524 // Close the Ip6 protocol on this instance's IpInfo.\r
525 //\r
526 gBS->CloseProtocol (\r
527 Instance->IpInfo->ChildHandle,\r
528 &gEfiIp6ProtocolGuid,\r
529 gUdp6DriverBinding.DriverBindingHandle,\r
530 Instance->ChildHandle\r
531 );\r
a3bcde70
HT
532\r
533 //\r
534 // Uninstall the Udp6Protocol previously installed on the ChildHandle.\r
535 //\r
536 Status = gBS->UninstallMultipleProtocolInterfaces (\r
537 ChildHandle,\r
538 &gEfiUdp6ProtocolGuid,\r
539 (VOID *) &Instance->Udp6Proto,\r
540 NULL\r
541 );\r
542 if (EFI_ERROR (Status)) {\r
216f7970 543 Instance->InDestroy = FALSE;\r
a3bcde70
HT
544 return Status;\r
545 }\r
546\r
547 //\r
548 // Reset the configuration in case the instance's consumer forgets to do this.\r
549 //\r
550 Udp6Proto->Configure (Udp6Proto, NULL);\r
551\r
552 //\r
553 // Remove the IpInfo this instance consumes.\r
554 //\r
555 IpIoRemoveIp (Udp6Service->IpIo, Instance->IpInfo);\r
556\r
557 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
558\r
559 //\r
560 // Remove this instance from the service context data's ChildrenList.\r
561 //\r
562 RemoveEntryList (&Instance->Link);\r
563 Udp6Service->ChildrenNumber--;\r
564\r
565 //\r
566 // Clean the instance.\r
567 //\r
568 Udp6CleanInstance (Instance);\r
569\r
570 gBS->RestoreTPL (OldTpl);\r
571\r
572 FreePool (Instance);\r
573\r
574 return EFI_SUCCESS;\r
575}\r
576\r
577/**\r
578 This is the declaration of an EFI image entry point. This entry point is\r
579 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers, including\r
580 both device drivers and bus drivers.\r
581\r
582 The entry point for Udp6 driver that installs the driver binding\r
583 and component name protocol on its ImageHandle.\r
584\r
585 @param[in] ImageHandle The firmware allocated handle for the UEFI image.\r
586 @param[in] SystemTable A pointer to the EFI System Table.\r
587\r
588 @retval EFI_SUCCESS The operation completed successfully.\r
589 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
590\r
591**/\r
592EFI_STATUS\r
593EFIAPI\r
594Udp6DriverEntryPoint (\r
595 IN EFI_HANDLE ImageHandle,\r
596 IN EFI_SYSTEM_TABLE *SystemTable\r
597 )\r
598{\r
599 EFI_STATUS Status;\r
600\r
601 //\r
602 // Install the Udp6DriverBinding and Udp6ComponentName protocols.\r
603 //\r
604\r
605 Status = EfiLibInstallDriverBindingComponentName2 (\r
606 ImageHandle,\r
607 SystemTable,\r
608 &gUdp6DriverBinding,\r
609 ImageHandle,\r
610 &gUdp6ComponentName,\r
611 &gUdp6ComponentName2\r
612 );\r
613 if (!EFI_ERROR (Status)) {\r
614 //\r
615 // Initialize the UDP random port.\r
616 //\r
617 mUdp6RandomPort = (UINT16)(\r
618 ((UINT16) NetRandomInitSeed ()) %\r
619 UDP6_PORT_KNOWN +\r
620 UDP6_PORT_KNOWN\r
621 );\r
622 }\r
623\r
624 return Status;\r
625}\r
626\r
627\r