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