refactor: function to check if mailbox is busy

Moved function 'msg_receiver_busy' into vm's module,
and renamed it accordingly. Function is checking if
the mailbox of an endpoint is busy.

Change-Id: If0076151fccb3a8d2f23a451f8c3f1c8bde9e26b
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/src/api.c b/src/api.c
index aa0ae8f..dc6d8eb 100644
--- a/src/api.c
+++ b/src/api.c
@@ -187,15 +187,6 @@
 }
 
 /**
- * Checks whether the given `to` VM's mailbox is currently busy.
- */
-static bool msg_receiver_busy(struct vm_locked to)
-{
-	return to.vm->mailbox.state != MAILBOX_STATE_EMPTY ||
-	       to.vm->mailbox.recv == NULL;
-}
-
-/**
  * Returns true if the given vCPU is executing in context of an
  * FFA_MSG_SEND_DIRECT_REQ invocation.
  */
@@ -353,7 +344,7 @@
 	uint32_t buffer_size;
 	struct ffa_value ret;
 
-	if (msg_receiver_busy(vm_locked)) {
+	if (vm_is_mailbox_busy(vm_locked)) {
 		/*
 		 * Can't retrieve memory information if the mailbox is not
 		 * available.
@@ -1611,7 +1602,7 @@
 
 	to_locked = vm_lock(to);
 
-	if (msg_receiver_busy(to_locked)) {
+	if (vm_is_mailbox_busy(to_locked)) {
 		ret = ffa_error(FFA_BUSY);
 		goto out;
 	}
@@ -2925,7 +2916,7 @@
 		 */
 		struct two_vm_locked vm_to_from_lock = vm_lock_both(to, from);
 
-		if (msg_receiver_busy(vm_to_from_lock.vm1)) {
+		if (vm_is_mailbox_busy(vm_to_from_lock.vm1)) {
 			ret = ffa_error(FFA_BUSY);
 			goto out_unlock;
 		}
@@ -3013,7 +3004,7 @@
 	 */
 	memcpy_s(retrieve_request, message_buffer_size, to_msg, length);
 
-	if (msg_receiver_busy(to_locked)) {
+	if (vm_is_mailbox_busy(to_locked)) {
 		/*
 		 * Can't retrieve memory information if the mailbox is not
 		 * available.
@@ -3134,7 +3125,7 @@
 
 	to_locked = vm_lock(to);
 
-	if (msg_receiver_busy(to_locked)) {
+	if (vm_is_mailbox_busy(to_locked)) {
 		/*
 		 * Can't retrieve memory information if the mailbox is not
 		 * available.
diff --git a/src/vm.c b/src/vm.c
index 7f52cec..299a63d 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -244,6 +244,15 @@
 }
 
 /**
+ * Checks whether the given `to` VM's mailbox is currently busy.
+ */
+bool vm_is_mailbox_busy(struct vm_locked to)
+{
+	return to.vm->mailbox.state != MAILBOX_STATE_EMPTY ||
+	       to.vm->mailbox.recv == NULL;
+}
+
+/**
  * Gets the ID of the VM which the given VM's wait entry is for.
  */
 ffa_vm_id_t vm_id_for_wait_entry(struct vm *vm, struct wait_entry *entry)