refactor(plat/ffa): memory handle refactorings
Replace the need for each platform to provide a definition of
`plat_ffa_memory_handle_make` and
`plat_ffa_memory_handle_allocated_by_current_world`. Instead, they only
need to provide a value for `plat_ffa_memory_handle_allocator`.
Move `FFA_MEMORY_HANDLE_ALLOCATOR_HYPERVISOR` and
`FFA_MEMORY_HANDLE_ALLOCATOR_SPMC` constants into an enum.
Add helper functions for getting a memory handle's allocator and index.
Change-Id: I4f4661a2e7e37769e947383b4b45718fb0ddfa1a
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
diff --git a/src/ffa_memory.c b/src/ffa_memory.c
index 802d26f..fd92e9f 100644
--- a/src/ffa_memory.c
+++ b/src/ffa_memory.c
@@ -70,14 +70,6 @@
}
/**
- * Extracts the index from a memory handle allocated by Hafnium's current world.
- */
-uint64_t ffa_memory_handle_get_index(ffa_memory_handle_t handle)
-{
- return handle & ~FFA_MEMORY_HANDLE_ALLOCATOR_MASK;
-}
-
-/**
* Initialises the next available `struct ffa_memory_share_state`. If `handle`
* is `FFA_MEMORY_HANDLE_INVALID` then allocates an appropriate handle,
* otherwise uses the provided handle which is assumed to be globally unique.
@@ -161,7 +153,7 @@
* handle is based on the index.
*/
if (plat_ffa_memory_handle_allocated_by_current_world(handle)) {
- uint64_t index = ffa_memory_handle_get_index(handle);
+ uint64_t index = ffa_memory_handle_index(handle);
if (index < MAX_MEM_SHARES) {
share_state = &share_states.share_states[index];