Align with Linux FF-A driver

The user space driver for FF-A has been updated. Align the necessary
parts and replace the driver header in external.

Signed-off-by: Balint Dobszay <balint.dobszay@arm.com>
Change-Id: I8bcf601d54e93584f6a9d624bd74039dc12eda18
diff --git a/components/rpc/ffarpc/caller/linux/component.cmake b/components/rpc/ffarpc/caller/linux/component.cmake
index 3bab840..ec5387c 100644
--- a/components/rpc/ffarpc/caller/linux/component.cmake
+++ b/components/rpc/ffarpc/caller/linux/component.cmake
@@ -1,14 +1,19 @@
 #-------------------------------------------------------------------------------
-# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
 #-------------------------------------------------------------------------------
-if (NOT DEFINED TGT)
+if(NOT DEFINED TGT)
 	message(FATAL_ERROR "mandatory parameter TGT is not defined.")
 endif()
 
+include(${TS_ROOT}/external/LinuxFFAUserShim/LinuxFFAUserShim.cmake)
+
 target_sources(${TGT} PRIVATE
 	"${CMAKE_CURRENT_LIST_DIR}/ffarpc_caller.c"
-	)
+)
 
+target_include_directories(${TGT} PRIVATE
+	"${LINUX_FFA_USER_SHIM_INCLUDE_DIR}"
+)
diff --git a/components/rpc/ffarpc/caller/linux/ffarpc_caller.c b/components/rpc/ffarpc/caller/linux/ffarpc_caller.c
index af86664..70d6ca3 100644
--- a/components/rpc/ffarpc/caller/linux/ffarpc_caller.c
+++ b/components/rpc/ffarpc/caller/linux/ffarpc_caller.c
@@ -1,11 +1,11 @@
 /*
- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
 #include "ffarpc_caller.h"
-#include <external/ffa_tool/buf_common.h>
+#include <arm_ffa_user.h>
 #include <rpc/ffarpc/endpoint/ffarpc_call_args.h>
 #include <rpc/ffarpc/endpoint/ffarpc_call_ops.h>
 #include <protocols/rpc/common/packed-c/status.h>
@@ -65,7 +65,7 @@
 	ffarpc_caller_close(s);
 }
 
-size_t ffarpc_caller_discover(const struct ffarpc_caller *s, const uint8_t *uuid,
+size_t ffarpc_caller_discover(const struct ffarpc_caller *s, const struct uuid_canonical *uuid,
 						uint16_t *partition_ids, size_t discover_limit)
 {
 	size_t discover_count = 0;
@@ -77,15 +77,12 @@
 
 		if (fd >= 0) {
 			int ioctl_status;
-			struct endpoint_id discovered_partition;
+			struct ffa_ioctl_ep_desc discovered_partition;
 
-			discovered_partition.uuid_0 = uuid[3]  << 24 | uuid[2]  << 16 | uuid[1]  << 8 | uuid[0];
-			discovered_partition.uuid_1 = uuid[7]  << 24 | uuid[6]  << 16 | uuid[5]  << 8 | uuid[4];
-			discovered_partition.uuid_2 = uuid[11] << 24 | uuid[10] << 16 | uuid[9]  << 8 | uuid[8];
-			discovered_partition.uuid_3 = uuid[15] << 24 | uuid[14] << 16 | uuid[13] << 8 | uuid[12];
+			discovered_partition.uuid_ptr = (uintptr_t)&uuid->characters;
 			discovered_partition.id = 0;
 
-			ioctl_status = ioctl(fd, GET_PART_ID, &discovered_partition);
+			ioctl_status = ioctl(fd, FFA_IOC_GET_PART_ID, &discovered_partition);
 
 			if ((ioctl_status == 0) && (discover_count < discover_limit)) {
 				partition_ids[discover_count] = discovered_partition.id;
@@ -109,7 +106,7 @@
 
 		if (s->fd >= 0) {
 			/* Allocate resource for session */
-			ioctl_status = ioctl(s->fd, SHARE_INIT, &s->shared_mem_handle);
+			ioctl_status = ioctl(s->fd, FFA_IOC_SHM_INIT, &s->shared_mem_handle);
 
 			if (ioctl_status == 0) {
 				/* Session successfully opened */
@@ -135,7 +132,7 @@
     if (s->fd >= 0) {
 
         unshare_mem_with_partition(s);
-        ioctl_status = ioctl(s->fd, SHARE_DEINIT);
+        ioctl_status = ioctl(s->fd, FFA_IOC_SHM_DEINIT);
         close(s->fd);
         s->fd = -1;
         s->call_ep_id = 0;
@@ -195,14 +192,14 @@
 
         if (kernel_op_status == 0) {
             /* Make direct call to send the request */
-            struct msg_args direct_msg;
+            struct ffa_ioctl_msg_args direct_msg;
             memset(&direct_msg, 0, sizeof(direct_msg));
 
 		    direct_msg.dst_id = s->call_ep_id;
 		    direct_msg.args[FFA_CALL_ARGS_OPCODE] = (uint64_t)opcode;
 		    direct_msg.args[FFA_CALL_ARGS_REQ_DATA_LEN] = (uint64_t)s->req_len;
 
-            kernel_op_status = ioctl(s->fd, SEND_SYNC_MSG, &direct_msg);
+            kernel_op_status = ioctl(s->fd, FFA_IOC_MSG_SEND, &direct_msg);
 
             if (kernel_op_status == 0) {
                 /* Send completed normally - ffa return args in msg_args struct */
@@ -263,11 +260,11 @@
 static int kernel_write_req_buf(struct ffarpc_caller *s) {
 
     int ioctl_status;
-    struct buf_descr req_descr;
+    struct ffa_ioctl_buf_desc req_descr;
 
-    req_descr.buf = s->req_buf;
-    req_descr.length = s->req_len;
-    ioctl_status = ioctl(s->fd, SHARE_WRITE, &req_descr);
+    req_descr.buf_ptr = (uintptr_t)s->req_buf;
+    req_descr.buf_len = s->req_len;
+    ioctl_status = ioctl(s->fd, FFA_IOC_SHM_WRITE, &req_descr);
 
     return ioctl_status;
 }
@@ -276,11 +273,11 @@
 static int kernel_read_resp_buf(struct ffarpc_caller *s) {
 
     int ioctl_status;
-    struct buf_descr resp_descr;
+    struct ffa_ioctl_buf_desc resp_descr;
 
-    resp_descr.buf = s->resp_buf;
-    resp_descr.length = s->resp_len;
-    ioctl_status = ioctl(s->fd, SHARE_READ, &resp_descr);
+    resp_descr.buf_ptr = (uintptr_t)s->resp_buf;
+    resp_descr.buf_len = s->resp_len;
+    ioctl_status = ioctl(s->fd, FFA_IOC_SHM_READ, &resp_descr);
 
     return ioctl_status;
 }
@@ -288,7 +285,7 @@
 static int share_mem_with_partition(struct ffarpc_caller *s) {
 
     int ioctl_status;
-    struct msg_args direct_msg;
+    struct ffa_ioctl_msg_args direct_msg;
     memset(&direct_msg, 0, sizeof(direct_msg));
 
     direct_msg.dst_id = s->call_ep_id;
@@ -297,7 +294,7 @@
     direct_msg.args[FFA_CALL_ARGS_SHARE_MEM_HANDLE_MSW] = (uint32_t)(s->shared_mem_handle >> 32);
     direct_msg.args[FFA_CALL_ARGS_SHARE_MEM_SIZE] = (uint64_t)s->shared_mem_required_size;
 
-    ioctl_status = ioctl(s->fd, SEND_SYNC_MSG, &direct_msg);
+    ioctl_status = ioctl(s->fd, FFA_IOC_MSG_SEND, &direct_msg);
 
     return ioctl_status;
 }
@@ -305,7 +302,7 @@
 static int unshare_mem_with_partition(struct ffarpc_caller *s) {
 
     int ioctl_status;
-    struct msg_args direct_msg;
+    struct ffa_ioctl_msg_args direct_msg;
     memset(&direct_msg, 0, sizeof(direct_msg));
 
     direct_msg.dst_id = s->call_ep_id;
@@ -313,7 +310,7 @@
     direct_msg.args[FFA_CALL_ARGS_SHARE_MEM_HANDLE_LSW] = (uint32_t)s->shared_mem_handle;
     direct_msg.args[FFA_CALL_ARGS_SHARE_MEM_HANDLE_MSW] = (uint32_t)(s->shared_mem_handle >> 32);
 
-    ioctl_status = ioctl(s->fd, SEND_SYNC_MSG, &direct_msg);
+    ioctl_status = ioctl(s->fd, FFA_IOC_MSG_SEND, &direct_msg);
 
     return ioctl_status;
 }
diff --git a/components/rpc/ffarpc/caller/linux/ffarpc_caller.h b/components/rpc/ffarpc/caller/linux/ffarpc_caller.h
index 69410ab..7e846ba 100644
--- a/components/rpc/ffarpc/caller/linux/ffarpc_caller.h
+++ b/components/rpc/ffarpc/caller/linux/ffarpc_caller.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -7,6 +7,7 @@
 #ifndef FFARPC_CALLER_H
 #define FFARPC_CALLER_H
 
+#include <common/uuid/uuid.h>
 #include <rpc_caller.h>
 #include <stdbool.h>
 
@@ -35,7 +36,7 @@
 
 struct rpc_caller *ffarpc_caller_init(struct ffarpc_caller *s, const char *device_path);
 void ffarpc_caller_deinit(struct ffarpc_caller *s);
-size_t ffarpc_caller_discover(const struct ffarpc_caller *s, const uint8_t *uuid,
+size_t ffarpc_caller_discover(const struct ffarpc_caller *s, const struct uuid_canonical *uuid,
 						uint16_t *partition_ids, size_t discover_limit);
 int ffarpc_caller_open(struct ffarpc_caller *s, uint16_t call_ep_id);
 int ffarpc_caller_close(struct ffarpc_caller *s);