1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4  */
5 
6 #ifndef APP_HEADER_PRIVATE_H
7 #define APP_HEADER_PRIVATE_H
8 
9 #ifndef __ASSEMBLER__
10 #include <app_header_structures.h>
11 #include <stddef.h>
12 #include <stdint.h>
13 #endif
14 
15 #define APP_HEADER_MAGIC	0x000E10ABB4EAD000UL  /* El0 APP HEAD */
16 
17 #define HEADER_VERSION_MAJOR	0U
18 #define HEADER_VERSION_MINOR	1U
19 #define HEADER_VERSION		((HEADER_VERSION_MAJOR << 16) | HEADER_VERSION_MINOR)
20 
21 #ifndef __ASSEMBLER__
22 
23 /*
24  * Get the index of the app from the app_id.
25  *
26  * Apps are indexed starting from 0, in the same order they appear in the RMM
27  * image.
28  *
29  * Arguments:
30  *	- app_id: The id of the app.
31  *	- app_idx: Out parameter, the index of the app with `app_id`.
32  *
33  * Return:
34  *	- 0 on success or a negative POSIX error otherwise.
35  */
36 int app_get_index(unsigned long app_id, size_t *app_index);
37 
38 /*
39  * Return a pointer to the app_header structure of an app of an app_id.
40  *
41  * Arguments:
42  *	- app_id: The id of the app.
43  *	- app_header: Out parameter, pointer to the app header of the `app_id`.
44  *
45  * Return:
46  *	- 0 on success or a negative POSIX error otherwise.
47  */
48 int app_get_header_ptr(unsigned long app_id, struct app_header **app_header);
49 
50 /*
51  * Get the number of instance specific pages that are necessary for the app.
52  *
53  * This can be used to get the number of instance specific granules necessary
54  * to instantiate an application that is identified by the app_header.
55  *
56  * Arguments:
57  *	- app_header: pointer to the app header.
58  *
59  * Return:
60  *	- The number of granules necessary.
61  */
62 size_t app_get_required_granule_count_from_header(struct app_header *app_header);
63 
64 #endif
65 
66 #endif /* APP_HEADER_PRIVATE_H */
67