Add support for FFA_PARTITION_INFO_GET
Add support for FFA_PARTITION_INFO_GET, which returns
information on the partitions instantiated in the system.
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I93070fe841b4b19c596645246203dbba14eddb12
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index 719da62..8a29933 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -28,6 +28,31 @@
}
/**
+ * Requests information for partitions instantiated in the system. The
+ * information is returned in the RX buffer of the caller as an array of
+ * partition information descriptors (struct ffa_partition_info).
+ *
+ * A Null UUID (UUID that is all zeros) returns information for all partitions,
+ * whereas a non-Null UUID returns information only for partitions that match.
+ *
+ * Returns:
+ * - FFA_SUCCESS on success. The count of partition information descriptors
+ * populated in the RX buffer is returned in arg2 (register w2).
+ * - FFA_BUSY if the caller's RX buffer is not free.
+ * - FFA_NO_MEMORY if the results do not fit in the callers RX buffer.
+ * - FFA_INVALID_PARAMETERS for an unrecognized UUID.
+ */
+static inline struct ffa_value ffa_partition_info_get(
+ const struct ffa_uuid *uuid)
+{
+ return ffa_call((struct ffa_value){.func = FFA_PARTITION_INFO_GET_32,
+ .arg1 = uuid->uuid[0],
+ .arg2 = uuid->uuid[1],
+ .arg3 = uuid->uuid[2],
+ .arg4 = uuid->uuid[3]});
+}
+
+/**
* Returns the VM's own ID.
*/
static inline ffa_vm_id_t hf_vm_get_id(void)
diff --git a/inc/vmapi/hf/ffa.h b/inc/vmapi/hf/ffa.h
index 02c0777..bc85337 100644
--- a/inc/vmapi/hf/ffa.h
+++ b/inc/vmapi/hf/ffa.h
@@ -290,6 +290,71 @@
}
/**
+ * Holds the UUID in a struct that is mappable directly to the SMCC calling
+ * convention, which is used for FF-A calls.
+ *
+ * Refer to table 84 of the FF-A 1.0 EAC specification as well as section 5.3
+ * of the SMCC Spec 1.2.
+ */
+struct ffa_uuid {
+ uint32_t uuid[4];
+};
+
+static inline void ffa_uuid_init(uint32_t w0, uint32_t w1, uint32_t w2,
+ uint32_t w3, struct ffa_uuid *uuid)
+{
+ uuid->uuid[0] = w0;
+ uuid->uuid[1] = w1;
+ uuid->uuid[2] = w2;
+ uuid->uuid[3] = w3;
+}
+
+static inline bool ffa_uuid_equal(const struct ffa_uuid *uuid1,
+ const struct ffa_uuid *uuid2)
+{
+ return (uuid1->uuid[0] == uuid2->uuid[0]) &&
+ (uuid1->uuid[1] == uuid2->uuid[1]) &&
+ (uuid1->uuid[2] == uuid2->uuid[2]) &&
+ (uuid1->uuid[3] == uuid2->uuid[3]);
+}
+
+static inline bool ffa_uuid_is_null(const struct ffa_uuid *uuid)
+{
+ return (uuid->uuid[0] == 0) && (uuid->uuid[1] == 0) &&
+ (uuid->uuid[2] == 0) && (uuid->uuid[3] == 0);
+}
+
+/**
+ * Flags to determine the partition properties, as required by
+ * FFA_PARTITION_INFO_GET.
+ *
+ * The values of the flags are specified in table 82 of the FF-A 1.0 EAC
+ * specification, "Partition information descriptor, partition properties".
+ */
+typedef uint32_t ffa_partition_properties_t;
+
+/** Partition property: partition supports receipt of direct requests. */
+#define FFA_PARTITION_DIRECT_RECV 0x1
+
+/** Partition property: partition can send direct requests. */
+#define FFA_PARTITION_DIRECT_SEND 0x2
+
+/** Partition property: partition can send and receive indirect messages. */
+#define FFA_PARTITION_INDIRECT_MSG 0x4
+
+/**
+ * Holds information returned for each partition by the FFA_PARTITION_INFO_GET
+ * interface.
+ * This corresponds to table 82 of the FF-A 1.0 EAC specification, "Partition
+ * information descriptor".
+ */
+struct ffa_partition_info {
+ ffa_vm_id_t vm_id;
+ ffa_vcpu_count_t vcpu_count;
+ ffa_partition_properties_t properties;
+};
+
+/**
* A set of contiguous pages which is part of a memory region. This corresponds
* to table 40 of the FF-A 1.0 EAC specification, "Constituent memory region
* descriptor".