1 /* 2 * Copyright (c) 2022-2025, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 8 #include <plat/common/platform.h> 9 #include <services/rmmd_svc.h> 10 #include "trp_private.h" 11 12 /* 13 * Per cpu data structure to populate parameters for an SMC in C code and use 14 * a pointer to this structure in assembler code to populate x0-x7 15 */ 16 static trp_args_t trp_smc_args[PLATFORM_CORE_COUNT]; 17 18 /* 19 * Set the arguments for SMC call 20 */ 21 trp_args_t *set_smc_args(uint64_t arg0, 22 uint64_t arg1, 23 uint64_t arg2, 24 uint64_t arg3, 25 uint64_t arg4, 26 uint64_t arg5, 27 uint64_t arg6, 28 uint64_t arg7, 29 uint64_t arg8, 30 uint64_t arg9, 31 uint64_t arg10, 32 uint64_t arg11) 33 { 34 uint32_t linear_id; 35 trp_args_t *pcpu_smc_args; 36 37 /* 38 * Return to Secure Monitor by raising an SMC. The results of the 39 * service are passed as an arguments to the SMC 40 */ 41 linear_id = plat_my_core_pos(); 42 pcpu_smc_args = &trp_smc_args[linear_id]; 43 write_trp_arg(pcpu_smc_args, TRP_ARG0, arg0); 44 write_trp_arg(pcpu_smc_args, TRP_ARG1, arg1); 45 write_trp_arg(pcpu_smc_args, TRP_ARG2, arg2); 46 write_trp_arg(pcpu_smc_args, TRP_ARG3, arg3); 47 write_trp_arg(pcpu_smc_args, TRP_ARG4, arg4); 48 write_trp_arg(pcpu_smc_args, TRP_ARG5, arg5); 49 write_trp_arg(pcpu_smc_args, TRP_ARG6, arg6); 50 write_trp_arg(pcpu_smc_args, TRP_ARG7, arg7); 51 write_trp_arg(pcpu_smc_args, TRP_ARG8, arg8); 52 write_trp_arg(pcpu_smc_args, TRP_ARG9, arg9); 53 write_trp_arg(pcpu_smc_args, TRP_ARG10, arg10); 54 write_trp_arg(pcpu_smc_args, TRP_ARG11, arg11); 55 56 return pcpu_smc_args; 57 } 58 59 /* 60 * Abort the boot process with the reason given in err. 61 */ 62 __dead2 void trp_boot_abort(uint64_t err) 63 { 64 (void)trp_smc(set_smc_args(RMM_BOOT_COMPLETE, err, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)); 65 panic(); 66 } 67