WifiConnectionMgrDriver.c 22 KB

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