1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4  */
5 
6 #ifndef APP_HEADER_STRUCTURES_H
7 #define APP_HEADER_STRUCTURES_H
8 
9 #include <stddef.h>
10 #include <stdint.h>
11 #include <utils_def.h>
12 
13 #define APP_NAME_BUF_SIZE	32U
14 #define APP_HEADER_SIZE		GRANULE_SIZE
15 
16 struct app_header {
17 	/* When the final rmm binary is constructed, an initial bl instruction
18 	 * is inserted at the beginning of the img file that branches to the
19 	 * offset of the function rmm_entry.
20 	 * The first 4 bytes of the padding field is modified to hold the bl
21 	 * instruction. This technique allows image packing logic to avoid
22 	 * adding an extra 4K alignment to the overall image and keep the
23 	 * alignments intact.
24 	 * Section offsets in this structures are calculated from the byte after
25 	 * the page containing the header.
26 	 * This structure needs to match the header format in app/gen_app_bin.py
27 	 * file.
28 	 */
29 	uint64_t padding;
30 
31 	uint64_t app_header_magic;
32 	uint32_t app_header_version;
33 	const char app_name[APP_NAME_BUF_SIZE]; /* Null terminated string */
34 	uint32_t app_id;
35 	uint64_t app_len; /* including header */
36 
37 	uintptr_t section_text_offset;
38 	uintptr_t section_text_va;
39 	size_t section_text_size;
40 
41 	uintptr_t section_rodata_offset;
42 	uintptr_t section_rodata_va;
43 	size_t section_rodata_size;
44 
45 	uintptr_t section_data_offset;
46 	uintptr_t section_data_va;
47 	size_t section_data_size;
48 
49 	/* Following are not allocated in the bin */
50 	uintptr_t section_bss_va;
51 	size_t section_bss_size;
52 
53 	uintptr_t section_shared_va;
54 
55 	size_t stack_page_count;
56 
57 	size_t heap_page_count;
58 
59 	/* Reserve a few dwords for later extending the header */
60 	uint64_t reserved[10];
61 
62 	uint64_t app_header_magic2;
63 };
64 COMPILER_ASSERT(sizeof(struct app_header) <= APP_HEADER_SIZE);
65 
66 #endif /* APP_HEADER_STRUCTURES_H */
67