Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | /* |
Olivier Deprez | 0be4abe | 2020-08-04 11:26:13 +0200 | [diff] [blame] | 2 | * Copyright (c) 2018-2020, 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> |
| 12 | #include <ffa_helpers.h> |
| 13 | |
Olivier Deprez | 0be4abe | 2020-08-04 11:26:13 +0200 | [diff] [blame] | 14 | #define SPM_VM_ID_FIRST SP_ID(1) |
J-Alves | 5aecd98 | 2020-06-11 10:25:33 +0100 | [diff] [blame] | 15 | |
Manish Pandey | 6b3840a | 2020-09-15 22:31:58 +0100 | [diff] [blame] | 16 | /* Should match with IDs defined in SPM/Hafnium */ |
| 17 | #define SPM_INTERRUPT_GET (0xFF04) |
J-Alves | 5aecd98 | 2020-06-11 10:25:33 +0100 | [diff] [blame] | 18 | #define SPM_DEBUG_LOG (0xBD000000) |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 19 | |
| 20 | typedef struct { |
Sandrine Bailleux | 1779506 | 2018-12-13 16:02:41 +0100 | [diff] [blame] | 21 | u_register_t fid; |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 22 | u_register_t arg1; |
| 23 | u_register_t arg2; |
| 24 | u_register_t arg3; |
| 25 | u_register_t arg4; |
| 26 | u_register_t arg5; |
| 27 | u_register_t arg6; |
| 28 | u_register_t arg7; |
| 29 | } svc_args; |
| 30 | |
| 31 | /* |
| 32 | * Trigger an SVC call. |
| 33 | * |
| 34 | * The arguments to pass through the SVC call must be stored in the svc_args |
| 35 | * structure. The return values of the SVC call will be stored in the same |
| 36 | * structure (overriding the input arguments). |
| 37 | * |
Sandrine Bailleux | 1779506 | 2018-12-13 16:02:41 +0100 | [diff] [blame] | 38 | * 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] | 39 | * provided as the return value for convenience. |
| 40 | */ |
| 41 | u_register_t sp_svc(svc_args *args); |
| 42 | |
| 43 | /* |
| 44 | * Choose a pseudo-random number within the [min,max] range (both limits are |
| 45 | * inclusive). |
| 46 | */ |
| 47 | uintptr_t bound_rand(uintptr_t min, uintptr_t max); |
| 48 | |
| 49 | /* |
| 50 | * Check that expr == expected. |
| 51 | * If not, loop forever. |
| 52 | */ |
| 53 | void expect(int expr, int expected); |
| 54 | |
| 55 | /* |
| 56 | * Test framework functions |
| 57 | */ |
| 58 | |
| 59 | void announce_test_section_start(const char *test_sect_desc); |
| 60 | void announce_test_section_end(const char *test_sect_desc); |
| 61 | |
| 62 | void announce_test_start(const char *test_desc); |
| 63 | void announce_test_end(const char *test_desc); |
| 64 | |
Antonio Nino Diaz | 2ac6f8f | 2018-07-02 09:04:07 +0100 | [diff] [blame] | 65 | /* Sleep for at least 'ms' milliseconds. */ |
| 66 | void sp_sleep(uint32_t ms); |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 67 | |
J-Alves | 5aecd98 | 2020-06-11 10:25:33 +0100 | [diff] [blame] | 68 | /* |
| 69 | * Hypervisor Calls Wrappers |
| 70 | */ |
| 71 | |
Manish Pandey | 6b3840a | 2020-09-15 22:31:58 +0100 | [diff] [blame] | 72 | ffa_int_id_t spm_interrupt_get(void); |
J-Alves | 5aecd98 | 2020-06-11 10:25:33 +0100 | [diff] [blame] | 73 | |
| 74 | void spm_debug_log(char c); |
| 75 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 76 | #endif /* SP_HELPERS_H */ |