1/* 2 * Copyright (c) 2021-2022, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7#include <asm_macros.S> 8#include <services/rmmd_svc.h> 9#include "trp_private.h" 10 11.global trp_head 12.global trp_smc 13 14.section ".head.text", "ax" 15 16 /* --------------------------------------------- 17 * Populate the params in x0-x7 from the pointer 18 * to the smc args structure in x0. 19 * --------------------------------------------- 20 */ 21 .macro restore_args_call_smc 22 ldp x6, x7, [x0, #TRP_ARG6] 23 ldp x4, x5, [x0, #TRP_ARG4] 24 ldp x2, x3, [x0, #TRP_ARG2] 25 ldp x0, x1, [x0, #TRP_ARG0] 26 smc #0 27 .endm 28 29 /* --------------------------------------------- 30 * Entry point for TRP 31 * --------------------------------------------- 32 */ 33trp_head: 34 bl plat_set_my_stack 35 36 /* 37 * Find out whether this is a cold or warm boot 38 */ 39 ldr x1, cold_boot_flag 40 cbz x1, warm_boot 41 42 /* 43 * Update cold boot flag to indicate cold boot is done 44 */ 45 adr x2, cold_boot_flag 46 str xzr, [x2] 47 48 49 /* --------------------------------------------- 50 * Zero out BSS section 51 * --------------------------------------------- 52 */ 53 ldr x0, =__BSS_START__ 54 ldr x1, =__BSS_SIZE__ 55 bl zeromem 56 57 bl trp_setup 58 59 bl trp_main 60warm_boot: 61 mov_imm x0, RMMD_RMI_REQ_COMPLETE 62 mov x1, xzr 63 smc #0 64 b trp_handler 65 66 /* 67 * Flag to mark if it is a cold boot. 68 * 1: cold boot, 0: warmboot. 69 */ 70.align 3 71cold_boot_flag: 72 .dword 1 73 74 /* --------------------------------------------- 75 * Direct SMC call to BL31 service provided by 76 * RMM Dispatcher 77 * --------------------------------------------- 78 */ 79func trp_smc 80 restore_args_call_smc 81 ret 82endfunc trp_smc 83 84 /* --------------------------------------------- 85 * RMI call handler 86 * --------------------------------------------- 87 */ 88func trp_handler 89 bl trp_rmi_handler 90 restore_args_call_smc 91 b trp_handler 92endfunc trp_handler 93