From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (NAM02-DM3-obe.outbound.protection.outlook.com [40.107.95.105]) by mx.groups.io with SMTP id smtpd.web09.9900.1631721653417356000 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=BI2GWaTv; spf=pass (domain: os.amperecomputing.com, ip: 40.107.95.105, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IppQUcbYfoNMXX28p6YHQ9uzlGsEp9VVrqh7uzT7IHsN+MDPkEC4FmCci2MHACnwb/b2eOjm/vBEwGN+N4NTrMA7aSWOrU9sNkUXlPItU3fXr33pHGyaWaPJGQTEEaeJVAScI5/beLOwq2MfNPlz1+xzxmSGbZoug0SZIhAtg4grhV/RJ0zlBm3LtCEzfuS66UFtOa/ArX8zHhaBfWYtYzJb/xNfgVErZ803jeLju8oGG55XtYQrLlVYoPFacpnMpI6hO6snOIQrWB727r5d31Ho1dl/BHOfRWuCkMX6THObooRbuiPAOzjJxkAfo2AlFnjxmgrn4SPyyBm3y36C7Q== 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=CgayxclrtyvNLB67u4jLuBYEB6Xfnu73JI6dd56ZSO4=; b=Zd1vEq3mwV8daNWyIDyxXLw0zOgXXSVs8g0gkGxGT9VnKPOf0Sp9dg/U7gaJ91mtQ8E+xkfYfzr8hlzfuen1pj5hmUzVKPSl08nHqvjQ2uN2bH3s5uFvloUZX9do6mp9kqC9BMY5GPzqCidwTiVZ+MAsiDZ8eZJAFxAHW87CBGyonNB8+btr5R+6ri309FeCP/grPgMk251OA0hSjrcM1Wo/h1USk3vP42/TsEd2y6+XU8RugCn0wuZFSgC544xlwgxgUHv4O4dMzLnTGjs21uHxfl4FKQns64bjDebIaKMzKjwtroRAW/0hjBp51MbowM+72IshqIbtlTOFi/DZeg== 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=CgayxclrtyvNLB67u4jLuBYEB6Xfnu73JI6dd56ZSO4=; b=BI2GWaTvWGAxIP5AMGl6PvbpXAI3LDvWqr/GeowWAhNCOvrE0JEh5wxCuy8wBykDhxkqSUf44v4q0a0XK7QBy+nyoHePNKaAmKVfZ+/naQjLwlW6Nur1lrBd4JX9Q/jdkpf26kwGQ+vKWwV5Z4XRuZgB0yajpPtbljfKP1OK/4A= 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 DM5PR01MB2761.prod.exchangelabs.com (2603:10b6:3:fd::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Wed, 15 Sep 2021 16:00:52 +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:52 +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 27/28] AmpereAltraPkg: Add configuration screen for Watchdog timer Date: Wed, 15 Sep 2021 22:55:26 +0700 Message-ID: <20210915155527.8176-28-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:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 959c3ff8-0125-4dd0-122d-08d97861fd92 X-MS-TrafficTypeDiagnostic: DM5PR01MB2761: X-MS-Exchange-Transport-Forked: True 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: i8x2b9WrtSsjA1jBm36XiiJ4JhvjeKSvErFaeC1J6+r+UkDcfhYQJN084+XKA2cnvGsccFaKUZRwa88UdBG9zFlqxFB3dj4g6MGH3rq43WjEqpiqenJsjIMez+b+JnLD3AQk+mK/85sNbj1nx9LlXhswCfXJVeqF9HEhjlTSrGym/GvYwGis4FDAPDXWRY3XL51mno7qe4u0IxBvGN8JKLeMV42RoVXCmPJlotVnJ3JWezI0DO+ZTy99/scPLgb+aihVcI1H/ACnmzzBPJ70L+Mzk+dOk2Q66n8kznGGmRHLN3vY7CXa6eskc7xoH8o8nTNH02OV4GM7HvkI99EePeJwa6tt6IzFR2klu/TCeodcq15XX0LJDfohwhT/8/Ceom3DG1bkiBvfisSH6lBfZIJADMcuUREShad6pL8o7TaNsG8cjrGCKH3ZO7Is6Udm0IE3rYxYmf02fhiig3YDgXAJwAtJtwvXXI91JZE29FLtiOmuq/REaSHqVbEH69LrSetVoiLG4AKbbHwT/9cfveHr8TQhVKKTwjRT7cBHR5HEs4ZbSTckuDOXyXHGb0iozrhdn1HxCg01lRnuhEx7zKSDitSiJvre9b4+huM/YcJEtG8ST1n1F/1YVQY02XRQ21Pt05YSXkyl7/ZIHCmmnHfC5yJMWF9+A4lGqzbi2cd/SHHa5LLeXuQCI8+OEM2p8PAyg4q8zuEdBbYLeKrJTJGw53BHSsTGVY0KnLK6QDxEFN7ZuyjQZMmnakQRk1usnNYZ5IGjgD3sXxByEs++DlEAW3I8qF7OudKUGZ7C1nE= 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)(366004)(66946007)(956004)(66476007)(66556008)(6666004)(4326008)(8936002)(30864003)(8676002)(316002)(38100700002)(38350700002)(5660300002)(6512007)(508600001)(186003)(52116002)(86362001)(6506007)(6916009)(1076003)(54906003)(2906002)(2616005)(83380400001)(66574015)(26005)(6486002)(290074003)(171213001)(44824005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?rERSQ0fsrvon/57UxKV4NuamHm1SU/970HrDrfw1MbFK+YMhGar8SWlD2eT2?= =?us-ascii?Q?RC/Lle/xmI9ikofJdFWfLVcOWUKfVQLG1x2qWVacaaLxXVzVvXMlKqqQsBOr?= =?us-ascii?Q?MqlvaXKJSMHC50A3mpM1ukYGXsq+G1UjUdx2nKGNXwCa8MLuxnl6e/vxy564?= =?us-ascii?Q?AnpHB1+N9KGP5KW2e4hgGoYtE4rcjg1l57pl6hn/H0VWwev6liNM24cSDzjo?= =?us-ascii?Q?sxxDT4b5A0c6A1v7YVA8t2RVW+Ki2/RccicxIIsg1nME7w2wd37DFiKN67vO?= =?us-ascii?Q?k/dgZmFNXIOjSv1vptczfXtC74j4dAGs1fy8m5QgQ5MFm7Yv/EjHumcXN42p?= =?us-ascii?Q?yCAQLVjaUn0EcmvkpWP/oJQy7ikbWwxSb5Jotg8tnVL277zLbSfOhkXoklos?= =?us-ascii?Q?5h6DxusyFIx/vpLRoUMwavccw9EwmxMoETB7WHPUlfyRwQevUD++S1nnjSuz?= =?us-ascii?Q?4nalGNaMh90ToinJYcbIjQa9PzA9qXzv1kujbPbu4CWuv58wmgvb24Yf6hgY?= =?us-ascii?Q?x4dHUTITyc7Bm/7oJ3vyGCkZ0iWTmqneuYWhQwSkVqN66oqBjHYLwQr0TZ3I?= =?us-ascii?Q?ILY+m8r+aBTR2JHuORF0y4gnupZuCCvHStUUUWgOSxHx6TwukranNsJ8iu01?= =?us-ascii?Q?vBVyM7dSAtVuoNDIHCCrrUgxQDrzD5GkXCX+IE4LMCzc7DFPZiQK8oxtGxBl?= =?us-ascii?Q?95sIwtw506r56UgFRpeP7j72zTLUmT01u6urA1yaLAigDl2ySvPBloD9diCu?= =?us-ascii?Q?DWJNRLuWxZ9k5XpLuhlLdSWLH3wCpPcLtavhXmS7Q7WwnuQFOwO2SRIFTa4r?= =?us-ascii?Q?2V1Vi7xtCW35A5Undu6s4ODKi856z5v+awAYyLF5782c5j1doztps2wrGlx9?= =?us-ascii?Q?EADjxnVi7B9xvdM+tJELC0rR/uPKVkm6E1XlsEyO8LPeUVTAhU+VGezoSJ4N?= =?us-ascii?Q?eAACBTbreZrnvCndRS+UywyrWrLhG4lBN4Dle7swlzMhvEobamXc3VLcJRVf?= =?us-ascii?Q?nRn4xpOjXPPBlck5lxzIWjSTxBqjlz1U1L0k3D580/uQPvMy9+7NWlPG5ZyM?= =?us-ascii?Q?5aA7fwUb1qyg0Z8+2Scu9hujEuI3DyZAMs2fxF3Hq9HZykpK2rT//VZxqJT8?= =?us-ascii?Q?I/BfZ2XWxc7Dq73reSZHHq/sQIl1eKph7Tj9KZ9o7eYFE6Oaw2LpOePMZBMh?= =?us-ascii?Q?SrzUprrTtwtYQCrpFFslU5+meXvdKy+96MSG4FnNURUvY14y7hEGffo0JPc/?= =?us-ascii?Q?QrQeZXE3yrFulhPIAlUJalahT/uskRIPu+gG74EGHPf1Mj4QnmbBthGi5xRd?= =?us-ascii?Q?qv4yPYnlKKvDvAQpXoP3pq+7?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 959c3ff8-0125-4dd0-122d-08d97861fd92 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:51.8810 (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: dUAV7+yQ93hfgzn29HPQEZrteD1ipa7VM81M7gFdlMG3ifE9HcMw1Wh7MpbBPvW0l0/QeiuV2+FDVj2A6vrdm1FHuaYY5Q6ud7utzxtVX7w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR01MB2761 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Vu Nguyen There are secure and non-secure watchdog timers supported in the Mt. Jade system. They are used to monitor the system booting like system firmware, UEFI, and OS. The system will be reset if the timer expires. So, this patch adds the configuration screen for the watchdog timer which provides options to configure the timeout of these timers. By default, the values of these options are 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: Vu Nguyen --- 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 | 82 ++++ Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfigNVDa= taStruct.h | 27 ++ Silicon/Ampere/AmpereAltraPkg/Include/Guid/WatchdogConfigHii.h = | 19 + Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfigVfr.= vfr | 58 +++ Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfigDxe.= c | 460 ++++++++++++++++++++ Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfigStri= ngs.uni | 26 ++ 10 files changed, 727 insertions(+) diff --git a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec b/Silicon/Amp= ere/AmpereAltraPkg/AmpereAltraPkg.dec index 196611d67280..b0e1f3ec6f2a 100644 --- a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec +++ b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec @@ -56,6 +56,9 @@ [Guids] # GUID for the ACPI HII configuration form gAcpiConfigFormSetGuid =3D { 0x0ceb6764, 0xd415, 0x4b01, { 0xa8, 0x43, 0= xd1, 0x01, 0xbc, 0xb0, 0xd8, 0x29 } } =20 + # GUID for the Watchdog HII configuration form + gWatchdogConfigFormSetGuid =3D { 0xC3F8EC6E, 0x95EE, 0x460C, { 0xA4, 0= x8D, 0xEA, 0x54, 0x2F, 0xFF, 0x01, 0x61 } } + ## NVParam MM GUID gNVParamMmGuid =3D { 0xE4AC5024, 0x29BE, 0x4ADC, { 0x93, 0= x36, 0x87, 0xB5, 0xA0, 0x76, 0x23, 0x2D } } =20 diff --git a/Platform/Ampere/JadePkg/Jade.dsc b/Platform/Ampere/JadePkg/Jad= e.dsc index b5ac2547c8f8..b752ea3e5264 100644 --- a/Platform/Ampere/JadePkg/Jade.dsc +++ b/Platform/Ampere/JadePkg/Jade.dsc @@ -201,3 +201,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 e0d4b049f6bf..8f3df6ccf01b 100644 --- a/Platform/Ampere/JadePkg/Jade.fdf +++ b/Platform/Ampere/JadePkg/Jade.fdf @@ -359,5 +359,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 Platform/Ampere/AmperePlatformPkg/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..5f47531c538e --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfi= gDxe.h @@ -0,0 +1,82 @@ +/** @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 +#include +#include +#include +#include +#include +#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..470a2821ffe7 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfi= gNVDataStruct.h @@ -0,0 +1,27 @@ +/** @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 NWDT_UEFI_DEFAULT_VALUE 300 // 5 minutes +#define SWDT_DEFAULT_VALUE 300 // 5 minutes + +#pragma pack(1) +typedef struct { + UINT32 WatchdogTimerUEFITimeout; + 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..48f2aef227f6 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfi= gVfr.vfr @@ -0,0 +1,58 @@ +/** @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.WatchdogTimerUEFITimeout, + prompt =3D STRING_TOKEN(STR_NWDT_TIMEOUT_UEFI), + help =3D STRING_TOKEN(STR_NWDT_TIMEOUT_UEFI_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 NWDT_UEFI_DEFAULT_VALUE, + endoneof; + + 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..bd7b929dccda --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfi= gDxe.c @@ -0,0 +1,460 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#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_WDT_BIOS_EXP_MINS, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status)) { + VarStoreConfig->WatchdogTimerUEFITimeout =3D NWDT_UEFI_DEFAULT_VALUE; + if (Status =3D=3D EFI_NOT_FOUND) { + SetDefault =3D TRUE; + } else { + ASSERT (FALSE); + } + } else { + VarStoreConfig->WatchdogTimerUEFITimeout =3D Value * 60; + } + + 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_WDT_BIOS_EXP_MINS, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status) + || Value !=3D (VarStoreConfig->WatchdogTimerUEFITimeout / 60)) + { + Status =3D NVParamSet ( + NV_SI_WDT_BIOS_EXP_MINS, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + (VarStoreConfig->WatchdogTimerUEFITimeout / 60) + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + + 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..1d0f820e456f --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfi= gStrings.uni @@ -0,0 +1,26 @@ +// +// 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_NWDT_TIMEOUT_OS #language en-US "OS Watchdog Time= out" +#string STR_NWDT_TIMEOUT_OS_HELP #language en-US "Timeout when boo= t OS." +#string STR_NWDT_TIMEOUT_UEFI #language en-US "UEFI Watchdog Ti= meout" +#string STR_NWDT_TIMEOUT_UEFI_HELP #language en-US "Timeout when boo= t UEFI" +#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