From 80273f9bcab14059ec92e5c05826ae52113cebe6 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Fri, 10 Dec 2021 20:10:41 +0000
Subject: [PATCH 14/27] efi_boottime: corstone1000: pass interface id and
 kernel event id using register w4

Initially the interface/event IDs are passed to the SP using register
w3 and w5.

Now the SE proxy SP requires this arguments to be in register w4.

This change is to pass interface ID(31:16) and kernel started
event ID(15:0) to SE proxy SP to trigger an event to
secure enclave just before ExitbootService().

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Upstream-Status: Pending [Not submitted to upstream yet]
---
 lib/efi_loader/efi_boottime.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index faab74474d77..36a0be7ba104 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -30,6 +30,11 @@
 #include <arm_ffa.h>
 #endif
 
+#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
+#include <linux/bitfield.h>
+#include <linux/bitops.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 /* Task priority level */
@@ -2120,10 +2125,12 @@ static int efi_corstone1000_kernel_started_event(void)
 	log_debug("[%s]\n", __func__);
 
 	/*
-	 * setting the kernel started  event arguments
+	 * setting the kernel started  event arguments:
+	 * setting capsule update interface ID(31:16)
+	 * the kernel started event ID(15:0)
 	 */
-	msg.data0 = CORSTONE1000_SEPROXY_UPDATE_SVC_ID; /* x3 */
-	msg.data2 = CORSTONE1000_KERNEL_STARTED_EVT; /* x5 */
+	msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
+		PREP_SEPROXY_EVT(CORSTONE1000_KERNEL_STARTED_EVT); /* w4 */
 
 	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
 }
-- 
2.39.1

