]>
Commit | Line | Data |
---|---|---|
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 | |
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 WF |
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 | |
85 | EFI_STATUS\r | |
86 | EFIAPI\r | |
87 | WifiMgrDxeDriverBindingSupported (\r | |
d1050b9d MK |
88 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
89 | IN EFI_HANDLE ControllerHandle,\r | |
90 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
90b24889 WF |
91 | )\r |
92 | {\r | |
d1050b9d | 93 | EFI_STATUS Status;\r |
90b24889 WF |
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 | |
155 | EFI_STATUS\r | |
156 | EFIAPI\r | |
157 | WifiMgrDxeDriverBindingStart (\r | |
d1050b9d MK |
158 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
159 | IN EFI_HANDLE ControllerHandle,\r | |
160 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
90b24889 WF |
161 | )\r |
162 | {\r | |
d1050b9d MK |
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 | |
90b24889 WF |
170 | \r |
171 | Nic = NULL;\r | |
172 | \r | |
173 | //\r | |
d1050b9d | 174 | // Open Protocols\r |
90b24889 WF |
175 | //\r |
176 | Status = gBS->OpenProtocol (\r | |
177 | ControllerHandle,\r | |
178 | &gEfiWiFi2ProtocolGuid,\r | |
d1050b9d | 179 | (VOID **)&Wmp,\r |
90b24889 WF |
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 | |
d1050b9d | 191 | (VOID **)&Supplicant,\r |
90b24889 WF |
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 | |
d1050b9d | 203 | (VOID **)&EapConfig,\r |
90b24889 WF |
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 | |
d1050b9d | 213 | // Initialize Nic device data\r |
90b24889 WF |
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 | |
d1050b9d MK |
220 | \r |
221 | Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE;\r | |
222 | Nic->DriverHandle = This->DriverBindingHandle;\r | |
223 | Nic->ControllerHandle = ControllerHandle;\r | |
224 | Nic->Private = mPrivate;\r | |
225 | Nic->Wmp = Wmp;\r | |
226 | Nic->Supplicant = Supplicant;\r | |
227 | Nic->EapConfig = EapConfig;\r | |
228 | Nic->UserSelectedProfile = NULL;\r | |
229 | Nic->OneTimeScanRequest = FALSE;\r | |
230 | Nic->ScanTickTime = WIFI_SCAN_FREQUENCY; // Initialize the first scan\r | |
90b24889 WF |
231 | \r |
232 | if (Nic->Supplicant != NULL) {\r | |
d1050b9d | 233 | WifiMgrGetSupportedSuites (Nic);\r |
90b24889 WF |
234 | }\r |
235 | \r | |
236 | InitializeListHead (&Nic->ProfileList);\r | |
237 | \r | |
238 | //\r | |
239 | // Record the MAC address of the incoming NIC.\r | |
240 | //\r | |
241 | Status = NetLibGetMacAddress (\r | |
242 | ControllerHandle,\r | |
d1050b9d | 243 | (EFI_MAC_ADDRESS *)&Nic->MacAddress,\r |
90b24889 WF |
244 | &AddressSize\r |
245 | );\r | |
246 | if (EFI_ERROR (Status)) {\r | |
247 | goto ERROR2;\r | |
248 | }\r | |
249 | \r | |
250 | //\r | |
251 | // Create and start the timer for the status check\r | |
252 | //\r | |
253 | Status = gBS->CreateEvent (\r | |
254 | EVT_NOTIFY_SIGNAL | EVT_TIMER,\r | |
255 | TPL_CALLBACK,\r | |
256 | WifiMgrOnTimerTick,\r | |
257 | Nic,\r | |
258 | &Nic->TickTimer\r | |
259 | );\r | |
260 | if (EFI_ERROR (Status)) {\r | |
261 | goto ERROR2;\r | |
262 | }\r | |
263 | \r | |
d1050b9d | 264 | Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500));\r |
90b24889 WF |
265 | if (EFI_ERROR (Status)) {\r |
266 | goto ERROR3;\r | |
267 | }\r | |
268 | \r | |
269 | Nic->ConnectState = WifiMgrDisconnected;\r | |
270 | Nic->ScanState = WifiMgrScanFinished;\r | |
271 | \r | |
272 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
273 | InsertTailList (&mPrivate->NicList, &Nic->Link);\r | |
d1050b9d | 274 | Nic->NicIndex = mPrivate->NicCount++;\r |
90b24889 WF |
275 | if (mPrivate->CurrentNic == NULL) {\r |
276 | mPrivate->CurrentNic = Nic;\r | |
277 | }\r | |
d1050b9d | 278 | \r |
90b24889 WF |
279 | gBS->RestoreTPL (OldTpl);\r |
280 | \r | |
281 | Status = gBS->InstallProtocolInterface (\r | |
282 | &ControllerHandle,\r | |
283 | &mEfiWifiMgrPrivateGuid,\r | |
284 | EFI_NATIVE_INTERFACE,\r | |
285 | &Nic->WifiMgrIdentifier\r | |
286 | );\r | |
287 | if (EFI_ERROR (Status)) {\r | |
288 | goto ERROR4;\r | |
289 | }\r | |
290 | \r | |
291 | return EFI_SUCCESS;\r | |
292 | \r | |
293 | ERROR4:\r | |
294 | \r | |
295 | gBS->SetTimer (Nic->TickTimer, TimerCancel, 0);\r | |
296 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
297 | RemoveEntryList (&Nic->Link);\r | |
298 | mPrivate->NicCount--;\r | |
299 | gBS->RestoreTPL (OldTpl);\r | |
300 | \r | |
301 | ERROR3:\r | |
302 | \r | |
303 | gBS->CloseEvent (Nic->TickTimer);\r | |
304 | \r | |
305 | ERROR2:\r | |
306 | \r | |
307 | if (Nic->Supplicant != NULL) {\r | |
308 | if (Nic->SupportedSuites.SupportedAKMSuites != NULL) {\r | |
309 | FreePool (Nic->SupportedSuites.SupportedAKMSuites);\r | |
310 | }\r | |
d1050b9d | 311 | \r |
90b24889 WF |
312 | if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) {\r |
313 | FreePool (Nic->SupportedSuites.SupportedSwCipherSuites);\r | |
314 | }\r | |
d1050b9d | 315 | \r |
90b24889 WF |
316 | if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) {\r |
317 | FreePool (Nic->SupportedSuites.SupportedHwCipherSuites);\r | |
318 | }\r | |
319 | }\r | |
d1050b9d | 320 | \r |
90b24889 WF |
321 | FreePool (Nic);\r |
322 | \r | |
323 | ERROR1:\r | |
324 | \r | |
325 | if (Supplicant != NULL) {\r | |
326 | gBS->CloseProtocol (\r | |
327 | ControllerHandle,\r | |
328 | &gEfiSupplicantProtocolGuid,\r | |
329 | This->DriverBindingHandle,\r | |
330 | ControllerHandle\r | |
331 | );\r | |
332 | }\r | |
333 | \r | |
334 | if (EapConfig != NULL) {\r | |
335 | gBS->CloseProtocol (\r | |
336 | ControllerHandle,\r | |
337 | &gEfiEapConfigurationProtocolGuid,\r | |
338 | This->DriverBindingHandle,\r | |
339 | ControllerHandle\r | |
340 | );\r | |
341 | }\r | |
342 | \r | |
343 | gBS->CloseProtocol (\r | |
344 | ControllerHandle,\r | |
345 | &gEfiWiFi2ProtocolGuid,\r | |
346 | This->DriverBindingHandle,\r | |
347 | ControllerHandle\r | |
348 | );\r | |
349 | \r | |
350 | return Status;\r | |
351 | }\r | |
352 | \r | |
353 | /**\r | |
354 | Stops a device controller or a bus controller.\r | |
355 | \r | |
356 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r | |
357 | As a result, much of the error checking on the parameters to Stop() has been moved\r | |
358 | into this common boot service. It is legal to call Stop() from other locations,\r | |
359 | but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r | |
360 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r | |
361 | same driver's Start() function.\r | |
362 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r | |
363 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r | |
364 | Start() function, and the Start() function must have called OpenProtocol() on\r | |
365 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r | |
366 | \r | |
367 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
368 | @param[in] ControllerHandle A handle to the device being stopped. The handle must\r | |
369 | support a bus specific I/O protocol for the driver\r | |
370 | to use to stop the device.\r | |
371 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
372 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r | |
373 | if NumberOfChildren is 0.\r | |
374 | \r | |
375 | @retval EFI_SUCCESS The device was stopped.\r | |
376 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
377 | \r | |
378 | **/\r | |
379 | EFI_STATUS\r | |
380 | EFIAPI\r | |
381 | WifiMgrDxeDriverBindingStop (\r | |
d1050b9d MK |
382 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
383 | IN EFI_HANDLE ControllerHandle,\r | |
384 | IN UINTN NumberOfChildren,\r | |
385 | IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r | |
90b24889 WF |
386 | )\r |
387 | {\r | |
d1050b9d MK |
388 | EFI_STATUS Status;\r |
389 | EFI_TPL OldTpl;\r | |
390 | WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier;\r | |
391 | WIFI_MGR_DEVICE_DATA *Nic;\r | |
90b24889 WF |
392 | \r |
393 | Status = gBS->OpenProtocol (\r | |
394 | ControllerHandle,\r | |
395 | &mEfiWifiMgrPrivateGuid,\r | |
d1050b9d | 396 | (VOID **)&WifiMgrIdentifier,\r |
90b24889 WF |
397 | This->DriverBindingHandle,\r |
398 | ControllerHandle,\r | |
399 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
400 | );\r | |
401 | if (EFI_ERROR (Status)) {\r | |
402 | return EFI_DEVICE_ERROR;\r | |
403 | }\r | |
404 | \r | |
405 | Nic = WIFI_MGR_DEVICE_DATA_FROM_IDENTIFIER (WifiMgrIdentifier);\r | |
406 | if (Nic == NULL) {\r | |
407 | return EFI_DEVICE_ERROR;\r | |
408 | }\r | |
409 | \r | |
410 | //\r | |
411 | // Close Event\r | |
412 | //\r | |
a6c63ee6 | 413 | gBS->SetTimer (Nic->TickTimer, TimerCancel, 0);\r |
90b24889 WF |
414 | gBS->CloseEvent (Nic->TickTimer);\r |
415 | \r | |
416 | //\r | |
417 | // Clean Supported Suites\r | |
418 | //\r | |
419 | if (Nic->Supplicant != NULL) {\r | |
420 | if (Nic->SupportedSuites.SupportedAKMSuites != NULL) {\r | |
421 | FreePool (Nic->SupportedSuites.SupportedAKMSuites);\r | |
422 | }\r | |
d1050b9d | 423 | \r |
90b24889 WF |
424 | if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) {\r |
425 | FreePool (Nic->SupportedSuites.SupportedSwCipherSuites);\r | |
426 | }\r | |
d1050b9d | 427 | \r |
90b24889 WF |
428 | if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) {\r |
429 | FreePool (Nic->SupportedSuites.SupportedHwCipherSuites);\r | |
430 | }\r | |
431 | }\r | |
432 | \r | |
433 | //\r | |
434 | // Close Protocols\r | |
435 | //\r | |
436 | Status = gBS->UninstallProtocolInterface (\r | |
d1050b9d MK |
437 | ControllerHandle,\r |
438 | &mEfiWifiMgrPrivateGuid,\r | |
439 | &Nic->WifiMgrIdentifier\r | |
440 | );\r | |
90b24889 WF |
441 | if (EFI_ERROR (Status)) {\r |
442 | return Status;\r | |
443 | }\r | |
444 | \r | |
445 | Status = gBS->CloseProtocol (\r | |
d1050b9d MK |
446 | ControllerHandle,\r |
447 | &gEfiWiFi2ProtocolGuid,\r | |
448 | Nic->DriverHandle,\r | |
449 | Nic->ControllerHandle\r | |
450 | );\r | |
90b24889 WF |
451 | if (EFI_ERROR (Status)) {\r |
452 | return Status;\r | |
453 | }\r | |
454 | \r | |
455 | if (Nic->Supplicant != NULL) {\r | |
456 | Status = gBS->CloseProtocol (\r | |
d1050b9d MK |
457 | ControllerHandle,\r |
458 | &gEfiSupplicantProtocolGuid,\r | |
459 | Nic->DriverHandle,\r | |
460 | Nic->ControllerHandle\r | |
461 | );\r | |
90b24889 WF |
462 | if (EFI_ERROR (Status)) {\r |
463 | return Status;\r | |
464 | }\r | |
465 | }\r | |
466 | \r | |
467 | if (Nic->EapConfig != NULL) {\r | |
468 | Status = gBS->CloseProtocol (\r | |
d1050b9d MK |
469 | ControllerHandle,\r |
470 | &gEfiEapConfigurationProtocolGuid,\r | |
471 | Nic->DriverHandle,\r | |
472 | Nic->ControllerHandle\r | |
473 | );\r | |
90b24889 WF |
474 | if (EFI_ERROR (Status)) {\r |
475 | return Status;\r | |
476 | }\r | |
477 | }\r | |
478 | \r | |
479 | //\r | |
480 | // Remove this Nic from Nic list\r | |
481 | //\r | |
482 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
483 | \r | |
484 | RemoveEntryList (&Nic->Link);\r | |
485 | mPrivate->NicCount--;\r | |
486 | if (mPrivate->CurrentNic == Nic) {\r | |
487 | mPrivate->CurrentNic = NULL;\r | |
488 | }\r | |
489 | \r | |
490 | gBS->RestoreTPL (OldTpl);\r | |
491 | \r | |
492 | WifiMgrFreeProfileList (&Nic->ProfileList);\r | |
493 | FreePool (Nic);\r | |
494 | \r | |
495 | DEBUG ((DEBUG_INFO, "[WiFi Connection Manager] Device Controller has been Disconnected!\n"));\r | |
496 | return EFI_SUCCESS;\r | |
497 | }\r | |
498 | \r | |
499 | /**\r | |
500 | This is the declaration of an EFI image entry point. This entry point is\r | |
501 | the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including\r | |
502 | both device drivers and bus drivers.\r | |
503 | \r | |
504 | @param ImageHandle The firmware allocated handle for the UEFI image.\r | |
505 | @param SystemTable A pointer to the EFI System Table.\r | |
506 | \r | |
507 | @retval EFI_SUCCESS The operation completed successfully.\r | |
508 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
509 | @retval Others An unexpected error occurred.\r | |
510 | \r | |
511 | **/\r | |
512 | EFI_STATUS\r | |
513 | EFIAPI\r | |
514 | WifiMgrDxeDriverEntryPoint (\r | |
d1050b9d MK |
515 | IN EFI_HANDLE ImageHandle,\r |
516 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
90b24889 WF |
517 | )\r |
518 | {\r | |
d1050b9d | 519 | EFI_STATUS Status;\r |
90b24889 WF |
520 | \r |
521 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
522 | ImageHandle,\r | |
523 | SystemTable,\r | |
524 | &gWifiMgrDxeDriverBinding,\r | |
525 | ImageHandle,\r | |
526 | &gWifiMgrDxeComponentName,\r | |
527 | &gWifiMgrDxeComponentName2\r | |
528 | );\r | |
529 | if (EFI_ERROR (Status)) {\r | |
530 | return Status;\r | |
531 | }\r | |
532 | \r | |
533 | //\r | |
534 | // Initialize the global private data structure.\r | |
535 | //\r | |
536 | mPrivate = AllocateZeroPool (sizeof (WIFI_MGR_PRIVATE_DATA));\r | |
537 | if (mPrivate == NULL) {\r | |
538 | Status = EFI_OUT_OF_RESOURCES;\r | |
539 | goto ERROR1;\r | |
540 | }\r | |
d1050b9d | 541 | \r |
90b24889 WF |
542 | mPrivate->Signature = WIFI_MGR_PRIVATE_DATA_SIGNATURE;\r |
543 | mPrivate->DriverHandle = ImageHandle;\r | |
544 | InitializeListHead (&mPrivate->NicList);\r | |
d1050b9d | 545 | mPrivate->NicCount = 0;\r |
90b24889 WF |
546 | mPrivate->CurrentNic = NULL;\r |
547 | InitializeListHead (&mPrivate->HiddenNetworkList);\r | |
548 | mPrivate->HiddenNetworkCount = 0;\r | |
549 | \r | |
550 | //\r | |
d1050b9d | 551 | // Create events for page refresh\r |
90b24889 WF |
552 | //\r |
553 | Status = gBS->CreateEventEx (\r | |
554 | EVT_NOTIFY_SIGNAL,\r | |
555 | TPL_CALLBACK,\r | |
556 | WifiMgrInternalEmptyFunction,\r | |
557 | NULL,\r | |
558 | &mWifiConfigNetworkListRefreshGuid,\r | |
559 | &mPrivate->NetworkListRefreshEvent\r | |
560 | );\r | |
561 | if (EFI_ERROR (Status)) {\r | |
562 | goto ERROR2;\r | |
563 | }\r | |
564 | \r | |
565 | Status = gBS->CreateEventEx (\r | |
566 | EVT_NOTIFY_SIGNAL,\r | |
567 | TPL_CALLBACK,\r | |
568 | WifiMgrInternalEmptyFunction,\r | |
569 | NULL,\r | |
570 | &mWifiConfigConnectFormRefreshGuid,\r | |
571 | &mPrivate->ConnectFormRefreshEvent\r | |
572 | );\r | |
573 | if (EFI_ERROR (Status)) {\r | |
574 | goto ERROR3;\r | |
575 | }\r | |
576 | \r | |
577 | Status = gBS->CreateEventEx (\r | |
578 | EVT_NOTIFY_SIGNAL,\r | |
579 | TPL_CALLBACK,\r | |
580 | WifiMgrInternalEmptyFunction,\r | |
581 | NULL,\r | |
582 | &mWifiConfigMainFormRefreshGuid,\r | |
583 | &mPrivate->MainPageRefreshEvent\r | |
584 | );\r | |
585 | if (EFI_ERROR (Status)) {\r | |
586 | goto ERROR4;\r | |
587 | }\r | |
588 | \r | |
589 | Status = WifiMgrDxeConfigFormInit (mPrivate);\r | |
590 | if (EFI_ERROR (Status)) {\r | |
591 | goto ERROR5;\r | |
592 | }\r | |
593 | \r | |
594 | return Status;\r | |
595 | \r | |
596 | ERROR5:\r | |
597 | gBS->CloseEvent (mPrivate->MainPageRefreshEvent);\r | |
598 | \r | |
599 | ERROR4:\r | |
600 | gBS->CloseEvent (mPrivate->ConnectFormRefreshEvent);\r | |
601 | \r | |
602 | ERROR3:\r | |
603 | gBS->CloseEvent (mPrivate->NetworkListRefreshEvent);\r | |
604 | \r | |
605 | ERROR2:\r | |
606 | if (mPrivate != NULL) {\r | |
607 | FreePool (mPrivate);\r | |
608 | mPrivate = NULL;\r | |
609 | }\r | |
610 | \r | |
611 | ERROR1:\r | |
612 | gBS->UninstallMultipleProtocolInterfaces (\r | |
613 | ImageHandle,\r | |
614 | &gEfiDriverBindingProtocolGuid,\r | |
615 | &gWifiMgrDxeDriverBinding,\r | |
616 | &gEfiComponentNameProtocolGuid,\r | |
617 | &gWifiMgrDxeComponentName,\r | |
618 | &gEfiComponentName2ProtocolGuid,\r | |
619 | &gWifiMgrDxeComponentName2,\r | |
620 | NULL\r | |
621 | );\r | |
622 | \r | |
623 | return Status;\r | |
624 | }\r |