/** @file\r
The driver binding protocol for the WiFi Connection Manager.\r
\r
- Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>\r
\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID;\r
EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID;\r
\r
+//\r
+// Wifi connection attempt counter for retries\r
+//\r
+extern UINT8 mWifiConnectionCount;\r
+\r
/**\r
Tests to see if this driver supports a given controller. If a child device is provided,\r
it further tests to see if this driver supports creating a handle for the specified child device.\r
EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp;\r
EFI_SUPPLICANT_PROTOCOL *Supplicant;\r
EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig;\r
+ EDKII_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol;\r
\r
- Nic = NULL;\r
+ mWifiConnectionCount = 0;\r
+ Nic = NULL;\r
\r
//\r
// Open Protocols\r
InitializeListHead (&Nic->ProfileList);\r
\r
//\r
- // Record the MAC address of the incoming NIC.\r
+ // WiFi profile sync protocol installation check for OS recovery flow.\r
//\r
- Status = NetLibGetMacAddress (\r
- ControllerHandle,\r
- (EFI_MAC_ADDRESS *)&Nic->MacAddress,\r
- &AddressSize\r
- );\r
- if (EFI_ERROR (Status)) {\r
- goto ERROR2;\r
- }\r
-\r
- //\r
- // Create and start the timer for the status check\r
- //\r
- Status = gBS->CreateEvent (\r
- EVT_NOTIFY_SIGNAL | EVT_TIMER,\r
- TPL_CALLBACK,\r
- WifiMgrOnTimerTick,\r
- Nic,\r
- &Nic->TickTimer\r
+ Status = gBS->LocateProtocol (\r
+ &gEdkiiWiFiProfileSyncProtocolGuid,\r
+ NULL,\r
+ (VOID **)&WiFiProfileSyncProtocol\r
);\r
- if (EFI_ERROR (Status)) {\r
- goto ERROR2;\r
- }\r
+ if (!EFI_ERROR (Status)) {\r
+ Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE));\r
+ if (Nic->ConnectPendingNetwork == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto ERROR1;\r
+ }\r
\r
- Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500));\r
- if (EFI_ERROR (Status)) {\r
- goto ERROR3;\r
- }\r
+ WiFiProfileSyncProtocol->GetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress);\r
+ if (Nic->ConnectPendingNetwork != NULL) {\r
+ Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork);\r
+ if (!EFI_ERROR (Status)) {\r
+ goto ERROR1;\r
+ }\r
+\r
+ WiFiProfileSyncProtocol->SetConnectState (Status);\r
+ }\r
+ } else {\r
+ //\r
+ // Record the MAC address of the incoming NIC.\r
+ //\r
+ Status = NetLibGetMacAddress (\r
+ ControllerHandle,\r
+ (EFI_MAC_ADDRESS *)&Nic->MacAddress,\r
+ &AddressSize\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto ERROR2;\r
+ }\r
\r
- Nic->ConnectState = WifiMgrDisconnected;\r
- Nic->ScanState = WifiMgrScanFinished;\r
+ //\r
+ // Create and start the timer for the status check\r
+ //\r
+ Status = gBS->CreateEvent (\r
+ EVT_NOTIFY_SIGNAL | EVT_TIMER,\r
+ TPL_CALLBACK,\r
+ WifiMgrOnTimerTick,\r
+ Nic,\r
+ &Nic->TickTimer\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto ERROR2;\r
+ }\r
\r
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
- InsertTailList (&mPrivate->NicList, &Nic->Link);\r
- Nic->NicIndex = mPrivate->NicCount++;\r
- if (mPrivate->CurrentNic == NULL) {\r
- mPrivate->CurrentNic = Nic;\r
- }\r
+ Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500));\r
+ if (EFI_ERROR (Status)) {\r
+ goto ERROR3;\r
+ }\r
\r
- gBS->RestoreTPL (OldTpl);\r
+ Nic->ConnectState = WifiMgrDisconnected;\r
+ Nic->ScanState = WifiMgrScanFinished;\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+ InsertTailList (&mPrivate->NicList, &Nic->Link);\r
+ Nic->NicIndex = mPrivate->NicCount++;\r
+ if (mPrivate->CurrentNic == NULL) {\r
+ mPrivate->CurrentNic = Nic;\r
+ }\r
+\r
+ gBS->RestoreTPL (OldTpl);\r
+ }\r
\r
Status = gBS->InstallProtocolInterface (\r
&ControllerHandle,\r
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_TPL OldTpl;\r
- WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier;\r
- WIFI_MGR_DEVICE_DATA *Nic;\r
+ EFI_STATUS Status;\r
+ EFI_TPL OldTpl;\r
+ WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier;\r
+ WIFI_MGR_DEVICE_DATA *Nic;\r
+ EDKII_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol;\r
\r
Status = gBS->OpenProtocol (\r
ControllerHandle,\r
//\r
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\r
- RemoveEntryList (&Nic->Link);\r
+ Status = gBS->LocateProtocol (\r
+ &gEdkiiWiFiProfileSyncProtocolGuid,\r
+ NULL,\r
+ (VOID **)&WiFiProfileSyncProtocol\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ RemoveEntryList (&Nic->Link);\r
+ }\r
+\r
mPrivate->NicCount--;\r
if (mPrivate->CurrentNic == Nic) {\r
mPrivate->CurrentNic = NULL;\r