Implement ffa_mem_perm_get/set functions

Add functions for invoking FFA_MEM_PERM_GET and FFA_MEM_PERM_SET FF-A
1.1 interfaces. These calls can be used to query or change the access
rights of the memory regions of the SP. The patch includes tests and
mock implementations as well.

Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I9e29551768951f6cd58aa57d18d3b65ad8e4f441
diff --git a/components/messaging/ffa/libsp/ffa.c b/components/messaging/ffa/libsp/ffa.c
index 6af0760..374e940 100644
--- a/components/messaging/ffa/libsp/ffa.c
+++ b/components/messaging/ffa/libsp/ffa.c
@@ -439,3 +439,37 @@
 	assert(result.a0 == FFA_SUCCESS_32);
 	return FFA_OK;
 }
+
+ffa_result ffa_mem_perm_get(const void *base_address, uint32_t *mem_perm)
+{
+	struct ffa_params result = {0};
+
+	ffa_svc(FFA_MEM_PERM_GET, (uintptr_t)base_address, FFA_PARAM_MBZ,
+		FFA_PARAM_MBZ, FFA_PARAM_MBZ, FFA_PARAM_MBZ, FFA_PARAM_MBZ,
+		FFA_PARAM_MBZ, &result);
+
+	if (result.a0 == FFA_ERROR)
+		return ffa_get_errorcode(&result);
+
+	assert(result.a0 == FFA_SUCCESS_32);
+	*mem_perm = result.a2;
+	return FFA_OK;
+}
+
+ffa_result ffa_mem_perm_set(const void *base_address, uint32_t page_count,
+			    uint32_t mem_perm)
+{
+	struct ffa_params result = {0};
+
+	assert((mem_perm & FFA_MEM_PERM_RESERVED_MASK) == 0);
+
+	ffa_svc(FFA_MEM_PERM_SET, (uintptr_t)base_address, page_count, mem_perm,
+		FFA_PARAM_MBZ, FFA_PARAM_MBZ, FFA_PARAM_MBZ, FFA_PARAM_MBZ,
+		&result);
+
+	if (result.a0 == FFA_ERROR)
+		return ffa_get_errorcode(&result);
+
+	assert(result.a0 == FFA_SUCCESS_32);
+	return FFA_OK;
+}