spmc_shared_mem.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (c) 2022, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef SPMC_SHARED_MEM_H
  7. #define SPMC_SHARED_MEM_H
  8. #include <services/el3_spmc_ffa_memory.h>
  9. /**
  10. * struct ffa_mem_relinquish_descriptor - Relinquish request descriptor.
  11. * @handle:
  12. * Id of shared memory object to relinquish.
  13. * @flags:
  14. * If bit 0 is set clear memory after unmapping from borrower. Must be 0
  15. * for share. Bit[1]: Time slicing. Not supported, must be 0. All other
  16. * bits are reserved 0.
  17. * @endpoint_count:
  18. * Number of entries in @endpoint_array.
  19. * @endpoint_array:
  20. * Array of endpoint ids.
  21. */
  22. struct ffa_mem_relinquish_descriptor {
  23. uint64_t handle;
  24. uint32_t flags;
  25. uint32_t endpoint_count;
  26. ffa_endpoint_id16_t endpoint_array[];
  27. };
  28. CASSERT(sizeof(struct ffa_mem_relinquish_descriptor) == 16,
  29. assert_ffa_mem_relinquish_descriptor_size_mismatch);
  30. /**
  31. * struct spmc_shmem_obj_state - Global state.
  32. * @data: Backing store for spmc_shmem_obj objects.
  33. * @data_size: The size allocated for the backing store.
  34. * @allocated: Number of bytes allocated in @data.
  35. * @next_handle: Handle used for next allocated object.
  36. * @lock: Lock protecting all state in this file.
  37. */
  38. struct spmc_shmem_obj_state {
  39. uint8_t *data;
  40. size_t data_size;
  41. size_t allocated;
  42. uint64_t next_handle;
  43. spinlock_t lock;
  44. };
  45. extern struct spmc_shmem_obj_state spmc_shmem_obj_state;
  46. extern int plat_spmc_shmem_begin(struct ffa_mtd *desc);
  47. extern int plat_spmc_shmem_reclaim(struct ffa_mtd *desc);
  48. long spmc_ffa_mem_send(uint32_t smc_fid,
  49. bool secure_origin,
  50. uint64_t total_length,
  51. uint32_t fragment_length,
  52. uint64_t address,
  53. uint32_t page_count,
  54. void *cookie,
  55. void *handle,
  56. uint64_t flags);
  57. long spmc_ffa_mem_frag_tx(uint32_t smc_fid,
  58. bool secure_origin,
  59. uint64_t handle_low,
  60. uint64_t handle_high,
  61. uint32_t fragment_length,
  62. uint32_t sender_id,
  63. void *cookie,
  64. void *handle,
  65. uint64_t flags);
  66. long spmc_ffa_mem_retrieve_req(uint32_t smc_fid,
  67. bool secure_origin,
  68. uint32_t total_length,
  69. uint32_t fragment_length,
  70. uint64_t address,
  71. uint32_t page_count,
  72. void *cookie,
  73. void *handle,
  74. uint64_t flags);
  75. long spmc_ffa_mem_frag_rx(uint32_t smc_fid,
  76. bool secure_origin,
  77. uint32_t handle_low,
  78. uint32_t handle_high,
  79. uint32_t fragment_offset,
  80. uint32_t sender_id,
  81. void *cookie,
  82. void *handle,
  83. uint64_t flags);
  84. int spmc_ffa_mem_relinquish(uint32_t smc_fid,
  85. bool secure_origin,
  86. uint32_t handle_low,
  87. uint32_t handle_high,
  88. uint32_t fragment_offset,
  89. uint32_t sender_id,
  90. void *cookie,
  91. void *handle,
  92. uint64_t flags);
  93. int spmc_ffa_mem_reclaim(uint32_t smc_fid,
  94. bool secure_origin,
  95. uint32_t handle_low,
  96. uint32_t handle_high,
  97. uint32_t mem_flags,
  98. uint64_t x4,
  99. void *cookie,
  100. void *handle,
  101. uint64_t flags);
  102. #endif /* SPMC_SHARED_MEM_H */