blob: bea40c451fcaa448a366f004025901861cfe0fd0 [file] [log] [blame]
Imre Kisc674b5b2021-02-09 19:05:27 +01001/* SPDX-License-Identifier: BSD-3-Clause */
2/*
Imre Kis1bc4a622022-07-19 17:38:00 +02003 * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
Imre Kisc674b5b2021-02-09 19:05:27 +01004 */
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 Kis1bc4a622022-07-19 17:38:00 +020012#include <stdbool.h>
Imre Kisc674b5b2021-02-09 19:05:27 +010013#include <stdint.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
Imre Kisaec6d142023-06-27 16:16:57 +020019#define SP_MSG_ARG_COUNT (5)
Imre Kisc674b5b2021-02-09 19:05:27 +010020
21/**
22 * @brief SP message type
23 */
24struct sp_msg {
25 uint16_t source_id;
26 uint16_t destination_id;
Imre Kis1bc4a622022-07-19 17:38:00 +020027 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 Kisc674b5b2021-02-09 19:05:27 +010032};
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 */
40sp_result sp_msg_wait(struct sp_msg *msg);
41
42/**
Gabor Toth0d6eb662025-03-11 10:44:43 +010043 * @brief Yield execution.
44 *
45 * @return The SP API result
46 */
47sp_result sp_yield(void);
48
49/**
Imre Kisc674b5b2021-02-09 19:05:27 +010050 * @brief Sends a request message and waits for the response message
51 * which it returns then.
52 *
53 * @param[in] req The request message
54 * @param[out] resp The response message
55 *
56 * @return The SP API result
57 */
58sp_result sp_msg_send_direct_req(const struct sp_msg *req, struct sp_msg *resp);
59
60/**
61 * @brief Sends a response message and waits for a new request which it
62 * returns then.
63 *
64 * @param[in] resp The response message
65 * @param[out] req The request message
66 *
67 * @return The SP API result
68 */
69sp_result sp_msg_send_direct_resp(const struct sp_msg *resp,
70 struct sp_msg *req);
71
Imre Kisbe97e772021-02-25 17:56:19 +010072#if FFA_DIRECT_MSG_ROUTING_EXTENSION
73/**
74 * @brief Sends a request on the return channel and waits for the response
75 * message which it returns then.
76 *
77 * @param[in] req The request message
78 * @param[out] resp The response message
79 * @return The SP API result
80 */
81sp_result sp_msg_send_rc_req(const struct sp_msg *req, struct sp_msg *resp);
82#endif /* FFA_DIRECT_MSG_ROUTING_EXTENSION */
83
Imre Kisc674b5b2021-02-09 19:05:27 +010084#ifdef __cplusplus
85}
86#endif
87
88#endif /* LIBSP_INCLUDE_SP_MESSAGING_H_ */