xref: /optee_os/ldelf/include/ldelf.h (revision 7509ff7ce5e5a7679319e6fa059b71dd6f6cc8b9)
1*7509ff7cSJens Wiklander /* SPDX-License-Identifier: BSD-2-Clause */
2*7509ff7cSJens Wiklander /*
3*7509ff7cSJens Wiklander  * Copyright (c) 2019, Linaro Limited
4*7509ff7cSJens Wiklander  */
5*7509ff7cSJens Wiklander 
6*7509ff7cSJens Wiklander #ifndef __LDELF_H
7*7509ff7cSJens Wiklander #define __LDELF_H
8*7509ff7cSJens Wiklander 
9*7509ff7cSJens Wiklander #include <stdint.h>
10*7509ff7cSJens Wiklander #include <tee_api_types.h>
11*7509ff7cSJens Wiklander 
12*7509ff7cSJens Wiklander /* Size of stack for TEE Core to allocate */
13*7509ff7cSJens Wiklander #define LDELF_STACK_SIZE	(4096 * 2)
14*7509ff7cSJens Wiklander 
15*7509ff7cSJens Wiklander /*
16*7509ff7cSJens Wiklander  * struct ldelf_arg - argument for ldelf
17*7509ff7cSJens Wiklander  * @uuid:	[in] UUID of TA to load
18*7509ff7cSJens Wiklander  * @is_32bit:	[out] 1 if a 32bit TA or 0 if a 64bit TA
19*7509ff7cSJens Wiklander  * @flags:	[out] Flags field of TA header
20*7509ff7cSJens Wiklander  * @entry_func:	[out] TA entry function
21*7509ff7cSJens Wiklander  * @stack_ptr:	[out] TA stack pointer
22*7509ff7cSJens Wiklander  */
23*7509ff7cSJens Wiklander struct ldelf_arg {
24*7509ff7cSJens Wiklander 	TEE_UUID uuid;
25*7509ff7cSJens Wiklander 	uint32_t is_32bit;
26*7509ff7cSJens Wiklander 	uint32_t flags;
27*7509ff7cSJens Wiklander 	uint64_t entry_func;
28*7509ff7cSJens Wiklander 	uint64_t stack_ptr;
29*7509ff7cSJens Wiklander };
30*7509ff7cSJens Wiklander 
31*7509ff7cSJens Wiklander /*
32*7509ff7cSJens Wiklander  * ldelf is loaded into memory by TEE Core. BSS is initialized and a
33*7509ff7cSJens Wiklander  * stack is allocated and supplied in SP register. A struct ldelf_arg
34*7509ff7cSJens Wiklander  * is placed in the stack and a pointer to the struct is provided in
35*7509ff7cSJens Wiklander  * r0/x0.
36*7509ff7cSJens Wiklander  *
37*7509ff7cSJens Wiklander  * ldelf relocates itself to the address where it is loaded before the main
38*7509ff7cSJens Wiklander  * C routine is called.
39*7509ff7cSJens Wiklander  *
40*7509ff7cSJens Wiklander  * In the main C routine the TA is loaded using the PTA System interface.
41*7509ff7cSJens Wiklander  */
42*7509ff7cSJens Wiklander 
43*7509ff7cSJens Wiklander #endif /*__LDELF_H*/
44