Harinarayan Bhatta | 57de1ea | 2016-11-29 16:33:23 -0600 | [diff] [blame] | 1 | /* |
| 2 | * OP-TEE related definitions |
| 3 | * |
| 4 | * (C) Copyright 2016 Linaro Limited |
| 5 | * Andrew F. Davis <andrew.davis@linaro.org> |
| 6 | * |
| 7 | * SPDX-License-Identifier: BSD-2-Clause |
| 8 | */ |
| 9 | |
| 10 | #ifndef _OPTEE_H |
| 11 | #define _OPTEE_H |
| 12 | |
Bryan O'Donoghue | 32ce617 | 2018-03-13 16:50:27 +0000 | [diff] [blame] | 13 | #include <linux/errno.h> |
| 14 | |
Harinarayan Bhatta | 57de1ea | 2016-11-29 16:33:23 -0600 | [diff] [blame] | 15 | #define OPTEE_MAGIC 0x4554504f |
| 16 | #define OPTEE_VERSION 1 |
| 17 | #define OPTEE_ARCH_ARM32 0 |
| 18 | #define OPTEE_ARCH_ARM64 1 |
| 19 | |
| 20 | struct optee_header { |
| 21 | uint32_t magic; |
| 22 | uint8_t version; |
| 23 | uint8_t arch; |
| 24 | uint16_t flags; |
| 25 | uint32_t init_size; |
| 26 | uint32_t init_load_addr_hi; |
| 27 | uint32_t init_load_addr_lo; |
| 28 | uint32_t init_mem_usage; |
| 29 | uint32_t paged_size; |
| 30 | }; |
| 31 | |
Bryan O'Donoghue | f794436 | 2018-03-13 16:50:31 +0000 | [diff] [blame^] | 32 | static inline uint32_t optee_image_get_entry_point(const image_header_t *hdr) |
| 33 | { |
| 34 | struct optee_header *optee_hdr = (struct optee_header *)(hdr + 1); |
| 35 | |
| 36 | return optee_hdr->init_load_addr_lo; |
| 37 | } |
| 38 | |
Bryan O'Donoghue | 32ce617 | 2018-03-13 16:50:27 +0000 | [diff] [blame] | 39 | #if defined(CONFIG_OPTEE) |
| 40 | int optee_verify_image(struct optee_header *hdr, unsigned long tzdram_start, |
| 41 | unsigned long tzdram_len, unsigned long image_len); |
| 42 | #else |
| 43 | static inline int optee_verify_image(struct optee_header *hdr, |
| 44 | unsigned long tzdram_start, |
| 45 | unsigned long tzdram_len, |
| 46 | unsigned long image_len) |
| 47 | { |
| 48 | return -EPERM; |
| 49 | } |
| 50 | |
| 51 | #endif |
| 52 | |
Harinarayan Bhatta | 57de1ea | 2016-11-29 16:33:23 -0600 | [diff] [blame] | 53 | #endif /* _OPTEE_H */ |