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