[edk2-devel] [edk2-platforms][PATCH v2 10/32] AmpereSiliconPkg: Add PlatformManagerUiLib library instance

Leif Lindholm leif at nuviainc.com
Fri Jun 4 23:37:19 UTC 2021


On Wed, May 26, 2021 at 17:07:02 +0700, Nhi Pham wrote:
> From: Vu Nguyen <vunguyen at os.amperecomputing.com>
> 
> The idea came from DeviceManagerUiLib that all related menu settings can be
> placed under a common entry. This change intends to provide a central point
> for all platform menus by creating a Platform Manager entry located under
> Device Manager entry of UiApp.
> 
> New classuuid called gPlatformManagerFormsetGuid was introduced for
> platform menus which want to be reached through this Platform Manager.
> 
> Cc: Thang Nguyen <thang at os.amperecomputing.com>
> Cc: Chuong Tran <chuong at os.amperecomputing.com>
> Cc: Phong Vo <phong at os.amperecomputing.com>
> Cc: Leif Lindholm <leif at nuviainc.com>
> Cc: Michael D Kinney <michael.d.kinney at intel.com>
> Cc: Ard Biesheuvel <ardb+tianocore at kernel.org>
> Cc: Nate DeSimone <nathaniel.l.desimone at intel.com>
> 
> Signed-off-by: Vu Nguyen <vunguyen at os.amperecomputing.com>

Reviewed-by: Leif Lindholm <leif at nuviainc.com>

/
    Leif

> ---
>  Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec                             |  19 ++
>  Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc                             |   1 +
>  Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerUiLib.inf   |  47 +++
>  Silicon/Ampere/AmpereSiliconPkg/Include/Guid/PlatformManagerHii.h                |  31 ++
>  Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManager.h          |  51 +++
>  Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerVfr.h       |  28 ++
>  Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManager.c          | 354 ++++++++++++++++++++
>  Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerStrings.uni |  21 ++
>  Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerUiLib.uni   |  13 +
>  Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerVfr.Vfr     |  29 ++
>  10 files changed, 594 insertions(+)
> 
> diff --git a/Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec b/Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec
> index 26e020715290..a72205aa5316 100755
> --- a/Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec
> +++ b/Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec
> @@ -22,12 +22,31 @@ [Defines]
>  #
>  ################################################################################
>  [Includes.common]
> +  Include                        # Root include for the package
>  
>  [LibraryClasses]
>  
>  [Guids]
>    gAmpereTokenSpaceGuid = { 0xdbd4436e, 0x89cb, 0x44dc, { 0xb5, 0xc0, 0x49, 0xc3, 0x91, 0x35, 0xbf, 0xdf } }
>  
> +  #
> +  # Platform Manager formset UUID
> +  #
> +  ## Include/Guid/PlatformManagerHii.h
> +  gPlatformManagerFormsetGuid  = { 0x83ABD546, 0x7AD9, 0x4DE7, { 0xBD, 0x52, 0x12, 0x23, 0xF6, 0xE8, 0xFD, 0x4B } }
> +
> +  #
> +  # Platform Manager entry UUID
> +  #
> +  ## Include/Guid/PlatformManagerHii.h
> +  gPlatformManagerEntryEventGuid = { 0x28A4731E, 0x14A9, 0x488A, { 0xA8, 0x19, 0xFF, 0x27, 0x80, 0x6E, 0xDB, 0x0E } }
> +
> +  #
> +  # Platform Manager exit UUID
> +  #
> +  ## Include/Guid/PlatformManagerHii.h
> +  gPlatformManagerExitEventGuid  = { 0xE8887242, 0x4EFF, 0x4323, { 0x81, 0xF4, 0xC9, 0x5F, 0xD5, 0x8D, 0x80, 0xD5 } }
> +
>  [Ppis]
>  
>  [PcdsFixedAtBuild]
> diff --git a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc
> index 65973569a41d..3c47099b8edc 100755
> --- a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc
> +++ b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc
> @@ -649,6 +649,7 @@ [Components.common]
>    MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
>    MdeModulePkg/Application/UiApp/UiApp.inf {
>      <LibraryClasses>
> +      NULL|Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerUiLib.inf
>        NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
>        NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
>        NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
> diff --git a/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerUiLib.inf b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerUiLib.inf
> new file mode 100644
> index 000000000000..1cc5788bcebb
> --- /dev/null
> +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerUiLib.inf
> @@ -0,0 +1,47 @@
> +## @file
> +#
> +# Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION                    = 0x0001001B
> +  BASE_NAME                      = PlatformManagerUiLib
> +  MODULE_UNI_FILE                = PlatformManagerUiLib.uni
> +  FILE_GUID                      = 9264993E-2E15-478A-8928-14573E34C606
> +  MODULE_TYPE                    = DXE_DRIVER
> +  VERSION_STRING                 = 1.0
> +  LIBRARY_CLASS                  = NULL|DXE_DRIVER UEFI_APPLICATION
> +  CONSTRUCTOR                    = PlatformManagerUiLibConstructor
> +  DESTRUCTOR                     = PlatformManagerUiLibDestructor
> +
> +[Sources]
> +  PlatformManager.h
> +  PlatformManagerVfr.Vfr
> +  PlatformManagerStrings.uni
> +  PlatformManager.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec
> +
> +[LibraryClasses]
> +  DevicePathLib
> +  BaseLib
> +  MemoryAllocationLib
> +  UefiBootServicesTableLib
> +  BaseMemoryLib
> +  DebugLib
> +  HiiLib
> +  UefiLib
> +  UefiHiiServicesLib
> +
> +[Guids]
> +  gPlatformManagerFormsetGuid                   ## CONSUMES ## GUID (Indicate the formset class guid to be displayed)
> +  gEfiIfrTianoGuid                              ## CONSUMES ## GUID (Extended IFR Guid Opcode)
> +  gEfiIfrFrontPageGuid                          ## CONSUMES ## GUID (Indicate the formset in this library need to display in which page)
> +  gPlatformManagerEntryEventGuid                ## CONSUMES ## GUID (Indicate enter PlatformManager)
> +  gPlatformManagerExitEventGuid                 ## CONSUMES ## GUID (Indicate exit PlatformManager)
> diff --git a/Silicon/Ampere/AmpereSiliconPkg/Include/Guid/PlatformManagerHii.h b/Silicon/Ampere/AmpereSiliconPkg/Include/Guid/PlatformManagerHii.h
> new file mode 100644
> index 000000000000..ee3ca13ddeb1
> --- /dev/null
> +++ b/Silicon/Ampere/AmpereSiliconPkg/Include/Guid/PlatformManagerHii.h
> @@ -0,0 +1,31 @@
> +/** @file
> +
> +  Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef PLATFORM_MANAGER_HII_GUID_H_
> +#define PLATFORM_MANAGER_HII_GUID_H_
> +
> +#define PLATFORM_MANAGER_FORMSET_GUID  \
> +  { \
> +  0x83ABD546, 0x7AD9, 0x4DE7, { 0xBD, 0x52, 0x12, 0x23, 0xF6, 0xE8, 0xFD, 0x4B } \
> +  }
> +
> +#define PLATFORM_MANAGER_ENTRY_EVENT_GUID  \
> +  { \
> +  0x28A4731E, 0x14A9, 0x488A, { 0xA8, 0x19, 0xFF, 0x27, 0x80, 0x6E, 0xDB, 0x0E } \
> +  }
> +
> +#define PLATFORM_MANAGER_EXIT_EVENT_GUID  \
> +  { \
> +  0xE8887242, 0x4EFF, 0x4323, { 0x81, 0xF4, 0xC9, 0x5F, 0xD5, 0x8D, 0x80, 0xD5 } \
> +  }
> +
> +extern EFI_GUID gPlatformManagerFormsetGuid;
> +extern EFI_GUID gPlatformManagerEntryEventGuid;
> +extern EFI_GUID gPlatformManagerExitEventGuid;
> +
> +#endif
> diff --git a/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManager.h b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManager.h
> new file mode 100644
> index 000000000000..49157e0cea47
> --- /dev/null
> +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManager.h
> @@ -0,0 +1,51 @@
> +/** @file
> +
> +  Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef PLATFORM_MANAGER_H_
> +#define PLATFORM_MANAGER_H_
> +
> +#include <Uefi.h>
> +
> +#include <Guid/MdeModuleHii.h>
> +#include <Guid/PlatformManagerHii.h>
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/DevicePathLib.h>
> +#include <Library/HiiLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiHiiServicesLib.h>
> +#include <Library/UefiLib.h>
> +
> +#include "PlatformManagerVfr.h"
> +
> +//
> +// These are the VFR compiler generated data representing our VFR data.
> +//
> +extern UINT8 PlatformManagerVfrBin[];
> +extern UINT8 PlatformManagerUiLibStrings[];
> +
> +///
> +/// HII specific Vendor Device Path definition.
> +///
> +typedef struct {
> +  VENDOR_DEVICE_PATH       VendorDevicePath;
> +  EFI_DEVICE_PATH_PROTOCOL End;
> +} HII_VENDOR_DEVICE_PATH;
> +
> +typedef struct {
> +  ///
> +  /// Platform Manager HII relative handles
> +  ///
> +  EFI_HII_HANDLE HiiHandle;
> +  EFI_HANDLE     DriverHandle;
> +
> +} PLATFORM_MANAGER_CALLBACK_DATA;
> +
> +#endif
> diff --git a/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerVfr.h b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerVfr.h
> new file mode 100644
> index 000000000000..205907d3777a
> --- /dev/null
> +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerVfr.h
> @@ -0,0 +1,28 @@
> +/** @file
> +
> +  Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef PLATFORM_MANAGER_VFR_H_
> +#define PLATFORM_MANAGER_VFR_H_
> +
> +#define FORMSET_GUID \
> +  { \
> +  0x6E7233C5, 0x2B79, 0x4383, { 0x81, 0x46, 0xD8, 0x6A, 0x9F, 0x0A, 0x0B, 0x99 } \
> +  }
> +
> +//
> +// These are defined as the same with vfr file
> +//
> +#define LABEL_FORM_ID_OFFSET                 0x0100
> +#define ENTRY_KEY_OFFSET                     0x4000
> +
> +#define PLATFORM_MANAGER_FORM_ID             0x1000
> +
> +#define LABEL_ENTRY_LIST                     0x1100
> +#define LABEL_END                            0xffff
> +
> +#endif /* PLATFORM_MANAGER_VFR_H_ */
> diff --git a/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManager.c b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManager.c
> new file mode 100644
> index 000000000000..1872aa80ed18
> --- /dev/null
> +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManager.c
> @@ -0,0 +1,354 @@
> +/** @file
> +
> +  Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "PlatformManager.h"
> +
> +PLATFORM_MANAGER_CALLBACK_DATA gPlatformManagerPrivate = {
> +  NULL,
> +  NULL
> +};
> +
> +EFI_GUID mPlatformManagerGuid = FORMSET_GUID;
> +
> +HII_VENDOR_DEVICE_PATH mPlatformManagerHiiVendorDevicePath = {
> +  {
> +    {
> +      HARDWARE_DEVICE_PATH,
> +      HW_VENDOR_DP,
> +      {
> +        (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
> +        (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
> +      }
> +    },
> +    //
> +    // {FC587265-0750-44D1-B68D-D1DDD3F29B0B}
> +    //
> +    { 0xFC587265, 0x0750, 0x44D1, {0xB6, 0x8D, 0xD1, 0xDD, 0xD3, 0xF2, 0x9B, 0x0B} }
> +  },
> +  {
> +    END_DEVICE_PATH_TYPE,
> +    END_ENTIRE_DEVICE_PATH_SUBTYPE,
> +    {
> +      (UINT8)(END_DEVICE_PATH_LENGTH),
> +      (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
> +    }
> +  }
> +};
> +
> +/**
> +  Extract device path for given HII handle and class guid.
> +
> +  @param Handle          The HII handle.
> +
> +  @retval  NULL          Fail to get the device path string.
> +  @return  PathString    Get the device path string.
> +
> +**/
> +CHAR16 *
> +PmExtractDevicePathFromHiiHandle (
> +  IN EFI_HII_HANDLE Handle
> +  )
> +{
> +  EFI_STATUS Status;
> +  EFI_HANDLE DriverHandle;
> +
> +  ASSERT (Handle != NULL);
> +
> +  if (Handle == NULL) {
> +    return NULL;
> +  }
> +
> +  Status = gHiiDatabase->GetPackageListHandle (gHiiDatabase, Handle, &DriverHandle);
> +  if (EFI_ERROR (Status)) {
> +    return NULL;
> +  }
> +  //
> +  // Get device path string.
> +  //
> +  return ConvertDevicePathToText (DevicePathFromHandle (DriverHandle), FALSE, FALSE);
> +}
> +
> +/**
> +  Dynamic create Hii information for Platform Manager.
> +
> +  @param   NextShowFormId     The FormId which need to be show.
> +
> +**/
> +VOID
> +CreatePlatformManagerForm (
> +  IN EFI_FORM_ID NextShowFormId
> +  )
> +{
> +  UINTN              Index;
> +  EFI_STRING         String;
> +  EFI_STRING_ID      Token;
> +  EFI_STRING_ID      TokenHelp;
> +  EFI_HII_HANDLE     *HiiHandles;
> +  EFI_HII_HANDLE     HiiHandle;
> +  EFI_GUID           FormSetGuid;
> +  VOID               *StartOpCodeHandle;
> +  VOID               *EndOpCodeHandle;
> +  EFI_IFR_GUID_LABEL *StartLabel;
> +  EFI_IFR_GUID_LABEL *EndLabel;
> +  CHAR16             *DevicePathStr;
> +  EFI_STRING_ID      DevicePathId;
> +  EFI_IFR_FORM_SET   *Buffer;
> +  UINTN              BufferSize;
> +  UINT8              ClassGuidNum;
> +  EFI_GUID           *ClassGuid;
> +  UINTN              TempSize;
> +  UINT8              *Ptr;
> +  EFI_STATUS         Status;
> +
> +  TempSize = 0;
> +  BufferSize = 0;
> +  Buffer = NULL;
> +
> +  HiiHandle = gPlatformManagerPrivate.HiiHandle;
> +
> +  //
> +  // Allocate space for creation of UpdateData Buffer
> +  //
> +  StartOpCodeHandle = HiiAllocateOpCodeHandle ();
> +  ASSERT (StartOpCodeHandle != NULL);
> +
> +  EndOpCodeHandle = HiiAllocateOpCodeHandle ();
> +  ASSERT (EndOpCodeHandle != NULL);
> +
> +  //
> +  // Create Hii Extend Label OpCode as the start opcode
> +  //
> +  StartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
> +                                       StartOpCodeHandle,
> +                                       &gEfiIfrTianoGuid,
> +                                       NULL,
> +                                       sizeof (EFI_IFR_GUID_LABEL)
> +                                       );
> +  ASSERT (StartLabel != NULL);
> +  StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
> +  //
> +  // According to the next show Form id(mNextShowFormId) to decide which form need to update.
> +  //
> +  StartLabel->Number       = (UINT16)(LABEL_FORM_ID_OFFSET + NextShowFormId);
> +
> +  //
> +  // Create Hii Extend Label OpCode as the end opcode
> +  //
> +  EndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
> +                                     EndOpCodeHandle,
> +                                     &gEfiIfrTianoGuid,
> +                                     NULL,
> +                                     sizeof (EFI_IFR_GUID_LABEL)
> +                                     );
> +  ASSERT (EndLabel != NULL);
> +  EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
> +  EndLabel->Number       = LABEL_END;
> +
> +  //
> +  // Get all the Hii handles
> +  //
> +  HiiHandles = HiiGetHiiHandles (NULL);
> +  ASSERT (HiiHandles != NULL);
> +
> +  //
> +  // Search for formset of each class type
> +  //
> +  for (Index = 0; HiiHandles[Index] != NULL; Index++) {
> +    Status = HiiGetFormSetFromHiiHandle (HiiHandles[Index], &Buffer,&BufferSize);
> +    if (EFI_ERROR (Status)) {
> +      continue;
> +    }
> +
> +    Ptr = (UINT8 *)Buffer;
> +
> +    while(TempSize < BufferSize) {
> +      TempSize += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
> +      if (((EFI_IFR_OP_HEADER *)Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {
> +        Ptr += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
> +        continue;
> +      }
> +
> +      ClassGuidNum = (UINT8)(((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3);
> +      ClassGuid = (EFI_GUID *)(VOID *)(Ptr + sizeof (EFI_IFR_FORM_SET));
> +      while (ClassGuidNum-- > 0) {
> +        if (CompareGuid (&gPlatformManagerFormsetGuid, ClassGuid)== 0) {
> +          ClassGuid++;
> +          continue;
> +        }
> +
> +        String = HiiGetString (HiiHandles[Index], ((EFI_IFR_FORM_SET *)Ptr)->FormSetTitle, NULL);
> +        if (String == NULL) {
> +          String = HiiGetString (HiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
> +          ASSERT (String != NULL);
> +        }
> +        Token = HiiSetString (HiiHandle, 0, String, NULL);
> +        FreePool (String);
> +
> +        String = HiiGetString (HiiHandles[Index], ((EFI_IFR_FORM_SET *)Ptr)->Help, NULL);
> +        if (String == NULL) {
> +          String = HiiGetString (HiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
> +          ASSERT (String != NULL);
> +        }
> +        TokenHelp = HiiSetString (HiiHandle, 0, String, NULL);
> +        FreePool (String);
> +
> +        CopyMem (&FormSetGuid, &((EFI_IFR_FORM_SET *)Ptr)->Guid, sizeof (EFI_GUID));
> +
> +        if (NextShowFormId == PLATFORM_MANAGER_FORM_ID) {
> +          DevicePathStr = PmExtractDevicePathFromHiiHandle (HiiHandles[Index]);
> +          DevicePathId  = 0;
> +          if (DevicePathStr != NULL) {
> +            DevicePathId =  HiiSetString (HiiHandle, 0, DevicePathStr, NULL);
> +            FreePool (DevicePathStr);
> +          }
> +
> +          HiiCreateGotoExOpCode (
> +            StartOpCodeHandle,
> +            0,
> +            Token,
> +            TokenHelp,
> +            0,
> +            (EFI_QUESTION_ID)(Index + ENTRY_KEY_OFFSET),
> +            0,
> +            &FormSetGuid,
> +            DevicePathId
> +            );
> +        }
> +        break;
> +      }
> +
> +      Ptr += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
> +    }
> +
> +    FreePool (Buffer);
> +    Buffer = NULL;
> +    TempSize = 0;
> +    BufferSize = 0;
> +  }
> +
> +  HiiUpdateForm (
> +    HiiHandle,
> +    &mPlatformManagerGuid,
> +    NextShowFormId,
> +    StartOpCodeHandle,
> +    EndOpCodeHandle
> +    );
> +
> +  HiiFreeOpCodeHandle (StartOpCodeHandle);
> +  HiiFreeOpCodeHandle (EndOpCodeHandle);
> +  FreePool (HiiHandles);
> +}
> +
> +/**
> +  Install Boot Manager Menu driver.
> +
> +  @param ImageHandle     The image handle.
> +  @param SystemTable     The system table.
> +
> +  @retval  EFI_SUCEESS  Install Boot manager menu success.
> +  @retval  Other        Return error status.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +PlatformManagerUiLibConstructor (
> +  IN EFI_HANDLE       ImageHandle,
> +  IN EFI_SYSTEM_TABLE *SystemTable
> +  )
> +{
> +  EFI_STATUS Status;
> +  EFI_EVENT  PlatformUiEntryEvent;
> +
> +  gPlatformManagerPrivate.DriverHandle = NULL;
> +  Status = gBS->InstallMultipleProtocolInterfaces (
> +                  &gPlatformManagerPrivate.DriverHandle,
> +                  &gEfiDevicePathProtocolGuid,
> +                  &mPlatformManagerHiiVendorDevicePath,
> +                  NULL
> +                  );
> +  ASSERT_EFI_ERROR (Status);
> +
> +  //
> +  // Publish our HII data.
> +  //
> +  gPlatformManagerPrivate.HiiHandle = HiiAddPackages (
> +                                        &mPlatformManagerGuid,
> +                                        gPlatformManagerPrivate.DriverHandle,
> +                                        PlatformManagerVfrBin,
> +                                        PlatformManagerUiLibStrings,
> +                                        NULL
> +                                        );
> +  if (gPlatformManagerPrivate.HiiHandle != NULL) {
> +    //
> +    // Update platform manager page
> +    //
> +    CreatePlatformManagerForm (PLATFORM_MANAGER_FORM_ID);
> +  } else {
> +    DEBUG ((DEBUG_ERROR, "%a: Failed to add Hii package\n", __FUNCTION__));
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  // Signal Entry event
> +  Status = gBS->CreateEventEx (
> +                  EVT_NOTIFY_SIGNAL,
> +                  TPL_CALLBACK,
> +                  EfiEventEmptyFunction,
> +                  NULL,
> +                  &gPlatformManagerEntryEventGuid,
> +                  &PlatformUiEntryEvent
> +                  );
> +  ASSERT_EFI_ERROR (Status);
> +  gBS->SignalEvent (PlatformUiEntryEvent);
> +  gBS->CloseEvent (PlatformUiEntryEvent);
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/**
> +  Unloads the application and its installed protocol.
> +
> +  @param  ImageHandle     Handle that identifies the image to be unloaded.
> +  @param  SystemTable     The system table.
> +
> +  @retval EFI_SUCCESS           The image has been unloaded.
> +**/
> +EFI_STATUS
> +EFIAPI
> +PlatformManagerUiLibDestructor (
> +  IN EFI_HANDLE       ImageHandle,
> +  IN EFI_SYSTEM_TABLE *SystemTable
> +  )
> +{
> +  EFI_STATUS Status;
> +  EFI_EVENT  PlatformUiExitEvent;
> +
> +  Status = gBS->UninstallMultipleProtocolInterfaces (
> +                  gPlatformManagerPrivate.DriverHandle,
> +                  &gEfiDevicePathProtocolGuid,
> +                  &mPlatformManagerHiiVendorDevicePath,
> +                  NULL
> +                  );
> +  ASSERT_EFI_ERROR (Status);
> +
> +  HiiRemovePackages (gPlatformManagerPrivate.HiiHandle);
> +
> +  // Signal Exit event
> +  Status = gBS->CreateEventEx (
> +                  EVT_NOTIFY_SIGNAL,
> +                  TPL_CALLBACK,
> +                  EfiEventEmptyFunction,
> +                  NULL,
> +                  &gPlatformManagerExitEventGuid,
> +                  &PlatformUiExitEvent
> +                  );
> +  ASSERT_EFI_ERROR (Status);
> +  gBS->SignalEvent (PlatformUiExitEvent);
> +  gBS->CloseEvent (PlatformUiExitEvent);
> +
> +  return EFI_SUCCESS;
> +}
> diff --git a/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerStrings.uni b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerStrings.uni
> new file mode 100644
> index 000000000000..3bb39413bc4b
> --- /dev/null
> +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerStrings.uni
> @@ -0,0 +1,21 @@
> +//
> +// Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
> +//
> +// SPDX-License-Identifier: BSD-2-Clause-Patent
> +//
> +
> +/=#
> +
> +#langdef   en-US "English"
> +
> +#string STR_EDKII_MENU_TITLE           #language en-US  "Platform Manager"
> +#string STR_EDKII_MENU_HELP            #language en-US  "This selection will take you to the Platform Manager"
> +#string STR_PLATFORM_LIST              #language en-US  "Platform Configuration"
> +#string STR_MISSING_STRING             #language en-US  "Missing String"
> +#string STR_EMPTY_STRING               #language en-US  ""
> +#string STR_EXIT_STRING                #language en-US  "Press ESC to exit."
> +//
> +// Ensure that this is the last string.  We are using it programmatically
> +// to do string token re-usage settings for the Device Manager since we are
> +// constantly recreating this page based on HII population.
> +////
> diff --git a/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerUiLib.uni b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerUiLib.uni
> new file mode 100644
> index 000000000000..217a7e999dab
> --- /dev/null
> +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerUiLib.uni
> @@ -0,0 +1,13 @@
> +//
> +// Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
> +//
> +// SPDX-License-Identifier: BSD-2-Clause-Patent
> +//
> +
> +#string STR_MODULE_ABSTRACT
> +#language en-US
> +"Platform Manager Library used by UiApp"
> +
> +#string STR_MODULE_DESCRIPTION
> +#language en-US
> +"Platform Manager Library used by UiApp"
> diff --git a/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerVfr.Vfr b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerVfr.Vfr
> new file mode 100644
> index 000000000000..bfda75319416
> --- /dev/null
> +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerVfr.Vfr
> @@ -0,0 +1,29 @@
> +/** @file
> +
> +  Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Guid/HiiPlatformSetupFormset.h>
> +#include "PlatformManagerVfr.h"
> +
> +formset
> +  guid      = FORMSET_GUID,
> +  title     = STRING_TOKEN(STR_EDKII_MENU_TITLE),
> +  help      = STRING_TOKEN(STR_EDKII_MENU_HELP),
> +  classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID,
> +
> +  form formid = PLATFORM_MANAGER_FORM_ID,
> +    title  = STRING_TOKEN(STR_EDKII_MENU_TITLE);
> +    subtitle text = STRING_TOKEN(STR_PLATFORM_LIST);
> +
> +    label LABEL_ENTRY_LIST;
> +    label LABEL_END;
> +
> +    subtitle text = STRING_TOKEN(STR_EMPTY_STRING);
> +    subtitle text = STRING_TOKEN(STR_EMPTY_STRING);
> +    subtitle text = STRING_TOKEN(STR_EXIT_STRING);
> +  endform;
> +endformset;
> -- 
> 2.17.1
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76091): https://edk2.groups.io/g/devel/message/76091
Mute This Topic: https://groups.io/mt/83097105/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list