blob: 4f64a8279a9b21989266017645cd443c558d7243 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
Olivier Deprez3383c942020-08-04 11:26:13 +02002 * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02003 *
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-Alves4f7bbd22020-06-11 10:25:33 +010011#include <tftf_lib.h>
12#include <ffa_helpers.h>
13
Olivier Deprez3383c942020-08-04 11:26:13 +020014#define SPM_VM_ID_FIRST SP_ID(1)
J-Alves4f7bbd22020-06-11 10:25:33 +010015
J-Alves4f7bbd22020-06-11 10:25:33 +010016#define SPM_DEBUG_LOG (0xBD000000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020017
18typedef struct {
Sandrine Bailleux69957a52018-12-13 16:02:41 +010019 u_register_t fid;
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020020 u_register_t arg1;
21 u_register_t arg2;
22 u_register_t arg3;
23 u_register_t arg4;
24 u_register_t arg5;
25 u_register_t arg6;
26 u_register_t arg7;
27} svc_args;
28
29/*
30 * Trigger an SVC call.
31 *
32 * The arguments to pass through the SVC call must be stored in the svc_args
33 * structure. The return values of the SVC call will be stored in the same
34 * structure (overriding the input arguments).
35 *
Sandrine Bailleux69957a52018-12-13 16:02:41 +010036 * Return the first return value. It is equivalent to args.fid but is also
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020037 * provided as the return value for convenience.
38 */
39u_register_t sp_svc(svc_args *args);
40
41/*
42 * Choose a pseudo-random number within the [min,max] range (both limits are
43 * inclusive).
44 */
45uintptr_t bound_rand(uintptr_t min, uintptr_t max);
46
47/*
48 * Check that expr == expected.
49 * If not, loop forever.
50 */
51void expect(int expr, int expected);
52
53/*
54 * Test framework functions
55 */
56
57void announce_test_section_start(const char *test_sect_desc);
58void announce_test_section_end(const char *test_sect_desc);
59
60void announce_test_start(const char *test_desc);
61void announce_test_end(const char *test_desc);
62
Antonio Nino Diaz2ac6f8f2018-07-02 09:04:07 +010063/* Sleep for at least 'ms' milliseconds. */
64void sp_sleep(uint32_t ms);
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020065
J-Alves4f7bbd22020-06-11 10:25:33 +010066/*
67 * Hypervisor Calls Wrappers
68 */
69
70ffa_vcpu_count_t spm_vcpu_get_count(ffa_vm_id_t vm_id);
71
72ffa_vm_count_t spm_vm_get_count(void);
73
74void spm_debug_log(char c);
75
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020076#endif /* SP_HELPERS_H */