blob: d06fec3b40122efb3909a5dd168201a0de51b978 [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>
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020011
12typedef struct {
Sandrine Bailleux17795062018-12-13 16:02:41 +010013 u_register_t fid;
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020014 u_register_t arg1;
15 u_register_t arg2;
16 u_register_t arg3;
17 u_register_t arg4;
18 u_register_t arg5;
19 u_register_t arg6;
20 u_register_t arg7;
21} svc_args;
22
23/*
24 * Trigger an SVC call.
25 *
26 * The arguments to pass through the SVC call must be stored in the svc_args
27 * structure. The return values of the SVC call will be stored in the same
28 * structure (overriding the input arguments).
29 *
Sandrine Bailleux17795062018-12-13 16:02:41 +010030 * Return the first return value. It is equivalent to args.fid but is also
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020031 * provided as the return value for convenience.
32 */
33u_register_t sp_svc(svc_args *args);
34
35/*
36 * Choose a pseudo-random number within the [min,max] range (both limits are
37 * inclusive).
38 */
39uintptr_t bound_rand(uintptr_t min, uintptr_t max);
40
41/*
42 * Check that expr == expected.
43 * If not, loop forever.
44 */
45void expect(int expr, int expected);
46
47/*
48 * Test framework functions
49 */
50
51void announce_test_section_start(const char *test_sect_desc);
52void announce_test_section_end(const char *test_sect_desc);
53
54void announce_test_start(const char *test_desc);
55void announce_test_end(const char *test_desc);
56
Antonio Nino Diaz2ac6f8f2018-07-02 09:04:07 +010057/* Sleep for at least 'ms' milliseconds. */
58void sp_sleep(uint32_t ms);
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020059
60#endif /* SP_HELPERS_H */