Summer Qin | 9db8f2e | 2017-04-24 16:49:28 +0100 | [diff] [blame] | 1 | /* |
Jeffrey Kardatzke | 7e6b09a | 2022-10-03 15:50:21 -0700 | [diff] [blame] | 2 | * Copyright (c) 2017-2023, ARM Limited and Contributors. All rights reserved. |
Summer Qin | 9db8f2e | 2017-04-24 16:49:28 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef OPTEE_UTILS_H |
| 8 | #define OPTEE_UTILS_H |
Summer Qin | 9db8f2e | 2017-04-24 16:49:28 +0100 | [diff] [blame] | 9 | |
Etienne Carriere | d3e31e7 | 2019-04-15 18:01:29 +0200 | [diff] [blame] | 10 | #include <stdbool.h> |
| 11 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 12 | #include <common/bl_common.h> |
Summer Qin | 9db8f2e | 2017-04-24 16:49:28 +0100 | [diff] [blame] | 13 | |
Etienne Carriere | d3e31e7 | 2019-04-15 18:01:29 +0200 | [diff] [blame] | 14 | bool optee_header_is_valid(uintptr_t header_base); |
| 15 | |
Summer Qin | 9db8f2e | 2017-04-24 16:49:28 +0100 | [diff] [blame] | 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 | |
Jeffrey Kardatzke | 7e6b09a | 2022-10-03 15:50:21 -0700 | [diff] [blame] | 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 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 56 | #endif /* OPTEE_UTILS_H */ |