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.113]) by mx.groups.io with SMTP id smtpd.web11.4139.1607505905308821561 for ; Wed, 09 Dec 2020 01:25:05 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=kTTk/g8f; spf=pass (domain: os.amperecomputing.com, ip: 40.107.94.113, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KxTKm6adX4z4C8MPugOX0kraNxvrjb6i9xT7f7Q7kkzXnMf1GrYTl+Yd/2hbF9W5OjZgZiuHog+KOOe5j0nG8R/+SNwL5o/ki6uDuiAJytHzWklKB63DNRp6xLdr1umzy9aK5TBMMP7Ho9oUln5bgddtC+Sajxm9abL8b4SHE+i9Nf7/jWPyYjnBwxFmiUnFf70zh15aQnQPIXZFe9+tZPkcg/s3zqtC4J6AaU9ssydX2l3SbNy26/rjFDgay3VLi+TYDvS4KoH2MIllWZnGl1TfhFCkHBlYvu1bLB4R1JVjHVqdqOfQ7Uqa6QnD4wG6a5Z5hji3olpnGzYzefVgYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qEmVKr6BAoEUql9yYH+GzzA3oIKnkUqXDvPM3nO8wtA=; b=h5l7Rc97Cy8HxbwW2AdpFdd4la/hl7GV2/KZXz4PGVI5gNpqG8Q/CcOmYdYXHVHI6woksq1Vt36AUuKAX8DoykcV0zGpcY0r5xm96reZixHhY/0QFjSAEnKgVZK+34fEyLcosI8XqldBPzvmx1+HK7qrDCA/+PUAcTcFumgRrQPFaS/StPWOEbLc8GSykaZ0Fwbv6QgtryfKnrgOAGCPjXqogO9yOFxGS6KNsedzGdzkNln7e4kY3+DUHi58fGU5HeBaE/GgPPALt6EwHGcc/4tOFO7TI4y1MPjXo+0tj4gPF8JXZdq4LJgkit0y3whtDzIOSrWQZKZod14fbqdFRw== 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=qEmVKr6BAoEUql9yYH+GzzA3oIKnkUqXDvPM3nO8wtA=; b=kTTk/g8fuyFNobj+acnqnMzVqs0yPCeOiFgKBfiT4RFCBZn8ho0JLtL8x9l681yZGgqqoY4ZipSACgmkpdLH8icZa7H4obMOj8PWNbNnaGEUzQJiyiAfpB2BYNR401HYDiRVglV9Rgk/qDYysfvrgX6eDJVbc/pUl7IkGKAAIsc= 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 DM6PR01MB5932.prod.exchangelabs.com (2603:10b6:5:14e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12; Wed, 9 Dec 2020 09:25:03 +0000 Received: from DM6PR01MB5849.prod.exchangelabs.com ([fe80::c814:9a08:5c2e:4076]) by DM6PR01MB5849.prod.exchangelabs.com ([fe80::c814:9a08:5c2e:4076%5]) with mapi id 15.20.3632.023; Wed, 9 Dec 2020 09:25:03 +0000 From: "Nhi Pham" To: devel@edk2.groups.io Cc: Quan Nguyen , Nhi Pham Subject: [edk2-platforms][PATCH 34/34] AmpereAltraPkg, JadePkg: Add RAS setting screen Date: Wed, 9 Dec 2020 16:25:31 +0700 Message-Id: <20201209092531.30867-35-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201209092531.30867-1-nhi@os.amperecomputing.com> References: <20201209092531.30867-1-nhi@os.amperecomputing.com> X-Originating-IP: [118.69.219.201] X-ClientProxiedBy: HK0PR01CA0054.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::18) To DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sw004.amperecomputing.com (118.69.219.201) by HK0PR01CA0054.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Wed, 9 Dec 2020 09:25:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 643c9d4e-06af-482b-23f8-08d89c244f40 X-MS-TrafficTypeDiagnostic: DM6PR01MB5932: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:220; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PMyog+PeGUOfBnvH5z8eMfQ+aEvWjE1o6pIHqREq/S/csy7kZRTarwCwenYmYHjVblF04WO9UgrDrgpUHRQaFYedz8RI7bcTkYytk3VBxa0eDViUHdAl12//xyaylPLatFMT6Nw7iVfWlYx2OFOd4uVG02XnjZHvLJPeIXdejBC5gAIRnW8gXer+wZqEum8+CT71cDETdUq8HgGi4ghtKrZYQb+j/i1BbgR350aFMShhbmrayDV+iSgIxjwY0gQCIX7mI4HJQnJmH1WxTaq0ELOGwe61OysATgxHkbpvBVstge6+9kJulG1aFxL2k7N3WVyt1UILX2QefM1qkSLhwfYf2EvnOvD0Zhfw+g+ellOn6N+aYrRvUaO95n+MIn+HnytG3diZ0Udq7a+mtI97vvY/pSPUdwEknoZBhVOsCDV7QpHYpfZRpAvJq7VZnkH+ 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)(346002)(376002)(136003)(186003)(26005)(8936002)(107886003)(16526019)(6666004)(2906002)(86362001)(508600001)(4326008)(30864003)(66556008)(66476007)(66946007)(5660300002)(6506007)(8676002)(34490700003)(1076003)(19627235002)(2616005)(52116002)(6512007)(956004)(6486002)(6916009)(66574015)(83380400001)(54906003)(290074003)(579004)(44824005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?7k4lmznnHIe0GcqtkOK9AQbNUy8/FraSMGj2XzNckuYITSw9aokLZfb+6s79?= =?us-ascii?Q?P1n05hxTnvWxkteG2HTkIYi6kZWa1hSikj7c0jMqts0c1J2chL6p+SHqsWAn?= =?us-ascii?Q?XxZSL3cwoH3HzB3E4Qg+39wdlvTa+XQKBBwk5D+yutsvRSE+nYUWyu8Y9H1n?= =?us-ascii?Q?4XZwMon5XGi7qmLvPTjuWGjAyDdn+rh8inxd91yN933RphXbsF8722x0sjhX?= =?us-ascii?Q?QLeMfxN+uqK+WvNZeAWr0jLl4x/8aOkxAY8vRv5kIJAgPL/iacOcxGjsiFSI?= =?us-ascii?Q?b2v9VzxOba1ceFI/Rk2u90IFLD56XF4ar7w5TH/d+TLaUs3p/PQPhMg6FKc5?= =?us-ascii?Q?3Wyr8CV6eqi6aWGHRpADJ36k/zi7MHCezkrpMs8Bvsut9zb4NMgnBMzXabFM?= =?us-ascii?Q?hPpTgwsWa3B1DV8E4bVumatLDGBXA34/zP4II5UBxxoC8TJmfyZbIYGfIj2E?= =?us-ascii?Q?g5uSebaYCIQv92DSE4O2GqsXCDmY9kVLTzQLVIDv2yebFAGzEYHW5whOohO+?= =?us-ascii?Q?br9QeijJcVvqLM2Cv4JX7f/1CzM1xMkilfExHwYzbJkeXmkg69zCGVjIKBzZ?= =?us-ascii?Q?PtVCwO6ILQcMNDujYvIYDAauR1Jbds+U3iKd5XI6mUlw2YEiri//29V9NRrN?= =?us-ascii?Q?+Qb/B6WM9XiBzQvSSykjtHU5X1fNSuyYHM1wyqvmiOWA1jg99RC0weE9mK4t?= =?us-ascii?Q?HOIZ5eaiUw7BJt0NzztiU2FmfaJzeFko2sTq0/Mfjvsf6vlxh8WcN53gKWI+?= =?us-ascii?Q?IMUAO4tiCCndZT5lUNLbeVEfLy/d2gvcHcJfYjGbo42XkFGrWj/YqA+ihDDa?= =?us-ascii?Q?2HdkSPC0TZfi87c76WEM2loPNZF+0BdlaWuWnPb9/h7lam9FC7vsyCXek6FM?= =?us-ascii?Q?5tiZjOmiUROJmXWOMWMAePKzX1nqYTu6oeBOuLHvvHNMjjkh9ODg/kZZSoXW?= =?us-ascii?Q?YHr9ggj2UfZjZUZNbGzBWl6wIhwafc4Y3KE04IQxzKmaz1yvp3WwQ3jX6myK?= =?us-ascii?Q?KHbT?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5849.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2020 09:25:03.4534 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-Network-Message-Id: 643c9d4e-06af-482b-23f8-08d89c244f40 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 37r7GpskrgAkkg2GPSacupvxPNK1Xb1PLP9ZlJZ6TdV6xwT3QspEWgC6SIP31e2G99858iXxc4TjA3dL5ZpXOtfpwoZxAFWudFWN3MVKa+k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB5932 Content-Type: text/plain From: Quan Nguyen This supports user to enable/disable ACPI/APEI tables. Signed-off-by: Nhi Pham Signed-off-by: Quan Nguyen --- Platform/Ampere/JadePkg/Jade.dsc | 2 + Platform/Ampere/JadePkg/Jade.fdf | 1 + Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf | 3 + Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.inf | 56 ++ Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.h | 30 + Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/NVDataStruc.h | 30 + Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.h | 81 +++ Silicon/Ampere/AmpereAltraPkg/Include/AcpiNVDataStruc.h | 14 + Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/Vfr.vfr | 8 + Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/Vfr.vfr | 97 +++ Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.c | 114 ++++ Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.c | 7 + Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.c | 649 ++++++++++++++++++++ Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/VfrStrings.uni | 3 + Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/VfrStrings.uni | 35 ++ 15 files changed, 1130 insertions(+) diff --git a/Platform/Ampere/JadePkg/Jade.dsc b/Platform/Ampere/JadePkg/Jade.dsc index 036971c565e3..9ecbfe4ace05 100755 --- a/Platform/Ampere/JadePkg/Jade.dsc +++ b/Platform/Ampere/JadePkg/Jade.dsc @@ -77,6 +77,7 @@ [LibraryClasses] AcpiLib|EmbeddedPkg/Library/AcpiLib/AcpiLib.inf AcpiHelperLib|Platform/Ampere/Library/AcpiHelperLib/AcpiHelperLib.inf AcpiPccLib|Platform/Ampere/Library/AcpiPccLib/AcpiPccLib.inf + AcpiApeiLib|Platform/Ampere/Library/AcpiApeiLib/AcpiApeiLib.inf # # Pcie Board @@ -193,3 +194,4 @@ [Components.common] Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfo/MemInfoDxe.inf Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.inf Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.inf + Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.inf diff --git a/Platform/Ampere/JadePkg/Jade.fdf b/Platform/Ampere/JadePkg/Jade.fdf index 422ce35449b5..53486532e7d4 100755 --- a/Platform/Ampere/JadePkg/Jade.fdf +++ b/Platform/Ampere/JadePkg/Jade.fdf @@ -392,6 +392,7 @@ [FV.FvMain] INF Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfo/MemInfoDxe.inf INF Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.inf INF Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/AcpiConfigDxe.inf + INF Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.inf [FV.SystemFirmwareDescriptor] FvAlignment = 8 diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf index d9caca9438de..4ba155d13589 100644 --- a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf +++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf @@ -15,6 +15,8 @@ [Defines] ENTRY_POINT = AcpiPlatformDxeInitialize [Sources.common] + AcpiApei.c + AcpiApei.h AcpiDsdt.c AcpiMADT.c AcpiNfit.c @@ -61,6 +63,7 @@ [Guids] gArmMpCoreInfoGuid gEfiAcpiTableGuid gEfiEventReadyToBootGuid + gAcpiConfigFormSetGuid [Protocols] gEfiAcpiTableProtocolGuid ## ALWAYS_CONSUMED diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.inf b/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.inf new file mode 100644 index 000000000000..3ea4373649fd --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.inf @@ -0,0 +1,56 @@ +## @file +# +# Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x0001001A + BASE_NAME = RasConfigDxe + FILE_GUID = 5b5ee6e3-3135-45f7-ad21-46a3f36813cc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RasConfigEntryPoint + +[Sources.common] + RasConfigDxe.c + RasConfigDxe.h + NVDataStruc.h + Vfr.vfr + VfrStrings.uni + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Silicon/Ampere/AmperePkg.dec + Silicon/Ampere/AmpereAltraPkg/Ac01Pkg.dec + +[LibraryClasses] + UefiDriverEntryPoint + UefiBootServicesTableLib + UefiRuntimeServicesTableLib + MemoryAllocationLib + BaseMemoryLib + BaseLib + UefiLib + DevicePathLib + DebugLib + HiiLib + DevicePathLib + NVParamLib + AmpereCpuLib + +[Guids] + gEfiIfrTianoGuid + gPlatformManagerFormsetGuid + gAcpiConfigFormSetGuid + +[Protocols] + gEfiDevicePathProtocolGuid ## CONSUMES + gEfiHiiConfigRoutingProtocolGuid ## CONSUMES + gEfiHiiConfigAccessProtocolGuid ## PRODUCES + +[Depex] + TRUE diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.h b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.h new file mode 100755 index 000000000000..8a77148e8238 --- /dev/null +++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.h @@ -0,0 +1,30 @@ +/** @file + + Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __ACPIAPEI_H__ +#define __ACPIAPEI_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +EFI_STATUS +EFIAPI +AcpiApeiUpdate (VOID); + +#endif /* __ACPIAPEI_H__ */ + diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/NVDataStruc.h b/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/NVDataStruc.h new file mode 100644 index 000000000000..8c35230c3400 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/NVDataStruc.h @@ -0,0 +1,30 @@ +/** @file + + Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _NVDATASTRUC_H_ +#define _NVDATASTRUC_H_ + +#include + +#define RAS_CONFIG_VARSTORE_ID 0x1234 +#define RAS_CONFIG_FORM_ID 0x1235 + +#define RAS_VARSTORE_NAME L"RasConfigNVData" + +#define RAS_CONFIG_FORMSET_GUID \ + { \ + 0x96934cc6, 0xcb15, 0x4d8a, { 0xbe, 0x5f, 0x8e, 0x7d, 0x55, 0x0e, 0xc9, 0xc6 } \ + } + +// +// Labels definition +// +#define LABEL_UPDATE 0x3234 +#define LABEL_END 0xffff + +#endif /* _NVDATASTRUC_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.h b/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.h new file mode 100644 index 000000000000..b3a4e52931e6 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.h @@ -0,0 +1,81 @@ +/** @file + + Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _RAS_CONFIG_DXE_H_ +#define _RAS_CONFIG_DXE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "NVDataStruc.h" + +// +// This is the generated IFR binary data for each formset defined in VFR. +// +extern UINT8 VfrBin[]; + +// +// This is the generated String package data for all .UNI files. +// +extern UINT8 RasConfigDxeStrings[]; + +#define RAS_2P_CE_THRESHOLD OFFSET_OF (RAS_CONFIG_VARSTORE_DATA, Ras2pCeThreshold) + +#define RAS_CONFIG_PRIVATE_SIGNATURE SIGNATURE_32 ('R', 'A', 'S', 'C') + +typedef struct { + UINTN Signature; + + EFI_HANDLE DriverHandle; + EFI_HII_HANDLE HiiHandle; + RAS_CONFIG_VARSTORE_DATA Configuration; + + // + // Consumed protocol + // + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + + // + // Produced protocol + // + EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess; +} RAS_CONFIG_PRIVATE_DATA; + +#define RAS_CONFIG_PRIVATE_FROM_THIS(a) CR (a, RAS_CONFIG_PRIVATE_DATA, ConfigAccess, RAS_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() + +#endif /* _RAS_CONFIG_DXE_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Include/AcpiNVDataStruc.h b/Silicon/Ampere/AmpereAltraPkg/Include/AcpiNVDataStruc.h index 79610c1a3fad..37cabb95a72b 100644 --- a/Silicon/Ampere/AmpereAltraPkg/Include/AcpiNVDataStruc.h +++ b/Silicon/Ampere/AmpereAltraPkg/Include/AcpiNVDataStruc.h @@ -15,6 +15,7 @@ // ACPI Configuration NV data structure definition // typedef struct { + UINT32 EnableApeiSupport; UINT32 AcpiCppcEnable; UINT32 AcpiLpiEnable; UINT32 AcpiTurboSupport; @@ -22,6 +23,19 @@ typedef struct { UINT32 Reserved[4]; } ACPI_CONFIG_VARSTORE_DATA; +// +// Ras Configuration NV data structure definition +// +typedef struct { + UINT32 EnableApeiSupport; + UINT32 RasHardwareEinj; + UINT32 RasSdeiEnabled; + UINT32 RasDdrCeThreshold; + UINT32 Ras2pCeThreshold; + UINT32 RasCpmCeThreshold; + UINT32 RasLinkErrThreshold; +} RAS_CONFIG_VARSTORE_DATA; + #pragma pack() #endif /* _ACPI_NV_DATA_STRUC_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/Vfr.vfr b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/Vfr.vfr index 6971b445818d..49d43ea5b578 100644 --- a/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/Vfr.vfr +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/Vfr.vfr @@ -27,6 +27,14 @@ formset title = STRING_TOKEN(STR_ACPI_FORM); subtitle text = STRING_TOKEN(STR_ACPI_FORM_HELP); + oneof + varid = AcpiConfigNVData.EnableApeiSupport, + prompt = STRING_TOKEN(STR_ACPI_APEI_SUPPORT_PROMPT), + help = STRING_TOKEN(STR_ACPI_APEI_SUPPORT_HELP), + option text = STRING_TOKEN(STR_ACPI_COMMON_DISABLE), value = 0, flags = 0; + option text = STRING_TOKEN(STR_ACPI_COMMON_ENABLE), value = 1, flags = DEFAULT; + endoneof; + oneof varid = AcpiConfigNVData.AcpiCppcEnable, prompt = STRING_TOKEN(STR_ACPI_CPPC_PROMPT), diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/Vfr.vfr b/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/Vfr.vfr new file mode 100644 index 000000000000..91456929eff0 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/Vfr.vfr @@ -0,0 +1,97 @@ +/** @file + + Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "NVDataStruc.h" + +formset + guid = RAS_CONFIG_FORMSET_GUID, + title = STRING_TOKEN(STR_RAS_FORM), + help = STRING_TOKEN(STR_RAS_FORM_HELP), + classguid = gPlatformManagerFormsetGuid, + + // + // Define a variable Storage + // + varstore RAS_CONFIG_VARSTORE_DATA, + varid = RAS_CONFIG_VARSTORE_ID, + name = RasConfigNVData, + guid = RAS_CONFIG_FORMSET_GUID; + + form formid = RAS_CONFIG_FORM_ID, + title = STRING_TOKEN(STR_RAS_FORM); + + subtitle text = STRING_TOKEN(STR_RAS_FORM); + + grayoutif ideqval RasConfigNVData.EnableApeiSupport == 0; + oneof varid = RasConfigNVData.RasHardwareEinj, + prompt = STRING_TOKEN(STR_RAS_HARDWARE_EINJ_PROMPT), + help = STRING_TOKEN(STR_RAS_HARDWARE_EINJ_HELP), + flags = NUMERIC_SIZE_4 | RESET_REQUIRED, + option text = STRING_TOKEN(STR_RAS_COMMON_ENABLE), value = 1, flags = DEFAULT; + option text = STRING_TOKEN(STR_RAS_COMMON_DISABLE), value = 0, flags = 0; + + endoneof; + endif; + + grayoutif ideqval RasConfigNVData.EnableApeiSupport == 0; + oneof varid = RasConfigNVData.RasSdeiEnabled, + prompt = STRING_TOKEN(STR_RAS_SDEI_ENABLED_PROMPT), + help = STRING_TOKEN(STR_RAS_SDEI_ENABLED_HELP), + flags = NUMERIC_SIZE_4 | RESET_REQUIRED, + option text = STRING_TOKEN(STR_RAS_COMMON_ENABLE), value = 1, flags = 0; + option text = STRING_TOKEN(STR_RAS_COMMON_DISABLE), value = 0, flags = DEFAULT; + + endoneof; + endif; + + grayoutif ideqval RasConfigNVData.EnableApeiSupport == 0; + numeric varid = RasConfigNVData.RasDdrCeThreshold, + prompt = STRING_TOKEN(STR_RAS_DDR_CE_THRESHOLD_PROMPT), + help = STRING_TOKEN(STR_RAS_DDR_CE_THRESHOLD_HELP), + flags = NUMERIC_SIZE_4 | RESET_REQUIRED, + minimum = 1, + maximum = 8192, + default = 1, + + endnumeric; + endif; + + label LABEL_UPDATE; + // + // This is where we will dynamically add other Action type op-code + // + label LABEL_END; + + grayoutif ideqval RasConfigNVData.EnableApeiSupport == 0; + numeric varid = RasConfigNVData.RasCpmCeThreshold, + prompt = STRING_TOKEN(STR_RAS_CPM_CE_THRESHOLD_PROMPT), + help = STRING_TOKEN(STR_RAS_CPM_CE_THRESHOLD_HELP), + flags = NUMERIC_SIZE_4 | RESET_REQUIRED, + minimum = 1, + maximum = 8192, + default = 1, + + endnumeric; + endif; + + grayoutif ideqval RasConfigNVData.EnableApeiSupport == 0; + numeric varid = RasConfigNVData.RasLinkErrThreshold, + prompt = STRING_TOKEN(STR_RAS_LINK_ERR_THRESHOLD_PROMPT), + help = STRING_TOKEN(STR_RAS_LINK_ERR_THRESHOLD_HELP), + flags = NUMERIC_SIZE_4 | RESET_REQUIRED, + minimum = 1, + maximum = 8192, + default = 1, + + endnumeric; + endif; + + + endform; + +endformset; diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.c b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.c new file mode 100755 index 000000000000..1397f3866961 --- /dev/null +++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.c @@ -0,0 +1,114 @@ +/** @file + + Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "AcpiApei.h" +#include +#include + +STATIC VOID +AcpiApeiUninstallTable ( + UINT32 Signature + ) +{ + EFI_STATUS Status; + EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; + EFI_ACPI_SDT_PROTOCOL *AcpiTableSdtProtocol; + EFI_ACPI_SDT_HEADER *Table; + EFI_ACPI_TABLE_VERSION TableVersion; + UINTN TableKey; + UINTN Idx; + + /* + * Get access to ACPI tables + */ + Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID**) &AcpiTableProtocol); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a:%d: Unable to locate ACPI table protocol\n", __FUNCTION__, __LINE__)); + return; + } + + Status = gBS->LocateProtocol (&gEfiAcpiSdtProtocolGuid, NULL, (VOID**) &AcpiTableSdtProtocol); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a:%d: Unable to locate ACPI table support protocol\n", __FUNCTION__, __LINE__)); + return; + } + + /* + * Search for ACPI Table Signature + */ + for (Idx = 0; ; Idx++) { + Status = AcpiTableSdtProtocol->GetAcpiTable (Idx, &Table, &TableVersion, &TableKey); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a:%d: Unable to get ACPI table index %d \n", __FUNCTION__, __LINE__, Idx)); + return; + } else if (Table->Signature == Signature) { + break; + } + } + + /* + * Uninstall ACPI Table + */ + Status = AcpiTableProtocol->UninstallAcpiTable (AcpiTableProtocol, TableKey); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a:%d: Unable to uninstall table\n", __FUNCTION__, __LINE__)); + } +} + +/* + * Checks Status of NV_SI_RAS_SDEI_ENABLED + * Returns 1 if enabled and 0 if disabled or error occurred + */ +UINT32 +IsSdeiEnabled (VOID) +{ + EFI_STATUS Status; + UINT32 Value; + + Status = NVParamGet ( + NV_SI_RAS_SDEI_ENABLED, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + + return (EFI_ERROR (Status)) ? 0 : Value; +} + +/* + * Update APEI + * + */ +EFI_STATUS +EFIAPI +AcpiApeiUpdate (VOID) +{ + EFI_STATUS Status; + ACPI_CONFIG_VARSTORE_DATA AcpiConfigData; + UINTN BufferSize; + + BufferSize = sizeof (ACPI_CONFIG_VARSTORE_DATA); + Status = gRT->GetVariable ( + L"AcpiConfigNVData", + &gAcpiConfigFormSetGuid, + NULL, + &BufferSize, + &AcpiConfigData + ); + if (!EFI_ERROR (Status) && (AcpiConfigData.EnableApeiSupport == 0)) { + AcpiApeiUninstallTable (EFI_ACPI_6_3_BOOT_ERROR_RECORD_TABLE_SIGNATURE); + AcpiApeiUninstallTable (EFI_ACPI_6_3_HARDWARE_ERROR_SOURCE_TABLE_SIGNATURE); + AcpiApeiUninstallTable (EFI_ACPI_6_3_SOFTWARE_DELEGATED_EXCEPTIONS_INTERFACE_TABLE_SIGNATURE); + AcpiApeiUninstallTable (EFI_ACPI_6_3_ERROR_INJECTION_TABLE_SIGNATURE); + } + + if (IsSdeiEnabled () == 0) { + AcpiApeiUninstallTable (EFI_ACPI_6_3_SOFTWARE_DELEGATED_EXCEPTIONS_INTERFACE_TABLE_SIGNATURE); + } + + return EFI_SUCCESS; +} diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.c b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.c index 31b635db2b7b..bc6b941c41fa 100644 --- a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.c +++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.c @@ -7,6 +7,7 @@ **/ #include "AcpiPlatform.h" +#include "AcpiApei.h" STATIC EFI_EVENT mAcpiRegistration = NULL; @@ -101,6 +102,12 @@ UpdateAcpiOnExitBootServices( DEBUG ((DEBUG_INFO, "DSDT Table updated!\n")); } + // Configure ACPI Platform Error Interfaces + Status = AcpiApeiUpdate (); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "APEI Table updated!\n")); + } + // Configure PCC mailbox base address and unmask interrupt Status = AcpiPcctInit(); if (!EFI_ERROR (Status)) { diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.c b/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.c new file mode 100644 index 000000000000..35a9401e0147 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.c @@ -0,0 +1,649 @@ +/** @file + + Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "RasConfigDxe.h" + +CHAR16 RasConfigVarstoreDataName[] = L"RasConfigNVData"; + +EFI_HANDLE mDriverHandle = NULL; +RAS_CONFIG_PRIVATE_DATA *mPrivateData = NULL; + +EFI_GUID mRasConfigFormSetGuid = RAS_CONFIG_FORMSET_GUID; + +HII_VENDOR_DEVICE_PATH mRasConfigHiiVendorDevicePath = { + { + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { + (UINT8) (sizeof (VENDOR_DEVICE_PATH)), + (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) + } + }, + RAS_CONFIG_FORMSET_GUID + }, + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + (UINT8) (END_DEVICE_PATH_LENGTH), + (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8) + } + } +}; + +// Return 0 when Apei is disable, else Apei enabled +STATIC +UINT32 +IsApeiSupport (VOID) +{ + EFI_STATUS Status; + ACPI_CONFIG_VARSTORE_DATA AcpiConfigData; + UINTN BufferSize; + + BufferSize = sizeof (ACPI_CONFIG_VARSTORE_DATA); + Status = gRT->GetVariable ( + L"AcpiConfigNVData", + &gAcpiConfigFormSetGuid, + NULL, + &BufferSize, + &AcpiConfigData); + if (!EFI_ERROR (Status)) { + return AcpiConfigData.EnableApeiSupport; + } + + return 0; +} + +STATIC +EFI_STATUS +RasConfigNvParamGet ( + OUT RAS_CONFIG_VARSTORE_DATA *Configuration + ) +{ + EFI_STATUS Status; + UINT32 Value; + + Status = NVParamGet ( + NV_SI_HARDWARE_EINJ, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + Configuration->RasHardwareEinj = (EFI_ERROR (Status)) ? 0 : Value; + + Status = NVParamGet ( + NV_SI_RAS_SDEI_ENABLED, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + Configuration->RasSdeiEnabled = (EFI_ERROR (Status)) ? 0 : Value; + + Status = NVParamGet ( + NV_SI_DDR_CE_RAS_THRESHOLD, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value); + Configuration->RasDdrCeThreshold = (EFI_ERROR (Status)) ? 1 : Value; + + Status = NVParamGet ( + NV_SI_2P_CE_RAS_THRESHOLD, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + Configuration->Ras2pCeThreshold = (EFI_ERROR (Status)) ? 1 : Value; + + Status = NVParamGet ( + NV_SI_CPM_CE_RAS_THRESHOLD, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + Configuration->RasCpmCeThreshold = (EFI_ERROR (Status)) ? 1 : Value; + + Status = NVParamGet ( + NV_SI_LINK_ERR_THRESHOLD, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + Configuration->RasLinkErrThreshold = (EFI_ERROR (Status)) ? 1 : Value; + + Configuration->EnableApeiSupport = IsApeiSupport (); + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +RasConfigNvParamSet ( + IN RAS_CONFIG_VARSTORE_DATA *Configuration + ) +{ + NVParamSet ( + NV_SI_HARDWARE_EINJ, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + Configuration->RasHardwareEinj + ); + + NVParamSet ( + NV_SI_RAS_SDEI_ENABLED, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + Configuration->RasSdeiEnabled + ); + + NVParamSet ( + NV_SI_DDR_CE_RAS_THRESHOLD, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + Configuration->RasDdrCeThreshold + ); + + NVParamSet ( + NV_SI_2P_CE_RAS_THRESHOLD, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + Configuration->Ras2pCeThreshold + ); + + NVParamSet ( + NV_SI_CPM_CE_RAS_THRESHOLD, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + Configuration->RasCpmCeThreshold + ); + + NVParamSet ( + NV_SI_LINK_ERR_THRESHOLD, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU |NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + Configuration->RasLinkErrThreshold + ); + + return EFI_SUCCESS; +} + +/** + This function allows a caller to extract the current configuration for one + or more named elements from the target driver. + + @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. + @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 terminator if + request was successful. Points to the most recent + '&' before the first failing name/value pair (or + the beginning of the string if the failure 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 values filled + in for the names in the Request string. String 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 name. + @retval EFI_NOT_FOUND Routing data doesn't match any storage in this + driver. + +**/ +EFI_STATUS +EFIAPI +RasConfigExtractConfig ( + 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; + RAS_CONFIG_PRIVATE_DATA *PrivateData; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + EFI_STRING ConfigRequest; + EFI_STRING ConfigRequestHdr; + UINTN Size; + BOOLEAN AllocatedRequest; + + if (Progress == NULL || Results == NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Initialize the local variables. + // + ConfigRequestHdr = NULL; + ConfigRequest = NULL; + Size = 0; + *Progress = Request; + AllocatedRequest = FALSE; + + if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &mRasConfigFormSetGuid, RasConfigVarstoreDataName)) { + return EFI_NOT_FOUND; + } + + PrivateData = RAS_CONFIG_PRIVATE_FROM_THIS (This); + HiiConfigRouting = PrivateData->HiiConfigRouting; + + // + // Get current setting from NVParam. + // + Status = RasConfigNvParamGet (&PrivateData->Configuration); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Convert buffer data to by helper function BlockToConfig() + // + BufferSize = sizeof (RAS_CONFIG_VARSTORE_DATA); + ConfigRequest = Request; + if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) { + // + // Request has no request element, construct full request string. + // Allocate and fill a buffer large enough to hold the template + // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator + // + ConfigRequestHdr = HiiConstructConfigHdr (&mRasConfigFormSetGuid, RasConfigVarstoreDataName, PrivateData->DriverHandle); + Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); + ConfigRequest = AllocateZeroPool (Size); + ASSERT (ConfigRequest != NULL); + if (ConfigRequest == NULL) { + return EFI_OUT_OF_RESOURCES; + } + AllocatedRequest = TRUE; + UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); + FreePool (ConfigRequestHdr); + } + + // + // Convert buffer data to by helper function BlockToConfig() + // + Status = HiiConfigRouting->BlockToConfig ( + HiiConfigRouting, + ConfigRequest, + (UINT8 *) &PrivateData->Configuration, + BufferSize, + Results, + Progress + ); + + // + // Free the allocated config request string. + // + if (AllocatedRequest) { + FreePool (ConfigRequest); + ConfigRequest = NULL; + } + + // + // Set Progress string to the original request string. + // + if (Request == NULL) { + *Progress = NULL; + } else if (StrStr (Request, L"OFFSET") == NULL) { + *Progress = Request + StrLen (Request); + } + + return Status; +} + +/** + This function processes the results of changes in configuration. + + @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. + @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 failing + name/value pair (or the beginning of the string if + the failure is in the first name/value pair) or + the terminating NULL if all was successful. + + @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 +RasConfigRouteConfig ( + IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, + IN CONST EFI_STRING Configuration, + OUT EFI_STRING *Progress + ) +{ + EFI_STATUS Status; + UINTN BufferSize; + RAS_CONFIG_PRIVATE_DATA *PrivateData; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + + if (Configuration == NULL || Progress == NULL) { + return EFI_INVALID_PARAMETER; + } + + PrivateData = RAS_CONFIG_PRIVATE_FROM_THIS (This); + HiiConfigRouting = PrivateData->HiiConfigRouting; + *Progress = Configuration; + + // + // Check routing data in . + // Note: if only one Storage is used, then this checking could be skipped. + // + if (!HiiIsConfigHdrMatch (Configuration, &mRasConfigFormSetGuid, RasConfigVarstoreDataName)) { + return EFI_NOT_FOUND; + } + + // + // Get configuration data from NVParam + // + Status = RasConfigNvParamGet (&PrivateData->Configuration); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Convert to buffer data by helper function ConfigToBlock() + // + BufferSize = sizeof (RAS_CONFIG_VARSTORE_DATA); + Status = HiiConfigRouting->ConfigToBlock ( + HiiConfigRouting, + Configuration, + (UINT8 *) &PrivateData->Configuration, + &BufferSize, + Progress + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Store configuration data back to NVParam + // + Status = RasConfigNvParamSet (&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_PROTOCOL. + @param Action Specifies the type of action taken by the browser. + @param QuestionId A unique value which is sent to the original + 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 original + exporting driver. + @param ActionRequest On return, points to the action requested by the + callback function. + + @retval EFI_SUCCESS The callback successfully handled the action. + @retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters. + +**/ +EFI_STATUS +EFIAPI +RasConfigCallback ( + 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 != EFI_BROWSER_ACTION_CHANGING) { + // + // Do nothing for other UEFI Action. Only do call back when data is changed. + // + return EFI_UNSUPPORTED; + } + if (((Value == NULL) + && (Action != EFI_BROWSER_ACTION_FORM_OPEN) + && (Action != EFI_BROWSER_ACTION_FORM_CLOSE)) + || (ActionRequest == NULL)) { + return EFI_INVALID_PARAMETER; + } + + return EFI_SUCCESS; +} + +STATIC +UINT8* +HiiCreateGrayoutIf ( + IN VOID *OpCodeHandle, + IN EFI_QUESTION_ID QuestionId + ) +{ + struct { + EFI_IFR_OP_HEADER Header; + EFI_IFR_EQ_ID_VAL Condition; + } Buffer; + + Buffer.Header.OpCode=EFI_IFR_GRAY_OUT_IF_OP; + Buffer.Header.Length=sizeof(EFI_IFR_OP_HEADER); + Buffer.Header.Scope=1; + Buffer.Condition.Header.OpCode=EFI_IFR_EQ_ID_VAL_OP; + Buffer.Condition.Header.Scope=0; + Buffer.Condition.Header.Length=sizeof(EFI_IFR_EQ_ID_VAL); + Buffer.Condition.QuestionId=QuestionId; + Buffer.Condition.Value=1; + return HiiCreateRawOpCodes(OpCodeHandle, (UINT8*)&Buffer, sizeof(Buffer)); +} + +STATIC +EFI_STATUS +UpdateRasConfigScreen ( + IN RAS_CONFIG_PRIVATE_DATA *PrivateData + ) +{ + EFI_STATUS Status; + VOID *StartOpCodeHandle; + EFI_IFR_GUID_LABEL *StartLabel; + VOID *EndOpCodeHandle; + EFI_IFR_GUID_LABEL *EndLabel; + + // + // Initialize the container for dynamic opcodes + // + StartOpCodeHandle = HiiAllocateOpCodeHandle (); + ASSERT (StartOpCodeHandle != NULL); + + EndOpCodeHandle = HiiAllocateOpCodeHandle (); + ASSERT (EndOpCodeHandle != NULL); + + // + // Create Hii Extend Label OpCode as the start opcode + // + StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode ( + StartOpCodeHandle, + &gEfiIfrTianoGuid, + NULL, + sizeof (EFI_IFR_GUID_LABEL) + ); + if (StartLabel == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto FreeOpCodeBuffer; + } + StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; + StartLabel->Number = LABEL_UPDATE; + + // + // Create Hii Extend Label OpCode as the end opcode + // + EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode ( + EndOpCodeHandle, + &gEfiIfrTianoGuid, + NULL, + sizeof (EFI_IFR_GUID_LABEL) + ); + if (EndLabel == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto FreeOpCodeBuffer; + } + EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; + EndLabel->Number = LABEL_END; + + if (GetNumberActiveSockets () > 1) { + if (PrivateData->Configuration.EnableApeiSupport == 0) { + HiiCreateGrayoutIf (StartOpCodeHandle, 0x8005); + } + // + // Create the numeric for 2P CE threshold + // + HiiCreateNumericOpCode ( + StartOpCodeHandle, // Container for dynamic created opcodes + 0x8005, // Question ID + RAS_CONFIG_VARSTORE_ID, // VarStore ID + (UINT16) RAS_2P_CE_THRESHOLD, // Offset in Buffer Storage + STRING_TOKEN (STR_RAS_2P_CE_THRESHOLD_PROMPT), // Question prompt text + STRING_TOKEN (STR_RAS_2P_CE_THRESHOLD_HELP), + EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED, + EFI_IFR_NUMERIC_SIZE_4, + 1, + 8192, + 1, + NULL + ); + + if (PrivateData->Configuration.EnableApeiSupport == 0) { + HiiCreateEndOpCode (StartOpCodeHandle); + } + } + + Status = HiiUpdateForm ( + PrivateData->HiiHandle, // HII handle + &mRasConfigFormSetGuid, // Formset GUID + RAS_CONFIG_FORM_ID, // Form ID + StartOpCodeHandle, // Label for where to insert opcodes + EndOpCodeHandle // Insert data + ); + +FreeOpCodeBuffer: + HiiFreeOpCodeHandle (StartOpCodeHandle); + HiiFreeOpCodeHandle (EndOpCodeHandle); + + return Status; +} + +EFI_STATUS +EFIAPI +RasConfigUnload ( + VOID + ) +{ + ASSERT (mPrivateData != NULL); + + if (mDriverHandle != NULL) { + gBS->UninstallMultipleProtocolInterfaces ( + mDriverHandle, + &gEfiDevicePathProtocolGuid, + &mRasConfigHiiVendorDevicePath, + &gEfiHiiConfigAccessProtocolGuid, + &mPrivateData->ConfigAccess, + NULL + ); + mDriverHandle = NULL; + } + + if (mPrivateData->HiiHandle != NULL) { + HiiRemovePackages (mPrivateData->HiiHandle); + } + + FreePool (mPrivateData); + mPrivateData = NULL; + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +RasConfigEntryPoint ( + 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 = AllocateZeroPool (sizeof (RAS_CONFIG_PRIVATE_DATA)); + if (mPrivateData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + mPrivateData->Signature = RAS_CONFIG_PRIVATE_SIGNATURE; + + mPrivateData->ConfigAccess.ExtractConfig = RasConfigExtractConfig; + mPrivateData->ConfigAccess.RouteConfig = RasConfigRouteConfig; + mPrivateData->ConfigAccess.Callback = RasConfigCallback; + + // + // Locate ConfigRouting protocol + // + Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &HiiConfigRouting); + if (EFI_ERROR (Status)) { + return Status; + } + mPrivateData->HiiConfigRouting = HiiConfigRouting; + + Status = gBS->InstallMultipleProtocolInterfaces ( + &mDriverHandle, + &gEfiDevicePathProtocolGuid, + &mRasConfigHiiVendorDevicePath, + &gEfiHiiConfigAccessProtocolGuid, + &mPrivateData->ConfigAccess, + NULL + ); + ASSERT_EFI_ERROR (Status); + + mPrivateData->DriverHandle = mDriverHandle; + + // + // Publish our HII data + // + HiiHandle = HiiAddPackages ( + &mRasConfigFormSetGuid, + mDriverHandle, + RasConfigDxeStrings, + VfrBin, + NULL + ); + if (HiiHandle == NULL) { + gBS->UninstallMultipleProtocolInterfaces ( + mDriverHandle, + &gEfiDevicePathProtocolGuid, + &mRasConfigHiiVendorDevicePath, + &gEfiHiiConfigAccessProtocolGuid, + &mPrivateData->ConfigAccess, + NULL + ); + return EFI_OUT_OF_RESOURCES; + } + + mPrivateData->HiiHandle = HiiHandle; + + Status = UpdateRasConfigScreen (mPrivateData); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a %d Fail to update Memory Configuration screen \n", + __FUNCTION__, __LINE__)); + RasConfigUnload (); + ASSERT_EFI_ERROR (Status); + return Status; + } + + return EFI_SUCCESS; +} diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/VfrStrings.uni b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/VfrStrings.uni index f15a8ba433fa..2219612900b4 100644 --- a/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/VfrStrings.uni +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/AcpiConfigDxe/VfrStrings.uni @@ -14,6 +14,9 @@ #string STR_ACPI_COMMON_DISABLE #language en-US "Disabled" #string STR_ACPI_UNSUPPORTED #language en-US "Unsupported" +#string STR_ACPI_APEI_SUPPORT_PROMPT #language en-US "APEI Support" +#string STR_ACPI_APEI_SUPPORT_HELP #language en-US "Enable/Disable ACPI Platform Error Interface support" + #string STR_ACPI_CPPC_PROMPT #language en-US "CPPC Support" #string STR_ACPI_CPPC_HELP #language en-US "Enables or Disables System ability to CPPC (Collaborative Processor Performance Control)" diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/VfrStrings.uni b/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/VfrStrings.uni new file mode 100644 index 000000000000..8cfa0999c023 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/VfrStrings.uni @@ -0,0 +1,35 @@ +// +// Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// + +#langdef en-US "English" + +#string STR_RAS_FORM #language en-US "RAS Configuration" +#string STR_RAS_FORM_HELP #language en-US "RAS Configuration" + +#string STR_RAS_FORM_SEPERATE_LINE #language en-US "" +#string STR_RAS_COMMON_ENABLE #language en-US "Enabled" +#string STR_RAS_COMMON_DISABLE #language en-US "Disabled" + +#string STR_RAS_HARDWARE_EINJ_PROMPT #language en-US "Hardware EINJ" +#string STR_RAS_HARDWARE_EINJ_HELP #language en-US "Enable hardware EINJ support, if disabled EINJ is software simulated" + +#string STR_RAS_BERT_ENABLED_PROMPT #language en-US "Enable BERT" +#string STR_RAS_BERT_ENABLED_HELP #language en-US "Enable Boot Error Record Table, if disabled BERT will not be populated" + +#string STR_RAS_SDEI_ENABLED_PROMPT #language en-US "Enable SDEI" +#string STR_RAS_SDEI_ENABLED_HELP #language en-US "Enable Software Delegated Exception Interface for NMI support" + +#string STR_RAS_DDR_CE_THRESHOLD_PROMPT #language en-US "DDR CE Threshold" +#string STR_RAS_DDR_CE_THRESHOLD_HELP #language en-US "Number of DDR CEs to occur during time interval before reporting" + +#string STR_RAS_2P_CE_THRESHOLD_PROMPT #language en-US "2P CE Threshold" +#string STR_RAS_2P_CE_THRESHOLD_HELP #language en-US "Number of 2P CEs to occur during time interval before reporting" + +#string STR_RAS_CPM_CE_THRESHOLD_PROMPT #language en-US "Processor CE Threshold" +#string STR_RAS_CPM_CE_THRESHOLD_HELP #language en-US "Number of processor CEs to occur during time interval before reporting" + +#string STR_RAS_LINK_ERR_THRESHOLD_PROMPT #language en-US "DDR Link Error Threshold" +#string STR_RAS_LINK_ERR_THRESHOLD_HELP #language en-US "Number of DDR link errors before considering it fatal severity" -- 2.17.1