]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/Udp6Dxe/Udp6Driver.c
Base on the value type to get the value for default opcode.
[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
192Udp6DestroyChildEntryInHandleBuffer (\r
193 IN LIST_ENTRY *Entry,\r
194 IN VOID *Context\r
195)\r
196{\r
197 UDP6_INSTANCE_DATA *Instance;\r
198 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
199 UINTN NumberOfChildren;\r
200 EFI_HANDLE *ChildHandleBuffer;\r
201\r
202 if (Entry == NULL || Context == NULL) {\r
203 return EFI_INVALID_PARAMETER;\r
204 }\r
205\r
206 Instance = NET_LIST_USER_STRUCT_S (Entry, UDP6_INSTANCE_DATA, Link, UDP6_INSTANCE_DATA_SIGNATURE);\r
207 ServiceBinding = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;\r
208 NumberOfChildren = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;\r
209 ChildHandleBuffer = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;\r
210\r
211 if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {\r
212 return EFI_SUCCESS;\r
213 }\r
214\r
215 return ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);\r
216}\r
217\r
a3bcde70
HT
218/**\r
219 Stop this driver on ControllerHandle.\r
220\r
221 This service is called by the EFI boot service DisconnectController(). In order to\r
222 make drivers as small as possible, there are a few calling\r
223 restrictions for this service. DisconnectController()\r
224 must follow these calling restrictions. If any other agent wishes\r
225 to call Stop(), it must also follow these calling restrictions.\r
226\r
227 @param[in] This Protocol instance pointer.\r
228 @param[in] ControllerHandle Handle of device to stop the driver on.\r
229 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If the number\r
230 of children is zero stop the entire bus driver.\r
231 @param[in] ChildHandleBuffer List of Child Handles to Stop. It is optional.\r
232\r
233 @retval EFI_SUCCES This driver is removed ControllerHandle.\r
234 @retval EFI_DEVICE_ERROR Can't find the NicHandle from the ControllerHandle and specified GUID.\r
235 @retval other This driver was not removed from this device.\r
236\r
237**/\r
238EFI_STATUS\r
239EFIAPI\r
240Udp6DriverBindingStop (\r
241 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
242 IN EFI_HANDLE ControllerHandle,\r
243 IN UINTN NumberOfChildren,\r
244 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
245 )\r
246{\r
247 EFI_STATUS Status;\r
248 EFI_HANDLE NicHandle;\r
249 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
250 UDP6_SERVICE_DATA *Udp6Service;\r
216f7970 251 LIST_ENTRY *List;\r
252 UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;\r
a3bcde70
HT
253\r
254 //\r
255 // Find the NicHandle where UDP6 ServiceBinding Protocol is installed.\r
256 //\r
257 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp6ProtocolGuid);\r
258 if (NicHandle == NULL) {\r
216f7970 259 return EFI_SUCCESS;\r
a3bcde70
HT
260 }\r
261\r
262 //\r
263 // Retrieve the UDP6 ServiceBinding Protocol.\r
264 //\r
265 Status = gBS->OpenProtocol (\r
266 NicHandle,\r
267 &gEfiUdp6ServiceBindingProtocolGuid,\r
268 (VOID **) &ServiceBinding,\r
269 This->DriverBindingHandle,\r
270 NicHandle,\r
271 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
272 );\r
273 if (EFI_ERROR (Status)) {\r
274 return EFI_DEVICE_ERROR;\r
275 }\r
276\r
277 Udp6Service = UDP6_SERVICE_DATA_FROM_THIS (ServiceBinding);\r
278\r
216f7970 279 if (NumberOfChildren != 0) {\r
280 //\r
281 // NumberOfChildren is not zero, destroy the children instances in ChildHandleBuffer.\r
282 //\r
283 List = &Udp6Service->ChildrenList;\r
284 Context.ServiceBinding = ServiceBinding;\r
285 Context.NumberOfChildren = NumberOfChildren;\r
286 Context.ChildHandleBuffer = ChildHandleBuffer;\r
287 Status = NetDestroyLinkList (\r
288 List,\r
289 Udp6DestroyChildEntryInHandleBuffer,\r
290 &Context,\r
291 NULL\r
292 );\r
293 } else if (IsListEmpty (&Udp6Service->ChildrenList)) {\r
a3bcde70
HT
294 gBS->UninstallMultipleProtocolInterfaces (\r
295 NicHandle,\r
296 &gEfiUdp6ServiceBindingProtocolGuid,\r
297 &Udp6Service->ServiceBinding,\r
298 NULL\r
299 );\r
300\r
301 Udp6ClearVariableData (Udp6Service);\r
302\r
303 Udp6CleanService (Udp6Service);\r
304\r
305 FreePool (Udp6Service);\r
a3bcde70 306\r
216f7970 307 Status = EFI_SUCCESS;\r
a3bcde70
HT
308 }\r
309\r
310 return Status;\r
311}\r
312\r
313/**\r
314 Creates a child handle and installs a protocol.\r
315\r
316 The CreateChild() function installs a protocol on ChildHandle.\r
317 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.\r
318 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.\r
319\r
320 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
321 @param[in, out] ChildHandle Pointer to the handle of the child to create. If it is NULL,\r
322 then a new handle is created. If it is a pointer to an existing UEFI handle,\r
323 then the protocol is added to the existing UEFI handle.\r
324\r
325 @retval EFI_SUCCES The protocol was added to ChildHandle.\r
326 @retval EFI_INVALID_PARAMETER This is NULL or ChildHandle is NULL.\r
327 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create\r
328 the child.\r
329 @retval other The child handle was not created.\r
330\r
331**/\r
332EFI_STATUS\r
333EFIAPI\r
334Udp6ServiceBindingCreateChild (\r
335 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
336 IN OUT EFI_HANDLE *ChildHandle\r
337 )\r
338{\r
339 EFI_STATUS Status;\r
340 UDP6_SERVICE_DATA *Udp6Service;\r
341 UDP6_INSTANCE_DATA *Instance;\r
342 EFI_TPL OldTpl;\r
343 VOID *Ip6;\r
344\r
345 if ((This == NULL) || (ChildHandle == NULL)) {\r
346 return EFI_INVALID_PARAMETER;\r
347 }\r
348\r
349 Udp6Service = UDP6_SERVICE_DATA_FROM_THIS (This);\r
350\r
351 //\r
352 // Allocate the instance private data structure.\r
353 //\r
354 Instance = AllocateZeroPool (sizeof (UDP6_INSTANCE_DATA));\r
355 if (Instance == NULL) {\r
356 return EFI_OUT_OF_RESOURCES;\r
357 }\r
358\r
359 Udp6InitInstance (Udp6Service, Instance);\r
360\r
361 //\r
362 // Add an IpInfo for this instance.\r
363 //\r
364 Instance->IpInfo = IpIoAddIp (Udp6Service->IpIo);\r
365 if (Instance->IpInfo == NULL) {\r
366 Status = EFI_OUT_OF_RESOURCES;\r
367 goto ON_ERROR;\r
368 }\r
369\r
370 //\r
371 // Install the Udp6Protocol for this instance.\r
372 //\r
373 Status = gBS->InstallMultipleProtocolInterfaces (\r
374 ChildHandle,\r
375 &gEfiUdp6ProtocolGuid,\r
376 &Instance->Udp6Proto,\r
377 NULL\r
378 );\r
379 if (EFI_ERROR (Status)) {\r
380 goto ON_ERROR;\r
381 }\r
382\r
383 Instance->ChildHandle = *ChildHandle;\r
384\r
385 //\r
386 // Open the default Ip6 protocol in the IP_IO BY_CHILD.\r
387 //\r
388 Status = gBS->OpenProtocol (\r
389 Udp6Service->IpIo->ChildHandle,\r
390 &gEfiIp6ProtocolGuid,\r
391 (VOID **) &Ip6,\r
392 gUdp6DriverBinding.DriverBindingHandle,\r
393 Instance->ChildHandle,\r
394 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
395 );\r
396 if (EFI_ERROR (Status)) {\r
397 goto ON_ERROR;\r
398 }\r
399\r
216f7970 400 //\r
401 // Open this instance's Ip6 protocol in the IpInfo BY_CHILD.\r
402 //\r
403 Status = gBS->OpenProtocol (\r
404 Instance->IpInfo->ChildHandle,\r
405 &gEfiIp6ProtocolGuid,\r
406 (VOID **) &Ip6,\r
407 gUdp6DriverBinding.DriverBindingHandle,\r
408 Instance->ChildHandle,\r
409 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
410 );\r
411 if (EFI_ERROR (Status)) {\r
412 goto ON_ERROR;\r
413 }\r
414 \r
a3bcde70
HT
415 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
416\r
417 //\r
418 // Link this instance into the service context data and increase the ChildrenNumber.\r
419 //\r
420 InsertTailList (&Udp6Service->ChildrenList, &Instance->Link);\r
421 Udp6Service->ChildrenNumber++;\r
422\r
423 gBS->RestoreTPL (OldTpl);\r
424\r
425 return EFI_SUCCESS;\r
426\r
427ON_ERROR:\r
428\r
429 if (Instance->ChildHandle != NULL) {\r
430 gBS->UninstallMultipleProtocolInterfaces (\r
431 Instance->ChildHandle,\r
432 &gEfiUdp6ProtocolGuid,\r
433 &Instance->Udp6Proto,\r
434 NULL\r
435 );\r
436 }\r
437\r
438 if (Instance->IpInfo != NULL) {\r
439 IpIoRemoveIp (Udp6Service->IpIo, Instance->IpInfo);\r
440 }\r
441\r
442 Udp6CleanInstance (Instance);\r
443\r
444 FreePool (Instance);\r
445\r
446 return Status;\r
447}\r
448\r
449/**\r
450 Destroys a child handle with a set of I/O services.\r
451 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol\r
452 that was installed by CreateChild() from ChildHandle. If the removed protocol is the\r
453 last protocol on ChildHandle, then ChildHandle is destroyed.\r
454\r
455 @param[in] This Protocol instance pointer.\r
456 @param[in] ChildHandle Handle of the child to destroy.\r
457\r
458 @retval EFI_SUCCES The I/O services were removed from the child\r
459 handle.\r
460 @retval EFI_UNSUPPORTED The child handle does not support the I/O services\r
461 that are being removed.\r
15ee13fc 462 @retval EFI_INVALID_PARAMETER Child handle is NULL.\r
a3bcde70
HT
463 @retval EFI_ACCESS_DENIED The child handle could not be destroyed because\r
464 its I/O services are being used.\r
465 @retval other The child handle was not destroyed.\r
466\r
467**/\r
468EFI_STATUS\r
469EFIAPI\r
470Udp6ServiceBindingDestroyChild (\r
471 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
472 IN EFI_HANDLE ChildHandle\r
473 )\r
474{\r
475 EFI_STATUS Status;\r
476 UDP6_SERVICE_DATA *Udp6Service;\r
477 EFI_UDP6_PROTOCOL *Udp6Proto;\r
478 UDP6_INSTANCE_DATA *Instance;\r
479 EFI_TPL OldTpl;\r
480\r
481 if ((This == NULL) || (ChildHandle == NULL)) {\r
482 return EFI_INVALID_PARAMETER;\r
483 }\r
484\r
485 Udp6Service = UDP6_SERVICE_DATA_FROM_THIS (This);\r
486\r
487 //\r
488 // Try to get the Udp6 protocol from the ChildHandle.\r
489 //\r
490 Status = gBS->OpenProtocol (\r
491 ChildHandle,\r
492 &gEfiUdp6ProtocolGuid,\r
493 (VOID **) &Udp6Proto,\r
494 gUdp6DriverBinding.DriverBindingHandle,\r
495 ChildHandle,\r
496 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
497 );\r
498 if (EFI_ERROR (Status)) {\r
499 return EFI_UNSUPPORTED;\r
500 }\r
501\r
502 Instance = UDP6_INSTANCE_DATA_FROM_THIS (Udp6Proto);\r
503\r
216f7970 504 if (Instance->InDestroy) {\r
a3bcde70
HT
505 return EFI_SUCCESS;\r
506 }\r
507\r
508 //\r
509 // Use the Destroyed flag to avoid the re-entering of the following code.\r
510 //\r
216f7970 511 Instance->InDestroy = TRUE;\r
a3bcde70
HT
512\r
513 //\r
216f7970 514 // Close the Ip6 protocol on the default IpIo.\r
a3bcde70
HT
515 //\r
516 gBS->CloseProtocol (\r
517 Udp6Service->IpIo->ChildHandle,\r
518 &gEfiIp6ProtocolGuid,\r
519 gUdp6DriverBinding.DriverBindingHandle,\r
520 Instance->ChildHandle\r
521 );\r
216f7970 522 //\r
523 // Close the Ip6 protocol on this instance's IpInfo.\r
524 //\r
525 gBS->CloseProtocol (\r
526 Instance->IpInfo->ChildHandle,\r
527 &gEfiIp6ProtocolGuid,\r
528 gUdp6DriverBinding.DriverBindingHandle,\r
529 Instance->ChildHandle\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
538 (VOID *) &Instance->Udp6Proto,\r
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
617 ((UINT16) NetRandomInitSeed ()) %\r
618 UDP6_PORT_KNOWN +\r
619 UDP6_PORT_KNOWN\r
620 );\r
621 }\r
622\r
623 return Status;\r
624}\r
625\r
626\r