Platform: Add CMake configurable flash sizes to Corstone-310

Add possibility to configure flash partition sizes in Corstone-310
using FLASH_S_PARTITION_SIZE and FLASH_NS_PARTITION_SIZE.

Signed-off-by: Gabor Toth <gabor.toth@arm.com>
Change-Id: I51bce0d6b60eaefd86f08847ca9f9651d756ebbc
diff --git a/platform/ext/target/arm/mps3/corstone310/an555/config_tfm_target.h b/platform/ext/target/arm/mps3/corstone310/an555/config_tfm_target.h
deleted file mode 100644
index f95f97d..0000000
--- a/platform/ext/target/arm/mps3/corstone310/an555/config_tfm_target.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2023, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#ifndef __CONFIG_TFM_TARGET_H__
-#define __CONFIG_TFM_TARGET_H__
-
-/* Size of secure partition */
-#define FLASH_S_PARTITION_SIZE   0x80000
-
-/* Size of non-secure partition */
-#define FLASH_NS_PARTITION_SIZE  0x300000
-
-#endif /* __CONFIG_TFM_TARGET_H__ */
diff --git a/platform/ext/target/arm/mps3/corstone310/common/common.cmake b/platform/ext/target/arm/mps3/corstone310/common/common.cmake
index 50cf3ed..727c409 100644
--- a/platform/ext/target/arm/mps3/corstone310/common/common.cmake
+++ b/platform/ext/target/arm/mps3/corstone310/common/common.cmake
@@ -262,3 +262,10 @@
         ${CMAKE_CURRENT_SOURCE_DIR}/dma_init.c
         $<$<OR:$<BOOL:${CONFIG_TFM_FLIH_API}>,$<BOOL:${CONFIG_TFM_SLIH_API}>>:${PLATFORM_DIR}/ext/common/tfm_interrupts.c>
 )
+
+#========================= platform_region_defs ===============================#
+target_compile_definitions(platform_region_defs
+    INTERFACE
+        FLASH_S_PARTITION_SIZE=${FLASH_S_PARTITION_SIZE}
+        FLASH_NS_PARTITION_SIZE=${FLASH_NS_PARTITION_SIZE}
+)
diff --git a/platform/ext/target/arm/mps3/corstone310/common/config.cmake b/platform/ext/target/arm/mps3/corstone310/common/config.cmake
index e64c4be..bd9dce1 100644
--- a/platform/ext/target/arm/mps3/corstone310/common/config.cmake
+++ b/platform/ext/target/arm/mps3/corstone310/common/config.cmake
@@ -12,6 +12,9 @@
 # Make FLIH IRQ test as the default IRQ test on Corstone-310
 set(TEST_NS_SLIH_IRQ                  OFF   CACHE BOOL    "Whether to build NS regression Second-Level Interrupt Handling tests")
 
+set(FLASH_S_PARTITION_SIZE   "0x80000"    CACHE STRING    "Secure code size")
+set(FLASH_NS_PARTITION_SIZE  "0x300000"   CACHE STRING    "Non-secure code size")
+
 if(BL2)
     set(BL2_TRAILER_SIZE 0x800 CACHE STRING "Trailer size")
 else()
diff --git a/platform/ext/target/arm/mps3/corstone310/common/partition/flash_layout.h b/platform/ext/target/arm/mps3/corstone310/common/partition/flash_layout.h
index 11b0064..8a1d7df 100644
--- a/platform/ext/target/arm/mps3/corstone310/common/partition/flash_layout.h
+++ b/platform/ext/target/arm/mps3/corstone310/common/partition/flash_layout.h
@@ -18,7 +18,6 @@
 #define __FLASH_LAYOUT_H__
 
 #include "platform_base_address.h"
-#include "config_tfm_target.h"
 
 /* Default Flash layout on Corstone-310 with BL2 (multiple image boot):
  *
@@ -55,7 +54,7 @@
  * with comment.
  */
 
-/* Size of a Secure and of a Non-secure image is set in platform config_tfm_target.h */
+/* Size of a Secure and of a Non-secure image is set in platform cmake */
 #if (FLASH_S_PARTITION_SIZE > FLASH_NS_PARTITION_SIZE)
 #define FLASH_MAX_PARTITION_SIZE FLASH_S_PARTITION_SIZE
 #else
diff --git a/platform/ext/target/arm/mps3/corstone310/fvp/config_tfm_target.h b/platform/ext/target/arm/mps3/corstone310/fvp/config_tfm_target.h
deleted file mode 100644
index f95f97d..0000000
--- a/platform/ext/target/arm/mps3/corstone310/fvp/config_tfm_target.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2023, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#ifndef __CONFIG_TFM_TARGET_H__
-#define __CONFIG_TFM_TARGET_H__
-
-/* Size of secure partition */
-#define FLASH_S_PARTITION_SIZE   0x80000
-
-/* Size of non-secure partition */
-#define FLASH_NS_PARTITION_SIZE  0x300000
-
-#endif /* __CONFIG_TFM_TARGET_H__ */