From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.101]) by mx.groups.io with SMTP id smtpd.web08.10074.1631721590744114829 for ; Wed, 15 Sep 2021 08:59:50 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@os.amperecomputing.com header.s=selector2 header.b=fj5g4dXL; spf=pass (domain: os.amperecomputing.com, ip: 40.107.94.101, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DZXziQhmUqECZstREEu5I5G3nATc5VAEImjT7pH/DOzBIcUROXIaK2GreRmwsSTE575Kra2d7dIV3DuuKQ/m5SxNdg9oXtJ1KYhUlSKeLa/P8NYlTIx8A8QE9LSpcocsLEa8+xfBEAbMvvIcFomo9ubtlq9C+le5QRpzYH58NH9be7ihu6rmKjyKL+930/OQqedsWhkOv4SbJVZv7XWeCOWdFiWJcnUxjVSRMuTYBTNOHPGaemPvyfwMT18OBUw6oeqWwj0wXj1s4s3xplFO7g+cwbBxggeYQbQYZxn7OdVseTYaH4Rxbv4q6NtXMNddMHgmp78zoLHYFlJMxMcHGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=M3ZntUjn10OxQWz++HiAdilLRbw3aSqCcyaCXu5rVI0=; b=RfkL02iPm4DNhpEzH6bXMoPc084ByiTJt7sStDKSXVCm9l88o+5xjhw2ESqQFHOoLyfJC463CRv6xJuJn2V4TamS9CFXul2aEtghdPW04UZnR0b6LpTdj8ijqKAfZm5QTvmj7Li2Zu5GQUpjg8GavG4/tyRkHWdrTQr1I44g+jqCkJ6bWDTuGKJ1QrgWF/CwrfjpqIjD0C6kOjOWu/dRqjP9syWB/G0Cc4Li7kkIVJjmuEf4ZBloyix/54UMQw6KwQ1LW8HDT9mBm5ZZue9wWCkNPU6Psul4M9MvZNz/UkC4fiIfcnYeAXVH781rAAolzzNL9EFN/JJa1Jz1A0nJFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M3ZntUjn10OxQWz++HiAdilLRbw3aSqCcyaCXu5rVI0=; b=fj5g4dXLYcMs2kz+Ggvmy1A7qFxMMSN3GmwwpBCTBpHVBmY2EDTTWlN5/NuckouY3QtMic9o7WRBsReiY91AQSX7meBtUJNL2ghmxqlRgqtmaOrQIuhp2/znkOfkyhV7jItdUG77ewSJLHaHhivffAHXejeJd38YyZa4NezQxzc= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) by DM5PR0101MB3065.prod.exchangelabs.com (2603:10b6:4:33::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.15; Wed, 15 Sep 2021 15:59:48 +0000 Received: from DM6PR01MB5849.prod.exchangelabs.com ([fe80::8eb:704f:2ba7:9bc3]) by DM6PR01MB5849.prod.exchangelabs.com ([fe80::8eb:704f:2ba7:9bc3%4]) with mapi id 15.20.4523.014; Wed, 15 Sep 2021 15:59:48 +0000 From: "Nhi Pham" To: devel@edk2.groups.io CC: patches@amperecomputing.com, nhi@os.amperecomputing.com, vunguyen@os.amperecomputing.com, Thang Nguyen , Chuong Tran , Phong Vo , Leif Lindholm , Michael D Kinney , Ard Biesheuvel , Nate DeSimone Subject: [PATCH v3 10/28] AmpereSiliconPkg: Add PlatformManagerUiLib library instance Date: Wed, 15 Sep 2021 22:55:09 +0700 Message-ID: <20210915155527.8176-11-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210915155527.8176-1-nhi@os.amperecomputing.com> References: <20210915155527.8176-1-nhi@os.amperecomputing.com> X-ClientProxiedBy: HK2PR0302CA0012.apcprd03.prod.outlook.com (2603:1096:202::22) To DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 Received: from sw004.amperecomputing.com (118.69.219.201) by HK2PR0302CA0012.apcprd03.prod.outlook.com (2603:1096:202::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.5 via Frontend Transport; Wed, 15 Sep 2021 15:59:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 34a0d23b-09c2-4571-3b13-08d97861d7b6 X-MS-TrafficTypeDiagnostic: DM5PR0101MB3065: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:67; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fGGC4chPoCsR9W2oOukLmXqrUzkf8o8+cvPKTsvX0quBkkdJcgTjYDcCrH3gXPZmdKSaCFnX0hFBNAs7uaPeRlwUwLyr4tD6Lmcr1nXd0IgrL7XTdD1u2eT7TbdcalNylTwl4xFPA03udkeWqe85OdFaZPWzAUBBn1RY9Vmy0O9GEMe9oSykXFh5oSjoS1VMlkiiIPkLwElIPHILvgxC84YtgSy4xoVwW9ztILpFrpeny3r99AxydlwUrl6EiXnuvBBHzc34DmeWse99/eIheyt8u1BT6VSqa7oqkQuhBf7M1t6LHv5dsoBU4NsUuZrzaQJY2+M+gxZDVQmFdcLHFGWDs3TYDp/joVXphjEEhSDUAM0KBP40378QZN6NI0BkHtGc3M/GitBp94U+0faYvbufVIdIQlcmDV8nDG2u7h5A+1FRwtulcbv5vXlDp6thb7G9DFUUhrg4IyZHT8kuALXUpG7atIO/vHpH3BPayMc37+gmRSB0nvM4y8rsm7xaj1XOSZ0RyVIjL8lWfrNiO8UMwLJ7VOy+YBgXDrILe2rBEnJZvLdANNaeM3ZH/wOJaV4GCYfjDOhC9F8WdlSxrpOqe8malnoZUw8h28K/doMEjD/VUnTo2qJL0qwWobwWFlrnN0VItLiok91dfFCdxiM/V+1D5I2YzFj4jfMW2GtIqdigbeI1fpBGQKpfzm1AgUS3HoDi/1nERC7AiUMAlQolNIL1aKSloZpIRSFMoTVkLQSNc/tV9DedcOR1c15O X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR01MB5849.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(6029001)(4636009)(136003)(346002)(396003)(366004)(376002)(39850400004)(2616005)(38100700002)(38350700002)(2906002)(6666004)(6916009)(83380400001)(30864003)(6512007)(26005)(8676002)(4326008)(186003)(8936002)(478600001)(6506007)(5660300002)(52116002)(1076003)(86362001)(316002)(66556008)(54906003)(956004)(6486002)(66476007)(66946007)(290074003)(44824005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?dy0DGapM646rIQ6QszgXvmYtwaVTklSVHXHzTefTykVEtb8r8YiPAyjlZnVY?= =?us-ascii?Q?/qoUxiWhLu8AXIONUGXDVGnnGtv2J2Pwd5eomgTdjs8oRcDnW2fcsF1MF5YQ?= =?us-ascii?Q?JbOSSBGFiFEPhBBt+ztSiw9M/xKo/NXIQrAEb44tQQo23J9g+broj64f5VnJ?= =?us-ascii?Q?Uwsyj6env5ee0hMTVRgn6m2Hg47IIM3iG/JSvkeBPEecDGj0PRhTXmGHwSHN?= =?us-ascii?Q?pM90Lahh3CTbH5qDhM4NA6A31izFw2mluRL7cI6hrOLtQ/lJ6G8mz+KxEOHy?= =?us-ascii?Q?k62a8vC7YUgKqmi9ceFv02FAd92d2PvuKvso3FGfuf9hn6yvfwYngC9sUfYA?= =?us-ascii?Q?3dy7qUUk7dFBJi9IX6UD14HUW/nm6zJKuCAg0bX6m1SngkriKQfyOsAcfHpD?= =?us-ascii?Q?PF6B5n4WL9JQGjdkDsv3SVWGYU1f0CpvPMs2+DKz5cJz4dYmAL0jyDFlpkkp?= =?us-ascii?Q?qGabYlOSWwJ03yupuVk7w6Z+5szwzc3Sz8dpppDXnBnj+YD+PfWkJOEwmq/m?= =?us-ascii?Q?2a+rC1VqAtk/I6785AZyUtR9K6/EZnVdCy/9N3WRnckypge8xVmGPd4rFpDY?= =?us-ascii?Q?HZkfemK5DGgWd7iJoVtxVvt4L3AxIA4SsSx401v0FeHb49PCkehmq/ajjcxr?= =?us-ascii?Q?kdPloZUh9MpknanSnzGs0kVAZRc/VDTqkrX+kv17S+XE50Wq5vtKBovCkcJc?= =?us-ascii?Q?9kARAABdFlipZ4ZzLofvzAEShbIvfS8YgCHmx1NX4OYFH22e4DdWVxIKupdv?= =?us-ascii?Q?1wNOiZkpg3bd2rR1pzFOc2BmfLRkQB8BZCZLdLcx+XUCgBfqXJz5upXolxDW?= =?us-ascii?Q?2w7FfU6vxmWlZpMjf9PVrgBwfp9Wy0wqHu4Fwj1tk3ILnhhcJIcgNIuSobEC?= =?us-ascii?Q?VfaQUZJApiwM1VQbJpQ8We+de6n9tq8Fn72FF7jcLg1FNYTxhRkVWKheq5uE?= =?us-ascii?Q?rX+yOjm4v7Wigw63uWR72APWNYse8o6bbu12W1hdvIQgfXZwaNHcdGkJE8Lw?= =?us-ascii?Q?DY2SLJDqeIbGdlfr71IT9cLvA2sT+L2JpphmOMVFKxpkcC8uSkUwDwCmXsQF?= =?us-ascii?Q?WxAyrGGj4GEeoChwrbIeYj4jsbSUgp5WZ28faWBE8X8Zk89freSIKymufOTd?= =?us-ascii?Q?MDL2MPsuILTHWqTvxVtFF6BIkT5j9NksvDaE1QfudvbHHkRTODrQjeaE4AOM?= =?us-ascii?Q?niIJAs9c+bU2CDPKGkiExNR/KhqHCojg/4S24mUuv62EtPBRTK+H2M6y8MvZ?= =?us-ascii?Q?VlP2qiG5T3urw4jnVQTz7qB89uY443272uAjn6qZBBesDG7Tl2889nAFsvLg?= =?us-ascii?Q?DtSgA3BGCMHlUSJwiRh+9PJe?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 34a0d23b-09c2-4571-3b13-08d97861d7b6 X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5849.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 15:59:48.1007 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nIF7s62sY8CpUYBOrSL5eNrSit49Bf6wzLtID3VsPDacdzwOpWWPrL07VjeY3aYi6vK+HasDnf0fELKPR4Isshp1nr0uJwFf68ZVNQeQ3B4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR0101MB3065 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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 --- 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/PlatformManagerStrin= gs.uni | 21 ++ Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerUiLib= .uni | 13 + Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManagerVfr.V= fr | 29 ++ 10 files changed, 594 insertions(+) diff --git a/Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec b/Silicon= /Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec index 646a53fc031c..36b1249c7a08 100644 --- 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 =20 [LibraryClasses] =20 [Guids] gAmpereTokenSpaceGuid =3D { 0xdbd4436e, 0x89cb, 0x44dc, { 0xb5, 0xc0, 0x= 49, 0xc3, 0x91, 0x35, 0xbf, 0xdf } } =20 + # + # Platform Manager formset UUID + # + ## Include/Guid/PlatformManagerHii.h + gPlatformManagerFormsetGuid =3D { 0x83ABD546, 0x7AD9, 0x4DE7, { 0xBD, 0= x52, 0x12, 0x23, 0xF6, 0xE8, 0xFD, 0x4B } } + + # + # Platform Manager entry UUID + # + ## Include/Guid/PlatformManagerHii.h + gPlatformManagerEntryEventGuid =3D { 0x28A4731E, 0x14A9, 0x488A, { 0xA8,= 0x19, 0xFF, 0x27, 0x80, 0x6E, 0xDB, 0x0E } } + + # + # Platform Manager exit UUID + # + ## Include/Guid/PlatformManagerHii.h + gPlatformManagerExitEventGuid =3D { 0xE8887242, 0x4EFF, 0x4323, { 0x81,= 0xF4, 0xC9, 0x5F, 0xD5, 0x8D, 0x80, 0xD5 } } + [Ppis] =20 [PcdsFixedAtBuild] diff --git a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc b/Silicon= /Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc index 7f84ac2df50a..aee00f114666 100644 --- a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc +++ b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc @@ -656,6 +656,7 @@ [Components.common] MdeModulePkg/Universal/BdsDxe/BdsDxe.inf MdeModulePkg/Application/UiApp/UiApp.inf { + NULL|Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformM= anagerUiLib.inf NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanc= eManagerUiLib.inf diff --git a/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/Platform= ManagerUiLib.inf b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/Pl= atformManagerUiLib.inf new file mode 100644 index 000000000000..1cc5788bcebb --- /dev/null +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManager= UiLib.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 =3D 0x0001001B + BASE_NAME =3D PlatformManagerUiLib + MODULE_UNI_FILE =3D PlatformManagerUiLib.uni + FILE_GUID =3D 9264993E-2E15-478A-8928-14573E34C606 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D NULL|DXE_DRIVER UEFI_APPLICATION + CONSTRUCTOR =3D PlatformManagerUiLibConstructor + DESTRUCTOR =3D 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 (Indic= ate the formset class guid to be displayed) + gEfiIfrTianoGuid ## CONSUMES ## GUID (Exten= ded IFR Guid Opcode) + gEfiIfrFrontPageGuid ## CONSUMES ## GUID (Indic= ate the formset in this library need to display in which page) + gPlatformManagerEntryEventGuid ## CONSUMES ## GUID (Indic= ate enter PlatformManager) + gPlatformManagerExitEventGuid ## CONSUMES ## GUID (Indic= ate exit PlatformManager) diff --git a/Silicon/Ampere/AmpereSiliconPkg/Include/Guid/PlatformManagerHi= i.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/Platform= Manager.h b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformM= anager.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/Platform= ManagerVfr.h b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/Platfo= rmManagerVfr.h new file mode 100644 index 000000000000..205907d3777a --- /dev/null +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManager= Vfr.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/Platform= Manager.c b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformM= anager.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 =3D { + NULL, + NULL +}; + +EFI_GUID mPlatformManagerGuid =3D FORMSET_GUID; + +HII_VENDOR_DEVICE_PATH mPlatformManagerHiiVendorDevicePath =3D { + { + { + 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, 0x9= B, 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 !=3D NULL); + + if (Handle =3D=3D NULL) { + return NULL; + } + + Status =3D gHiiDatabase->GetPackageListHandle (gHiiDatabase, Handle, &Dr= iverHandle); + if (EFI_ERROR (Status)) { + return NULL; + } + // + // Get device path string. + // + return ConvertDevicePathToText (DevicePathFromHandle (DriverHandle), FAL= SE, 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 =3D 0; + BufferSize =3D 0; + Buffer =3D NULL; + + HiiHandle =3D gPlatformManagerPrivate.HiiHandle; + + // + // Allocate space for creation of UpdateData Buffer + // + StartOpCodeHandle =3D HiiAllocateOpCodeHandle (); + ASSERT (StartOpCodeHandle !=3D NULL); + + EndOpCodeHandle =3D HiiAllocateOpCodeHandle (); + ASSERT (EndOpCodeHandle !=3D NULL); + + // + // Create Hii Extend Label OpCode as the start opcode + // + StartLabel =3D (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode ( + StartOpCodeHandle, + &gEfiIfrTianoGuid, + NULL, + sizeof (EFI_IFR_GUID_LABEL) + ); + ASSERT (StartLabel !=3D NULL); + StartLabel->ExtendOpCode =3D EFI_IFR_EXTEND_OP_LABEL; + // + // According to the next show Form id(mNextShowFormId) to decide which f= orm need to update. + // + StartLabel->Number =3D (UINT16)(LABEL_FORM_ID_OFFSET + NextShowFor= mId); + + // + // Create Hii Extend Label OpCode as the end opcode + // + EndLabel =3D (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode ( + EndOpCodeHandle, + &gEfiIfrTianoGuid, + NULL, + sizeof (EFI_IFR_GUID_LABEL) + ); + ASSERT (EndLabel !=3D NULL); + EndLabel->ExtendOpCode =3D EFI_IFR_EXTEND_OP_LABEL; + EndLabel->Number =3D LABEL_END; + + // + // Get all the Hii handles + // + HiiHandles =3D HiiGetHiiHandles (NULL); + ASSERT (HiiHandles !=3D NULL); + + // + // Search for formset of each class type + // + for (Index =3D 0; HiiHandles[Index] !=3D NULL; Index++) { + Status =3D HiiGetFormSetFromHiiHandle (HiiHandles[Index], &Buffer,&Buf= ferSize); + if (EFI_ERROR (Status)) { + continue; + } + + Ptr =3D (UINT8 *)Buffer; + + while(TempSize < BufferSize) { + TempSize +=3D ((EFI_IFR_OP_HEADER *)Ptr)->Length; + if (((EFI_IFR_OP_HEADER *)Ptr)->Length <=3D OFFSET_OF (EFI_IFR_FORM_= SET, Flags)) { + Ptr +=3D ((EFI_IFR_OP_HEADER *)Ptr)->Length; + continue; + } + + ClassGuidNum =3D (UINT8)(((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3); + ClassGuid =3D (EFI_GUID *)(VOID *)(Ptr + sizeof (EFI_IFR_FORM_SET)); + while (ClassGuidNum-- > 0) { + if (CompareGuid (&gPlatformManagerFormsetGuid, ClassGuid)=3D=3D 0)= { + ClassGuid++; + continue; + } + + String =3D HiiGetString (HiiHandles[Index], ((EFI_IFR_FORM_SET *)P= tr)->FormSetTitle, NULL); + if (String =3D=3D NULL) { + String =3D HiiGetString (HiiHandle, STRING_TOKEN (STR_MISSING_ST= RING), NULL); + ASSERT (String !=3D NULL); + } + Token =3D HiiSetString (HiiHandle, 0, String, NULL); + FreePool (String); + + String =3D HiiGetString (HiiHandles[Index], ((EFI_IFR_FORM_SET *)P= tr)->Help, NULL); + if (String =3D=3D NULL) { + String =3D HiiGetString (HiiHandle, STRING_TOKEN (STR_MISSING_ST= RING), NULL); + ASSERT (String !=3D NULL); + } + TokenHelp =3D HiiSetString (HiiHandle, 0, String, NULL); + FreePool (String); + + CopyMem (&FormSetGuid, &((EFI_IFR_FORM_SET *)Ptr)->Guid, sizeof (E= FI_GUID)); + + if (NextShowFormId =3D=3D PLATFORM_MANAGER_FORM_ID) { + DevicePathStr =3D PmExtractDevicePathFromHiiHandle (HiiHandles[I= ndex]); + DevicePathId =3D 0; + if (DevicePathStr !=3D NULL) { + DevicePathId =3D HiiSetString (HiiHandle, 0, DevicePathStr, N= ULL); + FreePool (DevicePathStr); + } + + HiiCreateGotoExOpCode ( + StartOpCodeHandle, + 0, + Token, + TokenHelp, + 0, + (EFI_QUESTION_ID)(Index + ENTRY_KEY_OFFSET), + 0, + &FormSetGuid, + DevicePathId + ); + } + break; + } + + Ptr +=3D ((EFI_IFR_OP_HEADER *)Ptr)->Length; + } + + FreePool (Buffer); + Buffer =3D NULL; + TempSize =3D 0; + BufferSize =3D 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 =3D NULL; + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &gPlatformManagerPrivate.DriverHandle, + &gEfiDevicePathProtocolGuid, + &mPlatformManagerHiiVendorDevicePath, + NULL + ); + ASSERT_EFI_ERROR (Status); + + // + // Publish our HII data. + // + gPlatformManagerPrivate.HiiHandle =3D HiiAddPackages ( + &mPlatformManagerGuid, + gPlatformManagerPrivate.DriverHand= le, + PlatformManagerVfrBin, + PlatformManagerUiLibStrings, + NULL + ); + if (gPlatformManagerPrivate.HiiHandle !=3D 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 =3D 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 =3D gBS->UninstallMultipleProtocolInterfaces ( + gPlatformManagerPrivate.DriverHandle, + &gEfiDevicePathProtocolGuid, + &mPlatformManagerHiiVendorDevicePath, + NULL + ); + ASSERT_EFI_ERROR (Status); + + HiiRemovePackages (gPlatformManagerPrivate.HiiHandle); + + // Signal Exit event + Status =3D 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/Platform= ManagerStrings.uni b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/= PlatformManagerStrings.uni new file mode 100644 index 000000000000..3bb39413bc4b --- /dev/null +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManager= Strings.uni @@ -0,0 +1,21 @@ +// +// Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// + +/=3D# + +#langdef en-US "English" + +#string STR_EDKII_MENU_TITLE #language en-US "Platform Manager" +#string STR_EDKII_MENU_HELP #language en-US "This selection wi= ll take you to the Platform Manager" +#string STR_PLATFORM_LIST #language en-US "Platform Configur= ation" +#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 ar= e +// constantly recreating this page based on HII population. +//// diff --git a/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/Platform= ManagerUiLib.uni b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/Pl= atformManagerUiLib.uni new file mode 100644 index 000000000000..217a7e999dab --- /dev/null +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManager= UiLib.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/Platform= ManagerVfr.Vfr b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/Plat= formManagerVfr.Vfr new file mode 100644 index 000000000000..bfda75319416 --- /dev/null +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/PlatformUiLib/PlatformManager= Vfr.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 =3D FORMSET_GUID, + title =3D STRING_TOKEN(STR_EDKII_MENU_TITLE), + help =3D STRING_TOKEN(STR_EDKII_MENU_HELP), + classguid =3D EFI_HII_PLATFORM_SETUP_FORMSET_GUID, + + form formid =3D PLATFORM_MANAGER_FORM_ID, + title =3D STRING_TOKEN(STR_EDKII_MENU_TITLE); + subtitle text =3D STRING_TOKEN(STR_PLATFORM_LIST); + + label LABEL_ENTRY_LIST; + label LABEL_END; + + subtitle text =3D STRING_TOKEN(STR_EMPTY_STRING); + subtitle text =3D STRING_TOKEN(STR_EMPTY_STRING); + subtitle text =3D STRING_TOKEN(STR_EXIT_STRING); + endform; +endformset; --=20 2.17.1