rse_comms_protocol.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2022, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef __RSE_COMMS_PROTOCOL_H__
  8. #define __RSE_COMMS_PROTOCOL_H__
  9. #include <cdefs.h>
  10. #include <stdint.h>
  11. #include <psa/client.h>
  12. #include "rse_comms_protocol_embed.h"
  13. #include "rse_comms_protocol_pointer_access.h"
  14. enum rse_comms_protocol_version_t {
  15. RSE_COMMS_PROTOCOL_EMBED = 0,
  16. RSE_COMMS_PROTOCOL_POINTER_ACCESS = 1,
  17. };
  18. struct __packed serialized_rse_comms_header_t {
  19. uint8_t protocol_ver;
  20. uint8_t seq_num;
  21. uint16_t client_id;
  22. };
  23. /* MHU message passed from Host to RSE to deliver a PSA client call */
  24. struct __packed serialized_rse_comms_msg_t {
  25. struct serialized_rse_comms_header_t header;
  26. union __packed {
  27. struct rse_embed_msg_t embed;
  28. struct rse_pointer_access_msg_t pointer_access;
  29. } msg;
  30. };
  31. /* MHU reply message to hold the PSA client reply result returned by RSE */
  32. struct __packed serialized_rse_comms_reply_t {
  33. struct serialized_rse_comms_header_t header;
  34. union __packed {
  35. struct rse_embed_reply_t embed;
  36. struct rse_pointer_access_reply_t pointer_access;
  37. } reply;
  38. };
  39. /* in_len and out_len are uint8_ts, therefore if there are more than 255 iovecs
  40. * an error may occur.
  41. */
  42. CASSERT(PSA_MAX_IOVEC <= UINT8_MAX, assert_rse_comms_max_iovec_too_large);
  43. psa_status_t rse_protocol_serialize_msg(psa_handle_t handle,
  44. int16_t type,
  45. const psa_invec *in_vec,
  46. uint8_t in_len,
  47. const psa_outvec *out_vec,
  48. uint8_t out_len,
  49. struct serialized_rse_comms_msg_t *msg,
  50. size_t *msg_len);
  51. psa_status_t rse_protocol_deserialize_reply(psa_outvec *out_vec,
  52. uint8_t out_len,
  53. psa_status_t *return_val,
  54. const struct serialized_rse_comms_reply_t *reply,
  55. size_t reply_size);
  56. #endif /* __RSE_COMMS_PROTOCOL_H__ */