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