1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2019, Linaro Limited 4 */ 5 6 #ifndef __LDELF_H 7 #define __LDELF_H 8 9 #include <types_ext.h> 10 #include <tee_api_types.h> 11 12 /* Size of stack for TEE Core to allocate */ 13 #define LDELF_STACK_SIZE (4096 * 2) 14 15 /* 16 * struct ldelf_arg - argument for ldelf 17 * @uuid: [in] UUID of TA to load 18 * @is_32bit: [out] 1 if a 32bit TA or 0 if a 64bit TA 19 * @flags: [out] Flags field of TA header 20 * @entry_func: [out] TA entry function 21 * @stack_ptr: [out] TA stack pointer 22 * @dump_entry: [out] Dump TA mappings and stack trace 23 */ 24 struct ldelf_arg { 25 TEE_UUID uuid; 26 uint32_t is_32bit; 27 uint32_t flags; 28 uint64_t entry_func; 29 uint64_t stack_ptr; 30 uint64_t dump_entry; 31 }; 32 33 #define DUMP_MAP_READ BIT(0) 34 #define DUMP_MAP_WRITE BIT(1) 35 #define DUMP_MAP_EXEC BIT(2) 36 #define DUMP_MAP_SECURE BIT(3) 37 #define DUMP_MAP_EPHEM BIT(4) 38 #define DUMP_MAP_LDELF BIT(7) 39 40 /* 41 * struct dump_entry_arg - argument for ldelf_dump() 42 */ 43 struct dump_entry_arg { 44 union { 45 struct { 46 uint32_t regs[16]; 47 } arm32; 48 struct { 49 uint64_t fp; 50 uint64_t sp; 51 uint64_t pc; 52 } arm64; 53 }; 54 bool is_arm32; 55 size_t num_maps; 56 struct dump_map { 57 vaddr_t va; 58 paddr_t pa; 59 size_t sz; 60 uint32_t flags; 61 } maps[]; 62 }; 63 64 /* 65 * ldelf is loaded into memory by TEE Core. BSS is initialized and a 66 * stack is allocated and supplied in SP register. A struct ldelf_arg 67 * is placed in the stack and a pointer to the struct is provided in 68 * r0/x0. 69 * 70 * ldelf relocates itself to the address where it is loaded before the main 71 * C routine is called. 72 * 73 * In the main C routine the TA is loaded using the PTA System interface. 74 */ 75 76 #endif /*__LDELF_H*/ 77