spd: trusty: Add FFA_PARTITION_INFO_GET am: 06db8b350c am: f5848e7060
Original change: https://android-review.googlesource.com/c/trusty/external/trusted-firmware-a/+/2185639
Change-Id: Ib555a6d53d9e6253b81a5f6d10afe0dd991abc41
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/services/spd/trusty/include/trusty/arm_ffa.h b/services/spd/trusty/include/trusty/arm_ffa.h
index f94d0a4..d8e7dfa 100644
--- a/services/spd/trusty/include/trusty/arm_ffa.h
+++ b/services/spd/trusty/include/trusty/arm_ffa.h
@@ -268,6 +268,25 @@
STATIC_ASSERT(sizeof(struct ffa_mem_relinquish_descriptor) == 16);
/**
+ * struct ffa_partition_info - FFA partition info descriptor.
+ * @id:
+ * 16-bit ID of the partition
+ * @execution_ctx_count:
+ * Number of execution contexts implemented by this partition
+ * @properties:
+ * Flags to determine partition properties. Like direct/indirect
+ * messages send/receive capabilities.
+ */
+struct ffa_partition_info {
+ uint16_t id;
+ uint16_t execution_ctx_count;
+#define FFA_PART_PROP_RECV_DIRECT (1U)
+#define FFA_PART_PROP_SEND_DIRECT (1U << 1)
+#define FFA_PART_PROP_VM_MSGS (1U << 6)
+ uint32_t properties;
+};
+
+/**
* typedef ffa_features2_t - FFA_FEATURES values returned in w2
*
* * @FFA_FEATURES2_RXTX_MAP_BUF_SIZE_MASK
diff --git a/services/spd/trusty/shared-mem-smcall.c b/services/spd/trusty/shared-mem-smcall.c
index 89a1b17..8eae42e 100644
--- a/services/spd/trusty/shared-mem-smcall.c
+++ b/services/spd/trusty/shared-mem-smcall.c
@@ -913,6 +913,49 @@
}
/**
+ * trusty_ffa_partition_info_get - FFA_PARTITION_INFO_GET implementation.
+ * @client: Client state
+ * @uuid_0: uuid 0
+ * @uuid_1: uuid 1
+ * @uuid_2 uuid 2
+ * @uuid_3: uuid 3
+ * @ret2: Pointer to return value2 on success. Contains partition
+ * count in case of UUID match.
+ * @ret3: Pointer to return value3 on success. Contains the size
+ * of each partition descriptor
+ *
+ * Return: 0 on success, error code on failure.
+ */
+static long trusty_ffa_partition_info_get(
+ struct trusty_shmem_client_state *client,
+ uint32_t uuid_0,
+ uint32_t uuid_1,
+ uint32_t uuid_2,
+ uint32_t uuid_3,
+ u_register_t *ret2,
+ u_register_t *ret3)
+{
+ uint32_t uuid[4] = { uuid_0, uuid_1, uuid_2, uuid_3 };
+
+ if (!memcmp(trusty_sp.uuid, uuid, sizeof(uuid)) ||
+ (uuid[0] == 0 && uuid[1] == 0 && uuid[2] == 0 && uuid[3] == 0)) {
+ struct ffa_partition_info *info;
+
+ info = (struct ffa_partition_info *)client->rx_buf;
+
+ info->id = trusty_sp.sp_id;
+ info->execution_ctx_count = PLATFORM_CORE_COUNT;
+ info->properties = trusty_sp.properties;
+
+ *ret2 = 1;
+ *ret3 = sizeof(info);
+ return 0;
+ }
+
+ return -ENOENT;
+}
+
+/**
* trusty_ffa_rx_release - FFA_RX_RELEASE implementation.
* @client: Client state.
*
@@ -1106,6 +1149,11 @@
ret = trusty_ffa_rx_release(client);
break;
+ case FFA_PARTITION_INFO_GET:
+ ret = trusty_ffa_partition_info_get(client, w1, w2, w3, w4,
+ &ret_reg2, &ret_reg3);
+ break;
+
case FFA_ID_GET:
ret = trusty_ffa_id_get(flags, &ret_reg2);
break;