VirtualBox

Ignore:
Timestamp:
Apr 14, 2023 3:17:44 PM (22 months ago)
Author:
vboxsync
Message:

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c

    r80721 r99404  
    22  The driver binding protocol for the WiFi Connection Manager.
    33
    4   Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>
    55
    66  SPDX-License-Identifier: BSD-2-Clause-Patent
     
    1313/// Driver Binding Protocol instance
    1414///
    15 EFI_DRIVER_BINDING_PROTOCOL gWifiMgrDxeDriverBinding = {
     15EFI_DRIVER_BINDING_PROTOCOL  gWifiMgrDxeDriverBinding = {
    1616  WifiMgrDxeDriverBindingSupported,
    1717  WifiMgrDxeDriverBindingStart,
     
    2323
    2424//
    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//
     27WIFI_MGR_PRIVATE_DATA  *mPrivate = NULL;
     28
     29//
     30// The private guid to identify WiFi Connection Manager
     31//
     32EFI_GUID  mEfiWifiMgrPrivateGuid = EFI_WIFIMGR_PRIVATE_GUID;
     33
     34//
     35// The Hii config guids
     36//
     37EFI_GUID  gWifiConfigFormSetGuid            = WIFI_CONNECTION_MANAGER_CONFIG_GUID;
     38EFI_GUID  mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_GUID;
     39EFI_GUID  mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID;
     40EFI_GUID  mWifiConfigMainFormRefreshGuid    = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID;
     41
     42//
     43// Wifi connection attempt counter for retries
     44//
     45extern UINT8  mWifiConnectionCount;
    4146
    4247/**
     
    8691EFIAPI
    8792WifiMgrDxeDriverBindingSupported (
    88   IN EFI_DRIVER_BINDING_PROTOCOL    *This,
    89   IN EFI_HANDLE                     ControllerHandle,
    90   IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath OPTIONAL
     93  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     94  IN EFI_HANDLE                   ControllerHandle,
     95  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
    9196  )
    9297{
    93   EFI_STATUS    Status;
     98  EFI_STATUS  Status;
    9499
    95100  Status = gBS->OpenProtocol (
     
    156161EFIAPI
    157162WifiMgrDxeDriverBindingStart (
    158   IN EFI_DRIVER_BINDING_PROTOCOL    *This,
    159   IN EFI_HANDLE                     ControllerHandle,
    160   IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath OPTIONAL
     163  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     164  IN EFI_HANDLE                   ControllerHandle,
     165  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
    161166  )
    162167{
    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
    175182  //
    176183  Status = gBS->OpenProtocol (
    177184                  ControllerHandle,
    178185                  &gEfiWiFi2ProtocolGuid,
    179                   (VOID**) &Wmp,
     186                  (VOID **)&Wmp,
    180187                  This->DriverBindingHandle,
    181188                  ControllerHandle,
     
    189196                  ControllerHandle,
    190197                  &gEfiSupplicantProtocolGuid,
    191                   (VOID**) &Supplicant,
     198                  (VOID **)&Supplicant,
    192199                  This->DriverBindingHandle,
    193200                  ControllerHandle,
     
    201208                  ControllerHandle,
    202209                  &gEfiEapConfigurationProtocolGuid,
    203                   (VOID**) &EapConfig,
     210                  (VOID **)&EapConfig,
    204211                  This->DriverBindingHandle,
    205212                  ControllerHandle,
     
    211218
    212219  //
    213   //Initialize Nic device data
     220  // Initialize Nic device data
    214221  //
    215222  Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA));
     
    218225    goto ERROR1;
    219226  }
    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
    230238
    231239  if (Nic->Supplicant != NULL) {
    232     WifiMgrGetSupportedSuites(Nic);
     240    WifiMgrGetSupportedSuites (Nic);
    233241  }
    234242
     
    236244
    237245  //
    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  }
    278313
    279314  Status = gBS->InstallProtocolInterface (
     
    307342      FreePool (Nic->SupportedSuites.SupportedAKMSuites);
    308343    }
     344
    309345    if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) {
    310346      FreePool (Nic->SupportedSuites.SupportedSwCipherSuites);
    311347    }
     348
    312349    if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) {
    313350      FreePool (Nic->SupportedSuites.SupportedHwCipherSuites);
    314351    }
    315352  }
     353
    316354  FreePool (Nic);
    317355
     
    375413EFIAPI
    376414WifiMgrDxeDriverBindingStop (
    377   IN EFI_DRIVER_BINDING_PROTOCOL    *This,
    378   IN EFI_HANDLE                     ControllerHandle,
    379   IN UINTN                          NumberOfChildren,
    380   IN EFI_HANDLE                     *ChildHandleBuffer OPTIONAL
     415  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     416  IN EFI_HANDLE                   ControllerHandle,
     417  IN UINTN                        NumberOfChildren,
     418  IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
    381419  )
    382420{
    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;
    387426
    388427  Status = gBS->OpenProtocol (
    389428                  ControllerHandle,
    390429                  &mEfiWifiMgrPrivateGuid,
    391                   (VOID **) &WifiMgrIdentifier,
     430                  (VOID **)&WifiMgrIdentifier,
    392431                  This->DriverBindingHandle,
    393432                  ControllerHandle,
     
    416455      FreePool (Nic->SupportedSuites.SupportedAKMSuites);
    417456    }
     457
    418458    if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) {
    419459      FreePool (Nic->SupportedSuites.SupportedSwCipherSuites);
    420460    }
     461
    421462    if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) {
    422463      FreePool (Nic->SupportedSuites.SupportedHwCipherSuites);
     
    428469  //
    429470  Status = gBS->UninstallProtocolInterface (
    430              ControllerHandle,
    431              &mEfiWifiMgrPrivateGuid,
    432              &Nic->WifiMgrIdentifier
    433              );
     471                  ControllerHandle,
     472                  &mEfiWifiMgrPrivateGuid,
     473                  &Nic->WifiMgrIdentifier
     474                  );
    434475  if (EFI_ERROR (Status)) {
    435476    return Status;
     
    437478
    438479  Status = gBS->CloseProtocol (
    439              ControllerHandle,
    440              &gEfiWiFi2ProtocolGuid,
    441              Nic->DriverHandle,
    442              Nic->ControllerHandle
    443              );
     480                  ControllerHandle,
     481                  &gEfiWiFi2ProtocolGuid,
     482                  Nic->DriverHandle,
     483                  Nic->ControllerHandle
     484                  );
    444485  if (EFI_ERROR (Status)) {
    445486    return Status;
     
    448489  if (Nic->Supplicant != NULL) {
    449490    Status = gBS->CloseProtocol (
    450                ControllerHandle,
    451                &gEfiSupplicantProtocolGuid,
    452                Nic->DriverHandle,
    453                Nic->ControllerHandle
    454                );
     491                    ControllerHandle,
     492                    &gEfiSupplicantProtocolGuid,
     493                    Nic->DriverHandle,
     494                    Nic->ControllerHandle
     495                    );
    455496    if (EFI_ERROR (Status)) {
    456497      return Status;
     
    460501  if (Nic->EapConfig != NULL) {
    461502    Status = gBS->CloseProtocol (
    462                ControllerHandle,
    463                &gEfiEapConfigurationProtocolGuid,
    464                Nic->DriverHandle,
    465                Nic->ControllerHandle
    466                );
     503                    ControllerHandle,
     504                    &gEfiEapConfigurationProtocolGuid,
     505                    Nic->DriverHandle,
     506                    Nic->ControllerHandle
     507                    );
    467508    if (EFI_ERROR (Status)) {
    468509      return Status;
     
    475516  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
    476517
    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
    478527  mPrivate->NicCount--;
    479528  if (mPrivate->CurrentNic == Nic) {
     
    506555EFIAPI
    507556WifiMgrDxeDriverEntryPoint (
    508   IN EFI_HANDLE          ImageHandle,
    509   IN EFI_SYSTEM_TABLE    *SystemTable
     557  IN EFI_HANDLE        ImageHandle,
     558  IN EFI_SYSTEM_TABLE  *SystemTable
    510559  )
    511560{
    512   EFI_STATUS                       Status;
     561  EFI_STATUS  Status;
    513562
    514563  Status = EfiLibInstallDriverBindingComponentName2 (
     
    532581    goto ERROR1;
    533582  }
     583
    534584  mPrivate->Signature    = WIFI_MGR_PRIVATE_DATA_SIGNATURE;
    535585  mPrivate->DriverHandle = ImageHandle;
    536586  InitializeListHead (&mPrivate->NicList);
    537   mPrivate->NicCount = 0;
     587  mPrivate->NicCount   = 0;
    538588  mPrivate->CurrentNic = NULL;
    539589  InitializeListHead (&mPrivate->HiddenNetworkList);
     
    541591
    542592  //
    543   //Create events for page refresh
     593  // Create events for page refresh
    544594  //
    545595  Status = gBS->CreateEventEx (
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette