Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 1 | /* |
Soby Mathew | 68ea954 | 2022-03-22 13:58:52 +0000 | [diff] [blame] | 2 | * Copyright (c) 2021-2022, Arm Limited. All rights reserved. |
Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <asm_macros.S> |
Soby Mathew | 68ea954 | 2022-03-22 13:58:52 +0000 | [diff] [blame] | 8 | #include <services/rmmd_svc.h> |
Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 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 | */ |
| 33 | trp_head: |
| 34 | bl plat_set_my_stack |
Mark Dykes | 50746c8 | 2021-12-01 15:08:02 -0600 | [diff] [blame] | 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 | |
Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 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 |
Mark Dykes | 50746c8 | 2021-12-01 15:08:02 -0600 | [diff] [blame] | 60 | warm_boot: |
Soby Mathew | 68ea954 | 2022-03-22 13:58:52 +0000 | [diff] [blame] | 61 | mov_imm x0, RMMD_RMI_REQ_COMPLETE |
Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 62 | mov x1, xzr |
| 63 | smc #0 |
| 64 | b trp_handler |
| 65 | |
Mark Dykes | 50746c8 | 2021-12-01 15:08:02 -0600 | [diff] [blame] | 66 | /* |
| 67 | * Flag to mark if it is a cold boot. |
| 68 | * 1: cold boot, 0: warmboot. |
| 69 | */ |
| 70 | .align 3 |
| 71 | cold_boot_flag: |
| 72 | .dword 1 |
| 73 | |
Zelalem Aweke | c8bc23e | 2021-07-09 15:32:21 -0500 | [diff] [blame] | 74 | /* --------------------------------------------- |
| 75 | * Direct SMC call to BL31 service provided by |
| 76 | * RMM Dispatcher |
| 77 | * --------------------------------------------- |
| 78 | */ |
| 79 | func trp_smc |
| 80 | restore_args_call_smc |
| 81 | ret |
| 82 | endfunc trp_smc |
| 83 | |
| 84 | /* --------------------------------------------- |
| 85 | * RMI call handler |
| 86 | * --------------------------------------------- |
| 87 | */ |
| 88 | func trp_handler |
| 89 | bl trp_rmi_handler |
| 90 | restore_args_call_smc |
| 91 | b trp_handler |
| 92 | endfunc trp_handler |