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