]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c
NetworkPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / NetworkPkg / WifiConnectionManagerDxe / WifiConnectionMgrDriver.c
CommitLineData
90b24889
WF
1/** @file\r
2 The driver binding protocol for the WiFi Connection Manager.\r
3\r
4 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
5\r
ecf98fbc 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
90b24889
WF
7\r
8**/\r
9\r
10#include "WifiConnectionMgrDxe.h"\r
11\r
12///\r
13/// Driver Binding Protocol instance\r
14///\r
15EFI_DRIVER_BINDING_PROTOCOL gWifiMgrDxeDriverBinding = {\r
16 WifiMgrDxeDriverBindingSupported,\r
17 WifiMgrDxeDriverBindingStart,\r
18 WifiMgrDxeDriverBindingStop,\r
19 WIFI_MGR_DXE_VERSION,\r
20 NULL,\r
21 NULL\r
22};\r
23\r
24//\r
25//The private global data for WiFi Connection Manager\r
26//\r
27WIFI_MGR_PRIVATE_DATA *mPrivate = NULL;\r
28\r
29//\r
30//The private guid to identify WiFi Connection Manager\r
31//\r
32EFI_GUID mEfiWifiMgrPrivateGuid = EFI_WIFIMGR_PRIVATE_GUID;\r
33\r
34//\r
35//The Hii config guids\r
36//\r
37EFI_GUID gWifiConfigFormSetGuid = WIFI_CONNECTION_MANAGER_CONFIG_GUID;\r
38EFI_GUID mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_GUID;\r
39EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID;\r
40EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID;\r
41\r
42/**\r
43 Tests to see if this driver supports a given controller. If a child device is provided,\r
44 it further tests to see if this driver supports creating a handle for the specified child device.\r
45\r
46 This function checks to see if the driver specified by This supports the device specified by\r
47 ControllerHandle. Drivers will typically use the device path attached to\r
48 ControllerHandle and/or the services from the bus I/O abstraction attached to\r
49 ControllerHandle to determine if the driver supports ControllerHandle. This function\r
50 may be called many times during platform initialization. In order to reduce boot times, the tests\r
51 performed by this function must be very small, and take as little time as possible to execute. This\r
52 function must not change the state of any hardware devices, and this function must be aware that the\r
53 device specified by ControllerHandle may already be managed by the same driver or a\r
54 different driver. This function must match its calls to AllocatePages() with FreePages(),\r
55 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r
56 Because ControllerHandle may have been previously started by the same driver, if a protocol is\r
57 already in the opened state, then it must not be closed with CloseProtocol(). This is required\r
58 to guarantee the state of ControllerHandle is not modified by this function.\r
59\r
60 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
61 @param[in] ControllerHandle The handle of the controller to test. This handle\r
62 must support a protocol interface that supplies\r
63 an I/O abstraction to the driver.\r
64 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r
65 parameter is ignored by device drivers, and is optional for bus\r
66 drivers. For bus drivers, if this parameter is not NULL, then\r
67 the bus driver must determine if the bus controller specified\r
68 by ControllerHandle and the child controller specified\r
69 by RemainingDevicePath are both supported by this\r
70 bus driver.\r
71\r
72 @retval EFI_SUCCESS The device specified by ControllerHandle and\r
73 RemainingDevicePath is supported by the driver specified by This.\r
74 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r
75 RemainingDevicePath is already being managed by the driver\r
76 specified by This.\r
77 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r
78 RemainingDevicePath is already being managed by a different\r
79 driver or an application that requires exclusive access.\r
80 Currently not implemented.\r
81 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r
82 RemainingDevicePath is not supported by the driver specified by This.\r
83\r
84**/\r
85EFI_STATUS\r
86EFIAPI\r
87WifiMgrDxeDriverBindingSupported (\r
88 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
89 IN EFI_HANDLE ControllerHandle,\r
90 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
91 )\r
92{\r
93 EFI_STATUS Status;\r
94\r
95 Status = gBS->OpenProtocol (\r
96 ControllerHandle,\r
97 &mEfiWifiMgrPrivateGuid,\r
98 NULL,\r
99 This->DriverBindingHandle,\r
100 ControllerHandle,\r
101 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
102 );\r
103 if (!EFI_ERROR (Status)) {\r
104 return EFI_ALREADY_STARTED;\r
105 }\r
106\r
107 //\r
108 // Test for the wireless MAC connection 2 protocol\r
109 //\r
110 return gBS->OpenProtocol (\r
111 ControllerHandle,\r
112 &gEfiWiFi2ProtocolGuid,\r
113 NULL,\r
114 This->DriverBindingHandle,\r
115 ControllerHandle,\r
116 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
117 );\r
118}\r
119\r
120/**\r
121 Starts a device controller or a bus controller.\r
122\r
123 The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
124 As a result, much of the error checking on the parameters to Start() has been moved into this\r
125 common boot service. It is legal to call Start() from other locations,\r
126 but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
127 1. ControllerHandle must be a valid EFI_HANDLE.\r
128 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
129 EFI_DEVICE_PATH_PROTOCOL.\r
130 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
131 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r
132\r
133 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
134 @param[in] ControllerHandle The handle of the controller to start. This handle\r
135 must support a protocol interface that supplies\r
136 an I/O abstraction to the driver.\r
137 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r
138 parameter is ignored by device drivers, and is optional for bus\r
139 drivers. For a bus driver, if this parameter is NULL, then handles\r
140 for all the children of Controller are created by this driver.\r
141 If this parameter is not NULL and the first Device Path Node is\r
142 not the End of Device Path Node, then only the handle for the\r
143 child device specified by the first Device Path Node of\r
144 RemainingDevicePath is created by this driver.\r
145 If the first Device Path Node of RemainingDevicePath is\r
146 the End of Device Path Node, no child handle is created by this\r
147 driver.\r
148\r
149 @retval EFI_SUCCESS The device was started.\r
150 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r
151 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
152 @retval Others The driver failded to start the device.\r
153\r
154**/\r
155EFI_STATUS\r
156EFIAPI\r
157WifiMgrDxeDriverBindingStart (\r
158 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
159 IN EFI_HANDLE ControllerHandle,\r
160 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
161 )\r
162{\r
163 EFI_STATUS Status;\r
164 EFI_TPL OldTpl;\r
165 UINTN AddressSize;\r
166 WIFI_MGR_DEVICE_DATA *Nic;\r
167 EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp;\r
168 EFI_SUPPLICANT_PROTOCOL *Supplicant;\r
169 EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig;\r
170\r
171 Nic = NULL;\r
172\r
173 //\r
174 //Open Protocols\r
175 //\r
176 Status = gBS->OpenProtocol (\r
177 ControllerHandle,\r
178 &gEfiWiFi2ProtocolGuid,\r
179 (VOID**) &Wmp,\r
180 This->DriverBindingHandle,\r
181 ControllerHandle,\r
182 EFI_OPEN_PROTOCOL_BY_DRIVER\r
183 );\r
184 if (EFI_ERROR (Status)) {\r
185 return Status;\r
186 }\r
187\r
188 Status = gBS->OpenProtocol (\r
189 ControllerHandle,\r
190 &gEfiSupplicantProtocolGuid,\r
191 (VOID**) &Supplicant,\r
192 This->DriverBindingHandle,\r
193 ControllerHandle,\r
194 EFI_OPEN_PROTOCOL_BY_DRIVER\r
195 );\r
196 if (EFI_ERROR (Status)) {\r
197 Supplicant = NULL;\r
198 }\r
199\r
200 Status = gBS->OpenProtocol (\r
201 ControllerHandle,\r
202 &gEfiEapConfigurationProtocolGuid,\r
203 (VOID**) &EapConfig,\r
204 This->DriverBindingHandle,\r
205 ControllerHandle,\r
206 EFI_OPEN_PROTOCOL_BY_DRIVER\r
207 );\r
208 if (EFI_ERROR (Status)) {\r
209 EapConfig = NULL;\r
210 }\r
211\r
212 //\r
213 //Initialize Nic device data\r
214 //\r
215 Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA));\r
216 if (Nic == NULL) {\r
217 Status = EFI_OUT_OF_RESOURCES;\r
218 goto ERROR1;\r
219 }\r
220 Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE;\r
221 Nic->DriverHandle = This->DriverBindingHandle;\r
222 Nic->ControllerHandle = ControllerHandle;\r
223 Nic->Private = mPrivate;\r
224 Nic->Wmp = Wmp;\r
225 Nic->Supplicant = Supplicant;\r
226 Nic->EapConfig = EapConfig;\r
227 Nic->UserSelectedProfile = NULL;\r
228 Nic->OneTimeScanRequest = FALSE;\r
229 Nic->ScanTickTime = WIFI_SCAN_FREQUENCY; //Initialize the first scan\r
230\r
231 if (Nic->Supplicant != NULL) {\r
232 WifiMgrGetSupportedSuites(Nic);\r
233 }\r
234\r
235 InitializeListHead (&Nic->ProfileList);\r
236\r
237 //\r
238 // Record the MAC address of the incoming NIC.\r
239 //\r
240 Status = NetLibGetMacAddress (\r
241 ControllerHandle,\r
242 (EFI_MAC_ADDRESS*) &Nic->MacAddress,\r
243 &AddressSize\r
244 );\r
245 if (EFI_ERROR (Status)) {\r
246 goto ERROR2;\r
247 }\r
248\r
249 //\r
250 // Create and start the timer for the status check\r
251 //\r
252 Status = gBS->CreateEvent (\r
253 EVT_NOTIFY_SIGNAL | EVT_TIMER,\r
254 TPL_CALLBACK,\r
255 WifiMgrOnTimerTick,\r
256 Nic,\r
257 &Nic->TickTimer\r
258 );\r
259 if (EFI_ERROR (Status)) {\r
260 goto ERROR2;\r
261 }\r
262\r
263 Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS(500));\r
264 if (EFI_ERROR (Status)) {\r
265 goto ERROR3;\r
266 }\r
267\r
268 Nic->ConnectState = WifiMgrDisconnected;\r
269 Nic->ScanState = WifiMgrScanFinished;\r
270\r
271 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
272 InsertTailList (&mPrivate->NicList, &Nic->Link);\r
273 Nic->NicIndex = mPrivate->NicCount ++;\r
274 if (mPrivate->CurrentNic == NULL) {\r
275 mPrivate->CurrentNic = Nic;\r
276 }\r
277 gBS->RestoreTPL (OldTpl);\r
278\r
279 Status = gBS->InstallProtocolInterface (\r
280 &ControllerHandle,\r
281 &mEfiWifiMgrPrivateGuid,\r
282 EFI_NATIVE_INTERFACE,\r
283 &Nic->WifiMgrIdentifier\r
284 );\r
285 if (EFI_ERROR (Status)) {\r
286 goto ERROR4;\r
287 }\r
288\r
289 return EFI_SUCCESS;\r
290\r
291ERROR4:\r
292\r
293 gBS->SetTimer (Nic->TickTimer, TimerCancel, 0);\r
294 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
295 RemoveEntryList (&Nic->Link);\r
296 mPrivate->NicCount--;\r
297 gBS->RestoreTPL (OldTpl);\r
298\r
299ERROR3:\r
300\r
301 gBS->CloseEvent (Nic->TickTimer);\r
302\r
303ERROR2:\r
304\r
305 if (Nic->Supplicant != NULL) {\r
306 if (Nic->SupportedSuites.SupportedAKMSuites != NULL) {\r
307 FreePool (Nic->SupportedSuites.SupportedAKMSuites);\r
308 }\r
309 if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) {\r
310 FreePool (Nic->SupportedSuites.SupportedSwCipherSuites);\r
311 }\r
312 if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) {\r
313 FreePool (Nic->SupportedSuites.SupportedHwCipherSuites);\r
314 }\r
315 }\r
316 FreePool (Nic);\r
317\r
318ERROR1:\r
319\r
320 if (Supplicant != NULL) {\r
321 gBS->CloseProtocol (\r
322 ControllerHandle,\r
323 &gEfiSupplicantProtocolGuid,\r
324 This->DriverBindingHandle,\r
325 ControllerHandle\r
326 );\r
327 }\r
328\r
329 if (EapConfig != NULL) {\r
330 gBS->CloseProtocol (\r
331 ControllerHandle,\r
332 &gEfiEapConfigurationProtocolGuid,\r
333 This->DriverBindingHandle,\r
334 ControllerHandle\r
335 );\r
336 }\r
337\r
338 gBS->CloseProtocol (\r
339 ControllerHandle,\r
340 &gEfiWiFi2ProtocolGuid,\r
341 This->DriverBindingHandle,\r
342 ControllerHandle\r
343 );\r
344\r
345 return Status;\r
346}\r
347\r
348/**\r
349 Stops a device controller or a bus controller.\r
350\r
351 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r
352 As a result, much of the error checking on the parameters to Stop() has been moved\r
353 into this common boot service. It is legal to call Stop() from other locations,\r
354 but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
355 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
356 same driver's Start() function.\r
357 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
358 EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
359 Start() function, and the Start() function must have called OpenProtocol() on\r
360 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
361\r
362 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
363 @param[in] ControllerHandle A handle to the device being stopped. The handle must\r
364 support a bus specific I/O protocol for the driver\r
365 to use to stop the device.\r
366 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
367 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r
368 if NumberOfChildren is 0.\r
369\r
370 @retval EFI_SUCCESS The device was stopped.\r
371 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
372\r
373**/\r
374EFI_STATUS\r
375EFIAPI\r
376WifiMgrDxeDriverBindingStop (\r
377 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
378 IN EFI_HANDLE ControllerHandle,\r
379 IN UINTN NumberOfChildren,\r
380 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
381 )\r
382{\r
383 EFI_STATUS Status;\r
384 EFI_TPL OldTpl;\r
385 WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier;\r
386 WIFI_MGR_DEVICE_DATA *Nic;\r
387\r
388 Status = gBS->OpenProtocol (\r
389 ControllerHandle,\r
390 &mEfiWifiMgrPrivateGuid,\r
391 (VOID **) &WifiMgrIdentifier,\r
392 This->DriverBindingHandle,\r
393 ControllerHandle,\r
394 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
395 );\r
396 if (EFI_ERROR (Status)) {\r
397 return EFI_DEVICE_ERROR;\r
398 }\r
399\r
400 Nic = WIFI_MGR_DEVICE_DATA_FROM_IDENTIFIER (WifiMgrIdentifier);\r
401 if (Nic == NULL) {\r
402 return EFI_DEVICE_ERROR;\r
403 }\r
404\r
405 //\r
406 // Close Event\r
407 //\r
a6c63ee6 408 gBS->SetTimer (Nic->TickTimer, TimerCancel, 0);\r
90b24889
WF
409 gBS->CloseEvent (Nic->TickTimer);\r
410\r
411 //\r
412 // Clean Supported Suites\r
413 //\r
414 if (Nic->Supplicant != NULL) {\r
415 if (Nic->SupportedSuites.SupportedAKMSuites != NULL) {\r
416 FreePool (Nic->SupportedSuites.SupportedAKMSuites);\r
417 }\r
418 if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) {\r
419 FreePool (Nic->SupportedSuites.SupportedSwCipherSuites);\r
420 }\r
421 if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) {\r
422 FreePool (Nic->SupportedSuites.SupportedHwCipherSuites);\r
423 }\r
424 }\r
425\r
426 //\r
427 // Close Protocols\r
428 //\r
429 Status = gBS->UninstallProtocolInterface (\r
430 ControllerHandle,\r
431 &mEfiWifiMgrPrivateGuid,\r
432 &Nic->WifiMgrIdentifier\r
433 );\r
434 if (EFI_ERROR (Status)) {\r
435 return Status;\r
436 }\r
437\r
438 Status = gBS->CloseProtocol (\r
439 ControllerHandle,\r
440 &gEfiWiFi2ProtocolGuid,\r
441 Nic->DriverHandle,\r
442 Nic->ControllerHandle\r
443 );\r
444 if (EFI_ERROR (Status)) {\r
445 return Status;\r
446 }\r
447\r
448 if (Nic->Supplicant != NULL) {\r
449 Status = gBS->CloseProtocol (\r
450 ControllerHandle,\r
451 &gEfiSupplicantProtocolGuid,\r
452 Nic->DriverHandle,\r
453 Nic->ControllerHandle\r
454 );\r
455 if (EFI_ERROR (Status)) {\r
456 return Status;\r
457 }\r
458 }\r
459\r
460 if (Nic->EapConfig != NULL) {\r
461 Status = gBS->CloseProtocol (\r
462 ControllerHandle,\r
463 &gEfiEapConfigurationProtocolGuid,\r
464 Nic->DriverHandle,\r
465 Nic->ControllerHandle\r
466 );\r
467 if (EFI_ERROR (Status)) {\r
468 return Status;\r
469 }\r
470 }\r
471\r
472 //\r
473 // Remove this Nic from Nic list\r
474 //\r
475 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
476\r
477 RemoveEntryList (&Nic->Link);\r
478 mPrivate->NicCount--;\r
479 if (mPrivate->CurrentNic == Nic) {\r
480 mPrivate->CurrentNic = NULL;\r
481 }\r
482\r
483 gBS->RestoreTPL (OldTpl);\r
484\r
485 WifiMgrFreeProfileList (&Nic->ProfileList);\r
486 FreePool (Nic);\r
487\r
488 DEBUG ((DEBUG_INFO, "[WiFi Connection Manager] Device Controller has been Disconnected!\n"));\r
489 return EFI_SUCCESS;\r
490}\r
491\r
492/**\r
493 This is the declaration of an EFI image entry point. This entry point is\r
494 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including\r
495 both device drivers and bus drivers.\r
496\r
497 @param ImageHandle The firmware allocated handle for the UEFI image.\r
498 @param SystemTable A pointer to the EFI System Table.\r
499\r
500 @retval EFI_SUCCESS The operation completed successfully.\r
501 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
502 @retval Others An unexpected error occurred.\r
503\r
504**/\r
505EFI_STATUS\r
506EFIAPI\r
507WifiMgrDxeDriverEntryPoint (\r
508 IN EFI_HANDLE ImageHandle,\r
509 IN EFI_SYSTEM_TABLE *SystemTable\r
510 )\r
511{\r
512 EFI_STATUS Status;\r
513\r
514 Status = EfiLibInstallDriverBindingComponentName2 (\r
515 ImageHandle,\r
516 SystemTable,\r
517 &gWifiMgrDxeDriverBinding,\r
518 ImageHandle,\r
519 &gWifiMgrDxeComponentName,\r
520 &gWifiMgrDxeComponentName2\r
521 );\r
522 if (EFI_ERROR (Status)) {\r
523 return Status;\r
524 }\r
525\r
526 //\r
527 // Initialize the global private data structure.\r
528 //\r
529 mPrivate = AllocateZeroPool (sizeof (WIFI_MGR_PRIVATE_DATA));\r
530 if (mPrivate == NULL) {\r
531 Status = EFI_OUT_OF_RESOURCES;\r
532 goto ERROR1;\r
533 }\r
534 mPrivate->Signature = WIFI_MGR_PRIVATE_DATA_SIGNATURE;\r
535 mPrivate->DriverHandle = ImageHandle;\r
536 InitializeListHead (&mPrivate->NicList);\r
537 mPrivate->NicCount = 0;\r
538 mPrivate->CurrentNic = NULL;\r
539 InitializeListHead (&mPrivate->HiddenNetworkList);\r
540 mPrivate->HiddenNetworkCount = 0;\r
541\r
542 //\r
543 //Create events for page refresh\r
544 //\r
545 Status = gBS->CreateEventEx (\r
546 EVT_NOTIFY_SIGNAL,\r
547 TPL_CALLBACK,\r
548 WifiMgrInternalEmptyFunction,\r
549 NULL,\r
550 &mWifiConfigNetworkListRefreshGuid,\r
551 &mPrivate->NetworkListRefreshEvent\r
552 );\r
553 if (EFI_ERROR (Status)) {\r
554 goto ERROR2;\r
555 }\r
556\r
557 Status = gBS->CreateEventEx (\r
558 EVT_NOTIFY_SIGNAL,\r
559 TPL_CALLBACK,\r
560 WifiMgrInternalEmptyFunction,\r
561 NULL,\r
562 &mWifiConfigConnectFormRefreshGuid,\r
563 &mPrivate->ConnectFormRefreshEvent\r
564 );\r
565 if (EFI_ERROR (Status)) {\r
566 goto ERROR3;\r
567 }\r
568\r
569 Status = gBS->CreateEventEx (\r
570 EVT_NOTIFY_SIGNAL,\r
571 TPL_CALLBACK,\r
572 WifiMgrInternalEmptyFunction,\r
573 NULL,\r
574 &mWifiConfigMainFormRefreshGuid,\r
575 &mPrivate->MainPageRefreshEvent\r
576 );\r
577 if (EFI_ERROR (Status)) {\r
578 goto ERROR4;\r
579 }\r
580\r
581 Status = WifiMgrDxeConfigFormInit (mPrivate);\r
582 if (EFI_ERROR (Status)) {\r
583 goto ERROR5;\r
584 }\r
585\r
586 return Status;\r
587\r
588ERROR5:\r
589 gBS->CloseEvent (mPrivate->MainPageRefreshEvent);\r
590\r
591ERROR4:\r
592 gBS->CloseEvent (mPrivate->ConnectFormRefreshEvent);\r
593\r
594ERROR3:\r
595 gBS->CloseEvent (mPrivate->NetworkListRefreshEvent);\r
596\r
597ERROR2:\r
598 if (mPrivate != NULL) {\r
599 FreePool (mPrivate);\r
600 mPrivate = NULL;\r
601 }\r
602\r
603ERROR1:\r
604 gBS->UninstallMultipleProtocolInterfaces (\r
605 ImageHandle,\r
606 &gEfiDriverBindingProtocolGuid,\r
607 &gWifiMgrDxeDriverBinding,\r
608 &gEfiComponentNameProtocolGuid,\r
609 &gWifiMgrDxeComponentName,\r
610 &gEfiComponentName2ProtocolGuid,\r
611 &gWifiMgrDxeComponentName2,\r
612 NULL\r
613 );\r
614\r
615 return Status;\r
616}\r