1#------------------------------------------------------------------------------- 2# Copyright (c) 2022, Arm Limited and Contributors. All rights reserved. 3# 4# SPDX-License-Identifier: BSD-3-Clause 5# 6#------------------------------------------------------------------------------- 7 8include(${CMAKE_CURRENT_LIST_DIR}/Uuid.cmake) 9 10#[===[.rst: 11.. cmake:command:: set_target_uuids 12 13.. code:: cmake 14 15set_target_uuids( 16 SP_UUID <uuid> 17 SP_NAME <name> 18 ) 19 20INPUTS: 21 22``SP_UUID`` 23The UUID of the SP as a string. 24 25``SP_NAME`` 26The name of the SP. 27 28#]===] 29 30function (set_target_uuids) 31 set(options) 32 set(oneValueArgs TGT SP_UUID) 33 set(multiValueArgs) 34 cmake_parse_arguments(_MY_PARAMS "${options}" "${oneValueArgs}" 35 "${multiValueArgs}" ${ARGN} ) 36 37 check_args(SP_UUID TGT) 38 39 # Convert the UUID to a C char array initializer e.g. 40 # { 0x01, 0x10, 0x9c, 0xf8, 0xe5, 0xca, 0x44, 0x6f, 41 # 0x9b, 0x55, 0xf3, 0xcd, 0xc6, 0x51, 0x10, 0xc8, } 42 # and "pass it" to C files. 43 uuid_canon_to_octets(UUID ${_MY_PARAMS_SP_UUID} RES UUID_OCTETS) 44 list(JOIN UUID_OCTETS ", 0x" UUID_BYTES ) 45 set(UUID_BYTES "{ 0x${UUID_BYTES} }") 46 target_compile_definitions(${_MY_PARAMS_TGT} 47 PRIVATE OPTEE_SP_UUID_BYTES=${UUID_BYTES} 48 ) 49 50 # Create a UUID structure with the UUID fileds 51 # { 0x01109cf8, 0xe5ca, 0x446f, \ 52 # { 0x9b, 0x55, 0xf3, 0xcd, 0xc6, 0x51, 0x10, 0xc8 } } 53 # and "pass it" to C files 54 uuid_canon_to_fields(UUID ${_MY_PARAMS_SP_UUID} 55 TIME_LOW "_uuid_timeLow" 56 TIME_MID "_uuid_timeMid" 57 TIME_HI_AND_VER "_uuid_timeHiAndVersion" 58 CLOCK_AND_SEQ "_uuid_clockSeqAndNode") 59 string(REGEX MATCHALL ".." _uuid_clockSeqAndNode "${_uuid_clockSeqAndNode}") 60 list(JOIN _uuid_clockSeqAndNode ", 0x" _uuid_clockSeqAndNode) 61 set(UUID_STRUCT "{ 0x${_uuid_timeLow}, 0x${_uuid_timeMid}, 0x${_uuid_timeHiAndVersion}, { 0x${_uuid_clockSeqAndNode} }}") 62 target_compile_definitions(${_MY_PARAMS_TGT} 63 PRIVATE OPTEE_SP_UUID=${UUID_STRUCT} 64 ) 65endfunction() 66