blob: 7173a9233090ca960ef4ac67d22be16d421ba115 [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
19#define SP_MSG_ARG_COUNT (4)
20
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/**
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 */
51sp_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 */
62sp_result sp_msg_send_direct_resp(const struct sp_msg *resp,
63 struct sp_msg *req);
64
Imre Kisbe97e772021-02-25 17:56:19 +010065#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 */
74sp_result sp_msg_send_rc_req(const struct sp_msg *req, struct sp_msg *resp);
75#endif /* FFA_DIRECT_MSG_ROUTING_EXTENSION */
76
Imre Kisc674b5b2021-02-09 19:05:27 +010077#ifdef __cplusplus
78}
79#endif
80
81#endif /* LIBSP_INCLUDE_SP_MESSAGING_H_ */