Allow build time configuration of MM comm carveout

The Linux MM comm RPC caller uses constant values compiled in to set
the physical address and size of the MM comm buffer location. This
is limiting portability and needs to be changed.
Introduce the following build options to allow build time
configuration:
   - MM_COMM_BUFFER_ADDRESS the physical address of the buffer
   - MM_COMM_BUFFER_SIZE the length of the buffer in bytes

Change-Id: Ie989aedf53ef5158021fcbdcd57f22dbbbb385e5
Signed-off-by: Gyorgy Szing <Gyorgy.Szing@arm.com>
diff --git a/components/rpc/mm_communicate/caller/linux/carveout.c b/components/rpc/mm_communicate/caller/linux/carveout.c
index e3cdf16..fb389b4 100644
--- a/components/rpc/mm_communicate/caller/linux/carveout.c
+++ b/components/rpc/mm_communicate/caller/linux/carveout.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -11,9 +11,12 @@
 #include <fcntl.h>
 #include "carveout.h"
 
-/* Need to be aligned with carve-out used by StMM or smm-gateway. */
-static const off_t carveout_pa = 0x0000000881000000;
-static const size_t carveout_len = 0x8000;
+#ifndef MM_COMM_BUFFER_ADDRESS
+#error "MM_COMM_BUFFER_ADDRESS macro is undefined!"
+#endif
+#ifndef MM_COMM_BUFFER_SIZE
+#error "MM_COMM_BUFFER_SIZE macro is undefined!"
+#endif
 
 int carveout_claim(uint8_t **buf, size_t *buf_size)
 {
@@ -22,14 +25,14 @@
 
 	if (fd >= 0) {
 
-		uint8_t *mem = mmap(NULL, carveout_len,
+		uint8_t *mem = mmap(NULL, (size_t)(MM_COMM_BUFFER_SIZE),
 			PROT_READ | PROT_WRITE, MAP_SHARED,
-			fd, carveout_pa);
+			fd, (off_t)(MM_COMM_BUFFER_ADDRESS));
 
 		if (mem != MAP_FAILED) {
 
 			*buf = mem;
-			*buf_size = carveout_len;
+			*buf_size = (size_t)(MM_COMM_BUFFER_SIZE);
 
 			status = 0;
 		}
diff --git a/components/rpc/mm_communicate/caller/linux/component.cmake b/components/rpc/mm_communicate/caller/linux/component.cmake
index 9435599..d670cf5 100644
--- a/components/rpc/mm_communicate/caller/linux/component.cmake
+++ b/components/rpc/mm_communicate/caller/linux/component.cmake
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -10,6 +10,14 @@
 
 include(${TS_ROOT}/external/LinuxFFAUserShim/LinuxFFAUserShim.cmake)
 
+if(NOT MM_COMM_BUFFER_ADDRESS OR NOT MM_COMM_BUFFER_SIZE)
+	message(FATAL_ERROR "Address and size of MM comm buffer is not set. Define MM_COMM_BUFFER_ADDRESS "
+						"and MM_COMM_BUFFER_SIZE.")
+endif()
+
+target_compile_definitions(${TGT} PRIVATE MM_COMM_BUFFER_ADDRESS=${MM_COMM_BUFFER_ADDRESS}
+									MM_COMM_BUFFER_SIZE=${MM_COMM_BUFFER_SIZE})
+
 target_sources(${TGT} PRIVATE
 	"${CMAKE_CURRENT_LIST_DIR}/mm_communicate_caller.c"
 	"${CMAKE_CURRENT_LIST_DIR}/mm_communicate_serializer.c"
diff --git a/deployments/libts/arm-linux/CMakeLists.txt b/deployments/libts/arm-linux/CMakeLists.txt
index b62d90b..cc589ba 100644
--- a/deployments/libts/arm-linux/CMakeLists.txt
+++ b/deployments/libts/arm-linux/CMakeLists.txt
@@ -19,6 +19,10 @@
 add_library(ts SHARED)
 target_include_directories(ts PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
 
+# Setting the MM communication buffer parameters
+set(MM_COMM_BUFFER_ADDRESS "0x881000000" CACHE STRING "Address of MM communicte buffer")
+set(MM_COMM_BUFFER_SIZE "8*4*1024" CACHE STRING "Size of the MM communicate buffer in bytes")
+
 #-------------------------------------------------------------------------------
 #  Components that are specific to deployment in the arm-linux environment.
 #