blob: 8224d5092a7624f65c3d490655d683bd725575da [file] [log] [blame]
Summer Qin9db8f2e2017-04-24 16:49:28 +01001/*
Jeffrey Kardatzke7e6b09a2022-10-03 15:50:21 -07002 * Copyright (c) 2017-2023, ARM Limited and Contributors. All rights reserved.
Summer Qin9db8f2e2017-04-24 16:49:28 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00006
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef OPTEE_UTILS_H
8#define OPTEE_UTILS_H
Summer Qin9db8f2e2017-04-24 16:49:28 +01009
Etienne Carriered3e31e72019-04-15 18:01:29 +020010#include <stdbool.h>
11
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <common/bl_common.h>
Summer Qin9db8f2e2017-04-24 16:49:28 +010013
Etienne Carriered3e31e72019-04-15 18:01:29 +020014bool optee_header_is_valid(uintptr_t header_base);
15
Summer Qin9db8f2e2017-04-24 16:49:28 +010016int parse_optee_header(entry_point_info_t *header_ep,
17 image_info_t *pager_image_info,
18 image_info_t *paged_image_info);
19
Jeffrey Kardatzke7e6b09a2022-10-03 15:50:21 -070020/*
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 */
25typedef 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 */
47typedef 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
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000056#endif /* OPTEE_UTILS_H */