mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-11 07:34:31 +00:00
6ccb05eae0
The loading convention for optee or any other tee on arm64 is as bl32 parameter to the trusted-firmware. So TF-A gets invoked with the TEE as bl32 and main u-boot as bl33. Once it has done its startup TF-A jumps into the bl32 for the TEE startup, returns to TF-A and then jumps to bl33. All of them get passed a devicetree as parameter and all components often get loaded from a FIT image. OP-TEE will create additional nodes in that devicetree namely a firmware node and possibly multiple reserved-memory nodes. While this devicetree is used in main u-boot, in most cases it won't be the one passed to the actual kernel. Instead most boot commands will load a new devicetree from somewhere like mass storage of the network, so if that happens u-boot should transfer the optee nodes to that new devicetree. To make that happen introduce optee_copy_fdt_nodes() called from the dt setup function in image-fdt which after checking for the optee presence in the u-boot dt will make sure a optee node is present in the kernel dt and transfer any reserved-memory regions it can find. Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
79 lines
1.8 KiB
C
79 lines
1.8 KiB
C
/* SPDX-License-Identifier: BSD-2-Clause */
|
|
/*
|
|
* OP-TEE related definitions
|
|
*
|
|
* (C) Copyright 2016 Linaro Limited
|
|
* Andrew F. Davis <andrew.davis@linaro.org>
|
|
*/
|
|
|
|
#ifndef _OPTEE_H
|
|
#define _OPTEE_H
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#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;
|
|
};
|
|
|
|
static inline uint32_t optee_image_get_entry_point(const image_header_t *hdr)
|
|
{
|
|
struct optee_header *optee_hdr = (struct optee_header *)(hdr + 1);
|
|
|
|
return optee_hdr->init_load_addr_lo;
|
|
}
|
|
|
|
static inline uint32_t optee_image_get_load_addr(const image_header_t *hdr)
|
|
{
|
|
return optee_image_get_entry_point(hdr) - sizeof(struct optee_header);
|
|
}
|
|
|
|
#if defined(CONFIG_OPTEE)
|
|
int optee_verify_image(struct optee_header *hdr, unsigned long tzdram_start,
|
|
unsigned long tzdram_len, unsigned long image_len);
|
|
#else
|
|
static inline int optee_verify_image(struct optee_header *hdr,
|
|
unsigned long tzdram_start,
|
|
unsigned long tzdram_len,
|
|
unsigned long image_len)
|
|
{
|
|
return -EPERM;
|
|
}
|
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_OPTEE)
|
|
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
|
|
|
|
#if defined(CONFIG_OPTEE) && defined(CONFIG_OF_LIBFDT)
|
|
int optee_copy_fdt_nodes(const void *old_blob, void *new_blob);
|
|
#else
|
|
static inline int optee_copy_fdt_nodes(const void *old_blob, void *new_blob)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#endif /* _OPTEE_H */
|