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