Integrate stub PSA FWU M proxy into se-proxy

Add FWU provider RPC interface which uses PSA FWU M update agent and
stub PSA FWU M interface implementation. Platforms must provide the real
PSA FWU M interface implementation an replace the placeholder stub.

Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: Ib8fa7ae0f12eff4019651d1621d5d9cbe3ea0355
diff --git a/deployments/se-proxy/env/commonsp/se_proxy_sp.c b/deployments/se-proxy/env/commonsp/se_proxy_sp.c
index c7ae99e..485d764 100644
--- a/deployments/se-proxy/env/commonsp/se_proxy_sp.c
+++ b/deployments/se-proxy/env/commonsp/se_proxy_sp.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: BSD-3-Clause
 /*
- * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2024, Arm Limited and Contributors. All rights reserved.
  */
 
 #include "components/rpc/common/endpoint/rpc_service_interface.h"
@@ -39,7 +39,7 @@
 		goto fatal_error;
 	}
 
-	rpc_status = ts_rpc_endpoint_sp_init(&rpc_endpoint, 4, 16);
+	rpc_status = ts_rpc_endpoint_sp_init(&rpc_endpoint, 5, 16);
 	if (rpc_status != RPC_SUCCESS) {
 		EMSG("Failed to initialize RPC endpoint: %d", rpc_status);
 		goto fatal_error;
@@ -94,6 +94,18 @@
 		goto fatal_error;
 	}
 
+	rpc_iface = fwu_proxy_create();
+	if (!rpc_iface) {
+		EMSG("Failed to create FWU proxy");
+		goto fatal_error;
+	}
+
+	rpc_status = ts_rpc_endpoint_sp_add_service(&rpc_endpoint, rpc_iface);
+	if (rpc_status != RPC_SUCCESS) {
+		EMSG("Failed to add service to RPC endpoint: %d", rpc_status);
+		goto fatal_error;
+	}
+
 	/* End of boot phase */
 	result = sp_msg_wait(&req_msg);
 	if (result != SP_RESULT_OK) {
diff --git a/deployments/se-proxy/infra/corstone1000/infra.cmake b/deployments/se-proxy/infra/corstone1000/infra.cmake
index a52a1b7..05b21cb 100644
--- a/deployments/se-proxy/infra/corstone1000/infra.cmake
+++ b/deployments/se-proxy/infra/corstone1000/infra.cmake
@@ -14,6 +14,7 @@
 add_components(TARGET "se-proxy"
 	BASE_DIR ${TS_ROOT}
 	COMPONENTS
+		"components/common/uuid"
 		"components/rpc/common/caller"
 		"components/rpc/rss_comms"
 		"components/messaging/rss_comms/sp"
@@ -21,6 +22,11 @@
 		"components/service/attestation/key_mngr/local"
 		"components/service/attestation/reporter/psa_ipc"
 		"components/service/crypto/backend/psa_ipc"
+		"components/service/fwu/common"
+		"components/service/fwu/provider"
+		"components/service/fwu/provider/serializer"
+		"components/service/fwu/psa_fwu_m/agent"
+		"components/service/fwu/psa_fwu_m/interface/stub"
 		"components/service/secure_storage/backend/secure_storage_ipc"
 )
 
diff --git a/deployments/se-proxy/infra/corstone1000/service_proxy_factory.c b/deployments/se-proxy/infra/corstone1000/service_proxy_factory.c
index b3b93cf..18cd7f6 100644
--- a/deployments/se-proxy/infra/corstone1000/service_proxy_factory.c
+++ b/deployments/se-proxy/infra/corstone1000/service_proxy_factory.c
@@ -12,6 +12,8 @@
 #include <service/attestation/provider/attest_provider.h>
 #include <service/attestation/provider/serializer/packed-c/packedc_attest_provider_serializer.h>
 #include <service/crypto/factory/crypto_provider_factory.h>
+#include "service/fwu/psa_fwu_m/agent/psa_fwu_m_update_agent.h"
+#include "service/fwu/provider/fwu_provider.h"
 #include <service/secure_storage/frontend/secure_storage_provider/secure_storage_provider.h>
 #include "service/secure_storage/frontend/secure_storage_provider/secure_storage_uuid.h"
 #include <trace.h>
@@ -129,3 +131,13 @@
 
 	return secure_storage_provider_init(&its_provider, backend, &its_uuid);
 }
+
+struct rpc_service_interface *fwu_proxy_create(void)
+{
+	static struct update_agent *agent;
+	static struct fwu_provider fwu_provider = { 0 };
+
+	agent = psa_fwu_m_update_agent_init(NULL, 0, 4096);
+
+	return fwu_provider_init(&fwu_provider, agent);
+}
diff --git a/deployments/se-proxy/infra/service_proxy_factory.h b/deployments/se-proxy/infra/service_proxy_factory.h
index caaea79..be83319 100644
--- a/deployments/se-proxy/infra/service_proxy_factory.h
+++ b/deployments/se-proxy/infra/service_proxy_factory.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2024, Arm Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -17,6 +17,7 @@
 struct rpc_service_interface *crypto_proxy_create(void);
 struct rpc_service_interface *ps_proxy_create(void);
 struct rpc_service_interface *its_proxy_create(void);
+struct rpc_service_interface *fwu_proxy_create(void);
 
 #ifdef __cplusplus
 }
diff --git a/deployments/se-proxy/infra/stub/service_proxy_factory.c b/deployments/se-proxy/infra/stub/service_proxy_factory.c
index 4cec9ce..0a8e6de 100644
--- a/deployments/se-proxy/infra/stub/service_proxy_factory.c
+++ b/deployments/se-proxy/infra/stub/service_proxy_factory.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2024, Arm Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -9,6 +9,8 @@
 #include "service/attestation/provider/attest_provider.h"
 #include "service/attestation/provider/serializer/packed-c/packedc_attest_provider_serializer.h"
 #include "service/crypto/factory/crypto_provider_factory.h"
+#include "service/fwu/psa_fwu_m/agent/psa_fwu_m_update_agent.h"
+#include "service/fwu/provider/fwu_provider.h"
 #include "service/secure_storage/frontend/secure_storage_provider/secure_storage_provider.h"
 #include "service/secure_storage/frontend/secure_storage_provider/secure_storage_uuid.h"
 
@@ -67,3 +69,13 @@
 
 	return secure_storage_provider_init(&its_provider, backend, &service_uuid);
 }
+
+struct rpc_service_interface *fwu_proxy_create(void)
+{
+	static struct update_agent *agent;
+	static struct fwu_provider fwu_provider = { 0 };
+
+	agent = psa_fwu_m_update_agent_init(NULL, 0, 4096);
+
+	return fwu_provider_init(&fwu_provider, agent);
+}
diff --git a/deployments/se-proxy/infra/stub/stub.cmake b/deployments/se-proxy/infra/stub/stub.cmake
index a364f8d..58beacd 100644
--- a/deployments/se-proxy/infra/stub/stub.cmake
+++ b/deployments/se-proxy/infra/stub/stub.cmake
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2022-2024, Arm Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -14,12 +14,18 @@
 add_components(TARGET "se-proxy"
 	BASE_DIR ${TS_ROOT}
 	COMPONENTS
+		"components/common/uuid"
 		"components/rpc/dummy"
 		"components/rpc/common/caller"
 		"components/service/attestation/reporter/stub"
 		"components/service/attestation/key_mngr/stub"
 		"components/service/crypto/backend/stub"
 		"components/service/crypto/client/psa"
+		"components/service/fwu/common"
+		"components/service/fwu/provider"
+		"components/service/fwu/provider/serializer"
+		"components/service/fwu/psa_fwu_m/agent"
+		"components/service/fwu/psa_fwu_m/interface/stub"
 		"components/service/secure_storage/backend/mock_store"
 )