feat(notifications): notifications set and get
Handle FF-A calls FFA_NOTIFICATION_SET and FFA_NOTIFICATION_GET.
The former is used for a sender to signal a notification to the
receiver; the latter is for the receiver to get whichever notifications
there are pending.
Change-Id: I7e9db94201d0d78ceecd599cd350eeb37a8cb1f8
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/inc/hf/api.h b/inc/hf/api.h
index be3903d..59755a4 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -106,3 +106,11 @@
ffa_vm_id_t sender_vm_id, ffa_vm_id_t receiver_vm_id, uint32_t flags,
ffa_notifications_bitmap_t notifications, bool is_bind,
struct vcpu *current);
+
+struct ffa_value api_ffa_notification_set(
+ ffa_vm_id_t sender_vm_id, ffa_vm_id_t receiver_vm_id, uint32_t flags,
+ ffa_notifications_bitmap_t notifications, struct vcpu *current);
+
+struct ffa_value api_ffa_notification_get(ffa_vm_id_t receiver_vm_id,
+ uint16_t vcpu_id, uint32_t flags,
+ struct vcpu *current);
diff --git a/inc/hf/arch/plat/ffa.h b/inc/hf/arch/plat/ffa.h
index 2b55f1b..bffc84d 100644
--- a/inc/hf/arch/plat/ffa.h
+++ b/inc/hf/arch/plat/ffa.h
@@ -35,6 +35,16 @@
ffa_vm_id_t sender_id,
ffa_vm_id_t receiver_id);
+bool plat_ffa_is_notification_set_valid(struct vcpu *current,
+ ffa_vm_id_t sender_id,
+ ffa_vm_id_t receiver_id);
+
+bool plat_ffa_is_notification_get_valid(struct vcpu *current,
+ ffa_vm_id_t receiver_id);
+
+bool plat_ffa_notifications_get_call(ffa_vm_id_t receiver_id, uint32_t vcpu_id,
+ uint32_t flags, struct ffa_value *ret);
+
/**
* Checks whether managed exit is supported by given SP.
*/
diff --git a/inc/hf/vm.h b/inc/hf/vm.h
index 7014799..c9bbebc 100644
--- a/inc/hf/vm.h
+++ b/inc/hf/vm.h
@@ -247,3 +247,9 @@
bool is_from_vm, ffa_vm_id_t sender_id,
ffa_notifications_bitmap_t notifications,
bool is_per_vcpu);
+void vm_notifications_set(struct vm_locked vm_locked, bool is_from_vm,
+ ffa_notifications_bitmap_t notifications,
+ ffa_vcpu_index_t vcpu_id, bool is_per_vcpu);
+ffa_notifications_bitmap_t vm_notifications_get_pending_and_clear(
+ struct vm_locked vm_locked, bool is_from_vm,
+ ffa_vcpu_index_t cur_vcpu_id);
diff --git a/inc/vmapi/hf/ffa.h b/inc/vmapi/hf/ffa.h
index af2b756..6f2dd27 100644
--- a/inc/vmapi/hf/ffa.h
+++ b/inc/vmapi/hf/ffa.h
@@ -417,6 +417,24 @@
}
/**
+ * Flags used in calls to FFA_NOTIFICATION_GET interface.
+ */
+#define FFA_NOTIFICATION_FLAG_BITMAP_SP UINT32_C(0x1 << 0)
+#define FFA_NOTIFICATION_FLAG_BITMAP_VM UINT32_C(0x1 << 1)
+#define FFA_NOTIFICATION_FLAG_BITMAP_SPM UINT32_C(0x1 << 2)
+#define FFA_NOTIFICATION_FLAG_BITMAP_HYP UINT32_C(0x1 << 3)
+
+static inline ffa_vm_id_t ffa_notifications_get_receiver(struct ffa_value args)
+{
+ return (args.arg1 >> 16) & 0xffffU;
+}
+
+static inline ffa_vm_id_t ffa_notifications_get_vcpu(struct ffa_value args)
+{
+ return args.arg1 & 0xffffU;
+}
+
+/**
* 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".