blob: eabc0de4c5f458c7d0cdb622877d9295889c6137 [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>
Max Shvetsov959be332021-03-16 14:18:13 +000011#include <test_helpers.h>
Ambroise Vincentfae77722019-03-07 10:17:15 +000012#include <tftf_lib.h>
13
14#include "./test_sve.h"
15
16#if __GNUC__ > 8 || (__GNUC__ == 8 && __GNUC_MINOR__ > 0)
17
18extern void sve_subtract_arrays(int *difference, const int *sve_op_1,
19 const int *sve_op_2);
20
21static int sve_difference[SVE_ARRAYSIZE];
22static int sve_op_1[SVE_ARRAYSIZE];
23static 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 */
34test_result_t test_sve_support(void)
35{
Max Shvetsov959be332021-03-16 14:18:13 +000036 SKIP_TEST_IF_SVE_NOT_SUPPORTED();
Ambroise Vincentfae77722019-03-07 10:17:15 +000037
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
53test_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) */