blob: fb2d8ac94ff8fa1619f17ca17c4069ec44cd15c0 [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 {
14 u_register_t arg0;
15 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 *
31 * Return the first return value. It is equivalent to args.arg0 but is also
32 * 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 */