| 1 |
/* |
| 2 |
* Copyright (c) 2022, Arm Limited. All rights reserved. |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: BSD-3-Clause |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef __RSE_COMMS_PROTOCOL_H__ |
| 9 |
#define __RSE_COMMS_PROTOCOL_H__ |
| 10 |
|
| 11 |
#include <cdefs.h> |
| 12 |
#include <stdint.h> |
| 13 |
|
| 14 |
#include <psa/client.h> |
| 15 |
#include "rse_comms_protocol_embed.h" |
| 16 |
#include "rse_comms_protocol_pointer_access.h" |
| 17 |
|
| 18 |
enum rse_comms_protocol_version_t { |
| 19 |
RSE_COMMS_PROTOCOL_EMBED = 0, |
| 20 |
RSE_COMMS_PROTOCOL_POINTER_ACCESS = 1, |
| 21 |
}; |
| 22 |
|
| 23 |
struct __packed serialized_rse_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 RSE to deliver a PSA client call */ |
| 30 |
struct __packed serialized_rse_comms_msg_t { |
| 31 |
struct serialized_rse_comms_header_t header; |
| 32 |
union __packed { |
| 33 |
struct rse_embed_msg_t embed; |
| 34 |
struct rse_pointer_access_msg_t pointer_access; |
| 35 |
} msg; |
| 36 |
}; |
| 37 |
|
| 38 |
/* MHU reply message to hold the PSA client reply result returned by RSE */ |
| 39 |
struct __packed serialized_rse_comms_reply_t { |
| 40 |
struct serialized_rse_comms_header_t header; |
| 41 |
union __packed { |
| 42 |
struct rse_embed_reply_t embed; |
| 43 |
struct rse_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 |
*/ |
| 50 |
CASSERT(PSA_MAX_IOVEC <= UINT8_MAX, assert_rse_comms_max_iovec_too_large); |
| 51 |
|
| 52 |
psa_status_t rse_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_rse_comms_msg_t *msg, |
| 59 |
size_t *msg_len); |
| 60 |
|
| 61 |
psa_status_t rse_protocol_deserialize_reply(psa_outvec *out_vec, |
| 62 |
uint8_t out_len, |
| 63 |
psa_status_t *return_val, |
| 64 |
const struct serialized_rse_comms_reply_t *reply, |
| 65 |
size_t reply_size); |
| 66 |
|
| 67 |
#endif /* __RSE_COMMS_PROTOCOL_H__ */ |