1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* 3 * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved. 4 */ 5 6 #ifndef LIBSP_INCLUDE_SP_MESSAGING_H_ 7 #define LIBSP_INCLUDE_SP_MESSAGING_H_ 8 9 #include "sp_api_defines.h" 10 #include "sp_api_types.h" 11 12 #include <stdbool.h> 13 #include <stdint.h> 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 #define SP_MSG_ARG_COUNT (5) 20 21 /** 22 * @brief SP message type 23 */ 24 struct sp_msg { 25 uint16_t source_id; 26 uint16_t destination_id; 27 bool is_64bit_message; 28 union { 29 uint32_t args32[SP_MSG_ARG_COUNT]; 30 uint64_t args64[SP_MSG_ARG_COUNT]; 31 } args; 32 }; 33 34 /** 35 * @brief Wait for a message and returns it. 36 * @param[out] msg The received message 37 * 38 * @return The SP API result 39 */ 40 sp_result sp_msg_wait(struct sp_msg *msg); 41 42 /** 43 * @brief Sends a request message and waits for the response message 44 * which it returns then. 45 * 46 * @param[in] req The request message 47 * @param[out] resp The response message 48 * 49 * @return The SP API result 50 */ 51 sp_result sp_msg_send_direct_req(const struct sp_msg *req, struct sp_msg *resp); 52 53 /** 54 * @brief Sends a response message and waits for a new request which it 55 * returns then. 56 * 57 * @param[in] resp The response message 58 * @param[out] req The request message 59 * 60 * @return The SP API result 61 */ 62 sp_result sp_msg_send_direct_resp(const struct sp_msg *resp, 63 struct sp_msg *req); 64 65 #if FFA_DIRECT_MSG_ROUTING_EXTENSION 66 /** 67 * @brief Sends a request on the return channel and waits for the response 68 * message which it returns then. 69 * 70 * @param[in] req The request message 71 * @param[out] resp The response message 72 * @return The SP API result 73 */ 74 sp_result sp_msg_send_rc_req(const struct sp_msg *req, struct sp_msg *resp); 75 #endif /* FFA_DIRECT_MSG_ROUTING_EXTENSION */ 76 77 #ifdef __cplusplus 78 } 79 #endif 80 81 #endif /* LIBSP_INCLUDE_SP_MESSAGING_H_ */ 82