blob: c5af1be8e8c03238217c8c665194ef10352a1a17 [file] [log] [blame]
Juan Pablo Conde88ffad22024-10-11 21:22:29 -05001/*
Javier Almansa Sobrino82cd82e2025-01-17 17:37:42 +00002 * Copyright (c) 2024-2025, Arm Limited. All rights reserved.
Juan Pablo Conde88ffad22024-10-11 21:22:29 -05003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef REALM_HELPERS_H
9#define REALM_HELPERS_H
10
Shruti Gupta91105082024-11-27 05:29:55 +000011#include <realm_rsi.h>
12
Juan Pablo Conde88ffad22024-10-11 21:22:29 -050013/* Generate 64-bit random number */
14unsigned long long realm_rand64(void);
Javier Almansa Sobrino82cd82e2025-01-17 17:37:42 +000015
16/* Reset the undefined aborts counter */
17void realm_reset_undef_abort_count(void);
18
19/* Return the undefined aborts counter value */
20unsigned int realm_get_undef_abort_count(void);
21
22/*
23 * Sync exception handler.
24 * If the exception is an undefined abort, it increases the value
25 * of the abort counter and returns 'true'. Otherwise, it returns 'false'
26 */
27bool realm_sync_exception_handler(void);
28
Shruti Gupta5abab762024-11-27 04:57:53 +000029/*
30 * Function to enter Aux Plane from Primary Plane
31 * arg1 == plane index
32 * arg2 == permission index to be used by plane
33 * arg3 == base entrypoint
34 * arg4 == entry flags
35 * aarg5 == run object, needs to be PAGE aligned
36 */
37bool realm_plane_enter(u_register_t plane_index, u_register_t perm_index,
38 u_register_t base, u_register_t flags, rsi_plane_run *run);
39
Shruti Gupta91105082024-11-27 05:29:55 +000040/* This function will call the Host to request IPA of the NS shared buffer */
41u_register_t realm_get_ns_buffer(void);
42
43/* This function will return plane index of current plane */
44unsigned int realm_get_my_plane_num(void);
45
46/** This function will return true for primary plane false for aux plane */
47bool realm_is_plane0(void);
48
Shruti Gupta5abab762024-11-27 04:57:53 +000049/* Function for initializing planes, called at Boot */
50void realm_plane_init(void);
Shruti Gupta41434682024-12-05 14:57:48 +000051bool plane_common_init(u_register_t plane_index, u_register_t perm_index,
52 u_register_t base, rsi_plane_run *run);
Juan Pablo Conde88ffad22024-10-11 21:22:29 -050053
54#endif /* REALM_HELPERS_H */
55