blob: 1b03c9fbc327d462552fa06c8061b916d79e908c [file] [log] [blame]
Zelalem Awekec8bc23e2021-07-09 15:32:21 -05001/*
Soby Mathew68ea9542022-03-22 13:58:52 +00002 * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
Zelalem Awekec8bc23e2021-07-09 15:32:21 -05003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <asm_macros.S>
Soby Mathew68ea9542022-03-22 13:58:52 +00008#include <services/rmmd_svc.h>
Zelalem Awekec8bc23e2021-07-09 15:32:21 -05009#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
Mark Dykes50746c82021-12-01 15:08:02 -060035
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
Zelalem Awekec8bc23e2021-07-09 15:32:21 -050048
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
Mark Dykes50746c82021-12-01 15:08:02 -060060warm_boot:
Soby Mathew68ea9542022-03-22 13:58:52 +000061 mov_imm x0, RMMD_RMI_REQ_COMPLETE
Zelalem Awekec8bc23e2021-07-09 15:32:21 -050062 mov x1, xzr
63 smc #0
64 b trp_handler
65
Mark Dykes50746c82021-12-01 15:08:02 -060066 /*
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
Zelalem Awekec8bc23e2021-07-09 15:32:21 -050074 /* ---------------------------------------------
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