Separate the generic part of SP deployments

Move the non opteesp environment dependent code of SP deployments into
a separate directory and split CMake files into a generic and an
environment specific part.

Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I4f09d6d3adef07644e98f2a05d6cb077a92b385b
diff --git a/deployments/protected-storage/opteesp/sp.c b/deployments/protected-storage/common/ps_sp.c
similarity index 95%
rename from deployments/protected-storage/opteesp/sp.c
rename to deployments/protected-storage/common/ps_sp.c
index af75d89..1b47710 100644
--- a/deployments/protected-storage/opteesp/sp.c
+++ b/deployments/protected-storage/common/ps_sp.c
@@ -1,10 +1,9 @@
 /*
- * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#include "sp.h"
 #include <ffa_api.h>
 #include <components/rpc/common/endpoint/rpc_interface.h>
 #include <components/rpc/ffarpc/endpoint/ffarpc_call_ep.h>
diff --git a/deployments/protected-storage/common/ps_sp.h b/deployments/protected-storage/common/ps_sp.h
new file mode 100644
index 0000000..43e257f
--- /dev/null
+++ b/deployments/protected-storage/common/ps_sp.h
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef PS_SP_H
+#define PS_SP_H
+
+#define PS_SP_UUID_BYTES \
+	{ 0x75, 0x1b, 0xf8, 0x01, 0x3d, 0xde, 0x47, 0x68, \
+	  0xa5, 0x14, 0x0f, 0x10, 0xae, 0xed, 0x17, 0x90 }
+
+#endif /* PS_SP_H */
diff --git a/deployments/protected-storage/opteesp/CMakeLists.txt b/deployments/protected-storage/opteesp/CMakeLists.txt
index 18df144..5ae11d8 100644
--- a/deployments/protected-storage/opteesp/CMakeLists.txt
+++ b/deployments/protected-storage/opteesp/CMakeLists.txt
@@ -24,37 +24,16 @@
 add_components(TARGET "protected-storage"
 	BASE_DIR ${TS_ROOT}
 	COMPONENTS
-		components/common/trace
-		components/common/utils
-		components/messaging/ffa/libsp
-		components/rpc/ffarpc/endpoint
-		components/rpc/common/interface
-		components/rpc/ffarpc/caller/sp
-		components/rpc/common/caller
-		components/service/common/include
-		components/service/common/client
-		components/service/common/provider
-		components/service/secure_storage/include
-		components/service/secure_storage/frontend/secure_storage_provider
-		components/service/secure_storage/backend/secure_storage_client
-		components/service/secure_storage/backend/null_store
-		components/service/secure_storage/factory/sp/optee_trusted_store
-		protocols/rpc/common/packed-c
-		protocols/service/secure_storage/packed-c
 		environments/opteesp
 )
 
-target_sources(protected-storage PRIVATE
-	sp.c
-)
+include(../protected-storage.cmake REQUIRED)
 
 target_compile_definitions(protected-storage PRIVATE
 	ARM64=1
 )
 
 target_include_directories(protected-storage PRIVATE
-	${TS_ROOT}
-	${TS_ROOT}/components
 	${TS_ROOT}/deployments/protected-storage/opteesp
 )
 
diff --git a/deployments/protected-storage/opteesp/optee_sp_user_defines.h b/deployments/protected-storage/opteesp/optee_sp_user_defines.h
index d86d29b..1da382a 100644
--- a/deployments/protected-storage/opteesp/optee_sp_user_defines.h
+++ b/deployments/protected-storage/opteesp/optee_sp_user_defines.h
@@ -3,11 +3,12 @@
  * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
  */
 
-#ifndef SP_HEADER_DEFINES_H
-#define SP_HEADER_DEFINES_H
+#ifndef OPTEE_SP_USER_DEFINES_H
+#define OPTEE_SP_USER_DEFINES_H
 
-/* To get UUID definition */
-#include "sp.h"
+#define OPTEE_SP_UUID \
+	{ 0x751bf801, 0x3dde, 0x4768, \
+		{ 0xa5, 0x14, 0x0f, 0x10, 0xae, 0xed, 0x17, 0x90 } }
 
 #define OPTEE_SP_FLAGS			0
 
diff --git a/deployments/protected-storage/opteesp/sp.h b/deployments/protected-storage/opteesp/sp.h
deleted file mode 100644
index 3bb4484..0000000
--- a/deployments/protected-storage/opteesp/sp.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef SP_H
-#define SP_H
-
-/* UUID for the Protected Store */
-#define OPTEE_SP_UUID \
-	{ 0x751bf801, 0x3dde, 0x4768, \
-		{ 0xa5, 0x14, 0x0f, 0x10, 0xae, 0xed, 0x17, 0x90 } }
-
-#define SP_UUID_BYTES \
-	{ 0x75, 0x1b, 0xf8, 0x01, 0x3d, 0xde, 0x47, 0x68, \
-	  0xa5, 0x14, 0x0f, 0x10, 0xae, 0xed, 0x17, 0x90 }
-
-#endif /* SP_H */
diff --git a/deployments/protected-storage/protected-storage.cmake b/deployments/protected-storage/protected-storage.cmake
new file mode 100644
index 0000000..7b22bdb
--- /dev/null
+++ b/deployments/protected-storage/protected-storage.cmake
@@ -0,0 +1,37 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+add_components(TARGET "protected-storage"
+	BASE_DIR ${TS_ROOT}
+	COMPONENTS
+		components/common/trace
+		components/common/utils
+		components/messaging/ffa/libsp
+		components/rpc/ffarpc/endpoint
+		components/rpc/common/interface
+		components/rpc/ffarpc/caller/sp
+		components/rpc/common/caller
+		components/service/common/include
+		components/service/common/client
+		components/service/common/provider
+		components/service/secure_storage/include
+		components/service/secure_storage/frontend/secure_storage_provider
+		components/service/secure_storage/backend/secure_storage_client
+		components/service/secure_storage/backend/null_store
+		components/service/secure_storage/factory/sp/optee_trusted_store
+		protocols/rpc/common/packed-c
+		protocols/service/secure_storage/packed-c
+)
+
+target_sources(protected-storage PRIVATE
+	${CMAKE_CURRENT_LIST_DIR}/common/ps_sp.c
+)
+
+target_include_directories(protected-storage PRIVATE
+	${TS_ROOT}
+	${TS_ROOT}/components
+)