blob: c6ed219ea9769aa7167fcacab69b452f8fa41b44 [file] [log] [blame]
mardyk01f5b46352023-10-24 16:23:23 -05001/*
2 * Copyright (c) 2023, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6#include <tsp_fuzz_helper.h>
7
8void tftf_test_tsp_smc(uint64_t tsp_id, char *funcstr)
9{
10 uint64_t fn_identifier = TSP_FAST_FID(tsp_id);
11 uint64_t arg1 = 4;
12 uint64_t arg2 = 6;
13 smc_args tsp_svc_params = {fn_identifier, arg1, arg2};
14 smc_ret_values tsp_result;
15
16 tsp_result = tftf_smc(&tsp_svc_params);
17
18 if (tsp_result.ret0) {
19 tftf_testcase_printf("TSP operation 0x%x failed, error:0x%x\n",
20 (unsigned int) fn_identifier,
21 (unsigned int) tsp_result.ret0);
22 }
23}
24
25void run_tsp_fuzz(char *funcstr)
26{
27 if (strcmp(funcstr, "tsp_add_op") == CMP_SUCCESS) {
28 tftf_test_tsp_smc(TSP_ADD, "tsp_add_op");
29 } else if (strcmp(funcstr, "tsp_sub_op") == CMP_SUCCESS) {
30 tftf_test_tsp_smc(TSP_SUB, "tsp_sub_op");
31 } else if (strcmp(funcstr, "tsp_mul_op") == CMP_SUCCESS) {
32 tftf_test_tsp_smc(TSP_MUL, "tsp_mul_op");
33 } else if (strcmp(funcstr, "tsp_div_op") == CMP_SUCCESS) {
34 tftf_test_tsp_smc(TSP_DIV, "tsp_div_op");
35 }
36}