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/attestation/attestation.cmake b/deployments/attestation/attestation.cmake
new file mode 100644
index 0000000..4f245d4
--- /dev/null
+++ b/deployments/attestation/attestation.cmake
@@ -0,0 +1,76 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+add_components(TARGET "attestation"
+	BASE_DIR ${TS_ROOT}
+	COMPONENTS
+		"components/common/fdt"
+		"components/common/tlv"
+		"components/common/trace"
+		"components/common/utils"
+		"components/common/endian"
+		"components/common/uuid"
+		"components/config/ramstore"
+		"components/config/loader/sp"
+		"components/messaging/ffa/libsp"
+		"components/rpc/ffarpc/endpoint"
+		"components/rpc/ffarpc/caller/sp"
+		"components/rpc/common/caller"
+		"components/rpc/common/interface"
+		"components/service/common/include"
+		"components/service/common/client"
+		"components/service/common/provider"
+		"components/service/locator"
+		"components/service/locator/interface"
+		"components/service/locator/sp"
+		"components/service/locator/sp/ffa"
+		"components/service/attestation/include"
+		"components/service/attestation/claims"
+		"components/service/attestation/claims/sources/boot_seed_generator"
+		"components/service/attestation/claims/sources/null_lifecycle"
+		"components/service/attestation/claims/sources/instance_id"
+		"components/service/attestation/claims/sources/implementation_id"
+		"components/service/attestation/claims/sources/event_log"
+		"components/service/attestation/claims/sources/event_log/mock"
+		"components/service/attestation/reporter/local"
+		"components/service/attestation/reporter/eat"
+		"components/service/attestation/key_mngr/local"
+		"components/service/attestation/provider"
+		"components/service/attestation/provider/serializer/packed-c"
+		"components/service/crypto/include"
+		"components/service/crypto/client/psa"
+		"protocols/rpc/common/packed-c"
+)
+
+target_sources(attestation PRIVATE
+	${CMAKE_CURRENT_LIST_DIR}/common/attestation_sp.c
+)
+
+#-------------------------------------------------------------------------------
+#  Components used from external projects
+#
+#-------------------------------------------------------------------------------
+
+# Get libc include dir
+get_property(LIBC_INCLUDE_PATH TARGET c PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+
+# Qcbor
+set (QCBOR_EXTERNAL_INCLUDE_PATHS ${LIBC_INCLUDE_PATH})
+include(${TS_ROOT}/external/qcbor/qcbor.cmake)
+target_link_libraries(attestation PRIVATE qcbor)
+
+# t_cose
+set (TCOSE_EXTERNAL_INCLUDE_PATHS ${LIBC_INCLUDE_PATH})
+include(${TS_ROOT}/external/t_cose/t_cose.cmake)
+target_link_libraries(attestation PRIVATE t_cose)
+
+#################################################################
+
+target_include_directories(attestation PRIVATE
+	${TS_ROOT}
+	${TS_ROOT}/components
+)
diff --git a/deployments/attestation/opteesp/attestation_sp.c b/deployments/attestation/common/attestation_sp.c
similarity index 100%
rename from deployments/attestation/opteesp/attestation_sp.c
rename to deployments/attestation/common/attestation_sp.c
diff --git a/deployments/attestation/common/attestation_sp.h b/deployments/attestation/common/attestation_sp.h
new file mode 100644
index 0000000..e949193
--- /dev/null
+++ b/deployments/attestation/common/attestation_sp.h
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ATTESTATION_SP_H
+#define ATTESTATION_SP_H
+
+#define ATTESTATION_SP_UUID_BYTES \
+	{0xa1, 0xba, 0xf1, 0x55, 0x88, 0x76, 0x46, 0x95, \
+	 0x8f, 0x7c, 0x54, 0x95, 0x5e, 0x8d, 0xb9, 0x74}
+
+#endif /* ATTESTATION_SP_H */
diff --git a/deployments/attestation/opteesp/CMakeLists.txt b/deployments/attestation/opteesp/CMakeLists.txt
index 8e7b174..6676f03 100644
--- a/deployments/attestation/opteesp/CMakeLists.txt
+++ b/deployments/attestation/opteesp/CMakeLists.txt
@@ -37,48 +37,10 @@
 add_components(TARGET "attestation"
 	BASE_DIR ${TS_ROOT}
 	COMPONENTS
-		"components/common/fdt"
-		"components/common/tlv"
-		"components/common/trace"
-		"components/common/utils"
-		"components/common/endian"
-		"components/common/uuid"
-		"components/config/ramstore"
-		"components/config/loader/sp"
-		"components/messaging/ffa/libsp"
-		"components/rpc/ffarpc/endpoint"
-		"components/rpc/ffarpc/caller/sp"
-		"components/rpc/common/caller"
-		"components/rpc/common/interface"
-		"components/service/common/include"
-		"components/service/common/client"
-		"components/service/common/provider"
-		"components/service/locator"
-		"components/service/locator/interface"
-		"components/service/locator/sp"
-		"components/service/locator/sp/ffa"
-		"components/service/attestation/include"
-		"components/service/attestation/claims"
-		"components/service/attestation/claims/sources/boot_seed_generator"
-		"components/service/attestation/claims/sources/null_lifecycle"
-		"components/service/attestation/claims/sources/instance_id"
-		"components/service/attestation/claims/sources/implementation_id"
-		"components/service/attestation/claims/sources/event_log"
-		"components/service/attestation/claims/sources/event_log/mock"
-		"components/service/attestation/reporter/local"
-		"components/service/attestation/reporter/eat"
-		"components/service/attestation/key_mngr/local"
-		"components/service/attestation/provider"
-		"components/service/attestation/provider/serializer/packed-c"
-		"components/service/crypto/include"
-		"components/service/crypto/client/psa"
-		"protocols/rpc/common/packed-c"
 		"environments/opteesp"
 )
 
-target_sources(attestation PRIVATE
-	attestation_sp.c
-)
+include(../attestation.cmake REQUIRED)
 
 #-------------------------------------------------------------------------------
 #  Set target platform to provide drivers needed by the deployment
@@ -86,33 +48,11 @@
 #-------------------------------------------------------------------------------
 add_platform(TARGET "attestation")
 
-#-------------------------------------------------------------------------------
-#  Components used from external projects
-#
-#-------------------------------------------------------------------------------
-
-# Get libc include dir
-get_property(LIBC_INCLUDE_PATH TARGET c PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
-
-# Qcbor
-set (QCBOR_EXTERNAL_INCLUDE_PATHS ${LIBC_INCLUDE_PATH})
-include(${TS_ROOT}/external/qcbor/qcbor.cmake)
-target_link_libraries(attestation PRIVATE qcbor)
-
-# t_cose
-set (TCOSE_EXTERNAL_INCLUDE_PATHS ${LIBC_INCLUDE_PATH})
-include(${TS_ROOT}/external/t_cose/t_cose.cmake)
-target_link_libraries(attestation PRIVATE t_cose)
-
-#################################################################
-
 target_compile_definitions(attestation PRIVATE
 	ARM64=1
 )
 
 target_include_directories(attestation PRIVATE
-	${TS_ROOT}
-	${TS_ROOT}/components
 	${TS_ROOT}/deployments/attestation/opteesp
 )
 
diff --git a/deployments/attestation/opteesp/attestation_sp.h b/deployments/attestation/opteesp/attestation_sp.h
deleted file mode 100644
index 7c4af58..0000000
--- a/deployments/attestation/opteesp/attestation_sp.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef ATTESTATION_SP_H
-#define ATTESTATION_SP_H
-
-#define ATTESTATION_SP_UUID \
-    {0xa1baf155, 0x8876, 0x4695, \
-                {0x8f, 0x7c, 0x54, 0x95, 0x5e, 0x8d, 0xb9, 0x74}}
-
-#define ATTESTATION_SP_UUID_BYTES \
-    {0xa1, 0xba, 0xf1, 0x55, 0x88, 0x76, 0x46, 0x95, \
-     0x8f, 0x7c, 0x54, 0x95, 0x5e, 0x8d, 0xb9, 0x74}
-
-#endif /* ATTESTATION_SP_H */
diff --git a/deployments/attestation/opteesp/optee_sp_user_defines.h b/deployments/attestation/opteesp/optee_sp_user_defines.h
index 95531fe..475a2b9 100644
--- a/deployments/attestation/opteesp/optee_sp_user_defines.h
+++ b/deployments/attestation/opteesp/optee_sp_user_defines.h
@@ -3,13 +3,13 @@
  * Copyright (c) 2021-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 "attestation_sp.h"
+#define OPTEE_SP_UUID \
+	{0xa1baf155, 0x8876, 0x4695, \
+		{0x8f, 0x7c, 0x54, 0x95, 0x5e, 0x8d, 0xb9, 0x74}}
 
-#define OPTEE_SP_UUID				ATTESTATION_SP_UUID
 #define OPTEE_SP_FLAGS				0
 
 /* Provisioned stack size */