VirtualBox

Ignore:
Timestamp:
Aug 14, 2024 1:16:30 PM (9 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
164367
Message:

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
1 added
4 edited

Legend:

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

  • trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c

    r101291 r105670  
    1818// Variables for using RFI Redfish Discover Protocol
    1919//
    20 VOID                           *gEfiRedfishDiscoverRegistration;
    21 EFI_HANDLE                     gEfiRedfishDiscoverControllerHandle = NULL;
    22 EFI_REDFISH_DISCOVER_PROTOCOL  *gEfiRedfishDiscoverProtocol        = NULL;
    23 BOOLEAN                        gRedfishDiscoverActivated           = FALSE;
    24 BOOLEAN                        gRedfishServiceDiscovered           = FALSE;
     20VOID                                    *gEfiRedfishDiscoverRegistration;
     21EFI_HANDLE                              gEfiRedfishDiscoverControllerHandle = NULL;
     22EFI_REDFISH_DISCOVER_PROTOCOL           *gEfiRedfishDiscoverProtocol        = NULL;
     23BOOLEAN                                 gRedfishDiscoverActivated           = FALSE;
     24BOOLEAN                                 gRedfishServiceDiscovered           = FALSE;
     25EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  *mNetworkInterfaces                 = NULL;
     26UINTN                                   mNumberOfNetworkInterfaces;
     27EFI_EVENT                               mEdkIIRedfishHostInterfaceReadyEvent;
     28VOID                                    *mEdkIIRedfishHostInterfaceRegistration;
    2529
    2630///
     
    341345
    342346/**
     347  Callback function executed when the gEdkIIRedfishHostInterfaceReadyProtocolGuid
     348  protocol interface is installed.
     349
     350  @param[in]   Event    Event whose notification function is being invoked.
     351  @param[in]   Context  Pointer to the Context buffer
     352
     353**/
     354VOID
     355EFIAPI
     356AcquireRedfishServiceOnNetworkInterfaceCallback (
     357  IN  EFI_EVENT  Event,
     358  IN  VOID       *Context
     359  )
     360{
     361  EFI_STATUS                              Status;
     362  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  *ThisNetworkInterface;
     363  UINTN                                   NetworkInterfaceIndex;
     364  EFI_REDFISH_DISCOVERED_TOKEN            *ThisRedfishDiscoveredToken;
     365
     366  ThisNetworkInterface = mNetworkInterfaces;
     367  //
     368  // Loop to discover Redfish service on each network interface.
     369  //
     370  for (NetworkInterfaceIndex = 0; NetworkInterfaceIndex < mNumberOfNetworkInterfaces; NetworkInterfaceIndex++) {
     371    ThisRedfishDiscoveredToken = (EFI_REDFISH_DISCOVERED_TOKEN *)AllocateZeroPool (sizeof (EFI_REDFISH_DISCOVERED_TOKEN));
     372    if (ThisRedfishDiscoveredToken == NULL) {
     373      DEBUG ((DEBUG_ERROR, "%a: Not enough memory for EFI_REDFISH_DISCOVERED_TOKEN.\n", __func__));
     374      return;
     375    }
     376
     377    ThisRedfishDiscoveredToken->Signature = REDFISH_DISCOVER_TOKEN_SIGNATURE;
     378
     379    //
     380    // Initial this Redfish Discovered Token
     381    //
     382    Status = gBS->CreateEvent (
     383                    EVT_NOTIFY_SIGNAL,
     384                    TPL_CALLBACK,
     385                    RedfishServiceDiscoveredCallback,
     386                    (VOID *)ThisRedfishDiscoveredToken,
     387                    &ThisRedfishDiscoveredToken->Event
     388                    );
     389    if (EFI_ERROR (Status)) {
     390      FreePool (ThisRedfishDiscoveredToken);
     391      DEBUG ((DEBUG_ERROR, "%a: Failed to create event for Redfish discovered token.\n", __func__));
     392      return;
     393    }
     394
     395    //
     396    // Acquire for Redfish service which is reported by
     397    // Redfish Host Interface.
     398    //
     399    Status = gEfiRedfishDiscoverProtocol->AcquireRedfishService (
     400                                            gEfiRedfishDiscoverProtocol,
     401                                            gRedfishConfigData.Image,
     402                                            ThisNetworkInterface,
     403                                            EFI_REDFISH_DISCOVER_HOST_INTERFACE,
     404                                            ThisRedfishDiscoveredToken
     405                                            );
     406
     407    //
     408    // Free Redfish Discovered Token if Discover Instance was not created and
     409    // Redfish Service Discovered Callback event was not triggered.
     410    //
     411    if ((ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound == 0) ||
     412        EFI_ERROR (ThisRedfishDiscoveredToken->DiscoverList.RedfishInstances->Status))
     413    {
     414      gBS->CloseEvent (ThisRedfishDiscoveredToken->Event);
     415      DEBUG ((DEBUG_ERROR, "%a: Free Redfish discovered token - %x.\n", __func__, ThisRedfishDiscoveredToken));
     416      FreePool (ThisRedfishDiscoveredToken);
     417    }
     418
     419    ThisNetworkInterface++;
     420  }
     421}
     422
     423/**
    343424  Callback function executed when the EFI_REDFISH_DISCOVER_PROTOCOL
    344425  protocol interface is installed.
    345426
    346427  @param[in]   Event    Event whose notification function is being invoked.
    347   @param[out]  Context  Pointer to the Context buffer
     428  @param[in]   Context  Pointer to the Context buffer
    348429
    349430**/
     
    352433RedfishDiscoverProtocolInstalled (
    353434  IN  EFI_EVENT  Event,
    354   OUT VOID       *Context
    355   )
    356 {
    357   EFI_STATUS                              Status;
    358   UINTN                                   BufferSize;
    359   EFI_HANDLE                              HandleBuffer;
    360   UINTN                                   NetworkInterfaceIndex;
    361   EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  *ThisNetworkInterface;
    362   EFI_REDFISH_DISCOVERED_TOKEN            *ThisRedfishDiscoveredToken;
    363   UINTN                                   NumberOfNetworkInterfaces;
     435  IN  VOID       *Context
     436  )
     437{
     438  EFI_STATUS  Status;
     439  UINTN       BufferSize;
     440  EFI_HANDLE  HandleBuffer;
     441  VOID        *RedfishHostInterfaceReadyProtocol;
    364442
    365443  DEBUG ((DEBUG_MANAGEABILITY, "%a: New network interface is installed on system by EFI Redfish discover driver.\n", __func__));
     
    402480                                          gEfiRedfishDiscoverProtocol,
    403481                                          gRedfishConfigData.Image,
    404                                           &NumberOfNetworkInterfaces,
    405                                           &ThisNetworkInterface
     482                                          &mNumberOfNetworkInterfaces,
     483                                          &mNetworkInterfaces
    406484                                          );
    407   if (EFI_ERROR (Status) || (NumberOfNetworkInterfaces == 0)) {
     485  if (EFI_ERROR (Status) || (mNumberOfNetworkInterfaces == 0)) {
    408486    DEBUG ((DEBUG_ERROR, "%a: No network interfaces found on the handle.\n", __func__));
    409487    return;
     
    411489
    412490  //
    413   // Loop to discover Redfish service on each network interface.
    414   //
    415   for (NetworkInterfaceIndex = 0; NetworkInterfaceIndex < NumberOfNetworkInterfaces; NetworkInterfaceIndex++) {
    416     ThisRedfishDiscoveredToken = (EFI_REDFISH_DISCOVERED_TOKEN *)AllocateZeroPool (sizeof (EFI_REDFISH_DISCOVERED_TOKEN));
    417     if (ThisRedfishDiscoveredToken == NULL) {
    418       DEBUG ((DEBUG_ERROR, "%a: Not enough memory for EFI_REDFISH_DISCOVERED_TOKEN.\n", __func__));
    419       return;
    420     }
    421 
    422     ThisRedfishDiscoveredToken->Signature = REDFISH_DISCOVER_TOKEN_SIGNATURE;
    423 
    424     //
    425     // Initial this Redfish Discovered Token
    426     //
     491  // Check if Redfish Host Interface is ready or not.
     492  //
     493  Status = gBS->LocateProtocol (&gEdkIIRedfishHostInterfaceReadyProtocolGuid, NULL, &RedfishHostInterfaceReadyProtocol);
     494  if (!EFI_ERROR (Status)) {
     495    // Acquire Redfish service;
     496    AcquireRedfishServiceOnNetworkInterfaceCallback ((EFI_EVENT)NULL, (VOID *)NULL);
     497  } else {
    427498    Status = gBS->CreateEvent (
    428499                    EVT_NOTIFY_SIGNAL,
    429500                    TPL_CALLBACK,
    430                     RedfishServiceDiscoveredCallback,
    431                     (VOID *)ThisRedfishDiscoveredToken,
    432                     &ThisRedfishDiscoveredToken->Event
     501                    AcquireRedfishServiceOnNetworkInterfaceCallback,
     502                    NULL,
     503                    &mEdkIIRedfishHostInterfaceReadyEvent
    433504                    );
    434505    if (EFI_ERROR (Status)) {
    435       FreePool (ThisRedfishDiscoveredToken);
    436       DEBUG ((DEBUG_ERROR, "%a: Failed to create event for Redfish discovered token.\n", __func__));
     506      DEBUG ((DEBUG_ERROR, "%a: Failed to create event for gEdkIIRedfishHostInterfaceReadyProtocolGuid installation.", __func__));
    437507      return;
    438508    }
    439509
    440     //
    441     // Acquire for Redfish service which is reported by
    442     // Redfish Host Interface.
    443     //
    444     Status = gEfiRedfishDiscoverProtocol->AcquireRedfishService (
    445                                             gEfiRedfishDiscoverProtocol,
    446                                             gRedfishConfigData.Image,
    447                                             ThisNetworkInterface,
    448                                             EFI_REDFISH_DISCOVER_HOST_INTERFACE,
    449                                             ThisRedfishDiscoveredToken
    450                                             );
    451 
    452     //
    453     // Free Redfish Discovered Token if Discover Instance was not created and
    454     // Redfish Service Discovered Callback event was not triggered.
    455     //
    456     if ((ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound == 0) ||
    457         EFI_ERROR (ThisRedfishDiscoveredToken->DiscoverList.RedfishInstances->Status))
    458     {
    459       gBS->CloseEvent (ThisRedfishDiscoveredToken->Event);
    460       DEBUG ((DEBUG_ERROR, "%a: Free Redfish discovered token - %x.\n", __func__, ThisRedfishDiscoveredToken));
    461       FreePool (ThisRedfishDiscoveredToken);
    462     }
    463 
    464     ThisNetworkInterface++;
     510    Status = gBS->RegisterProtocolNotify (
     511                    &gEdkIIRedfishHostInterfaceReadyProtocolGuid,
     512                    mEdkIIRedfishHostInterfaceReadyEvent,
     513                    &mEdkIIRedfishHostInterfaceRegistration
     514                    );
     515    if (EFI_ERROR (Status)) {
     516      DEBUG ((DEBUG_ERROR, "%a: Fail to register event for the installation of gEdkIIRedfishHostInterfaceReadyProtocolGuid.", __func__));
     517      return;
     518    }
    465519  }
    466520
     
    548602  // Install UEFI Driver Model protocol(s).
    549603  //
    550   Status = EfiLibInstallDriverBinding (
     604  Status = EfiLibInstallAllDriverProtocols2 (
    551605             ImageHandle,
    552606             SystemTable,
    553607             &gRedfishConfigDriverBinding,
    554              ImageHandle
     608             ImageHandle,
     609             &gRedfishConfigHandlerComponentName,
     610             &gRedfishConfigHandlerComponentName2,
     611             NULL,
     612             NULL,
     613             NULL,
     614             NULL
    555615             );
    556616  if (EFI_ERROR (Status)) {
  • trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.h

    r99404 r105670  
    2525// Protocol instances
    2626//
    27 extern EFI_DRIVER_BINDING_PROTOCOL  gRedfishConfigDriverBinding;
     27extern EFI_DRIVER_BINDING_PROTOCOL   gRedfishConfigDriverBinding;
     28extern EFI_COMPONENT_NAME_PROTOCOL   gRedfishConfigHandlerComponentName;
     29extern EFI_COMPONENT_NAME2_PROTOCOL  gRedfishConfigHandlerComponentName2;
    2830
    2931extern REDFISH_CONFIG_DRIVER_DATA         gRedfishConfigData;
  • trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.inf

    r101291 r105670  
    3131
    3232[Sources]
     33  ComponentName.c
    3334  RedfishConfigHandlerDriver.h
    3435  RedfishConfigHandlerDriver.c
     
    4748
    4849[Protocols]
    49   gEfiRedfishDiscoverProtocolGuid         ## CONSUMES
     50  gEfiRedfishDiscoverProtocolGuid              ## CONSUMES
    5051  gEfiRestExServiceBindingProtocolGuid
    51   gEfiRestExProtocolGuid                  ## CONSUMES
    52   gEdkIIRedfishCredentialProtocolGuid     ## CONSUMES
    53   gEdkIIRedfishConfigHandlerProtocolGuid  ## CONSUMES
     52  gEfiRestExProtocolGuid                       ## CONSUMES
     53  gEdkIIRedfishCredentialProtocolGuid          ## CONSUMES
     54  gEdkIIRedfishConfigHandlerProtocolGuid       ## CONSUMES
     55  gEdkIIRedfishHostInterfaceReadyProtocolGuid  ## CONSUMES
    5456
    5557[Guids]
Note: See TracChangeset for help on using the changeset viewer.

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