blob: 9a38057cd157ceab19a266c19e9735891bc9f744 [file] [log] [blame]
Raef Coles734aaac2022-06-15 14:37:22 +01001/*
2 * Copyright (c) 2022, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __RSS_COMMS_PROTOCOL_H__
9#define __RSS_COMMS_PROTOCOL_H__
10
11#include <cdefs.h>
12#include <stdint.h>
13
14#include <psa/client.h>
15#include "rss_comms_protocol_embed.h"
16#include "rss_comms_protocol_pointer_access.h"
17
18enum rss_comms_protocol_version_t {
19 RSS_COMMS_PROTOCOL_EMBED = 0,
20 RSS_COMMS_PROTOCOL_POINTER_ACCESS = 1,
21};
22
23struct __packed serialized_rss_comms_header_t {
24 uint8_t protocol_ver;
25 uint8_t seq_num;
26 uint16_t client_id;
27};
28
29/* MHU message passed from Host to RSS to deliver a PSA client call */
30struct __packed serialized_rss_comms_msg_t {
31 struct serialized_rss_comms_header_t header;
32 union __packed {
33 struct rss_embed_msg_t embed;
34 struct rss_pointer_access_msg_t pointer_access;
35 } msg;
36};
37
38/* MHU reply message to hold the PSA client reply result returned by RSS */
39struct __packed serialized_rss_comms_reply_t {
40 struct serialized_rss_comms_header_t header;
41 union __packed {
42 struct rss_embed_reply_t embed;
43 struct rss_pointer_access_reply_t pointer_access;
44 } reply;
45};
46
47/* in_len and out_len are uint8_ts, therefore if there are more than 255 iovecs
48 * an error may occur.
49 */
50CASSERT(PSA_MAX_IOVEC <= UINT8_MAX, assert_rss_comms_max_iovec_too_large);
51
52psa_status_t rss_protocol_serialize_msg(psa_handle_t handle,
53 int16_t type,
54 const psa_invec *in_vec,
55 uint8_t in_len,
56 const psa_outvec *out_vec,
57 uint8_t out_len,
58 struct serialized_rss_comms_msg_t *msg,
59 size_t *msg_len);
60
61psa_status_t rss_protocol_deserialize_reply(psa_outvec *out_vec,
62 uint8_t out_len,
63 psa_status_t *return_val,
64 const struct serialized_rss_comms_reply_t *reply,
65 size_t reply_size);
66
67#endif /* __RSS_COMMS_PROTOCOL_H__ */