refactor(hypervisor): enabling TEE interaction

At initialization hafnium initializes the other world's resources.
The hypervisor needs to enable its interaction with the TEE, deployed
in the SWd. This was done by passing a boolean to the function
'plat_ffa_init', which sets a local 'ffa_tee_enabled'.
Before forwarding a call to the SPMC, the hypervisor normally checks if
this boolean was set at initialization.
When loading the VMs the hypervisor might need to call the SPMC
with FFA_NOTIFICATION_BITMAP_CREATE, in case notifications are enabled.
The VMs were being loaded before the call to 'plat_ffa_init', so
setting 'ffa_tee_enabled' was factored out into its own function, which
is invoked before loading VMs.

Change-Id: Ifaaf11ee62cdbd5d09f75fabb57068de7d38d01d
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/src/arch/aarch64/plat/ffa/absent.c b/src/arch/aarch64/plat/ffa/absent.c
index ca8a080..ecf7075 100644
--- a/src/arch/aarch64/plat/ffa/absent.c
+++ b/src/arch/aarch64/plat/ffa/absent.c
@@ -36,11 +36,15 @@
 {
 }
 
-void plat_ffa_init(bool tee_enabled)
+void plat_ffa_set_tee_enabled(bool tee_enabled)
 {
 	(void)tee_enabled;
 }
 
+void plat_ffa_init(void)
+{
+}
+
 /**
  * Check validity of the FF-A memory send function attempt.
  */
diff --git a/src/arch/aarch64/plat/ffa/hypervisor.c b/src/arch/aarch64/plat/ffa/hypervisor.c
index 7effbdb..55507ae 100644
--- a/src/arch/aarch64/plat/ffa/hypervisor.c
+++ b/src/arch/aarch64/plat/ffa/hypervisor.c
@@ -62,6 +62,11 @@
 	dlog_info("Initializing Hafnium (Hypervisor)\n");
 }
 
+void plat_ffa_set_tee_enabled(bool tee_enabled)
+{
+	ffa_tee_enabled = tee_enabled;
+}
+
 static void plat_ffa_rxtx_map_spmc(paddr_t recv, paddr_t send,
 				   uint64_t page_count)
 {
@@ -74,12 +79,12 @@
 	CHECK(ret.func == FFA_SUCCESS_32);
 }
 
-void plat_ffa_init(bool tee_enabled)
+void plat_ffa_init(void)
 {
 	struct vm *other_world_vm = vm_find(HF_OTHER_WORLD_ID);
 	struct ffa_value ret;
 
-	if (!tee_enabled) {
+	if (!ffa_tee_enabled) {
 		return;
 	}
 
diff --git a/src/arch/aarch64/plat/ffa/spmc.c b/src/arch/aarch64/plat/ffa/spmc.c
index e8bcfc8..f817274 100644
--- a/src/arch/aarch64/plat/ffa/spmc.c
+++ b/src/arch/aarch64/plat/ffa/spmc.c
@@ -215,10 +215,13 @@
 	}
 }
 
-void plat_ffa_init(bool tee_enabled)
+void plat_ffa_set_tee_enabled(bool tee_enabled)
 {
 	(void)tee_enabled;
+}
 
+void plat_ffa_init(void)
+{
 	arch_ffa_init();
 	plat_ffa_vm_init();
 }
diff --git a/src/init.c b/src/init.c
index bff98b1..170c716 100644
--- a/src/init.c
+++ b/src/init.c
@@ -143,6 +143,8 @@
 		      manifest_strerror(manifest_ret));
 	}
 
+	plat_ffa_set_tee_enabled(manifest.ffa_tee_enabled);
+
 	if (!plat_iommu_init(&fdt, mm_stage1_locked, &ppool)) {
 		panic("Could not initialize IOMMUs.");
 	}
@@ -180,7 +182,7 @@
 	mm_vm_enable_invalidation();
 
 	/* Perform platform specfic FF-A initialization. */
-	plat_ffa_init(manifest.ffa_tee_enabled);
+	plat_ffa_init();
 
 	dlog_info("Hafnium initialisation completed\n");
 }