Imre Kis | c674b5b | 2021-02-09 19:05:27 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: BSD-3-Clause */ |
| 2 | /* |
| 3 | * Copyright (c) 2021, 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 <stdint.h> |
| 13 | |
| 14 | #ifdef __cplusplus |
| 15 | extern "C" { |
| 16 | #endif |
| 17 | |
| 18 | #define SP_MSG_ARG_COUNT (4) |
| 19 | |
| 20 | /** |
| 21 | * @brief SP message type |
| 22 | */ |
| 23 | struct sp_msg { |
| 24 | uint16_t source_id; |
| 25 | uint16_t destination_id; |
| 26 | uint32_t args[SP_MSG_ARG_COUNT]; |
| 27 | }; |
| 28 | |
| 29 | /** |
| 30 | * @brief Wait for a message and returns it. |
| 31 | * @param[out] msg The received message |
| 32 | * |
| 33 | * @return The SP API result |
| 34 | */ |
| 35 | sp_result sp_msg_wait(struct sp_msg *msg); |
| 36 | |
| 37 | /** |
| 38 | * @brief Sends a request message and waits for the response message |
| 39 | * which it returns then. |
| 40 | * |
| 41 | * @param[in] req The request message |
| 42 | * @param[out] resp The response message |
| 43 | * |
| 44 | * @return The SP API result |
| 45 | */ |
| 46 | sp_result sp_msg_send_direct_req(const struct sp_msg *req, struct sp_msg *resp); |
| 47 | |
| 48 | /** |
| 49 | * @brief Sends a response message and waits for a new request which it |
| 50 | * returns then. |
| 51 | * |
| 52 | * @param[in] resp The response message |
| 53 | * @param[out] req The request message |
| 54 | * |
| 55 | * @return The SP API result |
| 56 | */ |
| 57 | sp_result sp_msg_send_direct_resp(const struct sp_msg *resp, |
| 58 | struct sp_msg *req); |
| 59 | |
Imre Kis | be97e77 | 2021-02-25 17:56:19 +0100 | [diff] [blame^] | 60 | #if FFA_DIRECT_MSG_ROUTING_EXTENSION |
| 61 | /** |
| 62 | * @brief Sends a request on the return channel and waits for the response |
| 63 | * message which it returns then. |
| 64 | * |
| 65 | * @param[in] req The request message |
| 66 | * @param[out] resp The response message |
| 67 | * @return The SP API result |
| 68 | */ |
| 69 | sp_result sp_msg_send_rc_req(const struct sp_msg *req, struct sp_msg *resp); |
| 70 | #endif /* FFA_DIRECT_MSG_ROUTING_EXTENSION */ |
| 71 | |
Imre Kis | c674b5b | 2021-02-09 19:05:27 +0100 | [diff] [blame] | 72 | #ifdef __cplusplus |
| 73 | } |
| 74 | #endif |
| 75 | |
| 76 | #endif /* LIBSP_INCLUDE_SP_MESSAGING_H_ */ |