nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright (c) 2022, Arm Limited. All rights reserved. |
| 4 | * |
| 5 | * SPDX-License-Identifier: BSD-3-Clause |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #include <host_realm_rmi.h> |
| 10 | #include <lib/aarch64/arch_features.h> |
| 11 | #include <realm_rsi.h> |
| 12 | #include <smccc.h> |
| 13 | |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 14 | /* This function return RSI_ABI_VERSION */ |
Shruti Gupta | 40de8ec | 2023-10-12 21:45:12 +0100 | [diff] [blame] | 15 | u_register_t rsi_get_version(u_register_t req_ver) |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 16 | { |
| 17 | smc_ret_values res = {}; |
| 18 | |
| 19 | res = tftf_smc(&(smc_args) |
Shruti Gupta | 40de8ec | 2023-10-12 21:45:12 +0100 | [diff] [blame] | 20 | {RSI_VERSION, req_ver, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL}); |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 21 | |
Shruti Gupta | 40de8ec | 2023-10-12 21:45:12 +0100 | [diff] [blame] | 22 | if (res.ret0 == SMC_UNKNOWN) { |
| 23 | return SMC_UNKNOWN; |
| 24 | } |
| 25 | /* Return lower version. */ |
| 26 | return res.ret1; |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | /* This function will call the Host to request IPA of the NS shared buffer */ |
| 30 | u_register_t rsi_get_ns_buffer(void) |
| 31 | { |
| 32 | smc_ret_values res = {}; |
Shruti Gupta | 43a50c3 | 2023-11-28 10:54:27 +0000 | [diff] [blame^] | 33 | struct rsi_host_call host_cal __aligned(sizeof(struct rsi_host_call)); |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 34 | |
| 35 | host_cal.imm = HOST_CALL_GET_SHARED_BUFF_CMD; |
| 36 | res = tftf_smc(&(smc_args) {RSI_HOST_CALL, (u_register_t)&host_cal, |
| 37 | 0UL, 0UL, 0UL, 0UL, 0UL, 0UL}); |
| 38 | if (res.ret0 != RSI_SUCCESS) { |
| 39 | return 0U; |
| 40 | } |
| 41 | return host_cal.gprs[0]; |
| 42 | } |
| 43 | |
| 44 | /* This function call Host and request to exit Realm with proper exit code */ |
| 45 | void rsi_exit_to_host(enum host_call_cmd exit_code) |
| 46 | { |
Shruti Gupta | 43a50c3 | 2023-11-28 10:54:27 +0000 | [diff] [blame^] | 47 | struct rsi_host_call host_cal __aligned(sizeof(struct rsi_host_call)); |
| 48 | |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 49 | host_cal.imm = exit_code; |
Shruti Gupta | 8ce3053 | 2023-10-16 15:58:38 +0100 | [diff] [blame] | 50 | host_cal.gprs[0] = read_mpidr_el1() & MPID_MASK; |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 51 | tftf_smc(&(smc_args) {RSI_HOST_CALL, (u_register_t)&host_cal, |
| 52 | 0UL, 0UL, 0UL, 0UL, 0UL, 0UL}); |
| 53 | } |