blob: cacd0a7664083b58515a4c9933246bda926f77a7 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
Manish Pandey5d1e6fe2023-01-14 00:13:08 +00002 * Copyright (c) 2018-2023, Arm Limited. All rights reserved.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7
8#include <arch_helpers.h>
9#include <sdei.h>
10#include <tftf_lib.h>
11
Deepika Bhavnanic249d5e2020-02-06 16:29:45 -060012#ifdef __aarch64__
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020013
Manish Pandey9cb6f512023-03-06 10:14:50 +000014static volatile uint64_t sdei_event_received;
Manish Pandey5d1e6fe2023-01-14 00:13:08 +000015extern void inject_unrecoverable_ras_error(void);
Manish Pandey0674e412023-02-21 13:05:07 +000016extern int serror_sdei_event_handler(int ev, uint64_t arg);
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020017
Manish Pandey0674e412023-02-21 13:05:07 +000018int sdei_handler(int ev, uint64_t arg)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020019{
Manish Pandey0674e412023-02-21 13:05:07 +000020 sdei_event_received = 1;
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020021 tftf_testcase_printf("SError SDEI event received.\n");
22
23 return 0;
24}
25
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020026test_result_t test_single_fault(void)
27{
28 int64_t ret;
29 const int event_id = 5000;
30
31 /* Register SDEI handler */
32 ret = sdei_event_register(event_id, serror_sdei_event_handler, 0,
33 SDEI_REGF_RM_PE, read_mpidr_el1());
34 if (ret < 0) {
35 tftf_testcase_printf("SDEI event register failed: 0x%llx\n",
36 ret);
37 return TEST_RESULT_FAIL;
38 }
39
40 ret = sdei_event_enable(event_id);
41 if (ret < 0) {
42 tftf_testcase_printf("SDEI event enable failed: 0x%llx\n", ret);
43 return TEST_RESULT_FAIL;
44 }
45
46 ret = sdei_pe_unmask();
47 if (ret < 0) {
48 tftf_testcase_printf("SDEI pe unmask failed: 0x%llx\n", ret);
49 return TEST_RESULT_FAIL;
50 }
51
Manish Pandey5d1e6fe2023-01-14 00:13:08 +000052 inject_unrecoverable_ras_error();
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020053
Manish Pandey9cb6f512023-03-06 10:14:50 +000054 /* Wait until the SError fires */
55 do {
56 dmbish();
57 } while (sdei_event_received == 0);
58
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020059 return TEST_RESULT_SUCCESS;
60}
61
62#else
63
64test_result_t test_single_fault(void)
65{
66 tftf_testcase_printf("Not supported on AArch32.\n");
67 return TEST_RESULT_SKIPPED;
68}
69
70#endif