blob: 9f5400cea4d5a4f29f8be01336867f7549d72ba2 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
Olivier Deprez6967c242021-04-09 09:24:08 +02002 * Copyright (c) 2018-2021, 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-Alves5aecd982020-06-11 10:25:33 +010011#include <tftf_lib.h>
Ruari Phippsddc661a2020-09-10 09:06:14 +010012#include <spm_common.h>
J-Alves5aecd982020-06-11 10:25:33 +010013
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020014typedef struct {
Sandrine Bailleux17795062018-12-13 16:02:41 +010015 u_register_t fid;
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020016 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 Bailleux17795062018-12-13 16:02:41 +010032 * Return the first return value. It is equivalent to args.fid but is also
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020033 * provided as the return value for convenience.
34 */
35u_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 */
41uintptr_t bound_rand(uintptr_t min, uintptr_t max);
42
43/*
44 * Check that expr == expected.
45 * If not, loop forever.
46 */
47void expect(int expr, int expected);
48
49/*
50 * Test framework functions
51 */
52
53void announce_test_section_start(const char *test_sect_desc);
54void announce_test_section_end(const char *test_sect_desc);
55
56void announce_test_start(const char *test_desc);
57void announce_test_end(const char *test_desc);
58
Antonio Nino Diaz2ac6f8f2018-07-02 09:04:07 +010059/* Sleep for at least 'ms' milliseconds. */
60void sp_sleep(uint32_t ms);
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020061
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020062#endif /* SP_HELPERS_H */