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