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.119]) by mx.groups.io with SMTP id smtpd.web09.9901.1631721654823020684 for ; Wed, 15 Sep 2021 09:00:55 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@os.amperecomputing.com header.s=selector2 header.b=YI4Q604l; spf=pass (domain: os.amperecomputing.com, ip: 40.107.94.119, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JD99Nf6FTt0GN7ZxnCxRfhpP8+IPjao0Gc9n/SRePtH1X2RxiExj0cMK045QO0xgQKx7rqHcUiyXtsDrrDzrYO2f8A/Vs1wpt6IA3oDEM/f47NWJUjRvmUBjqFKziBTs9Ls+lx4lFsuJFWSgdWz3B5RKeomDsh8+iW8wxnvt7g673ovw9T3XE/St7RSyGOuR5DMzu5hya2QvKXuh+9efZIEHR9fTB1ZNFfh7549iV0hZu5NzQj23VkHppo1oX6OeFRd0F/9hhd2zFTlMAjgRzWl+HCuU55UDNggCrvxxlFSOHK0rVk9vSEuYg3IPtPv2FpK6/rBYhzqstHjdZFwStw== 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=FEl9VUcSi/6/kQwKdtJsVOUtgA0DOi/lUuJY8mysKVo=; b=XznJjA9yR283kRnxrWRvLMI76IPSxarOu2jtXYxJXvP2j0G8YnidDjV6JH/68Yg8o0DYwdpPV8kHH+gmNIV44Op70Pk/ku2/UXKjTiRFAlL8ms0s/2sAs0JcAHSKz1r5FKrQ8vSpCkAWJD7SxmvK8jR32bT7ivIONod3FS5z/A4PGEfUuxFYr0xh9I9Sr3j/8jcqxGEPOoLqtHHpEkEnAt5wuvdGXH6VCVsU9un8eSO8sQUOglo3o9ZuBT7id6/4aRFWDu/RuHMztQGn18tOCF63TIvFC6SmzOepo9tpnAdbSn3TcEOW+dKmQ/H0E823k+YuhWsAJCFXGnKWntraNA== 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=FEl9VUcSi/6/kQwKdtJsVOUtgA0DOi/lUuJY8mysKVo=; b=YI4Q604l2tZGlpOUz9Yj8vUF+C0m/6npTCWohWg62/Hr7vSkph9KaBK5K2oTx0Sn0vaSKjgjkIOE4bBZ4qFBjAu7aGJ50bC6RWw1OkmCjkwduBAk4RtKTFpDlqOnz4zZp7XJiJgRY8+vgXv7j/2Jr/sqxffQBLODKUhcDCe2MdQ= 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 16:00:49 +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 16:00:49 +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 23/28] AmpereAltraPkg: Add configuration screen for memory Date: Wed, 15 Sep 2021 22:55:22 +0700 Message-ID: <20210915155527.8176-24-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 16:00:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7128846a-a34b-4252-8819-08d97861f4ec X-MS-TrafficTypeDiagnostic: DM5PR0101MB3065: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8++M+hoERK1sFYNUC5jOtrSj9TQYNFlxGrDJtAkNNq/yWTsZXz0HZrKhks5SbwUQ+cxynsBr05sIwxbtEKBkiIyvEKxyp4/Ey5LQ+bo1F2O1pfJx3R9LXjd3/UVD1v3LpRhz1OsqPTNaIkDaJrsSPW6+hqfRXA4zodae9IH5mWOIB0nBUsWgy2sDPn/qpzAimxzeTZu5YDvxobHHmEE/wgd7GBqHtAC4DDvnWIVtMDGE2CsYo6MhKeAk2VNTO9toIc7DeeQf2x4ZmLfBvBx23v6p2g08Sx3yw0SJm3LBI0JZf8FyAALG6vYwveK2i4BWk1IrcCpQGB3AAHAAdP+cwvEXTZ4JRGAJXBxaP778zQpZqghF6HVCCm7MBdEZO3txVsJXWPQG8V5kZEy1D8xssIXEB+pWD5wJP2Ex7K5RBylKp85mexDKyRaDIWEaTR/z69V0A07Pud+8KtloaD40WqhyDNw3blish4SNw1pV9oQsi+ThhUizmN1no6lYNVMXO87DLQfzrZAbmVycytMFysLSpROuqs2YklD7xZFDP7WvSM3DHh0XCZgZb8QKe3FZOi8IZn5ZkUhX8m/RSetBCctFwTAEd5oyXKNuyr9s/kDPpo1+Y0t5dOEUruSKi0ANSfuZbTCYO3vJ6JUwtjASu3mM5al8NQ54eYdT51QAVbq70PswIaovGFh1BqhGakqAt2juniVv0nreD4P8mAL/RHCuZrALtOIEn83B/uCA/p+nuNLuVHsPX9/ApM6ZOJq8 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:(4636009)(136003)(346002)(396003)(366004)(376002)(39850400004)(2616005)(38100700002)(38350700002)(2906002)(6666004)(6916009)(83380400001)(30864003)(6512007)(26005)(8676002)(4326008)(186003)(19627235002)(8936002)(478600001)(66574015)(6506007)(5660300002)(52116002)(1076003)(86362001)(316002)(66556008)(54906003)(956004)(6486002)(66476007)(66946007)(290074003)(559001)(579004)(44824005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?sASj6a/3MD3/EgFTxGddoBaf0UWoxoCA5/IkwcyGc1r+tv/fJHY59QPZqZgA?= =?us-ascii?Q?1vP8Mq08cO5eJZeMmEoR0NOdeViY8mxkgb/ZjpG0KDoQTq5X1dA4FbyUHVKL?= =?us-ascii?Q?3PYxB0T0Ln3SeOZ8OXeL+tRgXV30hnPhJgW+YTTFdaN8Sfjo7w9LL0iuDZlk?= =?us-ascii?Q?w2ITisQX6CT9+uJe5MIBwWdz3jgh0rXHnfVdLmiG04cdZQnEoGRKeHmZS5vL?= =?us-ascii?Q?eZjR0HIvsHYvTo6hIKOA1Fj9i8u5aZL/qgOYZha1nlxKrelmyK0P2PIndsFC?= =?us-ascii?Q?2aJgT3wqOeO4EFHtuGS720QR0PyFbVT7pjxRsWWQp11I8smUGWC9huscD3B5?= =?us-ascii?Q?jQYfVqtVRaKTzkNgS3goQPnIDncizMrZJk2gcrDVLed/2VuyeAt4kgfxHw5O?= =?us-ascii?Q?S6sXQUHB35UBbeeZYVVUI+nwQBKz6Hzdruex7PdhcMuZ9la/sEKJJ6BG44yX?= =?us-ascii?Q?x9UavYho4qCzzZlfFkCv5DJCoMmcSJkLlYdkNJNzGVk9TCEPBT60XduImEng?= =?us-ascii?Q?b3MUiz8dVASPEpocmPTu6yo2m8EDKlrqM9acdx7Ib/KPKYA0exv1SzH0BmYS?= =?us-ascii?Q?XTipYwLypqoDjvDirD0bHjqtoAor0EWvsW0BSJmxAyE5pgJB3YlkQAKlRfpL?= =?us-ascii?Q?At2gAumg657cLUvvo4Abvt0ixUaMlubPb7KOPSvp2k7l3f3kuCKwAg00PVDF?= =?us-ascii?Q?q7clPemVqhTS/KlxUsYO0xtR/H9H16zm/VEy3TDzZzZqOTxkHAmyd84I7zip?= =?us-ascii?Q?vJ2Hd22f9hqArAVILr66lm88ORkE6/jC+MEfkHorTYFQD9gaEAApfxGk/4Pw?= =?us-ascii?Q?67usMX1QIOHpxZmgSW9rsHie0IxaBMqqtYElu6i7jMp+++NqVO9yHr2JzhP1?= =?us-ascii?Q?pihQfof8rU10pMzt0sTSaLv0KwtOngk07w/IXVeKPvj4X8YABa1LQ3Buap5m?= =?us-ascii?Q?Fop6zzMa+fohbx+vGPv/yUw82iGOVbk+OgnhAv5OPzWha3LIV/lztJzdDC8D?= =?us-ascii?Q?jxnHEC94bj29iU70lusBh+3X8fkUbuajiU3OtXukfQxoE7BVbu1f5JU7G6Zi?= =?us-ascii?Q?Vh+MKQI+jubOjDnLim3m7l5FV9T9EPOcJFNS5T09ZIR+B7+bdmcQIheqXqsR?= =?us-ascii?Q?ETZeOIG8wqJwcWaDFANm73i27cnIJK4gYP6y42LsB/8ECIGK0ju7lKUzmHfK?= =?us-ascii?Q?fHMHDddEkyHgyYNjImxZNHFdDA+RkaiTOtYHApowyxp3VaBqTihGOFvthS8b?= =?us-ascii?Q?RD0IR6vVcWcaBa1jRhtWADfWTCQV6kv5ZpikXNgeMdJgh/fnngRVPvCMORxa?= =?us-ascii?Q?KXt4dL4R5f3+/mtTdYrdGZFK?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7128846a-a34b-4252-8819-08d97861f4ec X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5849.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 16:00:37.0346 (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: AbrYQkSXTF2T8jajn+a/Bgf23ulU1rfZQjxYW1OnXhOfErpa8o1pWpxZe76lX/amUXTT9rOfxKC5o7ich3sS5Jl9Wcczfn1RvRG5+9T0wl8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR0101MB3065 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable From: Vu Nguyen Provide memory screen with below info: * Memory total capacity * Memory RAS and Performance Configuration * Per DIMM Information 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 --- Platform/Ampere/JadePkg/Jade.dsc = | 1 + Platform/Ampere/JadePkg/Jade.fdf = | 1 + Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.inf = | 59 + Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreen.h = | 170 +++ Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreenNVDataStruct= .h | 47 + Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreenVfr.vfr = | 62 + Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoNvramLib.c = | 394 ++++++ Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreen.c = | 1325 ++++++++++++++++++++ Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.uni = | 9 + Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxeExtra.uni = | 9 + Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreenStrings.uni = | 64 + 11 files changed, 2141 insertions(+) diff --git a/Platform/Ampere/JadePkg/Jade.dsc b/Platform/Ampere/JadePkg/Jad= e.dsc index f723be6997e6..5fc83745cdbc 100644 --- a/Platform/Ampere/JadePkg/Jade.dsc +++ b/Platform/Ampere/JadePkg/Jade.dsc @@ -197,3 +197,4 @@ [Components.common] # HII # Silicon/Ampere/AmpereAltraPkg/Drivers/PlatformInfoDxe/PlatformInfoDxe.in= f + Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.inf diff --git a/Platform/Ampere/JadePkg/Jade.fdf b/Platform/Ampere/JadePkg/Jad= e.fdf index c54b46f95ad5..6fe023025034 100644 --- a/Platform/Ampere/JadePkg/Jade.fdf +++ b/Platform/Ampere/JadePkg/Jade.fdf @@ -355,5 +355,6 @@ [FV.FvMain] # HII # INF Silicon/Ampere/AmpereAltraPkg/Drivers/PlatformInfoDxe/PlatformInfoDx= e.inf + INF Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.inf =20 !include Platform/Ampere/AmperePlatformPkg/FvRules.fdf.inc diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.in= f b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.inf new file mode 100644 index 000000000000..fbb2ac9dad21 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.inf @@ -0,0 +1,59 @@ +## @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 MemInfoDxe + MODULE_UNI_FILE =3D MemInfoDxe.uni + FILE_GUID =3D D9EFCEFE-189B-4599-BB07-04F0A8DF5C2F + MODULE_TYPE =3D DXE_DRIVER + ENTRY_POINT =3D MemInfoScreenInitialize + +[Sources] + MemInfoNvramLib.c + MemInfoScreen.c + MemInfoScreen.h + MemInfoScreenStrings.uni + MemInfoScreenNVDataStruct.h + MemInfoScreenVfr.vfr + +[Packages] + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec + Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec + +[LibraryClasses] + AmpereCpuLib + BaseLib + DevicePathLib + HiiLib + HobLib + MemoryAllocationLib + NVParamLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + +[Guids] + gEfiIfrTianoGuid ## PRODUCES ## UNDEFINED + gPlatformManagerFormsetGuid + gPlatformHobGuid + +[Protocols] + gEfiDevicePathProtocolGuid ## CONSUMES + gEfiHiiConfigRoutingProtocolGuid ## CONSUMES + gEfiHiiConfigAccessProtocolGuid ## PRODUCES + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + MemInfoDxeExtra.uni diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreen= .h b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreen.h new file mode 100644 index 000000000000..4b4b498062c8 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreen.h @@ -0,0 +1,170 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef MEM_INFO_SCREEN_H_ +#define MEM_INFO_SCREEN_H_ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "MemInfoScreenNVDataStruct.h" + +// +// This is the generated IFR binary data for each formset defined in VFR. +// This data array is ready to be used as input of HiiAddPackages() to +// create a packagelist (which contains Form packages, String packages, et= c). +// +extern UINT8 MemInfoScreenVfrBin[]; + +// +// This is the generated String package data for all .UNI files. +// This data array is ready to be used as input of HiiAddPackages() to +// create a packagelist (which contains Form packages, String packages, et= c). +// +extern UINT8 MemInfoDxeStrings[]; + +enum DDR_ECC_MODE { + ECC_DISABLE =3D 0, + ECC_SECDED, + SYMBOL_ECC +}; + +enum DDR_ERROR_CTRL_MODE_DE { + ERRCTLR_DE_DISABLE =3D 0, + ERRCTLR_DE_ENABLE, +}; + +enum DDR_ERROR_CTRL_MODE_FI { + ERRCTLR_FI_DISABLE =3D 0, + ERRCTLR_FI_ENABLE, +}; + +#define MEM_INFO_DDR_SPEED_SEL_OFFSET OFFSET_OF (MEM_I= NFO_VARSTORE_DATA, DDRSpeedSel) +#define MEM_INFO_ECC_MODE_SEL_OFFSET OFFSET_OF (MEM_I= NFO_VARSTORE_DATA, EccMode) +#define MEM_INFO_ERR_CTRL_DE_MODE_SEL_OFFSET OFFSET_OF (MEM_I= NFO_VARSTORE_DATA, ErrCtrl_DE) +#define MEM_INFO_ERR_CTRL_FI_MODE_SEL_OFFSET OFFSET_OF (MEM_I= NFO_VARSTORE_DATA, ErrCtrl_FI) +#define MEM_INFO_ERR_SLAVE_32BIT_OFFSET OFFSET_OF (MEM_I= NFO_VARSTORE_DATA, Slave32bit) +#define MEM_INFO_DDR_SCRUB_OFFSET OFFSET_OF (MEM_I= NFO_VARSTORE_DATA, ScrubPatrol) +#define MEM_INFO_DDR_DEMAND_SCRUB_OFFSET OFFSET_OF (MEM_I= NFO_VARSTORE_DATA, DemandScrub) +#define MEM_INFO_DDR_WRITE_CRC_OFFSET OFFSET_OF (MEM_I= NFO_VARSTORE_DATA, WriteCrc) +#define MEM_INFO_FGR_MODE_OFFSET OFFSET_OF (MEM_I= NFO_VARSTORE_DATA, FGRMode) +#define MEM_INFO_REFRESH2X_MODE_OFFSET OFFSET_OF (MEM_I= NFO_VARSTORE_DATA, Refresh2x) +#define MEM_INFO_NVDIMM_MODE_SEL_OFFSET OFFSET_OF (MEM_I= NFO_VARSTORE_DATA, NvdimmModeSel) + +#define MEM_INFO_SCREEN_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('M= ', 'E', 'M', 'i') + +#define MEM_INFO_DDR_SPEED_SEL_QUESTION_ID 0x8001 +#define MEM_INFO_FORM_PERFORMANCE_QUESTION_ID 0x8002 +#define MEM_INFO_FORM_PERFORMANCE_ECC_QUESTION_ID 0x8003 +#define MEM_INFO_FORM_PERFORMANCE_ERR_CTRL_DE_QUESTION_ID 0x8004 +#define MEM_INFO_FORM_PERFORMANCE_ERR_CTRL_FI_QUESTION_ID 0x8005 +#define MEM_INFO_DDR_SLAVE_32BIT_QUESTION_ID 0x8006 +#define MEM_INFO_DDR_SCRUB_PATROL_QUESTION_ID 0x8007 +#define MEM_INFO_DDR_DEMAND_SCRUB_QUESTION_ID 0x8008 +#define MEM_INFO_DDR_WRITE_CRC_QUESTION_ID 0x8009 +#define MEM_INFO_FGR_MODE_QUESTION_ID 0x800A +#define MEM_INFO_REFRESH2X_MODE_QUESTION_ID 0x800B +#define MEM_INFO_FORM_NVDIMM_QUESTION_ID 0x800C +#define MEM_INFO_FORM_NVDIMM_MODE_SEL_QUESTION_ID 0x800D + +#define MAX_NUMBER_OF_HOURS_IN_A_DAY 24 + +#define DDR_DEFAULT_SCRUB_PATROL_DURATION 24 +#define DDR_DEFAULT_DEMAND_SCRUB 1 +#define DDR_DEFAULT_WRITE_CRC 0 +#define DDR_DEFAULT_FGR_MODE 0 +#define DDR_DEFAULT_REFRESH2X_MODE 0 +#define DDR_DEFAULT_NVDIMM_MODE_SEL 3 + +#define DDR_FGR_MODE_GET(Value) ((Value) & 0x3) /* Bit 0, 1 */ +#define DDR_FGR_MODE_SET(Dst, Src) do { Dst =3D (((Dst) & ~0x3) | (= (Src) & 0x3)); } while (0) + +#define DDR_REFRESH_2X_GET(Value) ((Value) & 0x10000) >> 16 /* Bit= 16 only */ +#define DDR_REFRESH_2X_SET(Dst, Src) do { Dst =3D (((Dst) & ~0x10000)= | ((Src) & 0x1) << 16); } while (0) + +#define DDR_NVDIMM_MODE_SEL_MASK 0x7FFFFFFF +#define DDR_NVDIMM_MODE_SEL_VALID_BIT BIT31 + +typedef struct { + UINTN Signature; + + EFI_HANDLE DriverHandle; + EFI_HII_HANDLE HiiHandle; + MEM_INFO_VARSTORE_DATA VarStoreConfig; + + // + // Consumed protocol + // + EFI_HII_DATABASE_PROTOCOL *HiiDatabase; + EFI_HII_STRING_PROTOCOL *HiiString; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL *HiiKeywordHandler; + EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2; + + // + // Produced protocol + // + EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess; +} MEM_INFO_SCREEN_PRIVATE_DATA; + +#define MEM_INFO_SCREEN_PRIVATE_FROM_THIS(a) CR (a, MEM_INFO_SCREEN_PRIVA= TE_DATA, ConfigAccess, MEM_INFO_SCREEN_PRIVATE_DATA_SIGNATURE) + +#pragma pack(1) + +/// +/// HII specific Vendor Device Path definition. +/// +typedef struct { + VENDOR_DEVICE_PATH VendorDevicePath; + EFI_DEVICE_PATH_PROTOCOL End; +} HII_VENDOR_DEVICE_PATH; + +#pragma pack() + +EFI_STATUS +MemInfoScreenInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +EFI_STATUS +MemInfoScreenUnload ( + IN EFI_HANDLE ImageHandle + ); + +EFI_STATUS +MemInfoNvparamGet ( + OUT MEM_INFO_VARSTORE_DATA *VarStoreConfig + ); + +EFI_STATUS +MemInfoNvparamSet ( + IN MEM_INFO_VARSTORE_DATA *VarStoreConfig + ); + +#endif /* MEM_INFO_SCREEN_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreen= NVDataStruct.h b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoSc= reenNVDataStruct.h new file mode 100644 index 000000000000..75960c367880 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreenNVDataS= truct.h @@ -0,0 +1,47 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef MEM_INFO_SCREEN_NV_DATA_STRUCT_H_ +#define MEM_INFO_SCREEN_NV_DATA_STRUCT_H_ + +#define MEM_INFO_VARSTORE_NAME L"MemInfoIfrNVData" +#define MEM_INFO_VARSTORE_ID 0x1234 +#define MEM_INFO_FORM_ID 0x1235 +#define MEM_INFO_FORM_PERFORMANCE_ID 0x1236 +#define MEM_INFO_FORM_NVDIMM_ID 0x1237 +#define MEM_INFO_FORM_SET_GUID { 0xd58338ee, 0xe9f7, 0x= 4d8d, { 0xa7, 0x08, 0xdf, 0xb2, 0xc6, 0x66, 0x1d, 0x61 } } +#define MEM_INFO_FORM_SET_PERFORMANCE_GUID { 0x4a072c78, 0x42f9, 0x= 11ea, { 0xb7, 0x7f, 0x2e, 0x28, 0xce, 0x88, 0x12, 0x62 } } + +#pragma pack(1) + +// +// NV data structure definition +// +typedef struct { + UINT32 DDRSpeedSel; + UINT32 EccMode; + UINT32 ErrCtrl_DE; + UINT32 ErrCtrl_FI; + UINT32 Slave32bit; + UINT32 ScrubPatrol; + UINT32 DemandScrub; + UINT32 WriteCrc; + UINT32 FGRMode; + UINT32 Refresh2x; + UINT32 NvdimmModeSel; +} MEM_INFO_VARSTORE_DATA; + +// +// Labels definition +// +#define LABEL_UPDATE 0x2223 +#define LABEL_END 0x2224 + +#pragma pack() + +#endif diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreen= Vfr.vfr b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreenVfr= .vfr new file mode 100644 index 000000000000..e3d7aa0c44bd --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreenVfr.vfr @@ -0,0 +1,62 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include "MemInfoScreenNVDataStruct.h" + +formset + guid =3D MEM_INFO_FORM_SET_GUID, + title =3D STRING_TOKEN(STR_MEM_INFO_FORM), + help =3D STRING_TOKEN(STR_MEM_INFO_FORM_HELP), + classguid =3D gPlatformManagerFormsetGuid, + + // + // Define a variable Storage + // + varstore MEM_INFO_VARSTORE_DATA, + varid =3D MEM_INFO_VARSTORE_ID, + name =3D MemInfoIfrNVData, + guid =3D MEM_INFO_FORM_SET_GUID; + + form + formid =3D MEM_INFO_FORM_ID, + title =3D STRING_TOKEN(STR_MEM_INFO_FORM); + + subtitle text =3D STRING_TOKEN(STR_MEM_INFO_FORM); + + label LABEL_UPDATE; + // dynamic content here + label LABEL_END; + + endform; + + form + formid =3D MEM_INFO_FORM_PERFORMANCE_ID, + title =3D STRING_TOKEN(STR_MEM_INFO_PERFORMANCE_FORM); + + subtitle text =3D STRING_TOKEN(STR_MEM_INFO_PERFORMANCE_FORM); + + label LABEL_UPDATE; + // dynamic content here + label LABEL_END; + + endform; + + form + formid =3D MEM_INFO_FORM_NVDIMM_ID, + title =3D STRING_TOKEN(STR_MEM_INFO_NVDIMM_FORM); + + subtitle text =3D STRING_TOKEN(STR_MEM_INFO_NVDIMM_FORM); + + label LABEL_UPDATE; + // dynamic content here + label LABEL_END; + + endform; + +endformset; diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoNvramL= ib.c b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoNvramLib.c new file mode 100644 index 000000000000..c83f489f4078 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoNvramLib.c @@ -0,0 +1,394 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include + +#include "MemInfoScreen.h" +#include "NVParamDef.h" + +#define DDR_NVPARAM_ERRCTRL_DE_FIELD_SHIFT 0 +#define DDR_NVPARAM_ERRCTRL_DE_FIELD_MASK 0x1 + +#define DDR_NVPARAM_ERRCTRL_FI_FIELD_SHIFT 1 +#define DDR_NVPARAM_ERRCTRL_FI_FIELD_MASK 0x2 + +/** + This is function collects meminfo from NVParam + + @param Data The buffer to return the contents. + + @retval EFI_SUCCESS Get response data successfully. + @retval Other value Failed to get meminfo from NVParam +**/ +EFI_STATUS +MemInfoNvparamGet ( + OUT MEM_INFO_VARSTORE_DATA *VarStoreConfig + ) +{ + UINT32 Value; + EFI_STATUS Status; + + ASSERT (VarStoreConfig !=3D NULL); + + Status =3D NVParamGet ( + NV_SI_DDR_SPEED, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status)) { + VarStoreConfig->DDRSpeedSel =3D 0; /* Default auto mode */ + } else { + VarStoreConfig->DDRSpeedSel =3D Value; + } + + Status =3D NVParamGet ( + NV_SI_DDR_ECC_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status)) { + VarStoreConfig->EccMode =3D ECC_SECDED; /* Default enable */ + } else { + VarStoreConfig->EccMode =3D Value; + } + + Status =3D NVParamGet ( + NV_SI_DDR_ERRCTRL, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status)) { + VarStoreConfig->ErrCtrl_DE =3D ERRCTLR_DE_ENABLE; + VarStoreConfig->ErrCtrl_FI =3D ERRCTLR_FI_ENABLE; + } else { + VarStoreConfig->ErrCtrl_DE =3D (Value & DDR_NVPARAM_ERRCTRL_DE_FIELD_M= ASK) >> DDR_NVPARAM_ERRCTRL_DE_FIELD_SHIFT; + VarStoreConfig->ErrCtrl_FI =3D (Value & DDR_NVPARAM_ERRCTRL_FI_FIELD_M= ASK) >> DDR_NVPARAM_ERRCTRL_FI_FIELD_SHIFT; + } + + Status =3D NVParamGet ( + NV_SI_DDR_SLAVE_32BIT_MEM_EN, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status)) { + VarStoreConfig->Slave32bit =3D 0; /* Default disabled */ + } else { + VarStoreConfig->Slave32bit =3D Value; + } + + Status =3D NVParamGet ( + NV_SI_DDR_SCRUB_EN, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status)) { + VarStoreConfig->ScrubPatrol =3D DDR_DEFAULT_SCRUB_PATROL_DURATION; + } else { + VarStoreConfig->ScrubPatrol =3D Value; + } + + Status =3D NVParamGet ( + NV_SI_DDR_WR_BACK_EN, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status)) { + VarStoreConfig->DemandScrub =3D DDR_DEFAULT_DEMAND_SCRUB; + } else { + VarStoreConfig->DemandScrub =3D Value; + } + + Status =3D NVParamGet ( + NV_SI_DDR_CRC_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status)) { + VarStoreConfig->WriteCrc =3D DDR_DEFAULT_WRITE_CRC; + } else { + VarStoreConfig->WriteCrc =3D Value; + } + + Status =3D NVParamGet ( + NV_SI_DDR_REFRESH_GRANULARITY, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status)) { + VarStoreConfig->FGRMode =3D DDR_DEFAULT_FGR_MODE; + VarStoreConfig->Refresh2x =3D DDR_DEFAULT_REFRESH2X_MODE; + } else { + VarStoreConfig->FGRMode =3D DDR_FGR_MODE_GET (Value); + VarStoreConfig->Refresh2x =3D DDR_REFRESH_2X_GET (Value); + } + + Status =3D NVParamGet ( + NV_SI_NVDIMM_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status)) { + VarStoreConfig->NvdimmModeSel =3D DDR_DEFAULT_NVDIMM_MODE_SEL; + } else { + VarStoreConfig->NvdimmModeSel =3D Value & DDR_NVDIMM_MODE_SEL_MASK; /*= Mask out valid bit */ + } + + return EFI_SUCCESS; +} + +/** + This is function stores meminfo to corresponding NVParam + + @param VarStoreConfig The contents for the variable. + + @retval EFI_SUCCESS Set data successfully. + @retval Other value Failed to set meminfo to NVParam + +**/ +EFI_STATUS +MemInfoNvparamSet ( + IN MEM_INFO_VARSTORE_DATA *VarStoreConfig + ) +{ + EFI_STATUS Status; + UINT32 Value, TmpValue, Value2, Update; + + ASSERT (VarStoreConfig !=3D NULL); + + /* Set DDR speed */ + Status =3D NVParamGet ( + NV_SI_DDR_SPEED, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status) || Value !=3D VarStoreConfig->DDRSpeedSel) { + Status =3D NVParamSet ( + NV_SI_DDR_SPEED, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + VarStoreConfig->DDRSpeedSel + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + + /* Set ECC mode */ + Status =3D NVParamGet ( + NV_SI_DDR_ECC_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status) || Value !=3D VarStoreConfig->EccMode) { + Status =3D NVParamSet ( + NV_SI_DDR_ECC_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + VarStoreConfig->EccMode + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + + /* Set ErrCtrl */ + TmpValue =3D (VarStoreConfig->ErrCtrl_DE << DDR_NVPARAM_ERRCTRL_DE_FIELD= _SHIFT) | + (VarStoreConfig->ErrCtrl_FI << DDR_NVPARAM_ERRCTRL_FI_FIELD_S= HIFT); + Status =3D NVParamGet ( + NV_SI_DDR_ERRCTRL, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status) || Value !=3D TmpValue ) { + Status =3D NVParamSet ( + NV_SI_DDR_ERRCTRL, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + TmpValue + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + + /* Set slave's 32bit region */ + TmpValue =3D VarStoreConfig->Slave32bit; + Status =3D NVParamGet ( + NV_SI_DDR_SLAVE_32BIT_MEM_EN, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status) || Value !=3D TmpValue ) { + if (TmpValue =3D=3D 0) { + /* Default is disabled so just clear nvparam */ + Status =3D NVParamClr ( + NV_SI_DDR_SLAVE_32BIT_MEM_EN, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC + ); + } else { + Status =3D NVParamSet ( + NV_SI_DDR_SLAVE_32BIT_MEM_EN, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + TmpValue + ); + } + if (EFI_ERROR (Status)) { + return Status; + } + } + + /* Set Scrub patrol */ + TmpValue =3D VarStoreConfig->ScrubPatrol; + Status =3D NVParamGet ( + NV_SI_DDR_SCRUB_EN, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status) || Value !=3D TmpValue ) { + if (TmpValue =3D=3D DDR_DEFAULT_SCRUB_PATROL_DURATION) { + Status =3D NVParamClr ( + NV_SI_DDR_SCRUB_EN, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC + ); + } else { + Status =3D NVParamSet ( + NV_SI_DDR_SCRUB_EN, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + TmpValue + ); + } + if (EFI_ERROR (Status)) { + return Status; + } + } + + /* Demand Scrub */ + TmpValue =3D VarStoreConfig->DemandScrub; + Status =3D NVParamGet ( + NV_SI_DDR_WR_BACK_EN, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status) || Value !=3D TmpValue ) { + if (TmpValue =3D=3D DDR_DEFAULT_DEMAND_SCRUB) { + Status =3D NVParamClr ( + NV_SI_DDR_WR_BACK_EN, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC + ); + } else { + Status =3D NVParamSet ( + NV_SI_DDR_WR_BACK_EN, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + TmpValue + ); + } + if (EFI_ERROR (Status)) { + return Status; + } + } + + /* Write CRC */ + TmpValue =3D VarStoreConfig->WriteCrc; + Status =3D NVParamGet ( + NV_SI_DDR_CRC_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status) || Value !=3D TmpValue ) { + if (TmpValue =3D=3D DDR_DEFAULT_WRITE_CRC) { + Status =3D NVParamClr ( + NV_SI_DDR_CRC_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC + ); + } else { + Status =3D NVParamSet ( + NV_SI_DDR_CRC_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + TmpValue + ); + } + if (EFI_ERROR (Status)) { + return Status; + } + } + + /* Write FGR/Refresh2X */ + Value =3D 0; + Update =3D 0; + TmpValue =3D VarStoreConfig->FGRMode; + Status =3D NVParamGet ( + NV_SI_DDR_REFRESH_GRANULARITY, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + Value2 =3D DDR_FGR_MODE_GET (Value); + if ((EFI_ERROR (Status) && TmpValue !=3D DDR_DEFAULT_FGR_MODE) + || Value2 !=3D TmpValue) + { + DDR_FGR_MODE_SET (Value, TmpValue); + Update =3D 1; + } + + Value2 =3D DDR_REFRESH_2X_GET (Value); + TmpValue =3D VarStoreConfig->Refresh2x; + if ((EFI_ERROR (Status) && TmpValue !=3D DDR_DEFAULT_REFRESH2X_MODE) + || Value2 !=3D TmpValue) + { + DDR_REFRESH_2X_SET (Value, TmpValue); + Update =3D 1; + } + + if (Update =3D=3D 1) { + Status =3D NVParamSet ( + NV_SI_DDR_REFRESH_GRANULARITY, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + Value + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + + /* Write NVDIMM-N Mode selection */ + Value =3D 0; + TmpValue =3D VarStoreConfig->NvdimmModeSel; + Status =3D NVParamGet ( + NV_SI_NVDIMM_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + Value2 =3D Value & DDR_NVDIMM_MODE_SEL_MASK; /* Mask out valid bit */ + if (EFI_ERROR (Status) || Value2 !=3D TmpValue ) { + if (TmpValue =3D=3D DDR_DEFAULT_NVDIMM_MODE_SEL) { + Status =3D NVParamClr ( + NV_SI_NVDIMM_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC + ); + } else { + Value =3D TmpValue | DDR_NVDIMM_MODE_SEL_VALID_BIT; /* Add valid bit= */ + Status =3D NVParamSet ( + NV_SI_NVDIMM_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + Value + ); + } + if (EFI_ERROR (Status)) { + return Status; + } + } + + return EFI_SUCCESS; +} diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreen= .c b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreen.c new file mode 100644 index 000000000000..3a1a5840db9d --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreen.c @@ -0,0 +1,1325 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "MemInfoScreen.h" + +#define MAX_STRING_SIZE 64 +#define GB_SCALE_FACTOR (1024*1024*1024) +#define MB_SCALE_FACTOR (1024*1024) + +EFI_GUID gMemInfoFormSetGuid =3D MEM_INFO_FORM_SET_GUID; + +HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath =3D { + { + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { + (UINT8)(sizeof (VENDOR_DEVICE_PATH)), + (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8) + } + }, + MEM_INFO_FORM_SET_GUID + }, + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + (UINT8)(END_DEVICE_PATH_LENGTH), + (UINT8)((END_DEVICE_PATH_LENGTH) >> 8) + } + } +}; + +EFI_HANDLE DriverHandle =3D NULL; +MEM_INFO_SCREEN_PRIVATE_DATA *mPrivateData =3D NULL; + +/** + This function allows a caller to extract the current configuration for o= ne + or more named elements from the target driver. + @param This Points to the EFI_HII_CONFIG_ACCESS_PROTO= COL. + @param Request A null-terminated Unicode string in + format. + @param Progress On return, points to a character in the R= equest + string. Points to the string's null termi= nator if + request was successful. Points to the mos= t recent + '&' before the first failing name/value p= air (or + the beginning of the string if the failur= e is in + the first name/value pair) if the request= was not + successful. + @param Results A null-terminated Unicode string in + format which has all valu= es filled + in for the names in the Request string. S= tring to + be allocated by the called function. + @retval EFI_SUCCESS The Results is filled with the requested = values. + @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown nam= e. + @retval EFI_NOT_FOUND Routing data doesn't match any storage in= this + driver. +**/ +EFI_STATUS +EFIAPI +ExtractConfig ( + IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, + IN CONST EFI_STRING Request, + OUT EFI_STRING *Progress, + OUT EFI_STRING *Results + ) +{ + EFI_STATUS Status; + UINTN BufferSize; + MEM_INFO_SCREEN_PRIVATE_DATA *PrivateData; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + EFI_STRING ConfigRequest; + EFI_STRING ConfigRequestHdr; + UINTN Size; + CHAR16 *StrPointer; + BOOLEAN AllocatedRequest; + + if (Progress =3D=3D NULL || Results =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Initialize the local variables. + // + ConfigRequestHdr =3D NULL; + ConfigRequest =3D NULL; + Size =3D 0; + *Progress =3D Request; + AllocatedRequest =3D FALSE; + + PrivateData =3D MEM_INFO_SCREEN_PRIVATE_FROM_THIS (This); + HiiConfigRouting =3D PrivateData->HiiConfigRouting; + + // + // Get Buffer Storage data from EFI variable. + // Try to get the current setting from variable. + // + BufferSize =3D sizeof (MEM_INFO_VARSTORE_DATA); + Status =3D MemInfoNvparamGet (&PrivateData->VarStoreConfig); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + if (Request =3D=3D NULL) { + // + // Request is set to NULL, construct full request string. + // + + // + // Allocate and fill a buffer large enough to hold the tem= plate + // followed by "&OFFSET=3D0&WIDTH=3DWWWWWWWWWWWWWWWW" followed by a Nu= ll-terminator + // + ConfigRequestHdr =3D HiiConstructConfigHdr (&gMemInfoFormSetGuid, MEM_= INFO_VARSTORE_NAME, PrivateData->DriverHandle); + Size =3D (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); + ConfigRequest =3D AllocateZeroPool (Size); + ASSERT (ConfigRequest !=3D NULL); + AllocatedRequest =3D TRUE; + UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=3D0&WIDTH=3D%016LX", C= onfigRequestHdr, (UINT64)BufferSize); + FreePool (ConfigRequestHdr); + ConfigRequestHdr =3D NULL; + } else { + // + // Check routing data in . + // Note: if only one Storage is used, then this checking could be skip= ped. + // + if (!HiiIsConfigHdrMatch (Request, &gMemInfoFormSetGuid, NULL)) { + return EFI_NOT_FOUND; + } + + // + // Set Request to the unified request string. + // + ConfigRequest =3D Request; + + // + // Check whether Request includes Request Element. + // + if (StrStr (Request, L"OFFSET") =3D=3D NULL) { + // + // Check Request Element does exist in Request String + // + StrPointer =3D StrStr (Request, L"PATH"); + if (StrPointer =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + if (StrStr (StrPointer, L"&") =3D=3D NULL) { + Size =3D (StrLen (Request) + 32 + 1) * sizeof (CHAR16); + ConfigRequest =3D AllocateZeroPool (Size); + ASSERT (ConfigRequest !=3D NULL); + AllocatedRequest =3D TRUE; + UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=3D0&WIDTH=3D%016LX= ", Request, (UINT64)BufferSize); + } + } + } + + // + // Check if requesting Name/Value storage + // + if (StrStr (ConfigRequest, L"OFFSET") =3D=3D NULL) { + // + // Don't have any Name/Value storage names + // + Status =3D EFI_SUCCESS; + } else { + // + // Convert buffer data to by helper function BlockToConfi= g() + // + Status =3D HiiConfigRouting->BlockToConfig ( + HiiConfigRouting, + ConfigRequest, + (UINT8 *)&PrivateData->VarStoreConfig, + BufferSize, + Results, + Progress + ); + } + + // + // Free the allocated config request string. + // + if (AllocatedRequest) { + FreePool (ConfigRequest); + } + + if (ConfigRequestHdr !=3D NULL) { + FreePool (ConfigRequestHdr); + } + // + // Set Progress string to the original request string. + // + if (Request =3D=3D NULL) { + *Progress =3D NULL; + } else if (StrStr (Request, L"OFFSET") =3D=3D NULL) { + *Progress =3D Request + StrLen (Request); + } + + return Status; +} + +/** + This function processes the results of changes in configuration. + @param This Points to the EFI_HII_CONFIG_ACCESS_PROTO= COL. + @param Configuration A null-terminated Unicode string in + format. + @param Progress A pointer to a string filled in with the = offset of + the most recent '&' before the first fail= ing + name/value pair (or the beginning of the = string if + the failure is in the first name/value pa= ir) or + the terminating NULL if all was successfu= l. + @retval EFI_SUCCESS The Results is processed successfully. + @retval EFI_INVALID_PARAMETER Configuration is NULL. + @retval EFI_NOT_FOUND Routing data doesn't match any storage in= this + driver. +**/ +EFI_STATUS +EFIAPI +RouteConfig ( + IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, + IN CONST EFI_STRING Configuration, + OUT EFI_STRING *Progress + ) +{ + EFI_STATUS Status; + UINTN BufferSize; + MEM_INFO_SCREEN_PRIVATE_DATA *PrivateData; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + + if (Configuration =3D=3D NULL || Progress =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + PrivateData =3D MEM_INFO_SCREEN_PRIVATE_FROM_THIS (This); + HiiConfigRouting =3D PrivateData->HiiConfigRouting; + *Progress =3D Configuration; + + // + // Check routing data in . + // Note: if only one Storage is used, then this checking could be skippe= d. + // + if (!HiiIsConfigHdrMatch (Configuration, &gMemInfoFormSetGuid, NULL)) { + return EFI_NOT_FOUND; + } + + // + // Get Buffer Storage data from NVParam + // + Status =3D MemInfoNvparamGet (&PrivateData->VarStoreConfig); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Check if configuring Name/Value storage + // + if (StrStr (Configuration, L"OFFSET") =3D=3D NULL) { + // + // Don't have any Name/Value storage names + // + return EFI_SUCCESS; + } + + // + // Convert to buffer data by helper function ConfigToBlock(= ) + // + BufferSize =3D sizeof (MEM_INFO_VARSTORE_DATA); + Status =3D HiiConfigRouting->ConfigToBlock ( + HiiConfigRouting, + Configuration, + (UINT8 *)&PrivateData->VarStoreConfig, + &BufferSize, + Progress + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Store Buffer Storage back to NVParam + // + Status =3D MemInfoNvparamSet (&PrivateData->VarStoreConfig); + + return Status; +} + +/** + This function processes the results of changes in configuration. + @param This Points to the EFI_HII_CONFIG_ACCESS_PROTO= COL. + @param Action Specifies the type of action taken by the= browser. + @param QuestionId A unique value which is sent to the origi= nal + exporting driver so that it can identify = the type + of data to expect. + @param Type The type of value for the question. + @param Value A pointer to the data being sent to the o= riginal + exporting driver. + @param ActionRequest On return, points to the action requested= by the + callback function. + @retval EFI_SUCCESS The callback successfully handled the act= ion. + @retval EFI_INVALID_PARAMETER Configuration is NULL. + @retval EFI_UNSUPPORTED The specified Action is not supported by = the + callback. +**/ +EFI_STATUS +EFIAPI +DriverCallback ( + IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, + IN EFI_BROWSER_ACTION Action, + IN EFI_QUESTION_ID QuestionId, + IN UINT8 Type, + IN EFI_IFR_TYPE_VALUE *Value, + OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest + ) +{ + if (((Value =3D=3D NULL) && (Action !=3D EFI_BROWSER_ACTION_FORM_OPEN) + && (Action !=3D EFI_BROWSER_ACTION_FORM_CLOSE)) + || (ActionRequest =3D=3D NULL)) + { + return EFI_INVALID_PARAMETER; + } + + switch (Action) { + case EFI_BROWSER_ACTION_FORM_OPEN: + case EFI_BROWSER_ACTION_FORM_CLOSE: + break; + + case EFI_BROWSER_ACTION_DEFAULT_STANDARD: + case EFI_BROWSER_ACTION_DEFAULT_MANUFACTURING: + { + switch (QuestionId) { + case MEM_INFO_DDR_SPEED_SEL_QUESTION_ID: + // + // DDR speed selection default to auto + // + Value->u32 =3D 0; + break; + + case MEM_INFO_FORM_PERFORMANCE_ECC_QUESTION_ID: + // + // ECC mode default to be enabled + // + Value->u32 =3D ECC_SECDED; + break; + + case MEM_INFO_FORM_PERFORMANCE_ERR_CTRL_DE_QUESTION_ID: + // + // ErrCtrl_DE default to be enabled + // + Value->u32 =3D ERRCTLR_DE_ENABLE; + break; + + case MEM_INFO_FORM_PERFORMANCE_ERR_CTRL_FI_QUESTION_ID: + // + // ErrCtrl_FI default to be enabled + // + Value->u32 =3D ERRCTLR_FI_ENABLE; + break; + + case MEM_INFO_DDR_SLAVE_32BIT_QUESTION_ID: + // + // Slave's 32bit region to be disabled + // + Value->u32 =3D 0; + break; + + case MEM_INFO_DDR_SCRUB_PATROL_QUESTION_ID: + Value->u32 =3D DDR_DEFAULT_SCRUB_PATROL_DURATION; + break; + + case MEM_INFO_DDR_DEMAND_SCRUB_QUESTION_ID: + Value->u32 =3D DDR_DEFAULT_DEMAND_SCRUB; + break; + + case MEM_INFO_DDR_WRITE_CRC_QUESTION_ID: + Value->u32 =3D DDR_DEFAULT_WRITE_CRC; + break; + + case MEM_INFO_FGR_MODE_QUESTION_ID: + Value->u32 =3D DDR_DEFAULT_FGR_MODE; + break; + + case MEM_INFO_REFRESH2X_MODE_QUESTION_ID: + Value->u32 =3D DDR_DEFAULT_REFRESH2X_MODE; + break; + + case MEM_INFO_FORM_NVDIMM_MODE_SEL_QUESTION_ID: + Value->u32 =3D DDR_DEFAULT_NVDIMM_MODE_SEL; + break; + } + } + break; + + case EFI_BROWSER_ACTION_RETRIEVE: + case EFI_BROWSER_ACTION_CHANGING: + case EFI_BROWSER_ACTION_SUBMITTED: + break; + + default: + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +MemInfoMainScreen ( + PLATFORM_INFO_HOB *PlatformHob + ) +{ + MEM_INFO_SCREEN_PRIVATE_DATA *PrivateData =3D mPrivateData; + EFI_STATUS Status; + VOID *StartOpCodeHandle; + VOID *OptionsOpCodeHandle; + VOID *OptionsOpCodeHandle1; + EFI_IFR_GUID_LABEL *StartLabel; + EFI_STRING_ID StringId; + VOID *EndOpCodeHandle; + EFI_IFR_GUID_LABEL *EndLabel; + CHAR16 Str[MAX_STRING_SIZE], Str1[MAX_STRING_SIZE]= ; + EFI_HOB_RESOURCE_DESCRIPTOR *ResHob; + PLATFORM_DIMM_INFO *DimmInfo; + UINT64 Size; + UINTN Count; + + // + // Get Buffer Storage data from EFI variable + // + Status =3D MemInfoNvparamGet (&PrivateData->VarStoreConfig); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D EFI_SUCCESS; + + /* Update Total memory */ + UnicodeSPrint (Str, sizeof (Str), L"%d GB", PlatformHob->DramInfo.TotalS= ize / GB_SCALE_FACTOR); + HiiSetString ( + PrivateData->HiiHandle, + STRING_TOKEN (STR_MEM_INFO_TOTAL_MEM_VALUE), + Str, + NULL + ); + + /* Update effective memory */ + Size =3D 0; + ResHob =3D (EFI_HOB_RESOURCE_DESCRIPTOR *)GetFirstHob (EFI_HOB_TYPE_RESO= URCE_DESCRIPTOR); + while (ResHob !=3D NULL) { + if ((ResHob->ResourceType =3D=3D EFI_RESOURCE_SYSTEM_MEMORY)) { + Size +=3D ResHob->ResourceLength; + } + ResHob =3D (EFI_HOB_RESOURCE_DESCRIPTOR *)GetNextHob (EFI_HOB_TYPE_RES= OURCE_DESCRIPTOR,(VOID *)((UINTN)ResHob + ResHob->Header.HobLength)); + } + UnicodeSPrint (Str, sizeof (Str), L"%d GB", Size / GB_SCALE_FACTOR); + HiiSetString ( + PrivateData->HiiHandle, + STRING_TOKEN (STR_MEM_INFO_EFFECT_MEM_VALUE), + Str, + NULL + ); + + /* Update current DDR speed */ + UnicodeSPrint (Str, sizeof (Str), L"%d MHz", PlatformHob->DramInfo.MaxSp= eed); + HiiSetString ( + PrivateData->HiiHandle, + STRING_TOKEN (STR_MEM_INFO_CURRENT_SPEED_VALUE), + Str, + NULL + ); + + // + // Initialize the container for dynamic opcodes + // + StartOpCodeHandle =3D HiiAllocateOpCodeHandle (); + ASSERT (StartOpCodeHandle !=3D NULL); + + EndOpCodeHandle =3D HiiAllocateOpCodeHandle (); + ASSERT (EndOpCodeHandle !=3D NULL); + + // + // Create Option OpCode to display speed configuration + // + OptionsOpCodeHandle =3D HiiAllocateOpCodeHandle (); + ASSERT (OptionsOpCodeHandle !=3D NULL); + + // + // Create Option OpCode to display FGR mode configuration + // + OptionsOpCodeHandle1 =3D HiiAllocateOpCodeHandle (); + ASSERT (OptionsOpCodeHandle1 !=3D NULL); + + // + // Create Hii Extend Label OpCode as the start opcode + // + StartLabel =3D (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (StartOpCodeHan= dle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); + StartLabel->ExtendOpCode =3D EFI_IFR_EXTEND_OP_LABEL; + StartLabel->Number =3D LABEL_UPDATE; + + // + // Create Hii Extend Label OpCode as the end opcode + // + EndLabel =3D (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (EndOpCodeHandle,= &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); + EndLabel->ExtendOpCode =3D EFI_IFR_EXTEND_OP_LABEL; + EndLabel->Number =3D LABEL_END; + + // + // Create a total mem title + // + HiiCreateTextOpCode ( + StartOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_TOTAL_MEM), + STRING_TOKEN (STR_MEM_INFO_TOTAL_MEM), + STRING_TOKEN (STR_MEM_INFO_TOTAL_MEM_VALUE) + ); + + // + // Create a effective mem title + // + HiiCreateTextOpCode ( + StartOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_EFFECT_MEM), + STRING_TOKEN (STR_MEM_INFO_EFFECT_MEM), + STRING_TOKEN (STR_MEM_INFO_EFFECT_MEM_VALUE) + ); + + // + // Create a current speed title + // + HiiCreateTextOpCode ( + StartOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_CURRENT_SPEED), + STRING_TOKEN (STR_MEM_INFO_CURRENT_SPEED), + STRING_TOKEN (STR_MEM_INFO_CURRENT_SPEED_VALUE) + ); + + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_SPEED_SELECT_VALUE0), + 0, + EFI_IFR_NUMERIC_SIZE_4, + 0 + ); + + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_SPEED_SELECT_VALUE1), + 0, + EFI_IFR_NUMERIC_SIZE_4, + 2133 + ); + + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_SPEED_SELECT_VALUE2), + 0, + EFI_IFR_NUMERIC_SIZE_4, + 2400 + ); + + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_SPEED_SELECT_VALUE3), + 0, + EFI_IFR_NUMERIC_SIZE_4, + 2666 + ); + + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_SPEED_SELECT_VALUE4), + 0, + EFI_IFR_NUMERIC_SIZE_4, + 2933 + ); + + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_SPEED_SELECT_VALUE5), + 0, + EFI_IFR_NUMERIC_SIZE_4, + 3200 + ); + + HiiCreateOneOfOpCode ( + StartOpCodeHandle, // Container for = dynamic created opcodes + MEM_INFO_DDR_SPEED_SEL_QUESTION_ID, // Question ID (o= r call it "key") + MEM_INFO_VARSTORE_ID, // VarStore ID + (UINT16)MEM_INFO_DDR_SPEED_SEL_OFFSET, // Offset in Buff= er Storage + STRING_TOKEN (STR_MEM_INFO_SPEED_SELECT_PROMPT), // Question promp= t text + STRING_TOKEN (STR_MEM_INFO_SPEED_SELECT_HELP), // Question help = text + EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED, // Question flag + EFI_IFR_NUMERIC_SIZE_4, // Data type of Q= uestion Value + OptionsOpCodeHandle, // Option Opcode = list + NULL // Default Opcode= is NULl + ); + + if (IsSlaveSocketActive ()) { + /* Display enable slave's 32bit region */ + HiiCreateCheckBoxOpCode ( + StartOpCodeHandle, // Container f= or dynamic created opcodes + MEM_INFO_DDR_SLAVE_32BIT_QUESTION_ID, // Question ID + MEM_INFO_VARSTORE_ID, // VarStore ID + (UINT16)MEM_INFO_ERR_SLAVE_32BIT_OFFSET, // Offset in B= uffer Storage + STRING_TOKEN (STR_MEM_INFO_ENABLE_32GB_SLAVE_PROMPT), // Question pr= ompt text + STRING_TOKEN (STR_MEM_INFO_ENABLE_32GB_SLAVE_HELP), // Question he= lp text + EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED, + 0, + NULL + ); + } + + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle1, + STRING_TOKEN (STR_MEM_INFO_FGR_MODE_VALUE0), + 0, + EFI_IFR_NUMERIC_SIZE_4, + 0 + ); + + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle1, + STRING_TOKEN (STR_MEM_INFO_FGR_MODE_VALUE1), + 0, + EFI_IFR_NUMERIC_SIZE_4, + 1 + ); + + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle1, + STRING_TOKEN (STR_MEM_INFO_FGR_MODE_VALUE2), + 0, + EFI_IFR_NUMERIC_SIZE_4, + 2 + ); + + HiiCreateOneOfOpCode ( + StartOpCodeHandle, // Container for = dynamic created opcodes + MEM_INFO_FGR_MODE_QUESTION_ID, // Question ID (o= r call it "key") + MEM_INFO_VARSTORE_ID, // VarStore ID + (UINT16)MEM_INFO_FGR_MODE_OFFSET, // Offset in Buff= er Storage + STRING_TOKEN (STR_MEM_INFO_FGR_MODE_PROMPT), // Question promp= t text + STRING_TOKEN (STR_MEM_INFO_FGR_MODE_HELP), // Question help = text + EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED, // Question flag + EFI_IFR_NUMERIC_SIZE_4, // Data type of Q= uestion Value + OptionsOpCodeHandle1, // Option Opcode = list + NULL // Default Opcode= is NULl + ); + + // + // Create a Goto OpCode to ras memory configuration + // + HiiCreateGotoOpCode ( + StartOpCodeHandle, // Container for dy= namic created opcodes + MEM_INFO_FORM_PERFORMANCE_ID, // Target Form ID + STRING_TOKEN (STR_MEM_INFO_PERFORMANCE_FORM), // Prompt text + STRING_TOKEN (STR_MEM_INFO_PERFORMANCE_FORM_HELP), // Help text + 0, // Question flag + MEM_INFO_FORM_PERFORMANCE_QUESTION_ID // Question ID + ); + + // + // Create a Goto OpCode to nvdimm-n configuration + // + HiiCreateGotoOpCode ( + StartOpCodeHandle, // Container for dynamic= created opcodes + MEM_INFO_FORM_NVDIMM_ID, // Target Form ID + STRING_TOKEN (STR_MEM_INFO_NVDIMM_FORM), // Prompt text + STRING_TOKEN (STR_MEM_INFO_NVDIMM_FORM_HELP), // Help text + 0, // Question flag + MEM_INFO_FORM_NVDIMM_QUESTION_ID // Question ID + ); + + // + // Display DIMM list info + // + HiiCreateSubTitleOpCode ( + StartOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_DIMM_INFO), + 0, + 0, + 0 + ); + + for (Count =3D 0; Count < PlatformHob->DimmList.BoardDimmSlots; Count++)= { + DimmInfo =3D &PlatformHob->DimmList.Dimm[Count].Info; + switch (DimmInfo->DimmType) { + case UDIMM: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"UDIMM"); + break; + + case RDIMM: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"RDIMM"); + break; + + case SODIMM: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"SODIMM"); + break; + + case LRDIMM: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"LRDIMM"); + break; + + case RSODIMM: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"RSODIMM"); + break; + + case NVRDIMM: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"NV-RDIMM"); + break; + + default: + UnicodeSPrint (Str, sizeof (Str), L"Unknown Type"); + } + if (DimmInfo->DimmStatus =3D=3D DIMM_INSTALLED_OPERATIONAL) { + UnicodeSPrint (Str1, sizeof (Str1), L"Slot %2d: %d GB %s Installed&O= perational", Count + 1, DimmInfo->DimmSize, Str); + } else if (DimmInfo->DimmStatus =3D=3D DIMM_NOT_INSTALLED) { + UnicodeSPrint (Str1, sizeof (Str1), L"Slot %2d: Not Installed", Coun= t + 1, PlatformHob->DimmList.Dimm[Count].NodeId); + } else if (DimmInfo->DimmStatus =3D=3D DIMM_INSTALLED_NONOPERATIONAL) = { + UnicodeSPrint (Str1, sizeof (Str1), L"Slot %2d: Installed&Non-Operat= ional", Count + 1, PlatformHob->DimmList.Dimm[Count].NodeId); + } else { + UnicodeSPrint (Str1, sizeof (Str1), L"Slot %2d: Installed&Failed", C= ount + 1, PlatformHob->DimmList.Dimm[Count].NodeId); + } + + StringId =3D HiiSetString (PrivateData->HiiHandle, 0, Str1, NULL); + + HiiCreateSubTitleOpCode ( + StartOpCodeHandle, + StringId, + 0, + 0, + 0 + ); + } + + HiiUpdateForm ( + PrivateData->HiiHandle, // HII handle + &gMemInfoFormSetGuid, // Formset GUID + MEM_INFO_FORM_ID, // Form ID + StartOpCodeHandle, // Label for where to insert opcodes + EndOpCodeHandle // Insert data + ); + + HiiFreeOpCodeHandle (StartOpCodeHandle); + HiiFreeOpCodeHandle (EndOpCodeHandle); + HiiFreeOpCodeHandle (OptionsOpCodeHandle); + + return Status; +} + +EFI_STATUS +MemInfoMainPerformanceScreen ( + PLATFORM_INFO_HOB *PlatformHob + ) +{ + EFI_STATUS Status; + MEM_INFO_SCREEN_PRIVATE_DATA *PrivateData =3D mPrivateData; + VOID *StartOpCodeHandle; + VOID *OptionsEccOpCodeHandle, *OptionsScrubOpCod= eHandle; + EFI_IFR_GUID_LABEL *StartLabel; + VOID *EndOpCodeHandle; + EFI_IFR_GUID_LABEL *EndLabel; + EFI_STRING_ID StringId; + CHAR16 Str[MAX_STRING_SIZE]; + UINTN Idx; + + Status =3D EFI_SUCCESS; + + // + // Initialize the container for dynamic opcodes + // + 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 (StartOpCodeHan= dle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); + StartLabel->ExtendOpCode =3D EFI_IFR_EXTEND_OP_LABEL; + StartLabel->Number =3D LABEL_UPDATE; + + // + // Create Hii Extend Label OpCode as the end opcode + // + EndLabel =3D (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (EndOpCodeHandle,= &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); + EndLabel->ExtendOpCode =3D EFI_IFR_EXTEND_OP_LABEL; + EndLabel->Number =3D LABEL_END; + + /* Display ECC mode selection */ + OptionsEccOpCodeHandle =3D HiiAllocateOpCodeHandle (); + ASSERT (OptionsEccOpCodeHandle !=3D NULL); + + UnicodeSPrint (Str, sizeof (Str), L"Disabled"); + StringId =3D HiiSetString (PrivateData->HiiHandle, 0, Str, NULL); + + HiiCreateOneOfOptionOpCode ( + OptionsEccOpCodeHandle, + StringId, + 0, + EFI_IFR_NUMERIC_SIZE_4, + 0 + ); + + UnicodeSPrint (Str, sizeof (Str), L"SECDED"); + StringId =3D HiiSetString (PrivateData->HiiHandle, 0, Str, NULL); + + HiiCreateOneOfOptionOpCode ( + OptionsEccOpCodeHandle, + StringId, + 0, + EFI_IFR_NUMERIC_SIZE_4, + 1 + ); + + UnicodeSPrint (Str, sizeof (Str), L"Symbol"); + StringId =3D HiiSetString (PrivateData->HiiHandle, 0, Str, NULL); + + HiiCreateOneOfOptionOpCode ( + OptionsEccOpCodeHandle, + StringId, + 0, + EFI_IFR_NUMERIC_SIZE_4, + 2 + ); + + HiiCreateOneOfOpCode ( + StartOpCodeHandle, // Container for = dynamic created opcodes + MEM_INFO_FORM_PERFORMANCE_ECC_QUESTION_ID, // Question ID (o= r call it "key") + MEM_INFO_VARSTORE_ID, // VarStore ID + (UINT16)MEM_INFO_ECC_MODE_SEL_OFFSET, // Offset in Buff= er Storage + STRING_TOKEN (STR_MEM_INFO_ENABLE_ECC_PROMPT), // Question promp= t text + STRING_TOKEN (STR_MEM_INFO_ENABLE_ECC_HELP), // Question help = text + EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED, // Question flag + EFI_IFR_NUMERIC_SIZE_4, // Data type of Q= uestion Value + OptionsEccOpCodeHandle, // Option Opcode = list + NULL // Default Opcode= is NULl + ); + + /* + * Display ErrCtrl options + */ + HiiCreateCheckBoxOpCode ( + StartOpCodeHandle, // Container for= dynamic created opcodes + MEM_INFO_FORM_PERFORMANCE_ERR_CTRL_DE_QUESTION_ID, // Question ID + MEM_INFO_VARSTORE_ID, // VarStore ID + (UINT16)MEM_INFO_ERR_CTRL_DE_MODE_SEL_OFFSET, // Offset in Buf= fer Storage + STRING_TOKEN (STR_MEM_INFO_ENABLE_ERRCTRL_DE_PROMPT), // Question prom= pt text + STRING_TOKEN (STR_MEM_INFO_ENABLE_ERRCTRL_DE_HELP), // Question help= text + EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED, + 0, + NULL + ); + + HiiCreateCheckBoxOpCode ( + StartOpCodeHandle, // Container for= dynamic created opcodes + MEM_INFO_FORM_PERFORMANCE_ERR_CTRL_FI_QUESTION_ID, // Question ID + MEM_INFO_VARSTORE_ID, // VarStore ID + (UINT16)MEM_INFO_ERR_CTRL_FI_MODE_SEL_OFFSET, // Offset in Buf= fer Storage + STRING_TOKEN (STR_MEM_INFO_ENABLE_ERRCTRL_FI_PROMPT), // Question prom= pt text + STRING_TOKEN (STR_MEM_INFO_ENABLE_ERRCTRL_FI_HELP), // Question help= text + EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED, + 0, + NULL + ); + + /* Display Scrub Patrol selection */ + OptionsScrubOpCodeHandle =3D HiiAllocateOpCodeHandle (); + ASSERT (OptionsScrubOpCodeHandle !=3D NULL); + + UnicodeSPrint (Str, sizeof (Str), L"Disabled"); + StringId =3D HiiSetString (PrivateData->HiiHandle, 0, Str, NULL); + + HiiCreateOneOfOptionOpCode ( + OptionsScrubOpCodeHandle, + StringId, + 0, + EFI_IFR_NUMERIC_SIZE_4, + 0 + ); + + for (Idx =3D 1; Idx <=3D MAX_NUMBER_OF_HOURS_IN_A_DAY; Idx++) { + UnicodeSPrint (Str, sizeof (Str), L"%d", Idx); + StringId =3D HiiSetString ( + PrivateData->HiiHandle, + 0, + Str, + NULL + ); + HiiCreateOneOfOptionOpCode ( + OptionsScrubOpCodeHandle, + StringId, + 0, + EFI_IFR_NUMERIC_SIZE_4, + Idx + ); + } + + HiiCreateOneOfOpCode ( + StartOpCodeHandle, // Container for = dynamic created opcodes + MEM_INFO_DDR_SCRUB_PATROL_QUESTION_ID, // Question ID (o= r call it "key") + MEM_INFO_VARSTORE_ID, // VarStore ID + (UINT16)MEM_INFO_DDR_SCRUB_OFFSET, // Offset in Buff= er Storage + STRING_TOKEN (STR_MEM_INFO_ENABLE_SCRUB), // Question promp= t text + STRING_TOKEN (STR_MEM_INFO_ENABLE_SCRUB_HELP), // Question help = text + EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED, // Question flag + EFI_IFR_NUMERIC_SIZE_4, // Data type of Q= uestion Value + OptionsScrubOpCodeHandle, // Option Opcode = list + NULL // Default Opcode= is NULl + ); + + /* + * Display Demand Scrub options + */ + HiiCreateCheckBoxOpCode ( + StartOpCodeHandle, // Container f= or dynamic created opcodes + MEM_INFO_DDR_DEMAND_SCRUB_QUESTION_ID, // Question ID + MEM_INFO_VARSTORE_ID, // VarStore ID + (UINT16)MEM_INFO_DDR_DEMAND_SCRUB_OFFSET, // Offset in B= uffer Storage + STRING_TOKEN (STR_MEM_INFO_ENABLE_DEMAND_SCRUB_PROMPT), // Question pr= ompt text + STRING_TOKEN (STR_MEM_INFO_ENABLE_DEMAND_SCRUB_HELP), // Question he= lp text + EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED, + 0, + NULL + ); + + /* + * Display Write CRC options + */ + HiiCreateCheckBoxOpCode ( + StartOpCodeHandle, // Container for = dynamic created opcodes + MEM_INFO_DDR_WRITE_CRC_QUESTION_ID, // Question ID + MEM_INFO_VARSTORE_ID, // VarStore ID + (UINT16)MEM_INFO_DDR_WRITE_CRC_OFFSET, // Offset in Buff= er Storage + STRING_TOKEN (STR_MEM_INFO_ENABLE_WRITE_CRC_PROMPT), // Question promp= t text + STRING_TOKEN (STR_MEM_INFO_ENABLE_WRITE_CRC_HELP), // Question help = text + EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED, + 0, + NULL + ); + + /* + * Display CVE-2020-10255 options + */ + HiiCreateCheckBoxOpCode ( + StartOpCodeHandle, // Container for dy= namic created opcodes + MEM_INFO_REFRESH2X_MODE_QUESTION_ID, // Question ID + MEM_INFO_VARSTORE_ID, // VarStore ID + (UINT16)MEM_INFO_REFRESH2X_MODE_OFFSET, // Offset in Buffer= Storage + STRING_TOKEN (STR_MEM_INFO_REFRESH2X_MODE_PROMPT), // Question prompt = text + STRING_TOKEN (STR_MEM_INFO_REFRESH2X_MODE_HELP), // Question help te= xt + EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED, + 0, + NULL + ); + + HiiUpdateForm ( + PrivateData->HiiHandle, // HII handle + &gMemInfoFormSetGuid, // Formset GUID + MEM_INFO_FORM_PERFORMANCE_ID, // Form ID + StartOpCodeHandle, // Label for where to insert opco= des + EndOpCodeHandle // Insert data + ); + + HiiFreeOpCodeHandle (StartOpCodeHandle); + HiiFreeOpCodeHandle (EndOpCodeHandle); + HiiFreeOpCodeHandle (OptionsEccOpCodeHandle); + HiiFreeOpCodeHandle (OptionsScrubOpCodeHandle); + + return Status; +} + +EFI_STATUS +MemInfoMainNvdimmScreen ( + PLATFORM_INFO_HOB *PlatformHob + ) +{ + EFI_STATUS Status; + MEM_INFO_SCREEN_PRIVATE_DATA *PrivateData; + VOID *StartOpCodeHandle; + VOID *OptionsOpCodeHandle; + EFI_IFR_GUID_LABEL *StartLabel; + VOID *EndOpCodeHandle; + EFI_IFR_GUID_LABEL *EndLabel; + CHAR16 Str[MAX_STRING_SIZE]; + + Status =3D EFI_SUCCESS; + PrivateData =3D mPrivateData; + + if (PlatformHob =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Initialize the container for dynamic opcodes + // + 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) + ); + StartLabel->ExtendOpCode =3D EFI_IFR_EXTEND_OP_LABEL; + StartLabel->Number =3D LABEL_UPDATE; + + // + // Create Hii Extend Label OpCode as the end opcode + // + EndLabel =3D (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode ( + EndOpCodeHandle, + &gEfiIfrTianoGuid, + NULL, + sizeof (EFI_IFR_GUID_LABEL) + ); + EndLabel->ExtendOpCode =3D EFI_IFR_EXTEND_OP_LABEL; + EndLabel->Number =3D LABEL_END; + + // + // Update Current NVDIMM-N Mode title Socket0 + // + switch (PlatformHob->DramInfo.NvdimmMode[0]) { + case 0: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"Non-NVDIMM"); + break; + + case 1: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"Non-Hashed"); + break; + + case 2: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"Hashed"); + break; + + default: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"Unknown"); + break; + } + + HiiSetString ( + PrivateData->HiiHandle, + STRING_TOKEN (STR_MEM_INFO_NVDIMM_CUR_MODE_SK0_VALUE), + Str, + NULL + ); + + HiiCreateTextOpCode ( + StartOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_NVDIMM_CUR_MODE_SK0), + STRING_TOKEN (STR_MEM_INFO_NVDIMM_CUR_MODE_SK0), + STRING_TOKEN (STR_MEM_INFO_NVDIMM_CUR_MODE_SK0_VALUE) + ); + + // + // Update Current NVDIMM-N Mode title Socket1 + // + if (IsSlaveSocketActive ()) { + switch (PlatformHob->DramInfo.NvdimmMode[1]) { + case 0: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"Non-NVDIMM"); + break; + + case 1: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"Non-Hashed"); + break; + + case 2: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"Hashed"); + break; + + default: + UnicodeSPrint (Str, sizeof (Str), L"%s", L"Unknown"); + break; + } + + HiiSetString ( + PrivateData->HiiHandle, + STRING_TOKEN (STR_MEM_INFO_NVDIMM_CUR_MODE_SK1_VALUE), + Str, + NULL + ); + + HiiCreateTextOpCode ( + StartOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_NVDIMM_CUR_MODE_SK1), + STRING_TOKEN (STR_MEM_INFO_NVDIMM_CUR_MODE_SK1), + STRING_TOKEN (STR_MEM_INFO_NVDIMM_CUR_MODE_SK1_VALUE) + ); + } + // + // Create Option OpCode to NVDIMM-N Mode Selection + // + OptionsOpCodeHandle =3D HiiAllocateOpCodeHandle (); + ASSERT (OptionsOpCodeHandle !=3D NULL); + + // + // Create OpCode to NVDIMM-N Mode Selection + // + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_NVDIMM_MODE_SEL_VALUE0), + 0, + EFI_IFR_NUMERIC_SIZE_4, + 0 + ); + + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_NVDIMM_MODE_SEL_VALUE1), + 0, + EFI_IFR_NUMERIC_SIZE_4, + 1 + ); + + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_NVDIMM_MODE_SEL_VALUE2), + 0, + EFI_IFR_NUMERIC_SIZE_4, + 2 + ); + + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle, + STRING_TOKEN (STR_MEM_INFO_NVDIMM_MODE_SEL_VALUE3), + 0, + EFI_IFR_NUMERIC_SIZE_4, + 3 + ); + + HiiCreateOneOfOpCode ( + StartOpCodeHandle, // Container for = dynamic created opcodes + MEM_INFO_FORM_NVDIMM_MODE_SEL_QUESTION_ID, // Question ID (o= r call it "key") + MEM_INFO_VARSTORE_ID, // VarStore ID + (UINT16)MEM_INFO_NVDIMM_MODE_SEL_OFFSET, // Offset in Buff= er Storage + STRING_TOKEN (STR_MEM_INFO_NVDIMM_MODE_SEL_PROMPT), // Question promp= t text + STRING_TOKEN (STR_MEM_INFO_NVDIMM_MODE_SEL_HELP), // Question help = text + EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED, // Question flag + EFI_IFR_NUMERIC_SIZE_4, // Data type of Q= uestion Value + OptionsOpCodeHandle, // Option Opcode = list + NULL // Default Opcode= is NULl + ); + + HiiUpdateForm ( + PrivateData->HiiHandle, // HII handle + &gMemInfoFormSetGuid, // Formset GUID + MEM_INFO_FORM_NVDIMM_ID, // Form ID + StartOpCodeHandle, // Label for where to insert opco= des + EndOpCodeHandle // Insert data + ); + + HiiFreeOpCodeHandle (StartOpCodeHandle); + HiiFreeOpCodeHandle (EndOpCodeHandle); + HiiFreeOpCodeHandle (OptionsOpCodeHandle); + + return Status; +} + +/** + This function sets up the first elements of the form. + @param PrivateData Private data. + @retval EFI_SUCCESS The form is set up successfully. +**/ +EFI_STATUS +MemInfoScreenSetup ( + VOID + ) +{ + EFI_STATUS Status; + VOID *Hob; + PLATFORM_INFO_HOB *PlatformHob; + + /* Get the Platform HOB */ + Hob =3D GetFirstGuidHob (&gPlatformHobGuid); + if (Hob =3D=3D NULL) { + return EFI_DEVICE_ERROR; + } + PlatformHob =3D (PLATFORM_INFO_HOB *)GET_GUID_HOB_DATA (Hob); + + Status =3D MemInfoMainScreen (PlatformHob); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D MemInfoMainPerformanceScreen (PlatformHob); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D MemInfoMainNvdimmScreen (PlatformHob); + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +MemInfoScreenInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HII_HANDLE HiiHandle; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + BOOLEAN ActionFlag; + EFI_STRING ConfigRequestHdr; + + // + // Initialize driver private data + // + mPrivateData =3D AllocateZeroPool (sizeof (MEM_INFO_SCREEN_PRIVATE_DATA)= ); + if (mPrivateData =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + mPrivateData->Signature =3D MEM_INFO_SCREEN_PRIVATE_DATA_SIGNATURE; + + mPrivateData->ConfigAccess.ExtractConfig =3D ExtractConfig; + mPrivateData->ConfigAccess.RouteConfig =3D RouteConfig; + mPrivateData->ConfigAccess.Callback =3D DriverCallback; + + // + // Locate ConfigRouting protocol + // + Status =3D gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL,= (VOID **)&HiiConfigRouting); + if (EFI_ERROR (Status)) { + return Status; + } + mPrivateData->HiiConfigRouting =3D HiiConfigRouting; + + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &DriverHandle, + &gEfiDevicePathProtocolGuid, + &mHiiVendorDevicePath, + &gEfiHiiConfigAccessProtocolGuid, + &mPrivateData->ConfigAccess, + NULL + ); + ASSERT_EFI_ERROR (Status); + + mPrivateData->DriverHandle =3D DriverHandle; + + // + // Publish our HII data + // + HiiHandle =3D HiiAddPackages ( + &gMemInfoFormSetGuid, + DriverHandle, + MemInfoDxeStrings, + MemInfoScreenVfrBin, + NULL + ); + if (HiiHandle =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + mPrivateData->HiiHandle =3D HiiHandle; + + // + // Try to read NV config EFI variable first + // + ConfigRequestHdr =3D HiiConstructConfigHdr ( + &gMemInfoFormSetGuid, + MEM_INFO_VARSTORE_NAME, + DriverHandle + ); + ASSERT (ConfigRequestHdr !=3D NULL); + + // + // Validate Current Setting + // + ActionFlag =3D HiiValidateSettings (ConfigRequestHdr); + if (!ActionFlag) { + MemInfoScreenUnload (ImageHandle); + return EFI_INVALID_PARAMETER; + } + FreePool (ConfigRequestHdr); + + Status =3D MemInfoScreenSetup (); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +EFI_STATUS +MemInfoScreenUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + ASSERT (mPrivateData !=3D NULL); + + if (DriverHandle !=3D NULL) { + gBS->UninstallMultipleProtocolInterfaces ( + DriverHandle, + &gEfiDevicePathProtocolGuid, + &mHiiVendorDevicePath, + &gEfiHiiConfigAccessProtocolGuid, + &mPrivateData->ConfigAccess, + NULL + ); + DriverHandle =3D NULL; + } + + if (mPrivateData->HiiHandle !=3D NULL) { + HiiRemovePackages (mPrivateData->HiiHandle); + } + + FreePool (mPrivateData); + mPrivateData =3D NULL; + + return EFI_SUCCESS; +} diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.un= i b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.uni new file mode 100644 index 000000000000..a8c7cb99d6a7 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.uni @@ -0,0 +1,9 @@ +// +// Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// + +#string STR_MODULE_ABSTRACT #language en-US "An Altra DDR scre= en setup driver" + +#string STR_MODULE_DESCRIPTION #language en-US "This driver expos= es a screen setup for DDR information and configuration." diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxeExt= ra.uni b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxeExtra.u= ni new file mode 100644 index 000000000000..f44f210594be --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxeExtra.uni @@ -0,0 +1,9 @@ +// +// Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"Ampere Altra MemInfo DXE Driver" diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreen= Strings.uni b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScree= nStrings.uni new file mode 100644 index 000000000000..d170f9ee7313 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoScreenStrings= .uni @@ -0,0 +1,64 @@ +=EF=BB=BF// +// Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// + +#langdef en-US "English" // English + +#string STR_MEM_INFO_FORM #language en-US "Memory Config= uration" +#string STR_MEM_INFO_FORM_HELP #language en-US "Memory Config= uration" +#string STR_MEM_INFO_TOTAL_MEM #language en-US "Total Memory" +#string STR_MEM_INFO_TOTAL_MEM_VALUE #language en-US "0 GB" +#string STR_MEM_INFO_EFFECT_MEM #language en-US "Effective Mem= ory" +#string STR_MEM_INFO_EFFECT_MEM_VALUE #language en-US "0 MB" +#string STR_MEM_INFO_CURRENT_SPEED #language en-US "Memory Speed" +#string STR_MEM_INFO_CURRENT_SPEED_VALUE #language en-US "0 MHz" +#string STR_MEM_INFO_SPEED_SELECT_PROMPT #language en-US "Memory Operat= ing Speed Selection" +#string STR_MEM_INFO_SPEED_SELECT_HELP #language en-US "Force specifi= c Memory Operating Speed or use Auto setting." +#string STR_MEM_INFO_SPEED_SELECT_VALUE0 #language en-US "Auto" +#string STR_MEM_INFO_SPEED_SELECT_VALUE1 #language en-US "2133" +#string STR_MEM_INFO_SPEED_SELECT_VALUE2 #language en-US "2400" +#string STR_MEM_INFO_SPEED_SELECT_VALUE3 #language en-US "2666" +#string STR_MEM_INFO_SPEED_SELECT_VALUE4 #language en-US "2933" +#string STR_MEM_INFO_SPEED_SELECT_VALUE5 #language en-US "3200" +#string STR_MEM_INFO_DIMM_INFO #language en-US "DIMM Informat= ion" + +#string STR_MEM_INFO_PERFORMANCE_FORM #language en-US "Memory= RAS and Performance Configuration" +#string STR_MEM_INFO_PERFORMANCE_FORM_HELP #language en-US "Displa= ys and provides options to change the memory RAS and performance Settings" +#string STR_MEM_INFO_ENABLE_ECC_PROMPT #language en-US "ECC mo= de" +#string STR_MEM_INFO_ENABLE_ECC_HELP #language en-US "ECC mo= de: Disabled, SECDED or Symbol" +#string STR_MEM_INFO_ENABLE_ERRCTRL_DE_PROMPT #language en-US "Defer = uncorrectable read errors" +#string STR_MEM_INFO_ENABLE_ERRCTRL_DE_HELP #language en-US "When e= nabled the DMC defers uncorrectable read errors to the consumer by sending = an OK response and setting the TXDAT poison flag on the CHI-B interconnect.= If this bit is clear the DMC defaults to non-deferred behavior when encoun= tering an unrecoverable error" +#string STR_MEM_INFO_ENABLE_ERRCTRL_FI_PROMPT #language en-US "Fault = handling interrupt" +#string STR_MEM_INFO_ENABLE_ERRCTRL_FI_HELP #language en-US "Enable= s fault handling interrupt. The fault handling interrupt is raised to give = notice that ECC fault has been recorded" +#string STR_MEM_INFO_ENABLE_SCRUB #language en-US "Scrub = Patrol duration (hour)" +#string STR_MEM_INFO_ENABLE_SCRUB_HELP #language en-US "Select= duration (hour) for Scrub Patrol" +#string STR_MEM_INFO_ENABLE_DEMAND_SCRUB_PROMPT #language en-US "Demand= scrub" +#string STR_MEM_INFO_ENABLE_DEMAND_SCRUB_HELP #language en-US "Enable= /Disable the ability to write corrected data back to the memory once a corr= ectable error is detected" +#string STR_MEM_INFO_ENABLE_WRITE_CRC_PROMPT #language en-US "Write = CRC" +#string STR_MEM_INFO_ENABLE_WRITE_CRC_HELP #language en-US "Enable= /Disable Cyclic Redundancy Check (CRC) functionality on write data. Be note= d that enabling CRC will degrade Write bandwidth" + + +#string STR_MEM_INFO_ENABLE_32GB_SLAVE_PROMPT #language en-US "Enable= Slave 32bit memory region" +#string STR_MEM_INFO_ENABLE_32GB_SLAVE_HELP #language en-US "Enable= s 32bit memory region (2GB) for slave socket" +#string STR_MEM_INFO_FGR_MODE_PROMPT #language en-US "Fine G= ranularity Refresh (FGR)" +#string STR_MEM_INFO_FGR_MODE_VALUE0 #language en-US "1x" +#string STR_MEM_INFO_FGR_MODE_VALUE1 #language en-US "2x" +#string STR_MEM_INFO_FGR_MODE_VALUE2 #language en-US "4x" +#string STR_MEM_INFO_FGR_MODE_HELP #language en-US "Select= DDR Fine Granularity Refresh (FGR) mode 1x/2x/4x" +#string STR_MEM_INFO_REFRESH2X_MODE_PROMPT #language en-US "CVE-20= 20-10255 mitigation" +#string STR_MEM_INFO_REFRESH2X_MODE_HELP #language en-US "Enable= mitigation for CVE-2020-10255, TRRespass" + +#string STR_MEM_INFO_NVDIMM_FORM #language en-US "NVDIMM= -N Configuration" +#string STR_MEM_INFO_NVDIMM_FORM_HELP #language en-US "Displa= ys and provides options to change the NVDIMM-N Settings" +#string STR_MEM_INFO_NVDIMM_CUR_MODE_SK0 #language en-US "Socket= 0 Configured Mode" +#string STR_MEM_INFO_NVDIMM_CUR_MODE_SK1 #language en-US "Socket= 1 Configured Mode" +#string STR_MEM_INFO_NVDIMM_CUR_MODE_SK0_VALUE #language en-US "Non-NV= DIMM" +#string STR_MEM_INFO_NVDIMM_CUR_MODE_SK1_VALUE #language en-US "Non-NV= DIMM" +#string STR_MEM_INFO_NVDIMM_MODE_SEL_PROMPT #language en-US "Mode S= election" +#string STR_MEM_INFO_NVDIMM_MODE_SEL_VALUE0 #language en-US "Non-NV= DIMM" +#string STR_MEM_INFO_NVDIMM_MODE_SEL_VALUE1 #language en-US "Non-Ha= shed" +#string STR_MEM_INFO_NVDIMM_MODE_SEL_VALUE2 #language en-US "Hashed= " +#string STR_MEM_INFO_NVDIMM_MODE_SEL_VALUE3 #language en-US "Auto" +#string STR_MEM_INFO_NVDIMM_MODE_SEL_HELP #language en-US "Select= NVDIMM-N Mode (Non-NVDIMM/Non-Hashed/Hashed/Auto)" --=20 2.17.1