2018-05-06 21:58:06 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-2-Clause */
|
2016-11-29 22:33:23 +00:00
|
|
|
/*
|
|
|
|
* OP-TEE related definitions
|
|
|
|
*
|
|
|
|
* (C) Copyright 2016 Linaro Limited
|
|
|
|
* Andrew F. Davis <andrew.davis@linaro.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _OPTEE_H
|
|
|
|
#define _OPTEE_H
|
|
|
|
|
2018-03-13 16:50:27 +00:00
|
|
|
#include <linux/errno.h>
|
2020-05-10 17:40:01 +00:00
|
|
|
#include <image.h>
|
2018-03-13 16:50:27 +00:00
|
|
|
|
2016-11-29 22:33:23 +00:00
|
|
|
#define OPTEE_MAGIC 0x4554504f
|
|
|
|
#define OPTEE_VERSION 1
|
|
|
|
#define OPTEE_ARCH_ARM32 0
|
|
|
|
#define OPTEE_ARCH_ARM64 1
|
|
|
|
|
|
|
|
struct optee_header {
|
|
|
|
uint32_t magic;
|
|
|
|
uint8_t version;
|
|
|
|
uint8_t arch;
|
|
|
|
uint16_t flags;
|
|
|
|
uint32_t init_size;
|
|
|
|
uint32_t init_load_addr_hi;
|
|
|
|
uint32_t init_load_addr_lo;
|
|
|
|
uint32_t init_mem_usage;
|
|
|
|
uint32_t paged_size;
|
|
|
|
};
|
|
|
|
|
2020-05-10 17:40:01 +00:00
|
|
|
static inline uint32_t
|
2022-09-07 02:26:52 +00:00
|
|
|
optee_image_get_entry_point(const struct legacy_img_hdr *hdr)
|
2018-03-13 16:50:31 +00:00
|
|
|
{
|
|
|
|
struct optee_header *optee_hdr = (struct optee_header *)(hdr + 1);
|
|
|
|
|
|
|
|
return optee_hdr->init_load_addr_lo;
|
|
|
|
}
|
|
|
|
|
2020-05-10 17:40:01 +00:00
|
|
|
static inline uint32_t
|
2022-09-07 02:26:52 +00:00
|
|
|
optee_image_get_load_addr(const struct legacy_img_hdr *hdr)
|
2018-03-13 16:50:32 +00:00
|
|
|
{
|
|
|
|
return optee_image_get_entry_point(hdr) - sizeof(struct optee_header);
|
|
|
|
}
|
|
|
|
|
2021-09-02 09:56:16 +00:00
|
|
|
#if defined(CONFIG_OPTEE_IMAGE)
|
2018-03-13 16:50:33 +00:00
|
|
|
int optee_verify_bootm_image(unsigned long image_addr,
|
|
|
|
unsigned long image_load_addr,
|
|
|
|
unsigned long image_len);
|
|
|
|
#else
|
|
|
|
static inline int optee_verify_bootm_image(unsigned long image_addr,
|
|
|
|
unsigned long image_load_addr,
|
|
|
|
unsigned long image_len)
|
|
|
|
{
|
|
|
|
return -EPERM;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-09-02 09:56:16 +00:00
|
|
|
#if defined(CONFIG_OPTEE_LIB) && defined(CONFIG_OF_LIBFDT)
|
2021-02-08 12:54:31 +00:00
|
|
|
int optee_copy_fdt_nodes(void *new_blob);
|
2019-10-23 14:46:40 +00:00
|
|
|
#else
|
2021-02-08 12:54:31 +00:00
|
|
|
static inline int optee_copy_fdt_nodes(void *new_blob)
|
2019-10-23 14:46:40 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-11-29 22:33:23 +00:00
|
|
|
#endif /* _OPTEE_H */
|