1 /*
2  * Copyright (c) 2017-2023, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef OPTEE_UTILS_H
8 #define OPTEE_UTILS_H
9 
10 #include <stdbool.h>
11 
12 #include <common/bl_common.h>
13 
14 bool optee_header_is_valid(uintptr_t header_base);
15 
16 int parse_optee_header(entry_point_info_t *header_ep,
17 	image_info_t *pager_image_info,
18 	image_info_t *paged_image_info);
19 
20 /*
21  * load_addr_hi and load_addr_lo: image load address.
22  * image_id: 0 - pager, 1 - paged
23  * size: image size in bytes.
24  */
25 typedef struct optee_image {
26 	uint32_t load_addr_hi;
27 	uint32_t load_addr_lo;
28 	uint32_t image_id;
29 	uint32_t size;
30 } optee_image_t;
31 
32 #define OPTEE_PAGER_IMAGE_ID		0
33 #define OPTEE_PAGED_IMAGE_ID		1
34 
35 #define OPTEE_MAX_NUM_IMAGES		2u
36 
37 #define TEE_MAGIC_NUM_OPTEE		0x4554504f
38 /*
39  * magic: header magic number.
40  * version: OPTEE header version:
41  *		1 - not supported
42  *		2 - supported
43  * arch: OPTEE os architecture type: 0 - AARCH32, 1 - AARCH64.
44  * flags: unused currently.
45  * nb_images: number of images.
46  */
47 typedef struct optee_header {
48 	uint32_t magic;
49 	uint8_t version;
50 	uint8_t arch;
51 	uint16_t flags;
52 	uint32_t nb_images;
53 	optee_image_t optee_image_list[];
54 } optee_header_t;
55 
56 #endif /* OPTEE_UTILS_H */
57