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 * @ftrace_entry: [out] Dump TA mappings and ftrace buffer 24 */ 25 struct ldelf_arg { 26 TEE_UUID uuid; 27 uint32_t is_32bit; 28 uint32_t flags; 29 uint64_t entry_func; 30 uint64_t stack_ptr; 31 uint64_t dump_entry; 32 uint64_t ftrace_entry; 33 }; 34 35 #define DUMP_MAP_READ BIT(0) 36 #define DUMP_MAP_WRITE BIT(1) 37 #define DUMP_MAP_EXEC BIT(2) 38 #define DUMP_MAP_SECURE BIT(3) 39 #define DUMP_MAP_EPHEM BIT(4) 40 #define DUMP_MAP_LDELF BIT(7) 41 42 /* 43 * struct dump_entry_arg - argument for ldelf_dump() 44 */ 45 struct dump_entry_arg { 46 union { 47 struct { 48 uint32_t regs[16]; 49 } arm32; 50 struct { 51 uint64_t fp; 52 uint64_t sp; 53 uint64_t pc; 54 } arm64; 55 }; 56 bool is_arm32; 57 size_t num_maps; 58 struct dump_map { 59 vaddr_t va; 60 paddr_t pa; 61 size_t sz; 62 uint32_t flags; 63 } maps[]; 64 }; 65 66 /* 67 * ldelf is loaded into memory by TEE Core. BSS is initialized and a 68 * stack is allocated and supplied in SP register. A struct ldelf_arg 69 * is placed in the stack and a pointer to the struct is provided in 70 * r0/x0. 71 * 72 * ldelf relocates itself to the address where it is loaded before the main 73 * C routine is called. 74 * 75 * In the main C routine the TA is loaded using the PTA System interface. 76 */ 77 78 #endif /*__LDELF_H*/ 79