optee是从ATF中启动的,是作为一个svc来启动,启动玩后在optee中又通过smc返回到ATF中.
从core/arch/arm/kernel/kern.ld.S 中可以发现optee的入口,这也是个通用的规律,即从lds文件中找到入口函数
OUTPUT_FORMAT(CFG_KERN_LINKER_FORMAT)
OUTPUT_ARCH(CFG_KERN_LINKER_ARCH)
ENTRY(_start)
这里可以知道入口是_start,针对arm32的函数在entry_a32.S 中,针对arm64的入口函数在entry_a64.S中
_start 函数如下,这个函数中调用了很多其他函数,后面我们逐个分析.最后通过smc #0 返回到ATF中
FUNC _start , :
#if defined(CFG_CORE_SEL1_SPMC)
/*
* With OP-TEE as SPMC at S-EL1 the SPMD (SPD_spmd) in TF-A passes
* the DTB in x0, pagaeble part in x1 and the rest of the registers
* are unused
*/
mov x19, x1 /* Save pagable part */
mov x20, x0 /* Save DT address */
#else
mov x19, x0 /* Save pagable part address */
#if defined(CFG_DT_ADDR)
ldr x20, =CFG_DT_ADDR
#else
mov x20, x2 /* Save DT address */
#endif
#endif
adr x0, reset_vect_table
msr vbar_el1, x0
isb
set_sctlr_el1
isb
#ifdef CFG_WITH_PAGER
/*
* Move init code into correct location and move hashes to a
* temporary safe location until the heap is initialized.
*
* The binary is built as:
* [Pager code, rodata and data] : In correct location
&nb