mardyk01 | f5b4635 | 2023-10-24 16:23:23 -0500 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2023, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <sdei_fuzz_helper.h> |
| 8 | |
| 9 | void tftf_test_sdei_noarg(int64_t (*sdei_func)(void), char *funcstr) |
| 10 | { |
| 11 | int64_t ret = (*sdei_func)(); |
| 12 | |
| 13 | if (ret < 0) { |
| 14 | tftf_testcase_printf("%s failed: 0x%llx\n", funcstr, ret); |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | void tftf_test_sdei_singlearg(int64_t (*sdei_func)(uint64_t), char *funcstr) |
| 19 | { |
| 20 | int64_t ret = (*sdei_func)(0); |
| 21 | |
| 22 | if (ret < 0) { |
| 23 | tftf_testcase_printf("%s failed: 0x%llx\n", funcstr, ret); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | |
| 28 | void run_sdei_fuzz(char *funcstr) |
| 29 | { |
| 30 | if (strcmp(funcstr, "sdei_version") == CMP_SUCCESS) { |
| 31 | long long ret = sdei_version(); |
| 32 | |
| 33 | if (ret != MAKE_SDEI_VERSION(1, 0, 0)) { |
| 34 | tftf_testcase_printf("Unexpected SDEI version: 0x%llx\n", |
| 35 | ret); |
| 36 | } |
| 37 | } else if (strcmp(funcstr, "sdei_pe_unmask") == CMP_SUCCESS) { |
| 38 | tftf_test_sdei_noarg(sdei_pe_unmask, "sdei_pe_unmask"); |
| 39 | } else if (strcmp(funcstr, "sdei_pe_mask") == CMP_SUCCESS) { |
| 40 | tftf_test_sdei_noarg(sdei_pe_mask, "sdei_pe_mask"); |
| 41 | } else if (strcmp(funcstr, "sdei_event_status") == CMP_SUCCESS) { |
| 42 | tftf_test_sdei_singlearg((int64_t (*)(uint64_t))sdei_event_status, |
| 43 | "sdei_event_status"); |
| 44 | } else if (strcmp(funcstr, "sdei_event_signal") == CMP_SUCCESS) { |
| 45 | tftf_test_sdei_singlearg(sdei_event_signal, "sdei_event_signal"); |
| 46 | } else if (strcmp(funcstr, "sdei_private_reset") == CMP_SUCCESS) { |
| 47 | tftf_test_sdei_noarg(sdei_private_reset, "sdei_private_reset"); |
| 48 | } else if (strcmp(funcstr, "sdei_shared_reset") == CMP_SUCCESS) { |
| 49 | tftf_test_sdei_noarg(sdei_shared_reset, "sdei_shared_reset"); |
| 50 | } |
| 51 | } |