spm_test: allow configuring mem-region base addr.
Allow platform specific configuration of the base address of the memory
region used to test manifest handling of the SPMC.
The default platform specific value can optionally be overridden from
the command line using -DCFG_TEST_MEM_REGION_ADDRESS=<value>.
Change-Id: I08d0e419e453cdb7944d52395228b4d973f9e31a
Signed-off-by: Gyorgy Szing <gyorgy.szing@arm.com>
diff --git a/tools/cmake/common/Utils.cmake b/tools/cmake/common/Utils.cmake
index 256bbf9..6471619 100644
--- a/tools/cmake/common/Utils.cmake
+++ b/tools/cmake/common/Utils.cmake
@@ -106,3 +106,62 @@
set_target_properties(${_MY_PARAMS_TGT} PROPERTIES OUTPUT_NAME "${_out_name}")
endif()
endfunction()
+
+#[===[.rst:
+.. cmake:command:: uint64_split
+
+ .. code-block:: cmake
+
+ uint64_split(VALUE 4294967296 OUT_PREFIX RES)
+ message("RES_LO=${RES_LO} RES_HI=${RES_HI}")
+
+ uint64_split(VALUE 0x1122334455667788 OUT_PREFIX RES DECIMAL)
+ message("RES_LO=${RES_LO} RES_HI=${RES_HI}")
+
+ Split an uint64 integer to uint32 integers. The returned values will be hexadecimal unless the ``DECIMAL``
+ argument is passed.
+ The result is returned in two values <OUT_PREFIX>_LO and <OUT_PREFIX>_HI.
+
+ INPUTS:
+
+ ``VALUE``
+ Mandatory. uint64 value to be converted. The value shall either be an integer (e.g. 123) or a string representing
+ an integer (e.g. "123"). Hexadecimal numbers can be specified with "0x" prefix.
+
+ ``DECIMAL``
+ Optional. Set the format of the returned values to be decimal instead of hexadecimal.
+
+ OUTPUTS:
+
+ ``OUT_PREFIX``
+ Mandatory. The prefix of the output variables. Two variable will be created in the callers scope. <OUT_PREFIX>_LO
+ is the lower 32 bits and <OUT_PREFIX>_HI is the higher 32 bits.
+
+#]===]
+function(uint64_split )
+ set(options DECIMAL)
+ set(oneValueArgs VALUE OUT_PREFIX)
+ set(multiValueArgs)
+ cmake_parse_arguments(_MY_PARAMS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ check_args(uint64_split VALUE OUT_PREFIX)
+
+ # Ensure the input is a valid uint64 integer
+ if (NOT "${_MY_PARAMS_VALUE}" MATCHES "^(0x[0-9a-fA-F]+)|([0-9]+)$")
+ message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}: Invalid uint64 integer: ${_MY_PARAMS_VALUE}")
+ endif()
+
+ if (_MY_PARAMS_DECIMAL)
+ set(_out_format "DECIMAL")
+ else()
+ set(_out_format "HEXADECIMAL")
+ endif()
+
+ # Split the uint64 integer into two uint32 integers
+ math(EXPR _high_uint32 "(${_MY_PARAMS_VALUE} >> 32) & 0xFFFFFFFF" OUTPUT_FORMAT ${_out_format})
+ math(EXPR _low_uint32 "${_MY_PARAMS_VALUE} & 0xFFFFFFFF" OUTPUT_FORMAT ${_out_format})
+
+ # Return the results
+ set(${_MY_PARAMS_OUT_PREFIX}_LO ${_low_uint32} PARENT_SCOPE)
+ set(${_MY_PARAMS_OUT_PREFIX}_HI ${_high_uint32} PARENT_SCOPE)
+endfunction()