Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | /* |
Olivier Deprez | 6967c24 | 2021-04-09 09:24:08 +0200 | [diff] [blame] | 2 | * Copyright (c) 2018-2021, Arm Limited. All rights reserved. |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef SP_HELPERS_H |
| 8 | #define SP_HELPERS_H |
| 9 | |
| 10 | #include <stdint.h> |
J-Alves | 5aecd98 | 2020-06-11 10:25:33 +0100 | [diff] [blame] | 11 | #include <tftf_lib.h> |
Ruari Phipps | ddc661a | 2020-09-10 09:06:14 +0100 | [diff] [blame] | 12 | #include <spm_common.h> |
J-Alves | 5aecd98 | 2020-06-11 10:25:33 +0100 | [diff] [blame] | 13 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 14 | typedef struct { |
Sandrine Bailleux | 1779506 | 2018-12-13 16:02:41 +0100 | [diff] [blame] | 15 | u_register_t fid; |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 16 | u_register_t arg1; |
| 17 | u_register_t arg2; |
| 18 | u_register_t arg3; |
| 19 | u_register_t arg4; |
| 20 | u_register_t arg5; |
| 21 | u_register_t arg6; |
| 22 | u_register_t arg7; |
| 23 | } svc_args; |
| 24 | |
| 25 | /* |
| 26 | * Trigger an SVC call. |
| 27 | * |
| 28 | * The arguments to pass through the SVC call must be stored in the svc_args |
| 29 | * structure. The return values of the SVC call will be stored in the same |
| 30 | * structure (overriding the input arguments). |
| 31 | * |
Sandrine Bailleux | 1779506 | 2018-12-13 16:02:41 +0100 | [diff] [blame] | 32 | * Return the first return value. It is equivalent to args.fid but is also |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 33 | * provided as the return value for convenience. |
| 34 | */ |
| 35 | u_register_t sp_svc(svc_args *args); |
| 36 | |
| 37 | /* |
| 38 | * Choose a pseudo-random number within the [min,max] range (both limits are |
| 39 | * inclusive). |
| 40 | */ |
| 41 | uintptr_t bound_rand(uintptr_t min, uintptr_t max); |
| 42 | |
| 43 | /* |
| 44 | * Check that expr == expected. |
| 45 | * If not, loop forever. |
| 46 | */ |
| 47 | void expect(int expr, int expected); |
| 48 | |
| 49 | /* |
| 50 | * Test framework functions |
| 51 | */ |
| 52 | |
| 53 | void announce_test_section_start(const char *test_sect_desc); |
| 54 | void announce_test_section_end(const char *test_sect_desc); |
| 55 | |
| 56 | void announce_test_start(const char *test_desc); |
| 57 | void announce_test_end(const char *test_desc); |
| 58 | |
Madhukar Pappireddy | a09d5f7 | 2021-10-26 14:50:52 -0500 | [diff] [blame^] | 59 | /* Sleep for at least 'ms' milliseconds and return the elapsed time(ms). */ |
| 60 | uint64_t sp_sleep_elapsed_time(uint32_t ms); |
| 61 | |
Antonio Nino Diaz | 2ac6f8f | 2018-07-02 09:04:07 +0100 | [diff] [blame] | 62 | /* Sleep for at least 'ms' milliseconds. */ |
| 63 | void sp_sleep(uint32_t ms); |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 64 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 65 | #endif /* SP_HELPERS_H */ |