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/internal-trusted-storage/opteesp/sp.c b/deployments/internal-trusted-storage/common/its_sp.c
similarity index 95%
rename from deployments/internal-trusted-storage/opteesp/sp.c
rename to deployments/internal-trusted-storage/common/its_sp.c
index a469905..18df88f 100644
--- a/deployments/internal-trusted-storage/opteesp/sp.c
+++ b/deployments/internal-trusted-storage/common/its_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/internal-trusted-storage/common/its_sp.h b/deployments/internal-trusted-storage/common/its_sp.h
new file mode 100644
index 0000000..ffaf25e
--- /dev/null
+++ b/deployments/internal-trusted-storage/common/its_sp.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+#ifndef ITS_SP_H
+#define ITS_SP_H
+
+/* UUID for the Internal Trusted Store */
+#define ITS_SP_UUID_BYTES \
+	{ 0xdc, 0x1e, 0xef, 0x48, 0xb1, 0x7a, 0x4c, 0xcf, \
+	  0xac, 0x8b, 0xdf, 0xcf, 0xf7, 0x71, 0x1b, 0x14, }
+
+#endif /* ITS_SP_H */
diff --git a/deployments/internal-trusted-storage/internal-trusted-storage.cmake b/deployments/internal-trusted-storage/internal-trusted-storage.cmake
new file mode 100644
index 0000000..3ce5564
--- /dev/null
+++ b/deployments/internal-trusted-storage/internal-trusted-storage.cmake
@@ -0,0 +1,36 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+add_components(TARGET "internal-trusted-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/service/common/include
+		components/service/common/provider
+		components/service/secure_storage/include
+		components/service/secure_storage/frontend/secure_storage_provider
+		components/service/secure_storage/backend/secure_flash_store
+		components/service/secure_storage/backend/secure_flash_store/flash_fs
+		components/service/secure_storage/backend/secure_flash_store/flash
+		components/service/secure_storage/factory/common/sfs
+		protocols/rpc/common/packed-c
+		protocols/service/secure_storage/packed-c
+)
+
+target_sources(internal-trusted-storage PRIVATE
+	${CMAKE_CURRENT_LIST_DIR}/common/its_sp.c
+)
+
+target_include_directories(internal-trusted-storage PRIVATE
+	${TS_ROOT}
+	${TS_ROOT}/components
+	${TS_ROOT}/deployments/internal-trusted-storage/common
+)
diff --git a/deployments/internal-trusted-storage/opteesp/CMakeLists.txt b/deployments/internal-trusted-storage/opteesp/CMakeLists.txt
index 0a91c3d..245fd1e 100644
--- a/deployments/internal-trusted-storage/opteesp/CMakeLists.txt
+++ b/deployments/internal-trusted-storage/opteesp/CMakeLists.txt
@@ -24,35 +24,16 @@
 add_components(TARGET "internal-trusted-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/service/common/include
-		components/service/common/provider
-		components/service/secure_storage/include
-		components/service/secure_storage/frontend/secure_storage_provider
-		components/service/secure_storage/backend/secure_flash_store
-		components/service/secure_storage/backend/secure_flash_store/flash_fs
-		components/service/secure_storage/backend/secure_flash_store/flash
-		components/service/secure_storage/factory/common/sfs
-		protocols/rpc/common/packed-c
-		protocols/service/secure_storage/packed-c
 		environments/opteesp
 )
 
-target_sources(internal-trusted-storage PRIVATE
-	sp.c
-)
+include(../internal-trusted-storage.cmake REQUIRED)
 
 target_compile_definitions(internal-trusted-storage PRIVATE
 	ARM64=1
 )
 
 target_include_directories(internal-trusted-storage PRIVATE
-	${TS_ROOT}
-	${TS_ROOT}/components
 	${TS_ROOT}/deployments/internal-trusted-storage/opteesp
 )
 
diff --git a/deployments/internal-trusted-storage/opteesp/optee_sp_user_defines.h b/deployments/internal-trusted-storage/opteesp/optee_sp_user_defines.h
index d86d29b..304748a 100644
--- a/deployments/internal-trusted-storage/opteesp/optee_sp_user_defines.h
+++ b/deployments/internal-trusted-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 \
+	{ 0xdc1eef48, 0xb17a, 0x4ccf, \
+		{ 0xac, 0x8b, 0xdf, 0xcf, 0xf7, 0x71, 0x1b, 0x14 } }
 
 #define OPTEE_SP_FLAGS			0
 
diff --git a/deployments/internal-trusted-storage/opteesp/sp.h b/deployments/internal-trusted-storage/opteesp/sp.h
deleted file mode 100644
index 5aa76c3..0000000
--- a/deployments/internal-trusted-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 Internal Trusted Store */
-#define OPTEE_SP_UUID \
-	{ 0xdc1eef48, 0xb17a, 0x4ccf, \
-		{ 0xac, 0x8b, 0xdf, 0xcf, 0xf7, 0x71, 0x1b, 0x14 } }
-
-#define SP_UUID_BYTES \
-	{ 0xdc, 0x1e, 0xef, 0x48, 0xb1, 0x7a, 0x4c, 0xcf, \
-	  0xac, 0x8b, 0xdf, 0xcf, 0xf7, 0x71, 0x1b, 0x14, }
-
-#endif /* SP_H */