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