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 | |
| 14 | static struct rsi_host_call host_cal __aligned(sizeof(struct rsi_host_call)); |
| 15 | |
| 16 | /* This function return RSI_ABI_VERSION */ |
| 17 | u_register_t rsi_get_version(void) |
| 18 | { |
| 19 | smc_ret_values res = {}; |
| 20 | |
| 21 | res = tftf_smc(&(smc_args) |
| 22 | {RSI_ABI_VERSION, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL}); |
| 23 | |
| 24 | return res.ret0; |
| 25 | } |
| 26 | |
| 27 | /* This function will call the Host to request IPA of the NS shared buffer */ |
| 28 | u_register_t rsi_get_ns_buffer(void) |
| 29 | { |
| 30 | smc_ret_values res = {}; |
| 31 | |
| 32 | host_cal.imm = HOST_CALL_GET_SHARED_BUFF_CMD; |
| 33 | res = tftf_smc(&(smc_args) {RSI_HOST_CALL, (u_register_t)&host_cal, |
| 34 | 0UL, 0UL, 0UL, 0UL, 0UL, 0UL}); |
| 35 | if (res.ret0 != RSI_SUCCESS) { |
| 36 | return 0U; |
| 37 | } |
| 38 | return host_cal.gprs[0]; |
| 39 | } |
| 40 | |
| 41 | /* This function call Host and request to exit Realm with proper exit code */ |
| 42 | void rsi_exit_to_host(enum host_call_cmd exit_code) |
| 43 | { |
| 44 | host_cal.imm = exit_code; |
| 45 | tftf_smc(&(smc_args) {RSI_HOST_CALL, (u_register_t)&host_cal, |
| 46 | 0UL, 0UL, 0UL, 0UL, 0UL, 0UL}); |
| 47 | } |