From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web11.4138.1607505903123052670 for ; Wed, 09 Dec 2020 01:25:03 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=Bi/xkEue; spf=fail (domain: os.amperecomputing.com, ip: , mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jg68xaeTUSI+NC8iEYuMf5jnKLiDEKcLyJneKmJQhppDKUeHW6SMWDuFKx6Zy/YlAJ4IllGpI0anncn+yI68YmNH72eIWjUUHImzWXbZ5V3g6U2LxxBFuPpNq+L/JLt6JIM/ByDtCjMv+9+uZAN0xrjqjtRHtVtCyBkIBLuSyyw7ayjz5PdvFTvhzMTn04QJ8u6B33Tzti5x5OIujamv2xlOTYYcglwj8BC8qqHjljL52s1POFIAYk5TbPLqRlrYyzPHPMiu5WTHWQX+ofKIsafjQsRyjTZUTjcKel2uyYwA2UDU2W8klgiQfeonRs6B8QBbVRfOxIPErLBVGBHp8g== 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=oqQ3jeeyWVPlMPBFa6V0kU5OovWj6V1lzBK7FKJZd/E=; b=Y7VXwMOKflRGiaR4Sgdj777iax1ruRBUdQmmRsc8ayR9bXNcafDjzrZWDRhYAqplUKtGoAKhjPrreNFC7VBa2M8xWBoaTvGmO8UGrbX6QS/ufpHDAPrOGlqxxvLodn/LJITzAtFEhnare5QU0FnI/V/8GM4rJ5VGb/7gRzabw2s9Ys+Ua1n6G6o0KNsOvyyNx8XF+m+zEmZq8+pzPLs4osny9IXTeFtO2EsER2JsjIjPUXNsRxut8xwQLJfc7sN5Eo0Tnqbi+SssCOrDQSBfQUUCyhuk/RfCMcX+Wr9M75nH8VlwDZwIT0O5BbuxHJzMwm8LBSg4MEyJqdEpvTC5aw== 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=oqQ3jeeyWVPlMPBFa6V0kU5OovWj6V1lzBK7FKJZd/E=; b=Bi/xkEue88dGyjr2j4et2rNMch+1ZKcUK45HC2Hnw2rbdkE316V6bKwNjizSOBsQNK862CxjYw20LuFX4HHrICqShst7k1WCh5Npqm8jJBnjuE9JSLjUSeNietVT1lFR9EnxeE0G3Gf1J0FcuhoBgu6JDytSfDCN2SH5Ye8uT2o= 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:02 +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:02 +0000 From: "Nhi Pham" To: devel@edk2.groups.io Cc: Quan Nguyen , Nhi Pham Subject: [edk2-platforms][PATCH 33/34] Platform/Ampere: Add AcpiApeiLib Date: Wed, 9 Dec 2020 16:25:30 +0700 Message-Id: <20201209092531.30867-34-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:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1fd6e69b-4273-447f-fd5c-08d89c244e88 X-MS-TrafficTypeDiagnostic: DM6PR01MB5932: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jgwd2vNAJ4tNPrKs0+wX5i+6PfqfMcu0KPCS0+gAbQlgVx7Hzfn0yXyMIhuE4DLmWnIjQnm9+cF9EG3RDaF96NJ9MCIdpmrQCa+vVR8FXGp5BWbG0IgwnOcj8yy/vsRCQ49NjOJqsIxZGsv4yhU75l6HyU8BIKgxJaDgRYreSJYxk4Ng3UJL1Wj9ScgCdpnS/M+h5ADTK4i1bZP1sBSIqTxxg1GHMCj/sZR8BfjAkpGTCdTvS1uxue1IPPFOIiBLBlfe4Rs4iVICqeOFd6EeUv4i+G/uKTd2MhM4nqzvF8ln3OncsI+BXE/YDFAvP8zXKpRG2/JCMHm5NmuBS3D3piZvJKse27C3EuYOef91iRo1RCQG7+ezP53Binj01hqC 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)(83380400001)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?Uhd9438ZjCVBKgf/k3nLxXGg65VE0ntLMd3HrIvaQAyapnH0GnQOSXoDTWQq?= =?us-ascii?Q?PJdnlgWJ8Mon7ZsZk58lsyvVeIzCXe+3hJw6cXpCJnKaKa00UDO3KmySnalW?= =?us-ascii?Q?cDBJoola66+xsNbFZaWI3xZcvbB+KEqpJhtUXnW9Uxz/Hg1cLvu+ohBlXRPD?= =?us-ascii?Q?oeMvX7vfudGWh09Knpskjps4XAjNX6TF4Wfhls/yYTFRV9I5sKW8joSiAlxr?= =?us-ascii?Q?0ZY3KWO3fG50FurhwbS2feOMr+7OLZ9bF4yjW7Np3UiupBNeuDC9iZBM9UQg?= =?us-ascii?Q?+TnvIxxXJ73x66kHPZ/xI8fsO8fs4wv8PZZF5etOVpVfcejH1BnkkbhCpqDN?= =?us-ascii?Q?yrj+d/b7vZUBdjZo3xmZ9Pvy46prvdQJXrx62nE4Bp4CrOKT71dsSE6O+wh1?= =?us-ascii?Q?bit1pTrZ44c8xJ/lFNmOK4iRjAdkxpllTUrVGhGNbzzElEdoD9OUdUMnnuUR?= =?us-ascii?Q?UGx9jFME9qkolA0qZUUzS3Yy3TnZPS2FhmZzRQjwyWA/vezg68Hyp20EUapK?= =?us-ascii?Q?pqm/jby7fqN10lkLTliYWJqUznNRHpHvB2DUg6ANHQGaKia3WNYYIswEMvcb?= =?us-ascii?Q?IFLVJZepg47GyDU/ESg3iGyDEthEikzcMIG77M9uZG+NCsjUrr/0soj0YJEt?= =?us-ascii?Q?a1eAeo/vU8ThA/DIBih2UihbHTzzZVGX7XoYEe4LuIDNQ2zwGvNP4+4M8lur?= =?us-ascii?Q?61omEOzeXQmTL+UGgTWhY0W7hYpcRPN0bkAftz9WttBqOsDgV2u4Adu5tov5?= =?us-ascii?Q?lnTgOuR3IwLM1HnXjURiWyajVstcoHk/A86GsDaDZWlOVGEM4ylPONCj9/tv?= =?us-ascii?Q?/dyUKuBIq8Xkv9Zkiji2M/0u2Mkcdyqhl2QK6L8DZmKkM77Rm14bPqZ48c+6?= =?us-ascii?Q?8YGe5VyGXs/mLBFNELG2BSl3aWJIXN4P52I7tj16opEBKQ3QKsiCqBvaDykR?= =?us-ascii?Q?4MBnb+TJaihCSqxYj6aqbOseTmVZsKdYCLPV5wkXrvro7a5E8gct6IfAjqhB?= =?us-ascii?Q?UUm7?= 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:01.7295 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-Network-Message-Id: 1fd6e69b-4273-447f-fd5c-08d89c244e88 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6RwNDU1zDPfJSguSVGhf4hINKa5hQ2vHtNKQDAd+Shi0Yz/V3qh3YbDZKoRHFqQnBMb9LvojrKDrZn6I/XRcA7XzmssBNzFWLc0BhEI0DNw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB5932 Content-Type: text/plain From: Quan Nguyen This patch adds ACPI APEI helper library to support RAS features. Signed-off-by: Nhi Pham Signed-off-by: Quan Nguyen --- Platform/Ampere/Library/AcpiApeiLib/AcpiApeiLib.inf | 39 ++++ Platform/Ampere/Include/Library/AcpiApeiLib.h | 158 ++++++++++++++ Platform/Ampere/Library/AcpiApeiLib/AcpiApeiLib.c | 227 ++++++++++++++++++++ 3 files changed, 424 insertions(+) diff --git a/Platform/Ampere/Library/AcpiApeiLib/AcpiApeiLib.inf b/Platform/Ampere/Library/AcpiApeiLib/AcpiApeiLib.inf new file mode 100644 index 000000000000..def5265c4113 --- /dev/null +++ b/Platform/Ampere/Library/AcpiApeiLib/AcpiApeiLib.inf @@ -0,0 +1,39 @@ +## @file +# +# Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x0001001B + VERSION_STRING = 1.0 + BASE_NAME = AcpiApeiLib + MODULE_TYPE = BASE + LIBRARY_CLASS = AcpiApeiLib + FILE_GUID = DFC50F0A-C3D1-11E6-A4A6-CEC0C932CE01 + +[Sources.common] + AcpiApeiLib.c + +[Packages] + ArmPkg/ArmPkg.dec + MdePkg/MdePkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + Silicon/Ampere/AmperePkg.dec + Silicon/Ampere/AmpereAltraPkg/Ac01Pkg.dec + +[LibraryClasses] + ArmLib + ArmPlatformLib + BaseLib + BaseMemoryLib + DebugLib + DxeServicesLib + IoLib + MemoryAllocationLib + PrintLib + TimerLib + UefiLib + SMProLib diff --git a/Platform/Ampere/Include/Library/AcpiApeiLib.h b/Platform/Ampere/Include/Library/AcpiApeiLib.h new file mode 100644 index 000000000000..963932d02ec9 --- /dev/null +++ b/Platform/Ampere/Include/Library/AcpiApeiLib.h @@ -0,0 +1,158 @@ +/** @file + + Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _ACPI_APEI_LIB_H_ +#define _ACPI_APEI_LIB_H_ + +#include +#include +#include + +/* + * BERT entry list + * + * All errors in BERT fall under one Error Source + */ + +#define ACPI_APEI_BERT_MAX 1 + +/* + * GHES entry list + * + * NOTE, adding more GHES entries requires you to add more GHES + * entries in the HEST.adt file. + */ + +typedef enum { + ACPI_APEI_GHES_CPU = 0, + ACPI_APEI_GHES_L2C, + ACPI_APEI_GHES_L3C, + ACPI_APEI_GHES_MCU, + ACPI_APEI_GHES_IOB_RBM, + ACPI_APEI_GHES_IOB_GLBL, + ACPI_APEI_GHES_IOB_TRANS, + ACPI_APEI_GHES_XGIC, + ACPI_APEI_GHES_SMMU, + ACPI_APEI_GHES_SOC, + ACPI_APEI_GHES_SOC_MCU, + ACPI_APEI_GHES_MPA, + ACPI_APEI_GHES_MAX +} ACPI_APEI_GHES_ENTRY; + +/* + * For each GHES entry, there is Error Status and Error Data that needs + * to be gathered and reported. The Error Data is stored in the following + * APEI Data Structures. + */ + +#pragma pack(1) +typedef struct { + EFI_ACPI_6_3_GENERIC_ERROR_DATA_ENTRY_STRUCTURE GED; + EFI_PROCESSOR_GENERIC_ERROR_DATA PError; +} ACPI_APEI_ERROR_DATA; + +typedef struct { + EFI_ACPI_6_3_GENERIC_ERROR_DATA_ENTRY_STRUCTURE GED; + EFI_PLATFORM_MEMORY_ERROR_DATA MError; +} ACPI_APEI_MEM_ERROR_DATA; + +/* + * Error Status with one or more Error Data sections per error + * record make up an Error Status Block (ESB). The ESB will be + * linked to a GHES entry via the Error Status Address. + */ + +#define ACPI_APEI_ESB_MAX_BERT_ERRORS 8 +#define ACPI_APEI_ESB_MAX_GHES_ERRORS 1 +#define ACPI_APEI_ESB_MAX_ERROR_INFO 23 +#define ACPI_APEI_ESB_FIRMWARE_MEMORY 984 + +typedef struct { + EFI_ACPI_6_3_GENERIC_ERROR_STATUS_STRUCTURE GES; + ACPI_APEI_ERROR_DATA data; + ACPI_APEI_ERROR_DATA info[ACPI_APEI_ESB_MAX_ERROR_INFO]; +} ACPI_APEI_ESB; + + +/* + * Version 2 of RAS_APEI_ES between BIOS and Firmware. + * + * This is the memory view of Error Source Data for BERT and GHES entries + */ + +typedef struct { + UINT32 ErrorDataEntryCount; + UINT32 Length; + ACPI_APEI_ESB ESB[ACPI_APEI_ESB_MAX_BERT_ERRORS]; +} RAS_APEI_BERT_DATA; + +typedef struct { + UINT64 ErrorStatusAddress; + UINT32 ErrorDataEntryCount; + UINT32 Length; + ACPI_APEI_ESB ESB[ACPI_APEI_ESB_MAX_GHES_ERRORS]; + UINT32 Reserved; /* Reserved - keep data 64bit aligned */ + UINT8 FirmwareMemory[ACPI_APEI_ESB_FIRMWARE_MEMORY]; +} RAS_APEI_GHES_DATA; + +typedef struct { + UINT64 Resv1; /* v1 ErrorStatusAddress set to 0 */ + UINT64 Resv2; /* v1 GES set to 0 */ + UINT32 TotalLength; + UINT32 ErrorSourceCount; + RAS_APEI_BERT_DATA ErrorSourceData[ACPI_APEI_BERT_MAX]; +} RAS_APEI_BERT_ES; + +typedef struct { + UINT64 Resv1; /* v1 ErrorStatusAddress set to 0 */ + UINT64 Resv2; /* v1 GES set to 0 */ + UINT32 TotalLength; + UINT32 ErrorSourceCount; + RAS_APEI_GHES_DATA ErrorSourceData[ACPI_APEI_GHES_MAX]; +} RAS_APEI_GHES_ES; + +/* + * Version 1 of RAS_APEI_ES between BIOS and Firmware. + * + * This interface structure is no longer used. It is here + * only as reference for Version 2. + */ + +typedef struct { + UINT64 ErrorStatusAddress; /* pointer to GHES.ErrorStatusAddress */ + UINT64 Ges; /* pointer to GES (use to report ErrorBlockStatus) */ + UINT32 ErrorBlockStatus; /* ErrorBlockStatus to report */ + UINT32 Resv; /* Reserved */ +} RAS_APEI_ES_VERSION_1; +#pragma pack() + +/* + * AcpiApeiLib interface + */ + +EFI_STATUS +AcpiApeiLibInit (VOID); + +RAS_APEI_BERT_DATA* +AcpiApeiLibGetBertData (VOID); + +RAS_APEI_GHES_DATA* +AcpiApeiLibGetGhesData ( + IN UINT32 ErrorSourceIdx + ); + +#define APEI_ERROR_DETECTION_PMPRO 0 +#define APEI_ERROR_DETECTION_ATF 1 + +EFI_STATUS +AcpiApeiLibEnable ( + UINT8 Enable, + UINT8 FwErrorDetection + ); + +#endif /* _ACPI_APEI_LIB_H_ */ diff --git a/Platform/Ampere/Library/AcpiApeiLib/AcpiApeiLib.c b/Platform/Ampere/Library/AcpiApeiLib/AcpiApeiLib.c new file mode 100644 index 000000000000..9962429d26d4 --- /dev/null +++ b/Platform/Ampere/Library/AcpiApeiLib/AcpiApeiLib.c @@ -0,0 +1,227 @@ +/** @file + + Copyright (c) 2020, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SMC_XRAS_PROXY_FUNC_ID 0xc300ff07 + +enum { + SMC_XRAS_SET_APEI_PTR = 1, + SMC_XRAS_GET_APEI_PTR, + SMC_XRAS_ENABLE, + SMC_XRAS_DISABLE +}; + +/* + * Reserved Memory + */ +STATIC RAS_APEI_GHES_ES *FwRasApeiGhesLookUpTable = NULL; +STATIC RAS_APEI_BERT_ES *FwRasApeiBertLookUpTable = NULL; + +/* + * AcpiApeiLibAllocateReservedMemForErrorSourceTable + */ +STATIC EFI_STATUS +AcpiApeiLibAllocateReservedMemForErrorSourceTable (VOID) +{ + UINT32 Length; + + /* + * Allocate reserved memory for each Error Source and initialize it. + */ + Length = sizeof (RAS_APEI_GHES_ES); + FwRasApeiGhesLookUpTable = (RAS_APEI_GHES_ES *) AllocateReservedZeroPool (Length); + if (FwRasApeiGhesLookUpTable == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + FwRasApeiGhesLookUpTable->TotalLength = Length; + FwRasApeiGhesLookUpTable->ErrorSourceCount = ACPI_APEI_GHES_MAX; + + /* + * Allocate a BootErrorSource. + * + * BERT does not distinguish errors based on an Error Source Like the HEST + * table does by using GHES entries. All errors in BERT fall under one Error + * Source (let's call it the BERT Error Source). + */ + Length = sizeof (RAS_APEI_BERT_ES); + FwRasApeiBertLookUpTable = (RAS_APEI_BERT_ES *) AllocateReservedZeroPool (Length); + if (FwRasApeiBertLookUpTable == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + FwRasApeiBertLookUpTable->TotalLength = Length; + FwRasApeiBertLookUpTable->ErrorSourceCount = ACPI_APEI_BERT_MAX; + + return EFI_SUCCESS; +} + +/* + * AcpiApeiLibFreeReservedMem + */ +STATIC VOID +AcpiApeiLibFreeReservedMem (VOID) +{ + if (FwRasApeiGhesLookUpTable != NULL) { + FreePool (FwRasApeiGhesLookUpTable); + FwRasApeiGhesLookUpTable = NULL; + } + + if (FwRasApeiBertLookUpTable != NULL) { + FreePool (FwRasApeiBertLookUpTable); + FwRasApeiBertLookUpTable = NULL; + } +} + +/* + * AcpiApeiLibAllocateReservedMem + */ +STATIC EFI_STATUS +AcpiApeiLibAllocateReservedMem(VOID) +{ + EFI_STATUS Status; + + /* + * Reserve Memory For ACPI/APEI ErrorSourceTable + */ + Status = AcpiApeiLibAllocateReservedMemForErrorSourceTable (); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "%a: Allocating APEI Reserved Memory for ErrorSourceTable failed\n", + __FUNCTION__)); + goto Error; + } + + return Status; + +Error: + AcpiApeiLibFreeReservedMem (); + return Status; +} + +/* + * AcpiApeiLibGetGhesData + */ +RAS_APEI_GHES_DATA* +AcpiApeiLibGetGhesData ( + IN UINT32 ErrorSourceIdx + ) +{ + if ((FwRasApeiGhesLookUpTable == NULL) || (ErrorSourceIdx >= ACPI_APEI_GHES_MAX)) + return NULL; + + return &FwRasApeiGhesLookUpTable->ErrorSourceData[ErrorSourceIdx]; +} + +/* + * AcpiApeiLibGetBertData + */ +RAS_APEI_BERT_DATA* +AcpiApeiLibGetBertData (VOID) +{ + if (FwRasApeiBertLookUpTable == NULL) + return NULL; + + return &FwRasApeiBertLookUpTable->ErrorSourceData[0]; +} + +/* + * AcpiApeiLibInit + */ +EFI_STATUS +AcpiApeiLibInit (VOID) +{ + EFI_STATUS Status; + + /* + * Allocate Reserve Memory + */ + Status = AcpiApeiLibAllocateReservedMem (); + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + +STATIC VOID +AcpiApeiLibAtfRasEnable ( + UINT8 Enable + ) +{ + ARM_SMC_ARGS SmcArgs; + + SmcArgs.Arg0 = SMC_XRAS_PROXY_FUNC_ID; + SmcArgs.Arg1 = (Enable != 0) ? SMC_XRAS_ENABLE : SMC_XRAS_DISABLE; + SmcArgs.Arg2 = 0; + SmcArgs.Arg3 = 0; + SmcArgs.Arg4 = 0; + + ArmCallSmc (&SmcArgs); +} + +STATIC VOID +AcpiApeiLibAtfApeiSetup ( + UINT64 ApeiGhesPtr, + UINT64 ApeiBertPtr + ) +{ + ARM_SMC_ARGS SmcArgs; + + SmcArgs.Arg0 = SMC_XRAS_PROXY_FUNC_ID; + SmcArgs.Arg1 = SMC_XRAS_SET_APEI_PTR; + SmcArgs.Arg2 = ApeiGhesPtr; + SmcArgs.Arg3 = ApeiBertPtr; + SmcArgs.Arg4 = 0; + + ArmCallSmc (&SmcArgs); +} + +/* + * AcpiApeiLibEnable + */ +EFI_STATUS +AcpiApeiLibEnable ( + UINT8 Enable, + UINT8 FwErrorDetection + ) +{ + UINT64 ApeiGhesPtr; + UINT64 ApeiBertPtr; + + ArmInvalidateDataCache (); + + if (Enable != 0) { + /* + * Setup firmware (e.g. ATF) for RAS_APEI module support + */ + ApeiGhesPtr = (UINT64) FwRasApeiGhesLookUpTable; + ApeiBertPtr = (UINT64) FwRasApeiBertLookUpTable; + + if (FwErrorDetection == APEI_ERROR_DETECTION_ATF) { + AcpiApeiLibAtfApeiSetup (ApeiGhesPtr, ApeiBertPtr); + } + } + + if (FwErrorDetection == APEI_ERROR_DETECTION_ATF) { + AcpiApeiLibAtfRasEnable (Enable); + } + + return EFI_SUCCESS; +} -- 2.17.1