From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mx.groups.io with SMTP id smtpd.web12.6468.1622849842625446492 for ; Fri, 04 Jun 2021 16:37:23 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=uZoPHhKB; spf=pass (domain: nuviainc.com, ip: 209.85.128.52, mailfrom: leif@nuviainc.com) Received: by mail-wm1-f52.google.com with SMTP id p13-20020a05600c358db029019f44afc845so6419201wmq.3 for ; Fri, 04 Jun 2021 16:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ziJlFWdrA+bMIWwBvgjWhrtm+mE4XGce4u2BVJya/ec=; b=uZoPHhKBvzzB2mkDAY/C7v57JC3gzuMMFulIl8rGSncwZWJD/fKHdzacBvPIiDtlhx txpwTUVO4OnAcoxa4jA89CFwOkvlGOYn61OugF421nOGdfO2ChCyDh3UdipvOyLdokV+ AVfRet7N+HAPvRg+Qq9kCfxAmgPZrH1+5LmKtlQjnmfHYZGiLipQnXhzSEry3K4Y40Nq H0wjZNzqrP8/MriirVWOctmGdu2hiSwLTAmtBlKA4FjeBDa8NBPdK+rxaz0uHTs+8ntZ 56qNDCL8T7n27t3z3wSLXd5lj9n9nBzwQlfkVTU69RbsU5navYfO/0ZYoXvESFPDWILO NaVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ziJlFWdrA+bMIWwBvgjWhrtm+mE4XGce4u2BVJya/ec=; b=HsZ74FY2/qGMartUX4GdWjLX7tbV3wgoi5jxMQm2QZGkIzvl8c4t20P5PSqkKTgHfI lziPMU9/oGNbsZ0TZ1B5iA/NASM+deXeXEwMZ9oZEFaVFqOXnzlAm9n3RSGwp6UleiOL TrLiyj7jkOukSrnzzxNmmH4dQrryxpvxUdRfOCevQxCx00iu3geaGalEJVkMSdxKPS9E 9WOWQKD7nwvsCM+ttAQa6ISxQ+AfcjNNDOXK2WJGQFJE18WN9Djrqll9RQv680Pw5vpo 4wTfNcKMsfgCYVacDOIQgLmeceOkg66N6thYHZTPxZnIVNkx/kAd3mAmg6ZiJsnEY49e hcfQ== X-Gm-Message-State: AOAM532/dM4Fc+4/gvv9+Wzp7VrPli/HxheuQFbCc9C2nDzhkiY2rYr9 RJKEF4RhAqPMLWr37FZTEyxqQg== X-Google-Smtp-Source: ABdhPJxrVPewSiVoTm96zI3UIkmvBvZxuSvv3juAJHMxBKQocCazsbm6osozHBUsNTe6IQ9eOknfPQ== X-Received: by 2002:a05:600c:251:: with SMTP id 17mr5703707wmj.137.1622849841194; Fri, 04 Jun 2021 16:37:21 -0700 (PDT) Return-Path: Received: from leviathan (cpc1-cmbg19-2-0-cust915.5-4.cable.virginm.net. [82.27.183.148]) by smtp.gmail.com with ESMTPSA id f14sm7855907wry.40.2021.06.04.16.37.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 16:37:20 -0700 (PDT) Date: Sat, 5 Jun 2021 00:37:19 +0100 From: "Leif Lindholm" To: Nhi Pham Cc: devel@edk2.groups.io, Vu Nguyen , Thang Nguyen , Chuong Tran , Phong Vo , Michael D Kinney , Ard Biesheuvel , Nate DeSimone Subject: Re: [edk2-platforms][PATCH v2 10/32] AmpereSiliconPkg: Add PlatformManagerUiLib library instance Message-ID: <20210604233719.qfz3c3waqqaqaxpv@leviathan> References: <20210526100724.5359-1-nhi@os.amperecomputing.com> <20210526100724.5359-12-nhi@os.amperecomputing.com> MIME-Version: 1.0 In-Reply-To: <20210526100724.5359-12-nhi@os.amperecomputing.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, May 26, 2021 at 17:07:02 +0700, Nhi Pham wrote: > From: Vu Nguyen > > 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 > Cc: Chuong Tran > Cc: Phong Vo > Cc: Leif Lindholm > Cc: Michael D Kinney > Cc: Ard Biesheuvel > Cc: Nate DeSimone > > Signed-off-by: Vu Nguyen Reviewed-by: Leif Lindholm / 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 { > > + 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.
> +# > +# 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.
> + > + 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.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef PLATFORM_MANAGER_H_ > +#define PLATFORM_MANAGER_H_ > + > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#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.
> + > + 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.
> + > + 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.
> +// > +// 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.
> +// > +// 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.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#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 >