From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.116]) by mx.groups.io with SMTP id smtpd.web12.4050.1607505869275501706 for ; Wed, 09 Dec 2020 01:24:29 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=ZYdPSUZG; spf=pass (domain: os.amperecomputing.com, ip: 40.107.220.116, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EkhUVgovaeM3ZBpmjvl1UYiqipQc9hGbSIkG2SdbWGdYWbkkGt16VdNiOiWWA8wSPQOMGdRhzqMWmgykHgYt2l3cr98tmn+s9zX1iPLcXyOhG2MorXepvYW6Gt7yOKPdd0jR6FYOwSMIyC4WE1XHiVZZcIXarcNjSMo6EdL2CTk8ad/pfWU/mu57EiDwBOgmt6oqTzb/nwH+bGPNViZobf+aUvizgR9hHDyAAuCMb+Uk+eGnmJsE4RF/E/8amoiMYYowieCosE7dvLuL2fKutfZQVjqNwxYZMRdDzW53hBmYGPg/WJ1mV8PyYNHvTyE55i362xVrPaWvEsMtHUmjpA== 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:X-MS-Exchange-SenderADCheck; bh=BYolDxw+xRUMEDR/Vlt0+gMJwb8qYnZvRpwdnaXDEK0=; b=eUdVQ9V8zQzlZYSOT3U0Nq1lWBQg9OL+yEILu4k1yrF5dU3Toa5xRfNUz2Bpp94YoZo+O5TVMGWp3IurJw8O/YJ06Qw/BS4IZtmmKdxtEsDYuagGWtkAmwZYGnJmgeImgYI+y9ed/BDbQyZgkQkqwvW5IkSs7XalPCqZX8wdfOzfpoxjBq6KLIxxuwRFTJs+gw0c6qoc0vRxQNzZD0P9h7w4zXBQLlr2WU0kkfVJwcjHFX4Hh8eRClgjQVCn1ATMaEI1BtGTtgzhHjHhUzZHjt6sWyZILOFYamJ3U/g+6I+bQjudgkGYIkgHp0Wun8Fm2XhwPgTkkqmY3e94MgtYdw== 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=BYolDxw+xRUMEDR/Vlt0+gMJwb8qYnZvRpwdnaXDEK0=; b=ZYdPSUZG60VY88FgmdEIdBQgrcb8nSTEwgdx/sy5NqvR7GjwzN8gKv0lSlQ4OlrnTFTOoQshT9x7cAQgZLkA5QSeQpQYddIgohA2F6v3YJhql82ltMZy6ioTk16neogMtUbhazAHmRsYtvvHpZzu0TlZQNWsHX33mO9geT3/RfE= 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 DM6PR01MB5609.prod.exchangelabs.com (2603:10b6:5:157::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Wed, 9 Dec 2020 09:24:27 +0000 Received: from DM6PR01MB5849.prod.exchangelabs.com ([fe80::c814:9a08:5c2e:4076]) by DM6PR01MB5849.prod.exchangelabs.com ([fe80::c814:9a08:5c2e:4076%5]) with mapi id 15.20.3632.023; Wed, 9 Dec 2020 09:24:27 +0000 From: "Nhi Pham" To: devel@edk2.groups.io Cc: Vu Nguyen Subject: [edk2-platforms][PATCH 11/34] Silicon/Ampere: Support PlatformManagerUiLib Date: Wed, 9 Dec 2020 16:25:08 +0700 Message-Id: <20201209092531.30867-12-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201209092531.30867-1-nhi@os.amperecomputing.com> References: <20201209092531.30867-1-nhi@os.amperecomputing.com> X-Originating-IP: [118.69.219.201] X-ClientProxiedBy: HK0PR01CA0054.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::18) To DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sw004.amperecomputing.com (118.69.219.201) by HK0PR01CA0054.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Wed, 9 Dec 2020 09:24:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ac633cba-e1b8-4b67-2231-08d89c2439e6 X-MS-TrafficTypeDiagnostic: DM6PR01MB5609: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:61; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YiNnSNDEz94rQGn1lwogpT+IBNdR1dHSvPRTu3njuJgu6bT6dww8b4lACNyzB7EKCX394jUJbItU4+Kf8jXQqAV6yG5ffQ7Llkb8kottTI4W3YaPQVq0To39WGsulGzmVJuB/RtC6jEg8CUIR8NAxHQCq6O84H/3gW+jg5azenQQeDGe+6O+e4w4ovg4lGw6SJw9aApmr9aWONFyxwk/f+Uwv4TICQLOClTGOY6XFfgy/L6ptump6oxLvJe5QTIMm0xa2L0G+dhgUbvD86yg785WBGwwhfRbDQCUCQQC1nPdT5yXf8nHypZLkCx5fTxeIilWNo6kKUZ7C4Zvu5Hd/zHTSlbwtW5dmrTT8oM6OK9fW0X369eEwJxV9UpGSo+DficnRiQ1UuL+Ha1K7sDwe4o0kB0KhYJAPuoqIb5Abqwqzl1+BHgXocj1jDjy6rQ/ 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)(376002)(136003)(346002)(366004)(5660300002)(956004)(508600001)(52116002)(30864003)(66946007)(6916009)(2616005)(1076003)(19627235002)(86362001)(6512007)(66476007)(26005)(8936002)(16526019)(107886003)(6666004)(186003)(6486002)(8676002)(6506007)(83380400001)(2906002)(34490700003)(66556008)(4326008)(290074003)(44824005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?hLnS1/pdPJ9Xr2mN8DxI8ZpOhrY+6EEIM1SOfWp9VknE1CNsx6p5dWUwwssP?= =?us-ascii?Q?LcOgNme9TdgLAd71vFuzzrHs4G1XPijjhxVEssHHV66xtdrWqCd0X3NrksCm?= =?us-ascii?Q?TmIsGu2k8z2hlvToYpZBy4UGvldle6V1gM+TPD5tKD87toUf+uBwiev+eikf?= =?us-ascii?Q?qDWDGqFqhcmr5I0/kYmH2thb0kpHl/hmrSrCioTGDMQzlwMGV5V09PGjtOqW?= =?us-ascii?Q?W8hXP4XePOBmPYlNgRpY2gKOxKEBwLDjFFDxFPpRAcyJ4nzhD+yscUZmt7Ut?= =?us-ascii?Q?cZlQYLL/DApfeohqVX0NFmiF4iQai1+FdHFu+Cjgf7Mh1ZIgNCWUs5/q/We7?= =?us-ascii?Q?IGR94E982OhhG0cOhIokE3QVCW+44G+F3x/BNS1aC1RJyDCOedP6tVtxSaXl?= =?us-ascii?Q?4emlF4NB2Gp+5LSma3OxPbWJPqehgE+jgMuPEXjfkvQOAcpIvDsrIyHLOTeW?= =?us-ascii?Q?IQuRZ/UGz60ctKkGNs0ZzoygOZjk2VXCTRjqbwIUt45Bq2es9VuxxdRgOKNK?= =?us-ascii?Q?VjoD8LA8+iWeqeU1gjzxoy0V8rO0vZwwDBazBlnYXdJSc/mX1SRRxtZD1ALi?= =?us-ascii?Q?aYGbQbk4GaGB+06NZ4OQB//fKpO5g6GaZbj1kfFd1yVYXykNQhLO09KCUg1r?= =?us-ascii?Q?+/yOsYRN5ghYcwqdxLQC6fnO+J2csNVrM0XVLQueZ4/KVQpRMoR3qex/IZys?= =?us-ascii?Q?q/c9WFymIm3d09uawygi+NSSTa7axCc702xnkYf3gj4mYdKa2chtP3ARjffv?= =?us-ascii?Q?CvuIeEbliIjzF9mIL6P2FgPuF67Mx1XeRyPHk8Rgfy9i0ZmGWNflYkUu+jLf?= =?us-ascii?Q?Lg4NzDhTkmcymamv2dYHppPrN7Sd4O2RJmWlgybwgUqDvOPp5SQ31YtbugqX?= =?us-ascii?Q?9ipTwKr8HPAArhpbkiMXKWr5iitTWlXaS3yo4GyQHr74cGmjeke+xsk05Mbc?= =?us-ascii?Q?WNR42P03Zd6Ksnz0vGFbebdU5Z1Zhgi3wopB3pAb0ZdmoUJpBa6MJLivf2Gh?= =?us-ascii?Q?fTLu?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5849.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2020 09:24:27.6074 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-Network-Message-Id: ac633cba-e1b8-4b67-2231-08d89c2439e6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bS2rqnG/xplO/8YFC6PZcp7xBZ9ENU0JrimdCcowA6z7JxD3xibvzPk5X5cGquk9smEJl+oZ2elSjLqProbTx0tsIlNkUKhcANf02KI0KfA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB5609 Content-Type: text/plain From: Vu Nguyen The idea came from DeviceManagerUiLib that related device setting can be placed under a common entry. This change aims to provide a central point for all platform setting through a new Platform Manager entry located in Device Manager entry of UiApp. Platform VFRs can use gPlatformManagerFormsetGuid as its classuuid in order to be shown under Platform Manager entry. Signed-off-by: Vu Nguyen --- Silicon/Ampere/AmperePkg.dec | 15 + Silicon/Ampere/AmpereAltraPkg/Ac01Pkg.dsc.inc | 1 + Silicon/Ampere/Library/PlatformUiLib/PlatformManagerUiLib.inf | 47 +++ Silicon/Ampere/Include/Guid/PlatformManagerHii.h | 31 ++ Silicon/Ampere/Library/PlatformUiLib/PlatformManager.h | 52 +++ Silicon/Ampere/Library/PlatformUiLib/PlatformManagerVfr.h | 28 ++ Silicon/Ampere/Library/PlatformUiLib/PlatformManager.c | 354 ++++++++++++++++++++ Silicon/Ampere/Library/PlatformUiLib/PlatformManagerStrings.uni | 21 ++ Silicon/Ampere/Library/PlatformUiLib/PlatformManagerUiLib.uni | 13 + Silicon/Ampere/Library/PlatformUiLib/PlatformManagerVfr.Vfr | 29 ++ 10 files changed, 591 insertions(+) diff --git a/Silicon/Ampere/AmperePkg.dec b/Silicon/Ampere/AmperePkg.dec index 3d6ddfb39b97..2f349845d7de 100755 --- a/Silicon/Ampere/AmperePkg.dec +++ b/Silicon/Ampere/AmperePkg.dec @@ -34,6 +34,21 @@ [LibraryClasses] [Guids] gAmpereTokenSpaceGuid = { 0xdbd4436e, 0x89cb, 0x44dc, { 0xb5, 0xc0, 0x49, 0xc3, 0x91, 0x35, 0xbf, 0xdf } } + # + # Platform Manager formset UUID + # + gPlatformManagerFormsetGuid = { 0x83ABD546, 0x7AD9, 0x4DE7, { 0xBD, 0x52, 0x12, 0x23, 0xF6, 0xE8, 0xFD, 0x4B } } + + # + # Platform Manager entry UUID + # + gPlatformManagerEntryEventGuid = { 0x28A4731E, 0x14A9, 0x488A, { 0xA8, 0x19, 0xFF, 0x27, 0x80, 0x6E, 0xDB, 0x0E } } + + # + # Platform Manager exit UUID + # + gPlatformManagerExitEventGuid = { 0xE8887242, 0x4EFF, 0x4323, { 0x81, 0xF4, 0xC9, 0x5F, 0xD5, 0x8D, 0x80, 0xD5 } } + [Ppis] [PcdsFixedAtBuild] diff --git a/Silicon/Ampere/AmpereAltraPkg/Ac01Pkg.dsc.inc b/Silicon/Ampere/AmpereAltraPkg/Ac01Pkg.dsc.inc index 3fc1fd94ee62..bb583d6f75ef 100755 --- a/Silicon/Ampere/AmpereAltraPkg/Ac01Pkg.dsc.inc +++ b/Silicon/Ampere/AmpereAltraPkg/Ac01Pkg.dsc.inc @@ -672,6 +672,7 @@ [Components.common] MdeModulePkg/Universal/BdsDxe/BdsDxe.inf MdeModulePkg/Application/UiApp/UiApp.inf { + NULL|Silicon/Ampere/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/Library/PlatformUiLib/PlatformManagerUiLib.inf b/Silicon/Ampere/Library/PlatformUiLib/PlatformManagerUiLib.inf new file mode 100644 index 000000000000..0170edfefe3c --- /dev/null +++ b/Silicon/Ampere/Library/PlatformUiLib/PlatformManagerUiLib.inf @@ -0,0 +1,47 @@ +## @file +# +# Copyright (c) 2020, 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/AmperePkg.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/Include/Guid/PlatformManagerHii.h b/Silicon/Ampere/Include/Guid/PlatformManagerHii.h new file mode 100644 index 000000000000..47b07242bb61 --- /dev/null +++ b/Silicon/Ampere/Include/Guid/PlatformManagerHii.h @@ -0,0 +1,31 @@ +/** @file + + Copyright (c) 2020, 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/Library/PlatformUiLib/PlatformManager.h b/Silicon/Ampere/Library/PlatformUiLib/PlatformManager.h new file mode 100644 index 000000000000..56e9673bba07 --- /dev/null +++ b/Silicon/Ampere/Library/PlatformUiLib/PlatformManager.h @@ -0,0 +1,52 @@ +/** @file + + Copyright (c) 2020, 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/Library/PlatformUiLib/PlatformManagerVfr.h b/Silicon/Ampere/Library/PlatformUiLib/PlatformManagerVfr.h new file mode 100644 index 000000000000..4667de9275e3 --- /dev/null +++ b/Silicon/Ampere/Library/PlatformUiLib/PlatformManagerVfr.h @@ -0,0 +1,28 @@ +/** @file + + Copyright (c) 2020, 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/Library/PlatformUiLib/PlatformManager.c b/Silicon/Ampere/Library/PlatformUiLib/PlatformManager.c new file mode 100644 index 000000000000..d395f091cd6e --- /dev/null +++ b/Silicon/Ampere/Library/PlatformUiLib/PlatformManager.c @@ -0,0 +1,354 @@ +/** @file + + Copyright (c) 2020, 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/Library/PlatformUiLib/PlatformManagerStrings.uni b/Silicon/Ampere/Library/PlatformUiLib/PlatformManagerStrings.uni new file mode 100644 index 000000000000..4351b6fb11dd --- /dev/null +++ b/Silicon/Ampere/Library/PlatformUiLib/PlatformManagerStrings.uni @@ -0,0 +1,21 @@ +// +// Copyright (c) 2020, 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/Library/PlatformUiLib/PlatformManagerUiLib.uni b/Silicon/Ampere/Library/PlatformUiLib/PlatformManagerUiLib.uni new file mode 100644 index 000000000000..bf96c309e458 --- /dev/null +++ b/Silicon/Ampere/Library/PlatformUiLib/PlatformManagerUiLib.uni @@ -0,0 +1,13 @@ +// +// Copyright (c) 2020, 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/Library/PlatformUiLib/PlatformManagerVfr.Vfr b/Silicon/Ampere/Library/PlatformUiLib/PlatformManagerVfr.Vfr new file mode 100644 index 000000000000..5474983982df --- /dev/null +++ b/Silicon/Ampere/Library/PlatformUiLib/PlatformManagerVfr.Vfr @@ -0,0 +1,29 @@ +/** @file + + Copyright (c) 2020, 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