blob: 7096daf52b9dd337d931f0b0e7f78c13b1c5b82c [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
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-Alves5aecd982020-06-11 10:25:33 +010011#include <tftf_lib.h>
12#include <ffa_helpers.h>
13
14#define SPM_VM_ID_FIRST (1)
Ruari Phippsd75596a2020-07-17 16:41:34 +010015#define SPM_VM_ID_SECOND (2)
16#define SPM_VM_ID_THIRD (3)
J-Alves5aecd982020-06-11 10:25:33 +010017
18#define SPM_VM_GET_COUNT (0xFF01)
19#define SPM_VCPU_GET_COUNT (0xFF02)
20#define SPM_DEBUG_LOG (0xBD000000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020021
22typedef struct {
Sandrine Bailleux17795062018-12-13 16:02:41 +010023 u_register_t fid;
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020024 u_register_t arg1;
25 u_register_t arg2;
26 u_register_t arg3;
27 u_register_t arg4;
28 u_register_t arg5;
29 u_register_t arg6;
30 u_register_t arg7;
31} svc_args;
32
33/*
34 * Trigger an SVC call.
35 *
36 * The arguments to pass through the SVC call must be stored in the svc_args
37 * structure. The return values of the SVC call will be stored in the same
38 * structure (overriding the input arguments).
39 *
Sandrine Bailleux17795062018-12-13 16:02:41 +010040 * Return the first return value. It is equivalent to args.fid but is also
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020041 * provided as the return value for convenience.
42 */
43u_register_t sp_svc(svc_args *args);
44
45/*
46 * Choose a pseudo-random number within the [min,max] range (both limits are
47 * inclusive).
48 */
49uintptr_t bound_rand(uintptr_t min, uintptr_t max);
50
51/*
52 * Check that expr == expected.
53 * If not, loop forever.
54 */
55void expect(int expr, int expected);
56
57/*
58 * Test framework functions
59 */
60
61void announce_test_section_start(const char *test_sect_desc);
62void announce_test_section_end(const char *test_sect_desc);
63
64void announce_test_start(const char *test_desc);
65void announce_test_end(const char *test_desc);
66
Antonio Nino Diaz2ac6f8f2018-07-02 09:04:07 +010067/* Sleep for at least 'ms' milliseconds. */
68void sp_sleep(uint32_t ms);
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020069
J-Alves5aecd982020-06-11 10:25:33 +010070/*
71 * Hypervisor Calls Wrappers
72 */
73
74ffa_vcpu_count_t spm_vcpu_get_count(ffa_vm_id_t vm_id);
75
76ffa_vm_count_t spm_vm_get_count(void);
77
78void spm_debug_log(char c);
79
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020080#endif /* SP_HELPERS_H */