Ambroise Vincent | fae7772 | 2019-03-07 10:17:15 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch_features.h> |
| 8 | #include <arch_helpers.h> |
| 9 | #include <debug.h> |
| 10 | #include <stdlib.h> |
Max Shvetsov | 959be33 | 2021-03-16 14:18:13 +0000 | [diff] [blame] | 11 | #include <test_helpers.h> |
Ambroise Vincent | fae7772 | 2019-03-07 10:17:15 +0000 | [diff] [blame] | 12 | #include <tftf_lib.h> |
| 13 | |
| 14 | #include "./test_sve.h" |
| 15 | |
| 16 | #if __GNUC__ > 8 || (__GNUC__ == 8 && __GNUC_MINOR__ > 0) |
| 17 | |
| 18 | extern void sve_subtract_arrays(int *difference, const int *sve_op_1, |
| 19 | const int *sve_op_2); |
| 20 | |
| 21 | static int sve_difference[SVE_ARRAYSIZE]; |
| 22 | static int sve_op_1[SVE_ARRAYSIZE]; |
| 23 | static int sve_op_2[SVE_ARRAYSIZE]; |
| 24 | |
| 25 | /* |
| 26 | * @Test_Aim@ Test SVE support when the extension is enabled. |
| 27 | * |
| 28 | * Execute some SVE instructions. These should not be trapped to EL3, as TF-A is |
| 29 | * responsible for enabling SVE for Non-secure world. |
| 30 | * |
| 31 | * If they are trapped, we won't recover from that and the test session will |
| 32 | * effectively be aborted. |
| 33 | */ |
| 34 | test_result_t test_sve_support(void) |
| 35 | { |
Max Shvetsov | 959be33 | 2021-03-16 14:18:13 +0000 | [diff] [blame] | 36 | SKIP_TEST_IF_SVE_NOT_SUPPORTED(); |
Ambroise Vincent | fae7772 | 2019-03-07 10:17:15 +0000 | [diff] [blame] | 37 | |
| 38 | for (int i = 0; i < SVE_ARRAYSIZE; i++) { |
| 39 | /* Generate a random number between 200 and 299 */ |
| 40 | sve_op_1[i] = (rand() % 100) + 200; |
| 41 | /* Generate a random number between 0 and 99 */ |
| 42 | sve_op_2[i] = rand() % 100; |
| 43 | } |
| 44 | |
| 45 | /* Perform SVE operations */ |
| 46 | sve_subtract_arrays(sve_difference, sve_op_1, sve_op_2); |
| 47 | |
| 48 | return TEST_RESULT_SUCCESS; |
| 49 | } |
| 50 | |
| 51 | #else |
| 52 | |
| 53 | test_result_t test_sve_support(void) |
| 54 | { |
| 55 | tftf_testcase_printf("Unsupported compiler\n"); |
| 56 | return TEST_RESULT_SKIPPED; |
| 57 | } |
| 58 | |
| 59 | #endif /* __GNUC__ > 8 || (__GNUC__ == 8 && __GNUC_MINOR__ > 0) */ |