MLECO-2985 Adding Corstone-310 support

Change-Id: Ifa4b11154478355c10cb3e747b9938a74afd242b
Signed-off-by: Eanna O Cathain <eanna.ocathain@arm.com>
diff --git a/scripts/cmake/platforms/mps3/build_configuration.cmake b/scripts/cmake/platforms/mps3/build_configuration.cmake
index 76c9e78..6e21d9b 100644
--- a/scripts/cmake/platforms/mps3/build_configuration.cmake
+++ b/scripts/cmake/platforms/mps3/build_configuration.cmake
@@ -17,11 +17,35 @@
 
 function(set_platform_global_defaults)
     message(STATUS "Platform: MPS3 FPGA Prototyping Board or FVP")
+
+    if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
+        if (TARGET_SUBSYSTEM STREQUAL sse-300)
+            set(CMAKE_SYSTEM_PROCESSOR cortex-m55 CACHE STRING "Cortex-M CPU to use")
+        elseif(TARGET_SUBSYSTEM STREQUAL sse-310)
+            # For CMake versions older than 3.21, the compiler and linker flags for
+            # ArmClang are added by CMake automatically which makes it mandatory to
+            # define the system processor. For CMake versions 3.21 or later (that
+            # implement policy CMP0123) we use armv8.1-m as the arch until the
+            # toolchain officially supports Cortex-M85. For older version of CMake
+            # we revert to using Cortex-M55 as the processor (as this will work
+            # for M85 too).
+            if(POLICY CMP0123)
+                set(CMAKE_SYSTEM_ARCH armv8.1-m.main CACHE STRING "System arch to use")
+            else()
+                set(CMAKE_SYSTEM_PROCESSOR  cortex-m55)
+            endif()
+        endif()
+    endif()
+
     if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
         set(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_DIR}/bare-metal-gcc.cmake
                 CACHE FILEPATH "Toolchain file")
     endif()
 
+    if ((ETHOS_U_NPU_ID STREQUAL U65) AND (TARGET_SUBSYSTEM STREQUAL sse-310))
+        message(FATAL_ERROR "Non compatible Ethos-U NPU processor ${ETHOS_U_NPU_ID} and target subsystem ${TARGET_SUBSYSTEM}")
+    endif()
+
     set(LINKER_SCRIPT_NAME "mps3-${TARGET_SUBSYSTEM}" PARENT_SCOPE)
     set(PLATFORM_DRIVERS_DIR "${HAL_PLATFORM_DIR}/mps3" PARENT_SCOPE)
 
@@ -35,7 +59,7 @@
     # Add link options for the linker script to be used:
     add_linker_script(
             ${PARSED_TARGET_NAME}          # Target
-            ${CMAKE_SCRIPTS_DIR}/platforms/mps3    # Directory path
+            ${CMAKE_SCRIPTS_DIR}/platforms/mps3/${TARGET_SUBSYSTEM}    # Directory path
             ${LINKER_SCRIPT_NAME})  # Name of the file without suffix
 
     add_target_map_file(
@@ -48,8 +72,13 @@
     file(REMOVE_RECURSE ${SECTORS_BIN_DIR})
     file(MAKE_DIRECTORY ${SECTORS_BIN_DIR})
 
-    set(LINKER_SECTION_TAGS     "*.at_itcm" "*.at_ddr")
-    set(LINKER_OUTPUT_BIN_TAGS  "itcm.bin"  "ddr.bin")
+    if (TARGET_SUBSYSTEM STREQUAL sse-310)
+        set(LINKER_SECTION_TAGS     "*.at_bram" "*.at_ddr")
+        set(LINKER_OUTPUT_BIN_TAGS  "bram.bin"  "ddr.bin")
+    else()
+        set(LINKER_SECTION_TAGS     "*.at_itcm" "*.at_ddr")
+        set(LINKER_OUTPUT_BIN_TAGS  "itcm.bin"  "ddr.bin")
+    endif()
 
     add_bin_generation_command(
             TARGET_NAME ${PARSED_TARGET_NAME}
@@ -64,4 +93,4 @@
             POST_BUILD
             COMMAND ${CMAKE_COMMAND} -E copy ${MPS3_FPGA_CONFIG} ${SECTORS_DIR})
 
-endfunction()
\ No newline at end of file
+endfunction()