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.web08.10538.1604047328816555511 for ; Fri, 30 Oct 2020 01:42:08 -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 6D935D6E; Fri, 30 Oct 2020 01:42:08 -0700 (PDT) Received: from usa.arm.com (a076764.blr.arm.com [10.162.16.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C559A3F719; Fri, 30 Oct 2020 01:42:06 -0700 (PDT) From: "Omkar Anand Kulkarni" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Sami Mujawar , Jiewen Yao Subject: [edk2-platforms][PATCH 2/6] Platform/ARM/Sgi: Install SDEI ACPI table Date: Fri, 30 Oct 2020 14:11:52 +0530 Message-Id: <20201030084156.8291-3-omkar.kulkarni@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201030084156.8291-1-omkar.kulkarni@arm.com> References: <20201030084156.8291-1-omkar.kulkarni@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On SGI/RD platforms that require SDEI mechanism to let OS know about a high priority system event, such as a RAS event, create and install the SDEI ACPI table. Co-authored-by: Thomas Abraham Signed-off-by: Omkar Anand Kulkarni --- Platform/ARM/SgiPkg/SgiPlatform.dec | 1 + Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf | 1 + Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c | 79 +++++++++++= +++++++++ 3 files changed, 81 insertions(+) diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/Sg= iPlatform.dec index dac7fdc308b1..f139b90d81e3 100644 --- a/Platform/ARM/SgiPkg/SgiPlatform.dec +++ b/Platform/ARM/SgiPkg/SgiPlatform.dec @@ -31,6 +31,7 @@ [PcdsFeatureFlag.common] gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|FALSE|BOOLEAN|0x00000001 gArmSgiTokenSpaceGuid.PcdVirtioNetSupported|FALSE|BOOLEAN|0x00000010 + gArmSgiTokenSpaceGuid.PcdSdeiSupported|FALSE|BOOLEAN|0x0000000D =20 [PcdsFixedAtBuild] gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000002 diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Pl= atform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf index 9d89314a594e..2ea2c09e3920 100644 --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf @@ -33,6 +33,7 @@ gArmSgiAcpiTablesGuid =20 [FeaturePcd] + gArmSgiTokenSpaceGuid.PcdSdeiSupported gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported gArmSgiTokenSpaceGuid.PcdVirtioNetSupported =20 diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Plat= form/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c index 2f72e7152ff3..9250243decb8 100644 --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c @@ -6,9 +6,16 @@ * **/ =20 +#include + #include +#include #include #include +#include + +#include + #include =20 VOID @@ -16,6 +23,71 @@ InitVirtioDevices ( VOID ); =20 +/** + 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. Build and install the = SDEI + table to enable support for SDEI. + + @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, + "Failed to locate ACPI table protocol, status: %r\n", + Status + )); + return Status; + } + + Status =3D mAcpiTableProtocol->InstallAcpiTable ( + mAcpiTableProtocol, + &Header, + Header.Length, + &AcpiTableHandle + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "Failed to install SDEI ACPI table, status: %r\n", + Status + )); + } + + return Status; +} + EFI_STATUS EFIAPI ArmSgiPkgEntryPoint ( @@ -31,6 +103,13 @@ ArmSgiPkgEntryPoint ( return Status; } =20 + if (FeaturePcdGet (PcdSdeiSupported)) { + Status =3D InstallSdeiTable (); + if (EFI_ERROR (Status)) { + return Status; + } + } + InitVirtioDevices (); =20 return Status; --=20 2.17.1