Reintroduce Cactus-MM and SPM-MM tests

The code has been taken from commit 99f4fd283b6f ("cactus: Use UART2
instead of UART0") and modified slightly to be integrated in the current
master.

There are three tests that are failing in the CI. They have been
disabled for the time being:

- mem_attr_changes_tests() in cactus_main() in the file
  spm/cactus_mm/cactus_mm_main.c.

- Two tests in the file tftf/tests/tests-spm-mm.xml.

Change-Id: I6332cbff1cefeb82b9447fae1b613879e65186a1
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
diff --git a/include/common/debug.h b/include/common/debug.h
index 9b2d842..4b30175 100644
--- a/include/common/debug.h
+++ b/include/common/debug.h
@@ -9,6 +9,10 @@
 
 #include <stdio.h>
 
+#ifdef IMAGE_CACTUS_MM
+/* Remove dependency on spinlocks for Cactus-MM */
+#define mp_printf printf
+#else
 /*
  * Print a formatted string on the UART.
  *
@@ -18,6 +22,7 @@
  */
 __attribute__((format(printf, 1, 2)))
 void mp_printf(const char *fmt, ...);
+#endif /* IMAGE_CACTUS_MM */
 
 /*
  * The log output macros print output to the console. These macros produce
diff --git a/include/runtime_services/secure_el0_payloads/mm_svc.h b/include/runtime_services/secure_el0_payloads/mm_svc.h
new file mode 100644
index 0000000..290fd7d
--- /dev/null
+++ b/include/runtime_services/secure_el0_payloads/mm_svc.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef __MM_SVC_H__
+#define __MM_SVC_H__
+
+#include <utils_def.h>
+
+#define MM_VERSION_MAJOR	U(1)
+#define MM_VERSION_MAJOR_SHIFT	16
+#define MM_VERSION_MAJOR_MASK	U(0x7FFF)
+#define MM_VERSION_MINOR	U(0)
+#define MM_VERSION_MINOR_SHIFT	0
+#define MM_VERSION_MINOR_MASK	U(0xFFFF)
+#define MM_VERSION_FORM(major, minor)	((major << MM_VERSION_MAJOR_SHIFT) | (minor))
+#define MM_VERSION_COMPILED	MM_VERSION_FORM(MM_VERSION_MAJOR, MM_VERSION_MINOR)
+
+/*
+ * SMC IDs defined in [1] for accessing MM services from the Non-secure world.
+ * These FIDs occupy the range 0x40 - 0x5f.
+ * [1] DEN0060A_ARM_MM_Interface_Specification.pdf
+ */
+#define MM_VERSION_AARCH32		U(0x84000040)
+
+#define MM_COMMUNICATE_AARCH64		U(0xC4000041)
+#define MM_COMMUNICATE_AARCH32		U(0x84000041)
+
+#endif /* __MM_SVC_H__ */
diff --git a/include/runtime_services/secure_el0_payloads/secure_partition.h b/include/runtime_services/secure_el0_payloads/secure_partition.h
index 0a41dde..14d2090 100644
--- a/include/runtime_services/secure_el0_payloads/secure_partition.h
+++ b/include/runtime_services/secure_el0_payloads/secure_partition.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -7,9 +7,22 @@
 #ifndef SECURE_PARTITION_H
 #define SECURE_PARTITION_H
 
+#ifndef __ASSEMBLY__
+#include <cassert.h>
 #include <param_header.h>
 #include <stdint.h>
 #include <utils_def.h>
+#endif
+
+/*
+ * Definitions used to access the members of secure_partition_boot_info from
+ * assembly code.
+ */
+#define SP_BOOT_INFO_STACK_BASE_OFFSET		U(32)
+#define SP_BOOT_INFO_IMAGE_SIZE_OFFSET		U(64)
+#define SP_BOOT_INFO_PCPU_STACK_SIZE_OFFSET	U(72)
+
+#ifndef __ASSEMBLY__
 
 /*
  * Flags used by the secure_partition_mp_info structure to describe the
@@ -30,9 +43,60 @@
 
 typedef struct secure_partition_boot_info {
 	param_header_t		h;
+	uint64_t		sp_mem_base;
+	uint64_t		sp_mem_limit;
+	uint64_t		sp_image_base;
+	uint64_t		sp_stack_base;
+	uint64_t		sp_heap_base;
+	uint64_t		sp_ns_comm_buf_base;
+	uint64_t		sp_shared_buf_base;
+	uint64_t		sp_image_size;
+	uint64_t		sp_pcpu_stack_size;
+	uint64_t		sp_heap_size;
+	uint64_t		sp_ns_comm_buf_size;
+	uint64_t		sp_shared_buf_size;
+	uint32_t		num_sp_mem_regions;
 	uint32_t		num_cpus;
 	secure_partition_mp_info_t *mp_info;
 } secure_partition_boot_info_t;
 
+/*
+ * This structure is used to pass data associated to secure service requests.
+ */
+#define SPS_MAX_PAYLOAD_SIZE	32
+typedef struct secure_partition_request_info {
+	uint32_t		id;
+	uint64_t		data_size;
+	uint8_t			data[SPS_MAX_PAYLOAD_SIZE];
+} secure_partition_request_info_t;
+
+/* Define some fast secure partition requests (SPS) IDs. */
+#define SPS_TIMER_SLEEP			1
+#define SPS_CHECK_ALIVE			2
+
+#define CACTUS_FAST_REQUEST_SUCCESS	0xCACF900D
+
+secure_partition_request_info_t *create_sps_request(uint32_t id,
+						    const void *data,
+						    uint64_t data_size);
+
+/*
+ * Compile time assertions related to the 'secure_partition_boot_info' structure
+ * to ensure that the assembler and the compiler view of the offsets of the
+ * structure members is the same.
+ */
+CASSERT(SP_BOOT_INFO_STACK_BASE_OFFSET ==
+	__builtin_offsetof(secure_partition_boot_info_t, sp_stack_base), \
+	assert_secure_partition_boot_info_sp_stack_base_offset_mismatch);
+
+CASSERT(SP_BOOT_INFO_IMAGE_SIZE_OFFSET ==
+	__builtin_offsetof(secure_partition_boot_info_t, sp_image_size), \
+	assert_secure_partition_boot_info_sp_image_size_offset_mismatch);
+
+CASSERT(SP_BOOT_INFO_PCPU_STACK_SIZE_OFFSET ==
+	__builtin_offsetof(secure_partition_boot_info_t, sp_pcpu_stack_size), \
+	assert_secure_partition_boot_info_sp_pcpu_stack_size_offset_mismatch);
+
+#endif /* __ASSEMBLY__ */
 
 #endif /* SECURE_PARTITION_H */
diff --git a/include/runtime_services/secure_el0_payloads/spm_svc.h b/include/runtime_services/secure_el0_payloads/spm_svc.h
index e1f9df3..e3b6cc5 100644
--- a/include/runtime_services/secure_el0_payloads/spm_svc.h
+++ b/include/runtime_services/secure_el0_payloads/spm_svc.h
@@ -33,6 +33,7 @@
  * They occupy the range 0x60-0x7f.
  */
 #define SPM_VERSION_AARCH32			U(0x84000060)
+#define SP_EVENT_COMPLETE_AARCH64		U(0xC4000061)
 #define SP_MEMORY_ATTRIBUTES_GET_AARCH64	U(0xC4000064)
 #define SP_MEMORY_ATTRIBUTES_SET_AARCH64	U(0xC4000065)