J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 1 | /* |
Madhukar Pappireddy | d655d58 | 2024-01-16 14:45:39 -0600 | [diff] [blame] | 2 | * Copyright (c) 2021-2024, Arm Limited. All rights reserved. |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef CACTUS_TEST_CMDS |
| 8 | #define CACTUS_TEST_CMDS |
| 9 | |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 10 | #include <ffa_helpers.h> |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 11 | #include <spm_common.h> |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 12 | |
| 13 | /** |
| 14 | * Success and error return to be sent over a msg response. |
| 15 | */ |
J-Alves | 0e1e7ca | 2021-01-25 14:11:06 +0000 | [diff] [blame] | 16 | #define CACTUS_SUCCESS U(0) |
| 17 | #define CACTUS_ERROR U(-1) |
| 18 | |
| 19 | /** |
| 20 | * Error codes. |
| 21 | */ |
| 22 | #define CACTUS_ERROR_INVALID U(1) |
| 23 | #define CACTUS_ERROR_TEST U(2) |
| 24 | #define CACTUS_ERROR_FFA_CALL U(3) |
J-Alves | 4cb9dee | 2021-03-03 13:59:52 +0000 | [diff] [blame] | 25 | #define CACTUS_ERROR_UNHANDLED U(4) |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 26 | |
Madhukar Pappireddy | 4d76de0 | 2022-06-22 17:38:21 -0500 | [diff] [blame] | 27 | #define ECHO_VAL1 U(0xa0a0a0a0) |
| 28 | #define ECHO_VAL2 U(0xb0b0b0b0) |
| 29 | #define ECHO_VAL3 U(0xc0c0c0c0) |
| 30 | |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 31 | /** |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 32 | * Get command from struct ffa_value. |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 33 | */ |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 34 | static inline uint64_t cactus_get_cmd(struct ffa_value ret) |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 35 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 36 | return (uint64_t)ret.arg3; |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 37 | } |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * Template for commands to be sent to CACTUS partitions over direct |
| 41 | * messages interfaces. |
| 42 | */ |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 43 | static inline struct ffa_value cactus_send_cmd( |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 44 | ffa_id_t source, ffa_id_t dest, uint64_t cmd, uint64_t val0, |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 45 | uint64_t val1, uint64_t val2, uint64_t val3) |
| 46 | { |
J-Alves | ecd3074 | 2021-02-19 18:31:06 +0000 | [diff] [blame] | 47 | return ffa_msg_send_direct_req64(source, dest, cmd, val0, val1, val2, |
| 48 | val3); |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 49 | } |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 50 | |
J-Alves | 7d28b33 | 2021-02-11 16:08:08 +0000 | [diff] [blame] | 51 | /** |
| 52 | * Template for responses to Cactus commands. |
| 53 | * 'cactus_send_response' is the template for custom responses, in case there is |
| 54 | * a need to propagate more than one value in the response of a command. |
| 55 | */ |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 56 | static inline struct ffa_value cactus_send_response( |
J-Alves | 7a59528 | 2021-03-29 15:11:11 +0100 | [diff] [blame] | 57 | ffa_id_t source, ffa_id_t dest, uint32_t resp, uint64_t val0, |
J-Alves | 7d28b33 | 2021-02-11 16:08:08 +0000 | [diff] [blame] | 58 | uint64_t val1, uint64_t val2, uint64_t val3) |
| 59 | { |
J-Alves | ecd3074 | 2021-02-19 18:31:06 +0000 | [diff] [blame] | 60 | return ffa_msg_send_direct_resp64(source, dest, resp, val0, val1, |
| 61 | val2, val3); |
J-Alves | 7d28b33 | 2021-02-11 16:08:08 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | /** |
| 65 | * For responses of one value only. |
| 66 | */ |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 67 | static inline struct ffa_value cactus_response( |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 68 | ffa_id_t source, ffa_id_t dest, uint32_t response) |
J-Alves | 7d28b33 | 2021-02-11 16:08:08 +0000 | [diff] [blame] | 69 | { |
Madhukar Pappireddy | 3c28726 | 2021-08-05 14:39:24 -0500 | [diff] [blame] | 70 | return cactus_send_response(source, dest, response, 0, 0, 0, 0); |
J-Alves | 7d28b33 | 2021-02-11 16:08:08 +0000 | [diff] [blame] | 71 | } |
| 72 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 73 | static inline uint32_t cactus_get_response(struct ffa_value ret) |
J-Alves | 7d28b33 | 2021-02-11 16:08:08 +0000 | [diff] [blame] | 74 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 75 | return (uint32_t)ret.arg3; |
J-Alves | 7d28b33 | 2021-02-11 16:08:08 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | /** |
| 79 | * In a successful test, in case the SP needs to propagate an extra value |
| 80 | * to conclude the test. |
| 81 | * If more arguments are needed, a custom response should be defined for the |
| 82 | * specific test. |
| 83 | */ |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 84 | static inline struct ffa_value cactus_success_resp( |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 85 | ffa_id_t source, ffa_id_t dest, uint64_t value) |
J-Alves | 7d28b33 | 2021-02-11 16:08:08 +0000 | [diff] [blame] | 86 | { |
| 87 | return cactus_send_response(source, dest, CACTUS_SUCCESS, value, |
| 88 | 0, 0, 0); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * In case the test fails on the SP side, the 'error_code' should help specify |
| 93 | * the reason, which can be specific to the test, or general ones as defined |
| 94 | * in the error code list. |
| 95 | */ |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 96 | static inline struct ffa_value cactus_error_resp( |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 97 | ffa_id_t source, ffa_id_t dest, uint32_t error_code) |
J-Alves | 7d28b33 | 2021-02-11 16:08:08 +0000 | [diff] [blame] | 98 | { |
| 99 | return cactus_send_response(source, dest, CACTUS_ERROR, error_code, |
| 100 | 0, 0, 0); |
| 101 | } |
| 102 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 103 | static inline uint32_t cactus_error_code(struct ffa_value ret) |
J-Alves | 7d28b33 | 2021-02-11 16:08:08 +0000 | [diff] [blame] | 104 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 105 | return (uint32_t) ret.arg4; |
J-Alves | 7d28b33 | 2021-02-11 16:08:08 +0000 | [diff] [blame] | 106 | } |
| 107 | |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 108 | /** |
J-Alves | 28672f9 | 2020-11-09 15:34:31 +0000 | [diff] [blame] | 109 | * With this test command the sender transmits a 64-bit value that it then |
| 110 | * expects to receive on the respective command response. |
| 111 | * |
| 112 | * The id is the hex representation of the string 'echo'. |
| 113 | */ |
| 114 | #define CACTUS_ECHO_CMD U(0x6563686f) |
| 115 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 116 | static inline struct ffa_value cactus_echo_send_cmd( |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 117 | ffa_id_t source, ffa_id_t dest, uint64_t echo_val) |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 118 | { |
| 119 | return cactus_send_cmd(source, dest, CACTUS_ECHO_CMD, echo_val, 0, 0, |
| 120 | 0); |
| 121 | } |
J-Alves | 28672f9 | 2020-11-09 15:34:31 +0000 | [diff] [blame] | 122 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 123 | static inline uint64_t cactus_echo_get_val(struct ffa_value ret) |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 124 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 125 | return (uint64_t)ret.arg4; |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 126 | } |
J-Alves | 28672f9 | 2020-11-09 15:34:31 +0000 | [diff] [blame] | 127 | |
| 128 | /** |
| 129 | * Command to request a cactus secure partition to send an echo command to |
| 130 | * another partition. |
| 131 | * |
| 132 | * The sender of this command expects to receive CACTUS_SUCCESS if the requested |
| 133 | * echo interaction happened successfully, or CACTUS_ERROR otherwise. |
| 134 | */ |
| 135 | #define CACTUS_REQ_ECHO_CMD (CACTUS_ECHO_CMD + 1) |
| 136 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 137 | static inline struct ffa_value cactus_req_echo_send_cmd( |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 138 | ffa_id_t source, ffa_id_t dest, ffa_id_t echo_dest, |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 139 | uint64_t echo_val) |
| 140 | { |
| 141 | return cactus_send_cmd(source, dest, CACTUS_REQ_ECHO_CMD, echo_val, |
| 142 | echo_dest, 0, 0); |
| 143 | } |
J-Alves | 28672f9 | 2020-11-09 15:34:31 +0000 | [diff] [blame] | 144 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 145 | static inline ffa_id_t cactus_req_echo_get_echo_dest(struct ffa_value ret) |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 146 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 147 | return (ffa_id_t)ret.arg5; |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 148 | } |
J-Alves | 28672f9 | 2020-11-09 15:34:31 +0000 | [diff] [blame] | 149 | |
| 150 | /** |
J-Alves | 1d203f1 | 2020-11-11 11:38:49 +0000 | [diff] [blame] | 151 | * Command to create a cyclic dependency between SPs, which could result in |
| 152 | * a deadlock. This aims at proving such scenario cannot happen. |
| 153 | * If the deadlock happens, the system will just hang. |
| 154 | * If the deadlock is prevented, the last partition to use the command will |
| 155 | * send response CACTUS_SUCCESS. |
| 156 | * |
| 157 | * The id is the hex representation of the string 'dead'. |
| 158 | */ |
| 159 | #define CACTUS_DEADLOCK_CMD U(0x64656164) |
| 160 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 161 | static inline struct ffa_value cactus_deadlock_send_cmd( |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 162 | ffa_id_t source, ffa_id_t dest, ffa_id_t next_dest) |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 163 | { |
| 164 | return cactus_send_cmd(source, dest, CACTUS_DEADLOCK_CMD, next_dest, 0, |
| 165 | 0, 0); |
| 166 | } |
J-Alves | 1d203f1 | 2020-11-11 11:38:49 +0000 | [diff] [blame] | 167 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 168 | static inline ffa_id_t cactus_deadlock_get_next_dest(struct ffa_value ret) |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 169 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 170 | return (ffa_id_t)ret.arg4; |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 171 | } |
J-Alves | 1d203f1 | 2020-11-11 11:38:49 +0000 | [diff] [blame] | 172 | |
| 173 | /** |
| 174 | * Command to request a sequence CACTUS_DEADLOCK_CMD between the partitions |
| 175 | * of specified IDs. |
| 176 | */ |
| 177 | #define CACTUS_REQ_DEADLOCK_CMD (CACTUS_DEADLOCK_CMD + 1) |
| 178 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 179 | static inline struct ffa_value cactus_req_deadlock_send_cmd( |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 180 | ffa_id_t source, ffa_id_t dest, ffa_id_t next_dest1, |
| 181 | ffa_id_t next_dest2) |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 182 | { |
| 183 | return cactus_send_cmd(source, dest, CACTUS_REQ_DEADLOCK_CMD, |
| 184 | next_dest1, next_dest2, 0, 0); |
| 185 | } |
J-Alves | 1d203f1 | 2020-11-11 11:38:49 +0000 | [diff] [blame] | 186 | |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 187 | /* To get next_dest1 use CACTUS_DEADLOCK_GET_NEXT_DEST */ |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 188 | static inline ffa_id_t cactus_deadlock_get_next_dest2(struct ffa_value ret) |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 189 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 190 | return (ffa_id_t)ret.arg5; |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 191 | } |
J-Alves | 1d203f1 | 2020-11-11 11:38:49 +0000 | [diff] [blame] | 192 | |
| 193 | /** |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 194 | * Command to notify cactus of a memory management operation. The cmd value |
| 195 | * should be the memory management smc function id. |
J-Alves | b9085f8 | 2020-12-07 10:57:28 +0000 | [diff] [blame] | 196 | * |
| 197 | * The id is the hex representation of the string "mem" |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 198 | */ |
J-Alves | b9085f8 | 2020-12-07 10:57:28 +0000 | [diff] [blame] | 199 | #define CACTUS_MEM_SEND_CMD U(0x6d656d) |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 200 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 201 | static inline struct ffa_value cactus_mem_send_cmd( |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 202 | ffa_id_t source, ffa_id_t dest, uint32_t mem_func, |
J-Alves | 32ccd2b | 2021-12-14 14:59:51 +0000 | [diff] [blame] | 203 | ffa_memory_handle_t handle, ffa_memory_region_flags_t retrieve_flags, |
Daniel Boulby | 3d8cd68 | 2024-07-23 14:28:15 +0100 | [diff] [blame] | 204 | uint16_t word_to_write, bool expect_exception, bool is_normal_memory) |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 205 | { |
J-Alves | e742ba8 | 2024-01-11 10:38:29 +0000 | [diff] [blame] | 206 | uint64_t _expect_exception = expect_exception ? (1ULL << 32) : 0; |
Daniel Boulby | 3d8cd68 | 2024-07-23 14:28:15 +0100 | [diff] [blame] | 207 | uint64_t _is_normal_memory = is_normal_memory ? (1ULL << 33) : 0; |
| 208 | uint64_t packed = (uint64_t)word_to_write | _expect_exception | |
| 209 | _is_normal_memory; |
J-Alves | e742ba8 | 2024-01-11 10:38:29 +0000 | [diff] [blame] | 210 | |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 211 | return cactus_send_cmd(source, dest, CACTUS_MEM_SEND_CMD, mem_func, |
J-Alves | e742ba8 | 2024-01-11 10:38:29 +0000 | [diff] [blame] | 212 | handle, retrieve_flags, packed); |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 213 | } |
J-Alves | b9085f8 | 2020-12-07 10:57:28 +0000 | [diff] [blame] | 214 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 215 | static inline ffa_memory_handle_t cactus_mem_send_get_handle( |
| 216 | struct ffa_value ret) |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 217 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 218 | return (ffa_memory_handle_t)ret.arg5; |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 219 | } |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 220 | |
J-Alves | 32ccd2b | 2021-12-14 14:59:51 +0000 | [diff] [blame] | 221 | static inline ffa_memory_region_flags_t cactus_mem_send_get_retrv_flags( |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 222 | struct ffa_value ret) |
J-Alves | 32ccd2b | 2021-12-14 14:59:51 +0000 | [diff] [blame] | 223 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 224 | return (ffa_memory_region_flags_t)ret.arg6; |
J-Alves | 32ccd2b | 2021-12-14 14:59:51 +0000 | [diff] [blame] | 225 | } |
| 226 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 227 | static inline uint16_t cactus_mem_send_words_to_write(struct ffa_value ret) |
J-Alves | 32ccd2b | 2021-12-14 14:59:51 +0000 | [diff] [blame] | 228 | { |
J-Alves | e742ba8 | 2024-01-11 10:38:29 +0000 | [diff] [blame] | 229 | return (uint16_t)ret.arg7 & 0xFFFFU; |
| 230 | } |
| 231 | |
| 232 | static inline bool cactus_mem_send_expect_exception(struct ffa_value ret) |
| 233 | { |
Daniel Boulby | 3d8cd68 | 2024-07-23 14:28:15 +0100 | [diff] [blame] | 234 | return (bool)((ret.arg7 >> 32) & 0x1); |
| 235 | } |
| 236 | |
| 237 | static inline bool cactus_mem_send_is_normal_memory(struct ffa_value ret) |
| 238 | { |
| 239 | return (bool)((ret.arg7 >> 33) & 0x1); |
Federico Recanati | 6328fb0 | 2022-01-14 15:48:16 +0100 | [diff] [blame] | 240 | } |
| 241 | |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 242 | /** |
J-Alves | 542d8d8 | 2020-11-18 10:34:06 +0000 | [diff] [blame] | 243 | * Command to request a memory management operation. The 'mem_func' argument |
| 244 | * identifies the operation that is to be performend, and 'receiver' is the id |
| 245 | * of the partition to receive the memory region. |
| 246 | * |
| 247 | * The command id is the hex representation of the string "memory". |
| 248 | */ |
| 249 | #define CACTUS_REQ_MEM_SEND_CMD U(0x6d656d6f7279) |
| 250 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 251 | static inline struct ffa_value cactus_req_mem_send_send_cmd( |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 252 | ffa_id_t source, ffa_id_t dest, uint32_t mem_func, |
Federico Recanati | 6328fb0 | 2022-01-14 15:48:16 +0100 | [diff] [blame] | 253 | ffa_id_t receiver, bool non_secure) |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 254 | { |
| 255 | return cactus_send_cmd(source, dest, CACTUS_REQ_MEM_SEND_CMD, mem_func, |
Federico Recanati | 6328fb0 | 2022-01-14 15:48:16 +0100 | [diff] [blame] | 256 | receiver, non_secure, 0); |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 257 | } |
J-Alves | 542d8d8 | 2020-11-18 10:34:06 +0000 | [diff] [blame] | 258 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 259 | static inline uint32_t cactus_req_mem_send_get_mem_func(struct ffa_value ret) |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 260 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 261 | return (uint32_t)ret.arg4; |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 262 | } |
| 263 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 264 | static inline ffa_id_t cactus_req_mem_send_get_receiver(struct ffa_value ret) |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 265 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 266 | return (ffa_id_t)ret.arg5; |
J-Alves | 5339201 | 2020-11-18 14:51:57 +0000 | [diff] [blame] | 267 | } |
J-Alves | 542d8d8 | 2020-11-18 10:34:06 +0000 | [diff] [blame] | 268 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 269 | static inline bool cactus_req_mem_send_get_non_secure(struct ffa_value ret) |
Federico Recanati | 6328fb0 | 2022-01-14 15:48:16 +0100 | [diff] [blame] | 270 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 271 | return (bool)ret.arg6; |
Federico Recanati | 6328fb0 | 2022-01-14 15:48:16 +0100 | [diff] [blame] | 272 | } |
| 273 | |
J-Alves | 542d8d8 | 2020-11-18 10:34:06 +0000 | [diff] [blame] | 274 | /** |
Olivier Deprez | 881b199 | 2020-12-01 15:34:34 +0100 | [diff] [blame] | 275 | * Request to fill SIMD vectors with dummy values with purpose to check a |
| 276 | * save/restore routine during the context switches between secure world and |
| 277 | * normal world. |
| 278 | * |
| 279 | * The command id is the hex representation of the string "SIMD" |
| 280 | */ |
| 281 | #define CACTUS_REQ_SIMD_FILL_CMD U(0x53494d44) |
| 282 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 283 | static inline struct ffa_value cactus_req_simd_fill_send_cmd( |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 284 | ffa_id_t source, ffa_id_t dest) |
Olivier Deprez | 881b199 | 2020-12-01 15:34:34 +0100 | [diff] [blame] | 285 | { |
J-Alves | 0e1e7ca | 2021-01-25 14:11:06 +0000 | [diff] [blame] | 286 | return cactus_send_cmd(source, dest, CACTUS_REQ_SIMD_FILL_CMD, 0, 0, 0, |
| 287 | 0); |
Olivier Deprez | 881b199 | 2020-12-01 15:34:34 +0100 | [diff] [blame] | 288 | } |
| 289 | |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 290 | /** |
Shruti Gupta | 38133fa | 2023-04-19 17:00:38 +0100 | [diff] [blame] | 291 | * Request to compare FPU state(SIMD vectors, FPCR, FPSR) content |
| 292 | * with previous template values to check a save/restore routine during the |
| 293 | * context switches between secure world and normal world. |
| 294 | */ |
| 295 | #define CACTUS_CMP_SIMD_VALUE_CMD (CACTUS_REQ_SIMD_FILL_CMD + 1) |
| 296 | |
| 297 | static inline struct ffa_value cactus_req_simd_compare_send_cmd( |
| 298 | ffa_id_t source, ffa_id_t dest) |
| 299 | { |
| 300 | return cactus_send_cmd(source, dest, CACTUS_CMP_SIMD_VALUE_CMD, 0, 0, 0, |
| 301 | 0); |
| 302 | } |
| 303 | |
| 304 | /** |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 305 | * Command to request cactus to sleep for the given time in ms |
| 306 | * |
| 307 | * The command id is the hex representation of string "sleep" |
| 308 | */ |
| 309 | #define CACTUS_SLEEP_CMD U(0x736c656570) |
| 310 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 311 | static inline struct ffa_value cactus_sleep_cmd( |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 312 | ffa_id_t source, ffa_id_t dest, uint32_t sleep_time) |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 313 | { |
| 314 | return cactus_send_cmd(source, dest, CACTUS_SLEEP_CMD, sleep_time, 0, 0, |
| 315 | 0); |
| 316 | } |
| 317 | |
Madhukar Pappireddy | b640259 | 2021-08-20 13:13:49 -0500 | [diff] [blame] | 318 | /** |
| 319 | * Command to request cactus to forward sleep command for the given time in ms |
| 320 | * |
| 321 | * The sender of this command expects to receive CACTUS_SUCCESS if the requested |
| 322 | * echo interaction happened successfully, or CACTUS_ERROR otherwise. |
Madhukar Pappireddy | 4b29341 | 2022-09-12 11:39:20 -0500 | [diff] [blame] | 323 | * Moreover, the sender can send a hint to the destination SP to expect that |
| 324 | * the forwaded sleep command could be preempted by a non-secure interrupt. |
Madhukar Pappireddy | b640259 | 2021-08-20 13:13:49 -0500 | [diff] [blame] | 325 | */ |
| 326 | #define CACTUS_FWD_SLEEP_CMD (CACTUS_SLEEP_CMD + 1) |
| 327 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 328 | static inline struct ffa_value cactus_fwd_sleep_cmd( |
Madhukar Pappireddy | b640259 | 2021-08-20 13:13:49 -0500 | [diff] [blame] | 329 | ffa_id_t source, ffa_id_t dest, ffa_id_t fwd_dest, |
Madhukar Pappireddy | 4b29341 | 2022-09-12 11:39:20 -0500 | [diff] [blame] | 330 | uint32_t sleep_time, bool hint_interrupted) |
Madhukar Pappireddy | b640259 | 2021-08-20 13:13:49 -0500 | [diff] [blame] | 331 | { |
| 332 | return cactus_send_cmd(source, dest, CACTUS_FWD_SLEEP_CMD, sleep_time, |
Madhukar Pappireddy | 4b29341 | 2022-09-12 11:39:20 -0500 | [diff] [blame] | 333 | fwd_dest, hint_interrupted, 0); |
Madhukar Pappireddy | b640259 | 2021-08-20 13:13:49 -0500 | [diff] [blame] | 334 | } |
| 335 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 336 | static inline uint32_t cactus_get_sleep_time(struct ffa_value ret) |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 337 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 338 | return (uint32_t)ret.arg4; |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 339 | } |
| 340 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 341 | static inline ffa_id_t cactus_get_fwd_sleep_dest(struct ffa_value ret) |
Madhukar Pappireddy | b640259 | 2021-08-20 13:13:49 -0500 | [diff] [blame] | 342 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 343 | return (ffa_id_t)ret.arg5; |
Madhukar Pappireddy | b640259 | 2021-08-20 13:13:49 -0500 | [diff] [blame] | 344 | } |
| 345 | |
Madhukar Pappireddy | 4b29341 | 2022-09-12 11:39:20 -0500 | [diff] [blame] | 346 | static inline bool cactus_get_fwd_sleep_interrupted_hint(struct ffa_value ret) |
| 347 | { |
| 348 | return (bool)ret.arg6; |
| 349 | } |
| 350 | |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 351 | /** |
Madhukar Pappireddy | 407befc | 2021-12-17 11:06:17 -0600 | [diff] [blame] | 352 | * Command to request cactus to sleep for half the given time in ms, trigger |
| 353 | * trusted watchdog timer and then sleep again for another half the given time. |
| 354 | * |
| 355 | * The sender of this command expects to receive CACTUS_SUCCESS if the requested |
| 356 | * echo interaction happened successfully, or CACTUS_ERROR otherwise. |
| 357 | */ |
| 358 | #define CACTUS_SLEEP_TRIGGER_TWDOG_CMD (CACTUS_SLEEP_CMD + 2) |
| 359 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 360 | static inline struct ffa_value cactus_sleep_trigger_wdog_cmd( |
Madhukar Pappireddy | 407befc | 2021-12-17 11:06:17 -0600 | [diff] [blame] | 361 | ffa_id_t source, ffa_id_t dest, uint32_t sleep_time, |
| 362 | uint64_t wdog_time) |
| 363 | { |
| 364 | return cactus_send_cmd(source, dest, CACTUS_SLEEP_TRIGGER_TWDOG_CMD, sleep_time, |
| 365 | wdog_time, 0, 0); |
| 366 | } |
| 367 | |
| 368 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 369 | static inline uint32_t cactus_get_wdog_trigger_duration(struct ffa_value ret) |
Madhukar Pappireddy | 407befc | 2021-12-17 11:06:17 -0600 | [diff] [blame] | 370 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 371 | return (uint32_t)ret.arg5; |
Madhukar Pappireddy | 407befc | 2021-12-17 11:06:17 -0600 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | /** |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 375 | * Command to request cactus to enable/disable an interrupt |
| 376 | * |
| 377 | * The command id is the hex representation of string "intr" |
| 378 | */ |
| 379 | #define CACTUS_INTERRUPT_CMD U(0x696e7472) |
| 380 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 381 | static inline struct ffa_value cactus_interrupt_cmd( |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 382 | ffa_id_t source, ffa_id_t dest, uint32_t interrupt_id, |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 383 | bool enable, uint32_t pin) |
| 384 | { |
| 385 | return cactus_send_cmd(source, dest, CACTUS_INTERRUPT_CMD, interrupt_id, |
| 386 | enable, pin, 0); |
| 387 | } |
| 388 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 389 | static inline uint32_t cactus_get_interrupt_id(struct ffa_value ret) |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 390 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 391 | return (uint32_t)ret.arg4; |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 392 | } |
| 393 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 394 | static inline bool cactus_get_interrupt_enable(struct ffa_value ret) |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 395 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 396 | return (bool)ret.arg5; |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 397 | } |
| 398 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 399 | static inline enum interrupt_pin cactus_get_interrupt_pin(struct ffa_value ret) |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 400 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 401 | return (enum interrupt_pin)ret.arg6; |
Manish Pandey | 9ee6a8d | 2021-03-03 09:53:33 +0000 | [diff] [blame] | 402 | } |
| 403 | |
Madhukar Pappireddy | 172523b | 2020-12-31 19:25:33 -0600 | [diff] [blame] | 404 | /** |
| 405 | * Request to initiate DMA transaction by upstream peripheral. |
| 406 | * |
| 407 | * The command id is the hex representation of the string "SMMU" |
| 408 | */ |
| 409 | #define CACTUS_DMA_SMMUv3_CMD (0x534d4d55) |
| 410 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 411 | static inline struct ffa_value cactus_send_dma_cmd( |
Olivier Deprez | e71ec9c | 2022-02-28 18:57:26 +0100 | [diff] [blame] | 412 | ffa_id_t source, ffa_id_t dest, uint32_t operation, |
| 413 | uintptr_t base, size_t range, uint32_t attributes) |
Madhukar Pappireddy | 172523b | 2020-12-31 19:25:33 -0600 | [diff] [blame] | 414 | { |
Olivier Deprez | e71ec9c | 2022-02-28 18:57:26 +0100 | [diff] [blame] | 415 | return cactus_send_cmd(source, dest, CACTUS_DMA_SMMUv3_CMD, |
| 416 | (uint64_t)operation, (uint64_t)base, |
| 417 | (uint64_t)range, attributes); |
Madhukar Pappireddy | 172523b | 2020-12-31 19:25:33 -0600 | [diff] [blame] | 418 | } |
J-Alves | b4e89a2 | 2021-03-09 10:04:39 +0000 | [diff] [blame] | 419 | |
| 420 | /* |
| 421 | * Request SP to bind a notification to a FF-A endpoint. In case of error |
| 422 | * when using the FFA_NOTIFICATION_BIND interface, include the error code |
| 423 | * in the response to the command's request. The receiver and sender arguments |
| 424 | * are propagated through the command's arguments, to allow the test of |
| 425 | * erroneous uses of the FFA_NOTIFICATION_BIND interface. |
| 426 | * |
| 427 | * The command id is the hex representation of the string "bind". |
| 428 | */ |
| 429 | #define CACTUS_NOTIFICATION_BIND_CMD U(0x62696e64) |
| 430 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 431 | static inline struct ffa_value cactus_notification_bind_send_cmd( |
J-Alves | b4e89a2 | 2021-03-09 10:04:39 +0000 | [diff] [blame] | 432 | ffa_id_t source, ffa_id_t dest, ffa_id_t receiver, |
| 433 | ffa_id_t sender, ffa_notification_bitmap_t notifications, uint32_t flags) |
| 434 | { |
| 435 | return cactus_send_cmd(source, dest, CACTUS_NOTIFICATION_BIND_CMD, |
| 436 | receiver, sender, notifications, flags); |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * Request to SP unbind a notification. In case of error when using the |
| 441 | * FFA_NOTIFICATION_UNBIND interface, the test includes the error code in the |
| 442 | * response. The receiver and sender arguments are propagated throught the |
| 443 | * command's arguments, to allow the test of erroneous uses of the |
| 444 | * FFA_NOTIFICATION_BIND interface. |
| 445 | * |
| 446 | * The command id is the hex representation of the string "unbind". |
| 447 | */ |
| 448 | #define CACTUS_NOTIFICATION_UNBIND_CMD U(0x756e62696e64) |
| 449 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 450 | static inline struct ffa_value cactus_notification_unbind_send_cmd( |
J-Alves | b4e89a2 | 2021-03-09 10:04:39 +0000 | [diff] [blame] | 451 | ffa_id_t source, ffa_id_t dest, ffa_id_t receiver, |
| 452 | ffa_id_t sender, ffa_notification_bitmap_t notifications) |
| 453 | { |
| 454 | return cactus_send_cmd(source, dest, CACTUS_NOTIFICATION_UNBIND_CMD, |
| 455 | receiver, sender, notifications, 0); |
| 456 | } |
| 457 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 458 | static inline ffa_id_t cactus_notification_get_receiver(struct ffa_value ret) |
J-Alves | b4e89a2 | 2021-03-09 10:04:39 +0000 | [diff] [blame] | 459 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 460 | return (ffa_id_t)ret.arg4; |
J-Alves | b4e89a2 | 2021-03-09 10:04:39 +0000 | [diff] [blame] | 461 | } |
| 462 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 463 | static inline ffa_id_t cactus_notification_get_sender(struct ffa_value ret) |
J-Alves | b4e89a2 | 2021-03-09 10:04:39 +0000 | [diff] [blame] | 464 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 465 | return (ffa_id_t)ret.arg5; |
J-Alves | b4e89a2 | 2021-03-09 10:04:39 +0000 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | static inline ffa_notification_bitmap_t cactus_notification_get_notifications( |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 469 | struct ffa_value ret) |
J-Alves | b4e89a2 | 2021-03-09 10:04:39 +0000 | [diff] [blame] | 470 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 471 | return (uint64_t)ret.arg6; |
J-Alves | b4e89a2 | 2021-03-09 10:04:39 +0000 | [diff] [blame] | 472 | } |
| 473 | |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 474 | /** |
| 475 | * Request SP to get notifications. The arguments to use in ffa_notification_get |
| 476 | * are propagated on the command to test erroneous uses of the interface. |
| 477 | * In a successful call to the interface, the SP's response payload should |
| 478 | * include all bitmaps returned by the SPMC. |
| 479 | * |
| 480 | * The command id is the hex representation of the string "getnot". |
| 481 | */ |
| 482 | #define CACTUS_NOTIFICATION_GET_CMD U(0x6765746e6f74) |
| 483 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 484 | static inline struct ffa_value cactus_notification_get_send_cmd( |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 485 | ffa_id_t source, ffa_id_t dest, ffa_id_t receiver, |
J-Alves | a076d4c | 2021-10-19 16:06:15 +0100 | [diff] [blame] | 486 | uint32_t vcpu_id, uint32_t flags, bool check_npi_handled) |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 487 | { |
| 488 | return cactus_send_cmd(source, dest, CACTUS_NOTIFICATION_GET_CMD, |
J-Alves | a076d4c | 2021-10-19 16:06:15 +0100 | [diff] [blame] | 489 | receiver, vcpu_id, check_npi_handled, flags); |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 490 | } |
| 491 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 492 | static inline uint32_t cactus_notification_get_vcpu(struct ffa_value ret) |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 493 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 494 | return (uint32_t)ret.arg5; |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 495 | } |
| 496 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 497 | static inline uint32_t cactus_notification_get_flags(struct ffa_value ret) |
J-Alves | b4e89a2 | 2021-03-09 10:04:39 +0000 | [diff] [blame] | 498 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 499 | return (uint32_t)ret.arg7; |
J-Alves | b4e89a2 | 2021-03-09 10:04:39 +0000 | [diff] [blame] | 500 | } |
| 501 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 502 | static inline struct ffa_value cactus_notifications_get_success_resp( |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 503 | ffa_id_t source, ffa_id_t dest, uint64_t from_sp, |
| 504 | uint64_t from_vm) |
| 505 | { |
| 506 | return cactus_send_response(source, dest, CACTUS_SUCCESS, from_sp, |
| 507 | from_vm, 0, 0); |
| 508 | } |
| 509 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 510 | static inline uint64_t cactus_notifications_get_from_sp(struct ffa_value ret) |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 511 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 512 | return (uint64_t)ret.arg4; |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 513 | } |
| 514 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 515 | static inline uint64_t cactus_notifications_get_from_vm(struct ffa_value ret) |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 516 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 517 | return (uint64_t)ret.arg5; |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 518 | } |
| 519 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 520 | static inline bool cactus_notifications_check_npi_handled(struct ffa_value ret) |
J-Alves | a076d4c | 2021-10-19 16:06:15 +0100 | [diff] [blame] | 521 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 522 | return (bool)ret.arg6; |
J-Alves | a076d4c | 2021-10-19 16:06:15 +0100 | [diff] [blame] | 523 | } |
| 524 | |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 525 | /** |
| 526 | * Request SP to set notifications. The arguments to use in ffa_notification_set |
| 527 | * are propagated on the command to test erroneous uses of the interface. |
| 528 | * In case of error while calling the interface, the response should include the |
J-Alves | fbbbf62 | 2021-07-30 16:43:36 +0100 | [diff] [blame] | 529 | * error code. If in the flags a delay SRI is requested, cactus should |
| 530 | * send a CACTUS_ECHO_CMD to the SP specified as `echo_dest`. This should help |
| 531 | * validate that the SRI is only sent when returning execution to the NWd. |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 532 | */ |
| 533 | #define CACTUS_NOTIFICATIONS_SET_CMD U(0x6e6f74736574) |
| 534 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 535 | static inline struct ffa_value cactus_notifications_set_send_cmd( |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 536 | ffa_id_t source, ffa_id_t dest, ffa_id_t receiver, |
J-Alves | fbbbf62 | 2021-07-30 16:43:36 +0100 | [diff] [blame] | 537 | ffa_id_t sender, uint32_t flags, ffa_notification_bitmap_t notifications, |
| 538 | ffa_id_t echo_dest) |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 539 | { |
| 540 | return cactus_send_cmd(source, dest, CACTUS_NOTIFICATIONS_SET_CMD, |
J-Alves | fbbbf62 | 2021-07-30 16:43:36 +0100 | [diff] [blame] | 541 | (uint32_t)receiver | ((uint32_t)sender << 16), |
| 542 | echo_dest, |
| 543 | notifications, flags); |
| 544 | } |
| 545 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 546 | static inline ffa_id_t cactus_notifications_set_get_receiver( |
| 547 | struct ffa_value ret) |
J-Alves | fbbbf62 | 2021-07-30 16:43:36 +0100 | [diff] [blame] | 548 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 549 | return (ffa_id_t)(ret.arg4 & 0xFFFFU); |
J-Alves | fbbbf62 | 2021-07-30 16:43:36 +0100 | [diff] [blame] | 550 | } |
| 551 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 552 | static inline ffa_id_t cactus_notifications_set_get_sender(struct ffa_value ret) |
J-Alves | fbbbf62 | 2021-07-30 16:43:36 +0100 | [diff] [blame] | 553 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 554 | return (ffa_id_t)((ret.arg4 >> 16U) & 0xFFFFU); |
J-Alves | ab77591 | 2021-03-29 15:22:33 +0100 | [diff] [blame] | 555 | } |
| 556 | |
Madhukar Pappireddy | 3c28726 | 2021-08-05 14:39:24 -0500 | [diff] [blame] | 557 | /** |
| 558 | * Request to start trusted watchdog timer. |
| 559 | * |
| 560 | * The command id is the hex representaton of the string "WDOG" |
| 561 | */ |
| 562 | #define CACTUS_TWDOG_START_CMD U(0x57444f47) |
| 563 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 564 | static inline struct ffa_value cactus_send_twdog_cmd( |
Madhukar Pappireddy | 3c28726 | 2021-08-05 14:39:24 -0500 | [diff] [blame] | 565 | ffa_id_t source, ffa_id_t dest, uint64_t time) |
| 566 | { |
| 567 | return cactus_send_cmd(source, dest, CACTUS_TWDOG_START_CMD, time, 0, 0, |
| 568 | 0); |
| 569 | } |
| 570 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 571 | static inline uint32_t cactus_get_wdog_duration(struct ffa_value ret) |
Madhukar Pappireddy | 3c28726 | 2021-08-05 14:39:24 -0500 | [diff] [blame] | 572 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 573 | return (uint32_t)ret.arg4; |
Madhukar Pappireddy | 3c28726 | 2021-08-05 14:39:24 -0500 | [diff] [blame] | 574 | } |
| 575 | |
J-Alves | f7535f4 | 2021-07-30 11:58:41 +0100 | [diff] [blame] | 576 | /** |
| 577 | * Request SP to return the current count of handled requests. |
| 578 | * |
| 579 | * The command id is the hex representation of the string "getnot". |
| 580 | */ |
| 581 | #define CACTUS_GET_REQ_COUNT_CMD U(0x726571636f756e74) |
| 582 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 583 | static inline struct ffa_value cactus_get_req_count_send_cmd( |
J-Alves | f7535f4 | 2021-07-30 11:58:41 +0100 | [diff] [blame] | 584 | ffa_id_t source, ffa_id_t dest) |
| 585 | { |
| 586 | return cactus_send_cmd(source, dest, CACTUS_GET_REQ_COUNT_CMD, 0, 0, 0, |
| 587 | 0); |
| 588 | } |
| 589 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 590 | static inline uint32_t cactus_get_req_count(struct ffa_value ret) |
J-Alves | f7535f4 | 2021-07-30 11:58:41 +0100 | [diff] [blame] | 591 | { |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 592 | return (uint32_t)ret.arg4; |
J-Alves | f7535f4 | 2021-07-30 11:58:41 +0100 | [diff] [blame] | 593 | } |
| 594 | |
Madhukar Pappireddy | f4c8e8d | 2022-02-15 15:52:53 -0600 | [diff] [blame] | 595 | /** |
| 596 | * Request SP to return the last serviced secure virtual interrupt. |
| 597 | * |
| 598 | * The command id is the hex representaton of the string "vINT" |
| 599 | */ |
| 600 | #define CACTUS_LAST_INTERRUPT_SERVICED_CMD U(0x76494e54) |
| 601 | |
Daniel Boulby | ce386b1 | 2022-03-29 18:36:36 +0100 | [diff] [blame] | 602 | static inline struct ffa_value cactus_get_last_interrupt_cmd( |
Madhukar Pappireddy | f4c8e8d | 2022-02-15 15:52:53 -0600 | [diff] [blame] | 603 | ffa_id_t source, ffa_id_t dest) |
| 604 | { |
| 605 | return cactus_send_cmd(source, dest, CACTUS_LAST_INTERRUPT_SERVICED_CMD, |
| 606 | 0, 0, 0, 0); |
| 607 | } |
Madhukar Pappireddy | 0b0ca11 | 2022-09-19 13:39:48 -0500 | [diff] [blame] | 608 | |
| 609 | /** |
| 610 | * Request SP to resume the task requested by current endpoint after managed |
| 611 | * exit. |
| 612 | * |
| 613 | * The command id is the hex representation of the string "RAME" which denotes |
| 614 | * (R)esume (A)fter (M)anaged (E)xit. |
| 615 | */ |
| 616 | #define CACTUS_RESUME_AFTER_MANAGED_EXIT U(0x52414d45) |
| 617 | |
| 618 | static inline struct ffa_value cactus_resume_after_managed_exit( |
| 619 | ffa_id_t source, ffa_id_t dest) |
| 620 | { |
| 621 | return cactus_send_cmd(source, dest, CACTUS_RESUME_AFTER_MANAGED_EXIT, |
| 622 | 0, 0, 0, 0); |
| 623 | } |
Raghu Krishnamurthy | 9e267a0 | 2022-08-11 21:25:26 -0700 | [diff] [blame] | 624 | |
| 625 | /** |
| 626 | * Request SP to pend an interrupt in the extended SPI range. |
| 627 | * |
| 628 | * The command is the hex representation of the string "espi". |
| 629 | */ |
| 630 | #define CACTUS_TRIGGER_ESPI_CMD U(0x65737069) |
| 631 | static inline struct ffa_value cactus_trigger_espi_cmd( |
| 632 | ffa_id_t source, ffa_id_t dest, uint32_t espi_id) |
| 633 | { |
| 634 | return cactus_send_cmd(source, dest, CACTUS_TRIGGER_ESPI_CMD, |
| 635 | espi_id, 0, 0, 0); |
| 636 | } |
| 637 | |
| 638 | static inline uint32_t cactus_get_espi_id(struct ffa_value ret) |
| 639 | { |
| 640 | return (uint32_t)ret.arg4; |
| 641 | } |
| 642 | |
Madhukar Pappireddy | d655d58 | 2024-01-16 14:45:39 -0600 | [diff] [blame] | 643 | /* |
| 644 | * Request SP to mimic handling a RAS error delegated by an EL3 logical secure |
| 645 | * partition. |
| 646 | * |
| 647 | * The command ID is the hex representation of the string 'rase' which |
| 648 | * denotes RAS Error. |
| 649 | */ |
| 650 | #define CACTUS_RAS_DELEGATE_CMD U(0x72617365) |
| 651 | |
| 652 | static inline struct ffa_value cactus_ras_delegate_send_cmd( |
| 653 | ffa_id_t source, ffa_id_t dest, uint64_t event_id) |
| 654 | { |
| 655 | return cactus_send_cmd(source, dest, CACTUS_RAS_DELEGATE_CMD, event_id, 0, 0, |
| 656 | 0); |
| 657 | } |
| 658 | |
| 659 | static inline uint64_t cactus_ras_get_event_id(struct ffa_value ret) |
| 660 | { |
| 661 | return (uint64_t)ret.arg4; |
| 662 | } |
| 663 | |
J-Alves | 58cc4da | 2024-04-05 14:17:35 +0100 | [diff] [blame] | 664 | /** |
| 665 | * Request SP to send indirect message to FF-A endpoint. |
| 666 | * |
| 667 | * Command ID is string: MSGREQ. |
| 668 | */ |
| 669 | #define CACTUS_REQ_MSG_SEND_CMD U(0x4d5347524551a) |
| 670 | |
| 671 | static inline struct ffa_value cactus_req_ind_msg_send_cmd( |
| 672 | ffa_id_t source, ffa_id_t dest, ffa_id_t receiver, |
| 673 | ffa_id_t sender, uint32_t flags) |
| 674 | { |
| 675 | return cactus_send_cmd(source, dest, CACTUS_REQ_MSG_SEND_CMD, |
| 676 | flags, receiver, sender, 0); |
| 677 | } |
| 678 | |
| 679 | static inline ffa_id_t cactus_msg_send_receiver(struct ffa_value ret) |
| 680 | { |
| 681 | return (ffa_id_t)ret.arg5; |
| 682 | } |
| 683 | |
| 684 | static inline ffa_id_t cactus_msg_send_sender(struct ffa_value ret) |
| 685 | { |
| 686 | return (ffa_id_t)ret.arg6; |
| 687 | } |
| 688 | |
| 689 | static inline uint64_t cactus_msg_send_flags(struct ffa_value ret) |
| 690 | { |
| 691 | return (uint64_t)ret.arg4; |
| 692 | } |
| 693 | |
J-Alves | d1aae29 | 2020-10-08 17:16:58 +0100 | [diff] [blame] | 694 | #endif |