Changeset 99404 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c
- Timestamp:
- Apr 14, 2023 3:17:44 PM (22 months ago)
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-145445 /vendor/edk2/current 103735-103757,103769-103776,129194-156846
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c
r80721 r99404 2 2 The driver binding protocol for the WiFi Connection Manager. 3 3 4 Copyright (c) 2019 , Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR> 5 5 6 6 SPDX-License-Identifier: BSD-2-Clause-Patent … … 13 13 /// Driver Binding Protocol instance 14 14 /// 15 EFI_DRIVER_BINDING_PROTOCOL gWifiMgrDxeDriverBinding = {15 EFI_DRIVER_BINDING_PROTOCOL gWifiMgrDxeDriverBinding = { 16 16 WifiMgrDxeDriverBindingSupported, 17 17 WifiMgrDxeDriverBindingStart, … … 23 23 24 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; 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; 41 46 42 47 /** … … 86 91 EFIAPI 87 92 WifiMgrDxeDriverBindingSupported ( 88 IN EFI_DRIVER_BINDING_PROTOCOL 89 IN EFI_HANDLE 90 IN EFI_DEVICE_PATH_PROTOCOL 93 IN EFI_DRIVER_BINDING_PROTOCOL *This, 94 IN EFI_HANDLE ControllerHandle, 95 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL 91 96 ) 92 97 { 93 EFI_STATUS 98 EFI_STATUS Status; 94 99 95 100 Status = gBS->OpenProtocol ( … … 156 161 EFIAPI 157 162 WifiMgrDxeDriverBindingStart ( 158 IN EFI_DRIVER_BINDING_PROTOCOL 159 IN EFI_HANDLE 160 IN EFI_DEVICE_PATH_PROTOCOL 163 IN EFI_DRIVER_BINDING_PROTOCOL *This, 164 IN EFI_HANDLE ControllerHandle, 165 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL 161 166 ) 162 167 { 163 EFI_STATUS Status; 164 EFI_TPL OldTpl; 165 UINTN AddressSize; 166 WIFI_MGR_DEVICE_DATA *Nic; 167 EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; 168 EFI_SUPPLICANT_PROTOCOL *Supplicant; 169 EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; 170 171 Nic = NULL; 172 173 // 174 //Open Protocols 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 175 182 // 176 183 Status = gBS->OpenProtocol ( 177 184 ControllerHandle, 178 185 &gEfiWiFi2ProtocolGuid, 179 (VOID **)&Wmp,186 (VOID **)&Wmp, 180 187 This->DriverBindingHandle, 181 188 ControllerHandle, … … 189 196 ControllerHandle, 190 197 &gEfiSupplicantProtocolGuid, 191 (VOID **)&Supplicant,198 (VOID **)&Supplicant, 192 199 This->DriverBindingHandle, 193 200 ControllerHandle, … … 201 208 ControllerHandle, 202 209 &gEfiEapConfigurationProtocolGuid, 203 (VOID **)&EapConfig,210 (VOID **)&EapConfig, 204 211 This->DriverBindingHandle, 205 212 ControllerHandle, … … 211 218 212 219 // 213 // Initialize Nic device data220 // Initialize Nic device data 214 221 // 215 222 Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); … … 218 225 goto ERROR1; 219 226 } 220 Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE; 221 Nic->DriverHandle = This->DriverBindingHandle; 222 Nic->ControllerHandle = ControllerHandle; 223 Nic->Private = mPrivate; 224 Nic->Wmp = Wmp; 225 Nic->Supplicant = Supplicant; 226 Nic->EapConfig = EapConfig; 227 Nic->UserSelectedProfile = NULL; 228 Nic->OneTimeScanRequest = FALSE; 229 Nic->ScanTickTime = WIFI_SCAN_FREQUENCY; //Initialize the first scan 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 230 238 231 239 if (Nic->Supplicant != NULL) { 232 WifiMgrGetSupportedSuites (Nic);240 WifiMgrGetSupportedSuites (Nic); 233 241 } 234 242 … … 236 244 237 245 // 238 // Record the MAC address of the incoming NIC. 239 // 240 Status = NetLibGetMacAddress ( 241 ControllerHandle, 242 (EFI_MAC_ADDRESS*) &Nic->MacAddress, 243 &AddressSize 244 ); 245 if (EFI_ERROR (Status)) { 246 goto ERROR2; 247 } 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 263 Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS(500)); 264 if (EFI_ERROR (Status)) { 265 goto ERROR3; 266 } 267 268 Nic->ConnectState = WifiMgrDisconnected; 269 Nic->ScanState = WifiMgrScanFinished; 270 271 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 272 InsertTailList (&mPrivate->NicList, &Nic->Link); 273 Nic->NicIndex = mPrivate->NicCount ++; 274 if (mPrivate->CurrentNic == NULL) { 275 mPrivate->CurrentNic = Nic; 276 } 277 gBS->RestoreTPL (OldTpl); 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 } 278 313 279 314 Status = gBS->InstallProtocolInterface ( … … 307 342 FreePool (Nic->SupportedSuites.SupportedAKMSuites); 308 343 } 344 309 345 if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { 310 346 FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); 311 347 } 348 312 349 if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { 313 350 FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); 314 351 } 315 352 } 353 316 354 FreePool (Nic); 317 355 … … 375 413 EFIAPI 376 414 WifiMgrDxeDriverBindingStop ( 377 IN EFI_DRIVER_BINDING_PROTOCOL 378 IN EFI_HANDLE 379 IN UINTN 380 IN EFI_HANDLE 415 IN EFI_DRIVER_BINDING_PROTOCOL *This, 416 IN EFI_HANDLE ControllerHandle, 417 IN UINTN NumberOfChildren, 418 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL 381 419 ) 382 420 { 383 EFI_STATUS Status; 384 EFI_TPL OldTpl; 385 WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; 386 WIFI_MGR_DEVICE_DATA *Nic; 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; 387 426 388 427 Status = gBS->OpenProtocol ( 389 428 ControllerHandle, 390 429 &mEfiWifiMgrPrivateGuid, 391 (VOID **) 430 (VOID **)&WifiMgrIdentifier, 392 431 This->DriverBindingHandle, 393 432 ControllerHandle, … … 416 455 FreePool (Nic->SupportedSuites.SupportedAKMSuites); 417 456 } 457 418 458 if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { 419 459 FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); 420 460 } 461 421 462 if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { 422 463 FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); … … 428 469 // 429 470 Status = gBS->UninstallProtocolInterface ( 430 ControllerHandle,431 &mEfiWifiMgrPrivateGuid,432 &Nic->WifiMgrIdentifier433 );471 ControllerHandle, 472 &mEfiWifiMgrPrivateGuid, 473 &Nic->WifiMgrIdentifier 474 ); 434 475 if (EFI_ERROR (Status)) { 435 476 return Status; … … 437 478 438 479 Status = gBS->CloseProtocol ( 439 ControllerHandle,440 &gEfiWiFi2ProtocolGuid,441 Nic->DriverHandle,442 Nic->ControllerHandle443 );480 ControllerHandle, 481 &gEfiWiFi2ProtocolGuid, 482 Nic->DriverHandle, 483 Nic->ControllerHandle 484 ); 444 485 if (EFI_ERROR (Status)) { 445 486 return Status; … … 448 489 if (Nic->Supplicant != NULL) { 449 490 Status = gBS->CloseProtocol ( 450 ControllerHandle,451 &gEfiSupplicantProtocolGuid,452 Nic->DriverHandle,453 Nic->ControllerHandle454 );491 ControllerHandle, 492 &gEfiSupplicantProtocolGuid, 493 Nic->DriverHandle, 494 Nic->ControllerHandle 495 ); 455 496 if (EFI_ERROR (Status)) { 456 497 return Status; … … 460 501 if (Nic->EapConfig != NULL) { 461 502 Status = gBS->CloseProtocol ( 462 ControllerHandle,463 &gEfiEapConfigurationProtocolGuid,464 Nic->DriverHandle,465 Nic->ControllerHandle466 );503 ControllerHandle, 504 &gEfiEapConfigurationProtocolGuid, 505 Nic->DriverHandle, 506 Nic->ControllerHandle 507 ); 467 508 if (EFI_ERROR (Status)) { 468 509 return Status; … … 475 516 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 476 517 477 RemoveEntryList (&Nic->Link); 518 Status = gBS->LocateProtocol ( 519 &gEdkiiWiFiProfileSyncProtocolGuid, 520 NULL, 521 (VOID **)&WiFiProfileSyncProtocol 522 ); 523 if (EFI_ERROR (Status)) { 524 RemoveEntryList (&Nic->Link); 525 } 526 478 527 mPrivate->NicCount--; 479 528 if (mPrivate->CurrentNic == Nic) { … … 506 555 EFIAPI 507 556 WifiMgrDxeDriverEntryPoint ( 508 IN EFI_HANDLE 509 IN EFI_SYSTEM_TABLE 557 IN EFI_HANDLE ImageHandle, 558 IN EFI_SYSTEM_TABLE *SystemTable 510 559 ) 511 560 { 512 EFI_STATUS 561 EFI_STATUS Status; 513 562 514 563 Status = EfiLibInstallDriverBindingComponentName2 ( … … 532 581 goto ERROR1; 533 582 } 583 534 584 mPrivate->Signature = WIFI_MGR_PRIVATE_DATA_SIGNATURE; 535 585 mPrivate->DriverHandle = ImageHandle; 536 586 InitializeListHead (&mPrivate->NicList); 537 mPrivate->NicCount = 0;587 mPrivate->NicCount = 0; 538 588 mPrivate->CurrentNic = NULL; 539 589 InitializeListHead (&mPrivate->HiddenNetworkList); … … 541 591 542 592 // 543 // Create events for page refresh593 // Create events for page refresh 544 594 // 545 595 Status = gBS->CreateEventEx (
Note:
See TracChangeset
for help on using the changeset viewer.