From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.137]) by mx.groups.io with SMTP id smtpd.web10.9756.1637167874855866773 for ; Wed, 17 Nov 2021 08:51:15 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@os.amperecomputing.com header.s=selector2 header.b=eARqJNPs; spf=pass (domain: os.amperecomputing.com, ip: 40.107.243.137, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GUbXa9jZ2tcZJXmkr4KjqKPAjfl/8klkCXQNGiUlWm3IIml+5ksIbCCUuQwyKcop/v10GXmy2GHiI10edMilLE+DZEm3JfAgG3EuLqeQsZB3+DS/GMkC4h2qvVXXCPRPZ7LYg8p4oJZI7FOdtXaEniFOtHfZ2nq8omU79LXJILJeZQHso8JK+aqSyQ92pcayA5CK7FGUDOexjeT73vP+blGQ9l42IrE6pNVymefkKEmlDtoMD1YH1OTr/zjQvQoO147W3oipsKbcnXyfmen3ckng854bvQhzBhnST82qFEsHNYXb7cMjUpVxaL2OlNig+XPcVdrsl/tEw3laTfsprw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DYe2ZQ9GvlEyFz/ruEq6Qb6P5QVQkjF+Lqjl1fLbWzA=; b=mKaHRzVvU2yWSFk9KKOG/T0TOykTM4tYRhU38ECaCg6vf+30XTEMwtKm/F+FGCb1SuCDceEWmdBgyG3rWzFXOzJrjmO0yWHzQqxs7HKWICHGpy3VIy8TH5NL3nR+H9VQZ4TI52H8DV6/cS8OpiQrXQ7dDtXhthlK5TZiTbrqPAXcIkGN7LeiFRjIibmpXHNOMrWzPT7JoT+W/41SSm4/thY0jkfZaqkxNy54Rxnl4pZ8LAieEieyT+oU1aN9nM7jYMhih8OpCX83gM4w9VhN1RJhjQ1Xb5kv5vLwoovyVC2lcfcOoxh2WCst3495Yhm7Mwmm+GdH+61Sw9IpGMTNxA== 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=DYe2ZQ9GvlEyFz/ruEq6Qb6P5QVQkjF+Lqjl1fLbWzA=; b=eARqJNPs7zm9YNMBsuZpISBsiy9mVRFrdecii/TzpbqczbVhNTRsfLRPG+4f+D3Ww5v52JWzRp9yJstxiugopG+UPS+nGdfJL2/KrrzZnnA/g+zhMk0/TLtTgV2gkS25MpcPyRZ6ZnV8t3YOiXDkgzs4LIvUtQS8QMn/eLPZDhA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) by PH0PR01MB7400.prod.exchangelabs.com (2603:10b6:510:10b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19; Wed, 17 Nov 2021 16:51:13 +0000 Received: from PH0PR01MB7287.prod.exchangelabs.com ([fe80::254c:9533:7f35:aee]) by PH0PR01MB7287.prod.exchangelabs.com ([fe80::254c:9533:7f35:aee%4]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 16:51:13 +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: [edk2-platforms][PATCH v5 30/30] AmpereAltraPkg: Add configuration screen for Watchdog timer Date: Wed, 17 Nov 2021 23:47:27 +0700 Message-ID: <20211117164727.10922-31-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211117164727.10922-1-nhi@os.amperecomputing.com> References: <20211117164727.10922-1-nhi@os.amperecomputing.com> X-ClientProxiedBy: HKAPR04CA0001.apcprd04.prod.outlook.com (2603:1096:203:d0::11) To PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 Received: from sw004.amperecomputing.com (118.69.219.201) by HKAPR04CA0001.apcprd04.prod.outlook.com (2603:1096:203:d0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.21 via Frontend Transport; Wed, 17 Nov 2021 16:51:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae55fa27-a016-42d9-5de1-08d9a9ea7682 X-MS-TrafficTypeDiagnostic: PH0PR01MB7400: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bV1ti0mEwuWXt0ksocbUMCFuU6rA791V+2nh0w1XQORvODAPAPM9+L9qkiObDFRiAxZ6SGJmu1BnOxYBje4jXMNDAi27AG0R1xDR94cpJUpLv5Z/1OwCb0AFDfj5yfm8SRSCkZPW2dp2MevLPKDgOgDM7PNbFlv8jJ1f3IufvuGKY/AsILroosY3dQmY9TMxNP1XBHGAddATVSzC65NrG3IryelmPDys1kZ8Ip5KEmsuLwk3U2tsojV/knAOHBdLbY9sbEPvsLh2sfMWRvdOF3AzoySKrBDHBTHDo86YfCFhpJv2ytRkBsmxrUSi4X1+32MIdXB8npVul2I/o7GORzvyVU7zr5ATX9/PHiAXyLn+LqkTP316U2MHg1lZzQmSQGG670Wja2L5ymFaKQYcydoXXW5TfMhZlvMDUQ/JBTyJ96xfgptesTONJdWpRZ+aijcmzxci9LtnKtdPkOuErc1x1CKpiJarfligQYvW0sf8yR2heffcYK77HomM2cQIOwDtOjzKFW4zXiMO8N/FC+PSruDxuQPMftPlc63PlhVDfeBnw0wVxSAT41rM+FqTiYJk1mt3r3YIKssCzvB2okdDLKDAv1Av+NgPsU/94Ii064hGtw9VK8sKHUxdo8G2Ei3Kp5ogxFQr+m1GrtadlmkwqJ4nvfkfhBQzaRpzMonvpoYBEmNjm1+nahIOWCfyX3h5bI5IhmrJY//Gqv6/BWraaELv2KWAHfujZFERU807ZP0OrCvv/fRvrwruKIN61oc7L/fHg4Jy0XOTCRYus64VSHfYA56zkaGzmmEpua0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR01MB7287.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(30864003)(956004)(508600001)(186003)(38100700002)(6666004)(83380400001)(6486002)(52116002)(66574015)(66476007)(66946007)(2616005)(66556008)(1076003)(54906003)(8676002)(38350700002)(4326008)(316002)(6512007)(8936002)(2906002)(6916009)(5660300002)(6506007)(86362001)(26005)(290074003)(171213001)(44824005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?rYHDG0F9Ph2jDRBeCHwIdlKiZVOXdpMsR6qVEW6aejfVwwPOMkrUF7GF13Fk?= =?us-ascii?Q?mXX9wKoBhVCVTmkMc095pvY+ZtKuVJx8OgX8alpogCxgTBuABHYZXK9YYf+V?= =?us-ascii?Q?/H0uWUPrceWn5LUuHYU3KhuHiB/w53dIKUR6tUpbmPNnQQsg8rPxYuKf6NFR?= =?us-ascii?Q?QkLZUnFWerGOzLReLv7u7y8yZIweIgmnnpAmQU+wU2IS5u4yTF4qyQhlG0oD?= =?us-ascii?Q?r1Zjk2WABAH/CALuePyDA1pV2Mm0zfVTxEMkKmU+T9yKSpTZAmvYNrctREV6?= =?us-ascii?Q?eSop2OWnJf6zEfyKpJ6Qu7+Y1Aq7q4nG38e7cFCbKwk8+sWQ1530pyneOYQB?= =?us-ascii?Q?9Fo8475/JwJkdBzljYXTyO1jZSPS9F7SSD0nJ2BIN0mR3nCIP4ZbUNGEH7Yj?= =?us-ascii?Q?oXaVtpcUPHjw0IKk6KpUfylbW6G+1WUzXbWxlS3ABBk6dIXvNa3e3Fh/ANOq?= =?us-ascii?Q?yS/9mfzRKqAzRUHj9ZydnUP4q4+fHSJrgrsYs7NdgalaSAwPEW7/FGoL4agT?= =?us-ascii?Q?ZR+vTnTaExDqkhCM0+xfsqSi7ZmMPWB8fsO/mE3hL1ViNiT9hKECxzyRAMxj?= =?us-ascii?Q?K6+rsVgTv8idAlrU2gMixgrxahKhghkfBBZ9VMgKlVdfVAr72LZqn3FYRgkQ?= =?us-ascii?Q?mfbkONQxCPVjs+JuWZoS9ynfiZqfZ/dLi99Mw8Ce8XOsGdO/Ol2Q94XNQztV?= =?us-ascii?Q?1ZXuIyu1K7YNeZt86FdkDeLgVsaa/cQfbW9fRxLcB/zSjY4BUJkYO37LXzkN?= =?us-ascii?Q?TWIA5v6g37NeK2C0qHftoP/ZHHITjUo53JUwytJ43chwqX8Soy2yZTZg4+HJ?= =?us-ascii?Q?i5xFYPLY9LQr/OnFSBa02evAxBow5L+fp7ITgVOHg+l+f3HGewvhHt7uC3OU?= =?us-ascii?Q?OwyCK/BDMAQ3Vb27B+U9WPq+NQgO7aMvaQTl42qBGr2wSac8fo2bx7dEyyrS?= =?us-ascii?Q?ny/bZDekfGTblEMqRfDjJgxeQQnLFjblt4Xm3KMnqaKuI0H1Ha3CEn6SpYOU?= =?us-ascii?Q?/wxmuXcl9cK2IRTJBRXeKizvHHMkxdrAZo+ds1r9Sxc4Q/qtOrW/XpVWW5Tg?= =?us-ascii?Q?oysgtN9QWO93IDT1CcSVX96O7HmRGyLmvsVuDO/TH6WCxsFmADV9VnHSHPpR?= =?us-ascii?Q?YW1Y5IcyP36ZZnkxg1T6y57EN+ajzhHgF8UHk14nLFH8JNvHOJz/s5MNY/Ip?= =?us-ascii?Q?LUsrYiSt18dNxyGd38itXcpWj6VVAseub0KvP5z6YCqCPZhtA+RinzDrfhGh?= =?us-ascii?Q?AoXjJ6Qfx2gEIKJiQZ/vzrlzGo6OC1zTmk00axwVBKVUUVDOVZPyHy4LBlJ7?= =?us-ascii?Q?7Nyi/t+LSjFgS6I/5Z2kvstQ8HoQmYClMQg5l8kWX5xON6DCI9QcghWBZdhF?= =?us-ascii?Q?MBwu9FgAA0Sbnj5H5HBvPXOAVkCCN7Nk6c7nycD5JgVz2kBi6RdEhAG+kaYZ?= =?us-ascii?Q?FnsOUveX8Z3NklJw0xT5UDg0onJdVWLOULoCdzSTbMUdkueJqnpZW6DKydJ3?= =?us-ascii?Q?BbZ7xIxv6q1nfis8RhEFGjnM89fLEdMLwcEQHI96yKrYOD7I0DRUz+vzqOB9?= =?us-ascii?Q?W1sSDDb7php6UaLjiof5evRwZFM69OGF+y2oRBT0+866WQYn2BlTvtllVN7u?= =?us-ascii?Q?xBiOgZDutefmzFULoPGn+XSz/bo90sf/K6DjHjoJ0KVnYDH9yfTIksx1g9Wr?= =?us-ascii?Q?kQNSDauTkGHWucmYvNXmMBECg+Q=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae55fa27-a016-42d9-5de1-08d9a9ea7682 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7287.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 16:51:12.9275 (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: Lx644DWv3vuLuvrP2HzP3lzsfsl5JZere+Z4nn82PNcrQfnOa+18egKbsoUTQYjCsXSzNVwUpIMp+UnaiWL1jylJg7X4q4X6dqsMv18riGc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR01MB7400 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Vu Nguyen This adds an option to configure the timeout of the secure watchdog timer which are used to monitor the pre-UEFI system booting. The system will be reset if the timer expires. The default timeout is 5 minutes. 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: Nhi Pham --- Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec = | 3 + Platform/Ampere/JadePkg/Jade.dsc = | 1 + Platform/Ampere/JadePkg/Jade.fdf = | 1 + Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfigDxe.= inf | 50 +++ Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfigDxe.= h | 73 ++++ Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfigNVDa= taStruct.h | 25 ++ Silicon/Ampere/AmpereAltraPkg/Include/Guid/WatchdogConfigHii.h = | 19 + Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfigVfr.= vfr | 45 ++ Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfigDxe.= c | 435 ++++++++++++++++++++ Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfigStri= ngs.uni | 22 + 10 files changed, 674 insertions(+) diff --git a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec b/Silicon/Amp= ere/AmpereAltraPkg/AmpereAltraPkg.dec index d795c9229691..d43bf1a6f296 100644 --- a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec +++ b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec @@ -70,3 +70,6 @@ [Guids] =20 ## Include/Guid/AcpiConfigHii.h gAcpiConfigFormSetGuid =3D { 0x0ceb6764, 0xd415, 0x4b01, { 0xa8, 0x43, 0= xd1, 0x01, 0xbc, 0xb0, 0xd8, 0x29 } } + + ## Include/Guid/WatchdogConfigHii.h + gWatchdogConfigFormSetGuid =3D { 0xC3F8EC6E, 0x95EE, 0x460C, { 0xA4, 0= x8D, 0xEA, 0x54, 0x2F, 0xFF, 0x01, 0x61 } } diff --git a/Platform/Ampere/JadePkg/Jade.dsc b/Platform/Ampere/JadePkg/Jad= e.dsc index 980f431fc4de..eea3eec7f529 100644 --- a/Platform/Ampere/JadePkg/Jade.dsc +++ b/Platform/Ampere/JadePkg/Jade.dsc @@ -191,3 +191,4 @@ [Components.common] Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.inf Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.inf Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.inf + Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfigDx= e.inf diff --git a/Platform/Ampere/JadePkg/Jade.fdf b/Platform/Ampere/JadePkg/Jad= e.fdf index e88c95c57abe..3c2d315ec23a 100644 --- a/Platform/Ampere/JadePkg/Jade.fdf +++ b/Platform/Ampere/JadePkg/Jade.fdf @@ -357,5 +357,6 @@ [FV.FvMain] INF Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.inf INF Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.in= f INF Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.inf + INF Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConf= igDxe.inf =20 !include Silicon/Ampere/AmpereSiliconPkg/FvRules.fdf.inc diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/Watchd= ogConfigDxe.inf b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/W= atchdogConfigDxe.inf new file mode 100644 index 000000000000..3ed37bfb15da --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfi= gDxe.inf @@ -0,0 +1,50 @@ +## @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 WatchdogConfigDxe + FILE_GUID =3D 135A0CA5-4851-4EF5-9E1A-C6E4610C39A9 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D WatchdogConfigInitialize + +[Sources.common] + WatchdogConfigNVDataStruct.h + WatchdogConfigVfr.vfr + WatchdogConfigStrings.uni + WatchdogConfigDxe.c + WatchdogConfigDxe.h + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec + Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + DevicePathLib + HiiLib + NVParamLib + PrintLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Guids] + gPlatformManagerFormsetGuid + gWatchdogConfigFormSetGuid + +[Protocols] + gEfiDevicePathProtocolGuid ## CONSUMES + gEfiHiiConfigRoutingProtocolGuid ## CONSUMES + gEfiHiiConfigAccessProtocolGuid ## PRODUCES + +[Depex] + TRUE diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/Watchd= ogConfigDxe.h b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/Wat= chdogConfigDxe.h new file mode 100644 index 000000000000..95fc6c8f6269 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfi= gDxe.h @@ -0,0 +1,73 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef WATCHDOG_CONFIG_DXE_H_ +#define WATCHDOG_CONFIG_DXE_H_ + +#include + +#include +#include + +#include "WatchdogConfigNVDataStruct.h" + +// +// This is the generated IFR binary data for each formset defined in VFR. +// +extern UINT8 WatchdogConfigVfrBin[]; + +// +// This is the generated String package data for all .UNI files. +// +extern UINT8 WatchdogConfigDxeStrings[]; + +#define WATCHDOG_CONFIG_PRIVATE_SIGNATURE SIGNATURE_32 ('W', 'D', 'T', 'C'= ) + +typedef struct { + UINTN Signature; + + EFI_HANDLE DriverHandle; + EFI_HII_HANDLE HiiHandle; + WATCHDOG_CONFIG_VARSTORE_DATA Configuration; + + // + // Consumed protocol + // + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + + // + // Produced protocol + // + EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess; +} WATCHDOG_CONFIG_PRIVATE_DATA; + +#define WATCHDOG_CONFIG_PRIVATE_FROM_THIS(a) CR (a, WATCHDOG_CONFIG_PRIVA= TE_DATA, ConfigAccess, WATCHDOG_CONFIG_PRIVATE_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 +WatchdogConfigNvParamSet ( + IN WATCHDOG_CONFIG_VARSTORE_DATA *VarStoreConfig + ); + +EFI_STATUS +WatchdogConfigNvParamGet ( + OUT WATCHDOG_CONFIG_VARSTORE_DATA *VarStoreConfig + ); + +#endif /* WATCHDOG_CONFIG_DXE_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/Watchd= ogConfigNVDataStruct.h b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConf= igDxe/WatchdogConfigNVDataStruct.h new file mode 100644 index 000000000000..89fbd69d9538 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfi= gNVDataStruct.h @@ -0,0 +1,25 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef WATCHDOG_CONFIG_NV_DATA_STRUCT_H_ +#define WATCHDOG_CONFIG_NV_DATA_STRUCT_H_ + +#include + +#define WATCHDOG_CONFIG_VARSTORE_ID 0x1234 +#define WATCHDOG_CONFIG_FORM_ID 0x1235 + +#define SWDT_DEFAULT_VALUE 300 // 5 minutes + +#pragma pack(1) +typedef struct { + UINT32 SecureWatchdogTimerTimeout; +} WATCHDOG_CONFIG_VARSTORE_DATA; +#pragma pack() + +#endif /* WATCHDOG_CONFIG_NV_DATA_STRUCT_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Include/Guid/WatchdogConfigHii.h= b/Silicon/Ampere/AmpereAltraPkg/Include/Guid/WatchdogConfigHii.h new file mode 100644 index 000000000000..16319d61a759 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Include/Guid/WatchdogConfigHii.h @@ -0,0 +1,19 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef WATCHDOG_CONFIG_HII_H_ +#define WATCHDOG_CONFIG_HII_H_ + +#define WATCHDOG_CONFIG_FORMSET_GUID \ + { \ + 0xC3F8EC6E, 0x95EE, 0x460C, { 0xA4, 0x8D, 0xEA, 0x54, 0x2F, 0xFF, 0x01= , 0x61 } \ + } + +extern EFI_GUID gWatchdogConfigFormSetGuid; + +#endif /* WATCHDOG_CONFIG_HII_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/Watchd= ogConfigVfr.vfr b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/W= atchdogConfigVfr.vfr new file mode 100644 index 000000000000..18d2bf3d2547 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfi= gVfr.vfr @@ -0,0 +1,45 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "WatchdogConfigNVDataStruct.h" + +formset + guid =3D WATCHDOG_CONFIG_FORMSET_GUID, + title =3D STRING_TOKEN(STR_WATCHDOG_CONFIG_FORM), + help =3D STRING_TOKEN(STR_WATCHDOG_CONFIG_FORM_HELP), + classguid =3D gPlatformManagerFormsetGuid, + + // + // Define a variable Storage + // + varstore WATCHDOG_CONFIG_VARSTORE_DATA, + varid =3D WATCHDOG_CONFIG_VARSTORE_ID, + name =3D WatchdogConfigNVData, + guid =3D WATCHDOG_CONFIG_FORMSET_GUID; + + form + formid =3D WATCHDOG_CONFIG_FORM_ID, + title =3D STRING_TOKEN(STR_WATCHDOG_CONFIG_FORM); + subtitle text =3D STRING_TOKEN(STR_WATCHDOG_CONFIG_FORM_HELP); + + oneof varid =3D WatchdogConfigNVData.SecureWatchdogTimerTimeout, + prompt =3D STRING_TOKEN(STR_SWDT_TIMEOUT), + help =3D STRING_TOKEN(STR_SWDT_TIMEOUT_HELP), + flags =3D RESET_REQUIRED, + option text =3D STRING_TOKEN (STR_WDT_TIME_DISABLE), value =3D 0, fl= ags =3D 0; + option text =3D STRING_TOKEN (STR_WDT_TIME_5MIN), value =3D 300, fla= gs =3D 0; + option text =3D STRING_TOKEN (STR_WDT_TIME_6MIN), value =3D 360, fla= gs =3D 0; + option text =3D STRING_TOKEN (STR_WDT_TIME_10MIN), value =3D 600, fl= ags =3D 0; + option text =3D STRING_TOKEN (STR_WDT_TIME_15MIN), value =3D 900, fl= ags =3D 0; + option text =3D STRING_TOKEN (STR_WDT_TIME_20MIN), value =3D 1200, f= lags =3D 0; + default =3D SWDT_DEFAULT_VALUE, + endoneof; + + endform; + +endformset; diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/Watchd= ogConfigDxe.c b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/Wat= chdogConfigDxe.c new file mode 100644 index 000000000000..8165729eeccd --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfi= gDxe.c @@ -0,0 +1,435 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "WatchdogConfigDxe.h" + +CHAR16 WatchDogConfigVarstoreDataName[] =3D L"WatchdogConfigNVData"; + +EFI_HANDLE mDriverHandle =3D NULL; +WATCHDOG_CONFIG_PRIVATE_DATA *mPrivateData =3D NULL; + +HII_VENDOR_DEVICE_PATH mWatchdogConfigHiiVendorDevicePath =3D { + { + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { + (UINT8)(sizeof (VENDOR_DEVICE_PATH)), + (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8) + } + }, + WATCHDOG_CONFIG_FORMSET_GUID + }, + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + (UINT8)(END_DEVICE_PATH_LENGTH), + (UINT8)((END_DEVICE_PATH_LENGTH) >> 8) + } + } +}; + +EFI_STATUS +WatchdogConfigNvParamGet ( + OUT WATCHDOG_CONFIG_VARSTORE_DATA *VarStoreConfig + ) +{ + EFI_STATUS Status; + UINT32 Value; + BOOLEAN SetDefault; + + SetDefault =3D FALSE; + Status =3D NVParamGet ( + NV_SI_SEC_WDT_BIOS_EXP_MINS, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status)) { + VarStoreConfig->SecureWatchdogTimerTimeout =3D SWDT_DEFAULT_VALUE; + if (Status =3D=3D EFI_NOT_FOUND) { + SetDefault =3D TRUE; + } else { + ASSERT (FALSE); + } + } else { + VarStoreConfig->SecureWatchdogTimerTimeout =3D Value; + } + + if (SetDefault) { + WatchdogConfigNvParamSet (VarStoreConfig); + } + + return EFI_SUCCESS; +} + +EFI_STATUS +WatchdogConfigNvParamSet ( + IN WATCHDOG_CONFIG_VARSTORE_DATA *VarStoreConfig + ) +{ + EFI_STATUS Status; + UINT32 Value; + + Status =3D NVParamGet ( + NV_SI_SEC_WDT_BIOS_EXP_MINS, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status) + || Value !=3D VarStoreConfig->SecureWatchdogTimerTimeout) + { + Status =3D NVParamSet ( + NV_SI_SEC_WDT_BIOS_EXP_MINS, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + VarStoreConfig->SecureWatchdogTimerTimeout + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + + return EFI_SUCCESS; +} + +/** + 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= Request + 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_OUT_OF_RESOURCES Not enough memory to store the results. + @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 +WatchdogConfigExtractConfig ( + 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; + WATCHDOG_CONFIG_PRIVATE_DATA *PrivateData; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + EFI_STRING ConfigRequest; + EFI_STRING ConfigRequestHdr; + UINTN Size; + 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; + + if ((Request !=3D NULL) && !HiiIsConfigHdrMatch (Request, &gWatchdogConf= igFormSetGuid, WatchDogConfigVarstoreDataName)) { + return EFI_NOT_FOUND; + } + + PrivateData =3D WATCHDOG_CONFIG_PRIVATE_FROM_THIS (This); + HiiConfigRouting =3D PrivateData->HiiConfigRouting; + + // + // Get current setting from NVParam. + // + Status =3D WatchdogConfigNvParamGet (&PrivateData->Configuration); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Convert buffer data to by helper function BlockToConfig(= ) + // + BufferSize =3D sizeof (WATCHDOG_CONFIG_VARSTORE_DATA); + ConfigRequest =3D Request; + if ((Request =3D=3D NULL) || (StrStr (Request, L"OFFSET") =3D=3D NULL)) = { + // + // Request has no request element, 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 (&gWatchdogConfigFormSetGui= d, WatchDogConfigVarstoreDataName, PrivateData->DriverHandle); + Size =3D (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); + ConfigRequest =3D AllocateZeroPool (Size); + ASSERT (ConfigRequest !=3D NULL); + if (ConfigRequest =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + AllocatedRequest =3D TRUE; + UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=3D0&WIDTH=3D%016LX", C= onfigRequestHdr, (UINT64)BufferSize); + FreePool (ConfigRequestHdr); + } + + // + // Convert buffer data to by helper function BlockToConfig(= ) + // + Status =3D HiiConfigRouting->BlockToConfig ( + HiiConfigRouting, + ConfigRequest, + (UINT8 *)&PrivateData->Configuration, + BufferSize, + Results, + Progress + ); + + // + // Free the allocated config request string. + // + if (AllocatedRequest) { + FreePool (ConfigRequest); + ConfigRequest =3D NULL; + } + + // + // 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 +WatchdogConfigRouteConfig ( + IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, + IN CONST EFI_STRING Configuration, + OUT EFI_STRING *Progress + ) +{ + EFI_STATUS Status; + UINTN BufferSize; + WATCHDOG_CONFIG_PRIVATE_DATA *PrivateData; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + + if (Configuration =3D=3D NULL || Progress =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + PrivateData =3D WATCHDOG_CONFIG_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, &gWatchdogConfigFormSetGuid, Wa= tchDogConfigVarstoreDataName)) { + return EFI_NOT_FOUND; + } + + // + // Get configuration data from NVParam + // + Status =3D WatchdogConfigNvParamGet (&PrivateData->Configuration); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Convert to buffer data by helper function ConfigToBlock(= ) + // + BufferSize =3D sizeof (WATCHDOG_CONFIG_VARSTORE_DATA); + Status =3D HiiConfigRouting->ConfigToBlock ( + HiiConfigRouting, + Configuration, + (UINT8 *)&PrivateData->Configuration, + &BufferSize, + Progress + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Store configuration data back to NVParam + // + Status =3D WatchdogConfigNvParamSet (&PrivateData->Configuration); + if (EFI_ERROR (Status)) { + return Status; + } + + 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 The setup browser call this function with= invalid parameters. + +**/ +EFI_STATUS +EFIAPI +WatchdogConfigCallback ( + 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 (Action !=3D EFI_BROWSER_ACTION_CHANGING) { + // + // Do nothing for other UEFI Action. Only do call back when data is ch= anged. + // + return EFI_UNSUPPORTED; + } + 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; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +WatchdogConfigInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HII_HANDLE HiiHandle; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + + // + // Initialize driver private data + // + mPrivateData =3D AllocateZeroPool (sizeof (WATCHDOG_CONFIG_PRIVATE_DATA)= ); + if (mPrivateData =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + mPrivateData->Signature =3D WATCHDOG_CONFIG_PRIVATE_SIGNATURE; + + mPrivateData->ConfigAccess.ExtractConfig =3D WatchdogConfigExtractConfig= ; + mPrivateData->ConfigAccess.RouteConfig =3D WatchdogConfigRouteConfig; + mPrivateData->ConfigAccess.Callback =3D WatchdogConfigCallback; + + // + // 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 ( + &mDriverHandle, + &gEfiDevicePathProtocolGuid, + &mWatchdogConfigHiiVendorDevicePath, + &gEfiHiiConfigAccessProtocolGuid, + &mPrivateData->ConfigAccess, + NULL + ); + ASSERT_EFI_ERROR (Status); + + mPrivateData->DriverHandle =3D mDriverHandle; + + // + // Publish our HII data + // + HiiHandle =3D HiiAddPackages ( + &gWatchdogConfigFormSetGuid, + mDriverHandle, + WatchdogConfigDxeStrings, + WatchdogConfigVfrBin, + NULL + ); + if (HiiHandle =3D=3D NULL) { + gBS->UninstallMultipleProtocolInterfaces ( + mDriverHandle, + &gEfiDevicePathProtocolGuid, + &mWatchdogConfigHiiVendorDevicePath, + &gEfiHiiConfigAccessProtocolGuid, + &mPrivateData->ConfigAccess, + NULL + ); + return EFI_OUT_OF_RESOURCES; + } + + mPrivateData->HiiHandle =3D HiiHandle; + + return EFI_SUCCESS; +} diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/Watchd= ogConfigStrings.uni b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigD= xe/WatchdogConfigStrings.uni new file mode 100644 index 000000000000..25f4747abfdc --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfi= gStrings.uni @@ -0,0 +1,22 @@ +// +// Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// + +#langdef en-US "English" + +#string STR_WATCHDOG_CONFIG_FORM #language en-US "Watchdog Configur= ation" +#string STR_WATCHDOG_CONFIG_FORM_HELP #language en-US "Watchdog Configur= ation" + +#string STR_WDT_TIME_DISABLE #language en-US "Disabled" +#string STR_WDT_TIME_3MIN #language en-US "3 minutes" +#string STR_WDT_TIME_4MIN #language en-US "4 minutes" +#string STR_WDT_TIME_5MIN #language en-US "5 minutes" +#string STR_WDT_TIME_6MIN #language en-US "6 minutes" +#string STR_WDT_TIME_10MIN #language en-US "10 minutes" +#string STR_WDT_TIME_15MIN #language en-US "15 minutes" +#string STR_WDT_TIME_20MIN #language en-US "20 minutes" + +#string STR_SWDT_TIMEOUT #language en-US "Secure Watchdog = Timeout" +#string STR_SWDT_TIMEOUT_HELP #language en-US "Timeout when SCP= will reset system if it doesn't receive response from ARMv8." --=20 2.17.1