blob: 610fae0232138d6df946c8b674beb4f5f71dd334 [file] [log] [blame]
mardyk01f5b46352023-10-24 16:23:23 -05001/*
mardyk017b51dbe2024-01-17 15:25:36 -06002 * Copyright (c) 2024, Arm Limited. All rights reserved.
mardyk01f5b46352023-10-24 16:23:23 -05003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
mardyk017b51dbe2024-01-17 15:25:36 -06006#include <fuzz_names.h>
mardyk01f5b46352023-10-24 16:23:23 -05007#include <tsp_fuzz_helper.h>
8
mardyk017b51dbe2024-01-17 15:25:36 -06009/*
10 * Generic TSP based function call for math operations
11 */
mardyk01f5b46352023-10-24 16:23:23 -050012void tftf_test_tsp_smc(uint64_t tsp_id, char *funcstr)
13{
14 uint64_t fn_identifier = TSP_FAST_FID(tsp_id);
15 uint64_t arg1 = 4;
16 uint64_t arg2 = 6;
17 smc_args tsp_svc_params = {fn_identifier, arg1, arg2};
18 smc_ret_values tsp_result;
19
20 tsp_result = tftf_smc(&tsp_svc_params);
21
22 if (tsp_result.ret0) {
23 tftf_testcase_printf("TSP operation 0x%x failed, error:0x%x\n",
24 (unsigned int) fn_identifier,
25 (unsigned int) tsp_result.ret0);
26 }
27}
28
mardyk017b51dbe2024-01-17 15:25:36 -060029/*
30 * TSP function called from fuzzer
31 */
32void run_tsp_fuzz(int funcid)
mardyk01f5b46352023-10-24 16:23:23 -050033{
mardyk017b51dbe2024-01-17 15:25:36 -060034 if (funcid == tsp_add_op_funcid) {
mardyk01f5b46352023-10-24 16:23:23 -050035 tftf_test_tsp_smc(TSP_ADD, "tsp_add_op");
mardyk017b51dbe2024-01-17 15:25:36 -060036 } else if (funcid == tsp_sub_op_funcid) {
mardyk01f5b46352023-10-24 16:23:23 -050037 tftf_test_tsp_smc(TSP_SUB, "tsp_sub_op");
mardyk017b51dbe2024-01-17 15:25:36 -060038 } else if (funcid == tsp_mul_op_funcid) {
mardyk01f5b46352023-10-24 16:23:23 -050039 tftf_test_tsp_smc(TSP_MUL, "tsp_mul_op");
mardyk017b51dbe2024-01-17 15:25:36 -060040 } else if (funcid == tsp_div_op_funcid) {
mardyk01f5b46352023-10-24 16:23:23 -050041 tftf_test_tsp_smc(TSP_DIV, "tsp_div_op");
42 }
43}