blob: 235e2b8e3dd4166fb00fd6f4f6a52e400fd5bc23 [file] [log] [blame]
Ambroise Vincentfae77722019-03-07 10:17:15 +00001/*
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>
11#include <tftf_lib.h>
12
13#include "./test_sve.h"
14
15#if __GNUC__ > 8 || (__GNUC__ == 8 && __GNUC_MINOR__ > 0)
16
17extern void sve_subtract_arrays(int *difference, const int *sve_op_1,
18 const int *sve_op_2);
19
20static int sve_difference[SVE_ARRAYSIZE];
21static int sve_op_1[SVE_ARRAYSIZE];
22static int sve_op_2[SVE_ARRAYSIZE];
23
24/*
25 * @Test_Aim@ Test SVE support when the extension is enabled.
26 *
27 * Execute some SVE instructions. These should not be trapped to EL3, as TF-A is
28 * responsible for enabling SVE for Non-secure world.
29 *
30 * If they are trapped, we won't recover from that and the test session will
31 * effectively be aborted.
32 */
33test_result_t test_sve_support(void)
34{
35 /* Check if SVE is implemented and usable */
36 if (is_armv8_2_sve_present() == false) {
37 tftf_testcase_printf("SVE support absent\n");
38 return TEST_RESULT_SKIPPED;
39 }
40
41 for (int i = 0; i < SVE_ARRAYSIZE; i++) {
42 /* Generate a random number between 200 and 299 */
43 sve_op_1[i] = (rand() % 100) + 200;
44 /* Generate a random number between 0 and 99 */
45 sve_op_2[i] = rand() % 100;
46 }
47
48 /* Perform SVE operations */
49 sve_subtract_arrays(sve_difference, sve_op_1, sve_op_2);
50
51 return TEST_RESULT_SUCCESS;
52}
53
54#else
55
56test_result_t test_sve_support(void)
57{
58 tftf_testcase_printf("Unsupported compiler\n");
59 return TEST_RESULT_SKIPPED;
60}
61
62#endif /* __GNUC__ > 8 || (__GNUC__ == 8 && __GNUC_MINOR__ > 0) */