Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2018, Arm Limited. All rights reserved. |
| 3 | * |
| 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 | |
| 12 | #ifndef AARCH32 |
| 13 | |
| 14 | uint64_t serror_received; |
| 15 | |
| 16 | extern void inject_serror(void); |
| 17 | |
| 18 | int serror_handler(int ev, uint64_t arg) |
| 19 | { |
| 20 | serror_received = 1; |
| 21 | tftf_testcase_printf("SError SDEI event received.\n"); |
| 22 | |
| 23 | return 0; |
| 24 | } |
| 25 | |
| 26 | extern int serror_sdei_event_handler(int ev, uint64_t arg); |
| 27 | |
| 28 | test_result_t test_single_fault(void) |
| 29 | { |
| 30 | int64_t ret; |
| 31 | const int event_id = 5000; |
| 32 | |
| 33 | /* Register SDEI handler */ |
| 34 | ret = sdei_event_register(event_id, serror_sdei_event_handler, 0, |
| 35 | SDEI_REGF_RM_PE, read_mpidr_el1()); |
| 36 | if (ret < 0) { |
| 37 | tftf_testcase_printf("SDEI event register failed: 0x%llx\n", |
| 38 | ret); |
| 39 | return TEST_RESULT_FAIL; |
| 40 | } |
| 41 | |
| 42 | ret = sdei_event_enable(event_id); |
| 43 | if (ret < 0) { |
| 44 | tftf_testcase_printf("SDEI event enable failed: 0x%llx\n", ret); |
| 45 | return TEST_RESULT_FAIL; |
| 46 | } |
| 47 | |
| 48 | ret = sdei_pe_unmask(); |
| 49 | if (ret < 0) { |
| 50 | tftf_testcase_printf("SDEI pe unmask failed: 0x%llx\n", ret); |
| 51 | return TEST_RESULT_FAIL; |
| 52 | } |
| 53 | |
| 54 | inject_serror(); |
| 55 | |
| 56 | return TEST_RESULT_SUCCESS; |
| 57 | } |
| 58 | |
| 59 | #else |
| 60 | |
| 61 | test_result_t test_single_fault(void) |
| 62 | { |
| 63 | tftf_testcase_printf("Not supported on AArch32.\n"); |
| 64 | return TEST_RESULT_SKIPPED; |
| 65 | } |
| 66 | |
| 67 | #endif |