From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.35768.1629784847461016943 for ; Mon, 23 Aug 2021 23:00:47 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: omkar.kulkarni@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1955E1042; Mon, 23 Aug 2021 23:00:47 -0700 (PDT) Received: from usa.arm.com (a077433.blr.arm.com [10.162.46.10]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D98A93F766; Mon, 23 Aug 2021 23:00:45 -0700 (PDT) From: "Omkar Anand Kulkarni" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar Subject: [edk2-platforms][PATCH v3 5/5] Platform/Sgi: Add platform error handling driver Date: Tue, 24 Aug 2021 11:30:27 +0530 Message-Id: <20210824060027.27246-6-omkar.kulkarni@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210824060027.27246-1-omkar.kulkarni@arm.com> References: <20210824060027.27246-1-omkar.kulkarni@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Enables firmware first error handling on the given platform. Installs and publishes the SDEI and HEST ACPI tables required for firmware first error handling. Signed-off-by: Omkar Anand Kulkarni --- Platform/ARM/SgiPkg/SgiPlatform.dsc.inc = | 10 ++ Platform/ARM/SgiPkg/SgiPlatform.fdf = | 7 + Platform/ARM/SgiPkg/Drivers/PlatformErrorHandlerDxe/PlatformErrorHandler= Dxe.inf | 51 ++++++ Platform/ARM/SgiPkg/Drivers/PlatformErrorHandlerDxe/PlatformErrorHandler= Dxe.c | 171 ++++++++++++++++++++ 4 files changed, 239 insertions(+) diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc b/Platform/ARM/SgiPk= g/SgiPlatform.dsc.inc index 102d7926bde1..20f003b96cdb 100644 --- a/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc +++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc @@ -24,6 +24,9 @@ # To allow firmware first error handling, set this to TRUE. DEFINE ENABLE_GHES_MM =3D FALSE =20 + # To allow firmware first error handling, set this to TRUE. + DEFINE ENABLE_FIRWARE_FIRST =3D FALSE + [BuildOptions] *_*_*_CC_FLAGS =3D -D DISABLE_NEW_DEPRECATED_INTERFACES =20 @@ -326,6 +329,13 @@ # Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf =20 + # + # platform error handler driver + # +!if $(ENABLE_FIRMWARE_FIRST) =3D=3D TRUE + Platform/ARM/SgiPkg/Drivers/PlatformErrorHandlerDxe/PlatformErrorHandl= erDxe.inf +!endif + # # FAT filesystem + GPT/MBR partitioning # diff --git a/Platform/ARM/SgiPkg/SgiPlatform.fdf b/Platform/ARM/SgiPkg/Sg= iPlatform.fdf index d6e942e19b81..b1d088610c4c 100644 --- a/Platform/ARM/SgiPkg/SgiPlatform.fdf +++ b/Platform/ARM/SgiPkg/SgiPlatform.fdf @@ -190,6 +190,13 @@ READ_LOCK_STATUS =3D TRUE # INF Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf =20 + # + # platform error handler driver + # +!if $(ENABLE_FIRMWARE_FIRST) =3D=3D TRUE + INF Platform/ARM/SgiPkg/Drivers/PlatformErrorHandlerDxe/PlatformErrorH= andlerDxe.inf +!endif + # # Bds # diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformErrorHandlerDxe/Platform= ErrorHandlerDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformErrorHandlerDxe= /PlatformErrorHandlerDxe.inf new file mode 100644 index 000000000000..fe9ed4175b0b --- /dev/null +++ b/Platform/ARM/SgiPkg/Drivers/PlatformErrorHandlerDxe/PlatformErrorHa= ndlerDxe.inf @@ -0,0 +1,51 @@ +## @file +# Dxe driver to handle platform errors. +# +# This driver installs SDEI and HEST ACPI tables required for firmware = first +# error handling. +# +# Copyright (c) 2020 - 2021, ARM Limited. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D PlatformErrorHandlerDxe + FILE_GUID =3D a3187ea4-feb4-415f-b11e-2312623ffa6= f + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D PlatformErrorHandlerEntryPoint + +[Sources.common] + PlatformErrorHandlerDxe.c + +[Packages] + ArmPlatformPkg/ArmPlatformPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Platform/ARM/SgiPkg/SgiPlatform.dec + +[LibraryClasses] + AcpiLib + BaseLib + DebugLib + UefiDriverEntryPoint + +[Guids] + gArmSgiAcpiTablesGuid + +[Protocols] + gEfiAcpiTableProtocolGuid ## PROTOCOL ALWAYS_CONSUMED + gHestTableProtocolGuid ## PROTOCOL ALWAYS_CONSUMED + +[FixedPcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId + +[Depex] + AFTER gArmPlatformHestErrorSourcesGuid diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformErrorHandlerDxe/Platform= ErrorHandlerDxe.c b/Platform/ARM/SgiPkg/Drivers/PlatformErrorHandlerDxe/P= latformErrorHandlerDxe.c new file mode 100644 index 000000000000..25b29152f1bb --- /dev/null +++ b/Platform/ARM/SgiPkg/Drivers/PlatformErrorHandlerDxe/PlatformErrorHa= ndlerDxe.c @@ -0,0 +1,171 @@ +/** @file + Driver to handle and support all platform errors. + + Installs the SDEI and HEST ACPI tables for firmware first error handli= ng. + + Copyright (c) 2020 - 2021, ARM Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Specification Reference: + - ACPI 6.3, Table 18-382, Hardware Error Source Table + - SDEI Platform Design Document, revision b, 10 Appendix C, ACPI tab= le + definitions for SDEI +**/ + +#include + +#include +#include +#include +#include + +#include +#include + + +/** + Build and install the SDEI ACPI table. + + For platforms that allow firmware-first platform error handling, SDEI = is used + as the notification mechanism for those errors. + + @retval EFI_SUCCESS SDEI table installed successfully. + @retval Other For any error during installation. +**/ +STATIC +EFI_STATUS +InstallSdeiTable (VOID) +{ + EFI_ACPI_TABLE_PROTOCOL *mAcpiTableProtocol =3D NULL; + EFI_ACPI_DESCRIPTION_HEADER Header; + EFI_STATUS Status; + UINTN AcpiTableHandle; + + Header =3D + (EFI_ACPI_DESCRIPTION_HEADER) { + EFI_ACPI_6_3_SOFTWARE_DELEGATED_EXCEPTIONS_INTERFACE_TABLE_SIGNATUR= E, + sizeof (EFI_ACPI_DESCRIPTION_HEADER), // Length + 0x01, // Revision + 0x00, // Checksum + {'A', 'R', 'M', 'L', 'T', 'D'}, // OemId + 0x4152464e49464552, // OemTableId:"REFINFRA" + 0x20201027, // OemRevision + 0x204d5241, // CreatorId:"ARM " + 0x00000001, // CreatorRevision + }; + + Header.Checksum =3D CalculateCheckSum8 ((UINT8 *)&Header, Header.Lengt= h); + Status =3D gBS->LocateProtocol ( + &gEfiAcpiTableProtocolGuid, + NULL, + (VOID **)&mAcpiTableProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to locate ACPI table protocol, status: %r\n", + __FUNCTION__, + Status + )); + return Status; + } + + Status =3D mAcpiTableProtocol->InstallAcpiTable ( + mAcpiTableProtocol, + &Header, + Header.Length, + &AcpiTableHandle + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to install SDEI ACPI table, status: %r\n", + __FUNCTION__, + Status + )); + } + + return Status; +} + +/** + Install the HEST ACPI table. + + HEST ACPI table is used to list the platform errors for which the erro= r + handling has been supported. Use the HEST table generation protocol to + install the HEST table. + + @retval EFI_SUCCESS HEST table installed successfully. + @retval Other For any error during installation. +**/ +STATIC +EFI_STATUS +InstallHestTable (VOID) +{ + HEST_TABLE_PROTOCOL *HestProtocol; + EFI_STATUS Status; + + Status =3D gBS->LocateProtocol ( + &gHestTableProtocolGuid, + NULL, + (VOID **)&HestProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to locate HEST DXE Protocol, status: %r\n", + __FUNCTION__, + Status + )); + return Status; + } + + Status =3D HestProtocol->InstallHestTable (); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to install HEST table, status: %r\n", + __FUNCTION__, + Status + )); + } + + return Status; +} + +/** + Entry point for the DXE driver. + + This function installs the HEST ACPI table, using the HEST table gener= ation + protocol. Also creates and installs the SDEI ACPI table required for f= irmware + first error handling. + + @param[in] ImageHandle Handle to the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS On successful installation of ACPI tables + @retval Other On Failure +**/ +EFI_STATUS +EFIAPI +PlatformErrorHandlerEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // Build and install SDEI table. + Status =3D InstallSdeiTable (); + if (EFI_ERROR (Status)) { + return Status; + } + + // Install the created HEST table. + Status =3D InstallHestTable (); + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} --=20 2.17.1