Imre Kis | c674b5b | 2021-02-09 19:05:27 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: BSD-3-Clause */ |
| 2 | /* |
Imre Kis | 1bc4a62 | 2022-07-19 17:38:00 +0200 | [diff] [blame^] | 3 | * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved. |
Imre Kis | c674b5b | 2021-02-09 19:05:27 +0100 | [diff] [blame] | 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 | |
Imre Kis | 1bc4a62 | 2022-07-19 17:38:00 +0200 | [diff] [blame^] | 12 | #include <stdbool.h> |
Imre Kis | c674b5b | 2021-02-09 19:05:27 +0100 | [diff] [blame] | 13 | #include <stdint.h> |
| 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
| 19 | #define SP_MSG_ARG_COUNT (4) |
| 20 | |
| 21 | /** |
| 22 | * @brief SP message type |
| 23 | */ |
| 24 | struct sp_msg { |
| 25 | uint16_t source_id; |
| 26 | uint16_t destination_id; |
Imre Kis | 1bc4a62 | 2022-07-19 17:38:00 +0200 | [diff] [blame^] | 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; |
Imre Kis | c674b5b | 2021-02-09 19:05:27 +0100 | [diff] [blame] | 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 | |
Imre Kis | be97e77 | 2021-02-25 17:56:19 +0100 | [diff] [blame] | 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 | |
Imre Kis | c674b5b | 2021-02-09 19:05:27 +0100 | [diff] [blame] | 77 | #ifdef __cplusplus |
| 78 | } |
| 79 | #endif |
| 80 | |
| 81 | #endif /* LIBSP_INCLUDE_SP_MESSAGING_H_ */ |