nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef REALM_RSI_H |
| 9 | #define REALM_RSI_H |
| 10 | |
| 11 | #include <stdint.h> |
AlexeiFedorov | 2f30f10 | 2023-03-13 19:37:46 +0000 | [diff] [blame] | 12 | #include <host_shared_data.h> |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 13 | #include <tftf_lib.h> |
| 14 | |
| 15 | #define SMC_RSI_CALL_BASE 0xC4000190 |
| 16 | #define SMC_RSI_FID(_x) (SMC_RSI_CALL_BASE + (_x)) |
| 17 | /* |
| 18 | * This file describes the Realm Services Interface (RSI) Application Binary |
| 19 | * Interface (ABI) for SMC calls made from within the Realm to the RMM and |
| 20 | * serviced by the RMM. |
| 21 | * |
| 22 | * See doc/rmm_interface.md for more details. |
| 23 | */ |
| 24 | |
| 25 | /* |
| 26 | * The major version number of the RSI implementation. Increase this whenever |
| 27 | * the binary format or semantics of the SMC calls change. |
| 28 | */ |
| 29 | #define RSI_ABI_VERSION_MAJOR 12U |
| 30 | |
| 31 | /* |
| 32 | * The minor version number of the RSI implementation. Increase this when |
| 33 | * a bug is fixed, or a feature is added without breaking binary compatibility. |
| 34 | */ |
| 35 | #define RSI_ABI_VERSION_MINOR 0U |
| 36 | |
| 37 | #define RSI_ABI_VERSION_VAL ((RSI_ABI_VERSION_MAJOR << 16U) | \ |
| 38 | RSI_ABI_VERSION_MINOR) |
| 39 | |
| 40 | #define RSI_ABI_VERSION_GET_MAJOR(_version) ((_version) >> 16U) |
| 41 | #define RSI_ABI_VERSION_GET_MINOR(_version) ((_version) & 0xFFFFU) |
| 42 | |
| 43 | |
| 44 | /* RSI Status code enumeration as per Section D4.3.6 of the RMM Spec */ |
| 45 | typedef enum { |
| 46 | /* Command completed successfully */ |
| 47 | RSI_SUCCESS = 0U, |
| 48 | |
| 49 | /* |
| 50 | * The value of a command input value |
| 51 | * caused the command to fail |
| 52 | */ |
| 53 | RSI_ERROR_INPUT = 1U, |
| 54 | |
| 55 | /* |
| 56 | * The state of the current Realm or current REC |
| 57 | * does not match the state expected by the command |
| 58 | */ |
| 59 | RSI_ERROR_STATE = 2U, |
| 60 | |
| 61 | /* The operation requested by the command is not complete */ |
| 62 | RSI_INCOMPLETE = 3U, |
| 63 | |
| 64 | RSI_ERROR_COUNT |
| 65 | } rsi_status_t; |
| 66 | |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 67 | struct rsi_realm_config { |
| 68 | /* IPA width in bits */ |
| 69 | SET_MEMBER(unsigned long ipa_width, 0, 0x1000); /* Offset 0 */ |
| 70 | }; |
| 71 | |
| 72 | /* |
| 73 | * arg0 == IPA address of target region |
| 74 | * arg1 == Size of target region in bytes |
| 75 | * arg2 == RIPAS value |
| 76 | * ret0 == Status / error |
| 77 | * ret1 == Top of modified IPA range |
| 78 | */ |
| 79 | |
| 80 | #define RSI_HOST_CALL_NR_GPRS 7U |
| 81 | |
| 82 | struct rsi_host_call { |
| 83 | SET_MEMBER(struct { |
| 84 | /* Immediate value */ |
| 85 | unsigned int imm; /* Offset 0 */ |
| 86 | /* Registers */ |
| 87 | unsigned long gprs[RSI_HOST_CALL_NR_GPRS]; |
| 88 | }, 0, 0x100); |
| 89 | }; |
| 90 | |
| 91 | /* |
| 92 | * arg0 == struct rsi_host_call addr |
| 93 | */ |
| 94 | #define RSI_HOST_CALL SMC_RSI_FID(9U) |
| 95 | |
| 96 | |
| 97 | #define RSI_ABI_VERSION SMC_RSI_FID(0U) |
AlexeiFedorov | 2f30f10 | 2023-03-13 19:37:46 +0000 | [diff] [blame] | 98 | |
nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame] | 99 | /* |
| 100 | * arg0 == struct rsi_realm_config address |
| 101 | */ |
| 102 | #define RSI_REALM_CONFIG SMC_RSI_FID(6U) |
| 103 | |
| 104 | /* This function return RSI_ABI_VERSION */ |
| 105 | u_register_t rsi_get_version(void); |
| 106 | |
| 107 | /* This function will call the Host to request IPA of the NS shared buffer */ |
| 108 | u_register_t rsi_get_ns_buffer(void); |
| 109 | |
| 110 | /* This function call Host and request to exit Realm with proper exit code */ |
| 111 | void rsi_exit_to_host(enum host_call_cmd exit_code); |
| 112 | |
| 113 | #endif /* REALM_RSI_H */ |