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