Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Imre Kis | 7dfd497 | 2022-10-27 16:55:57 +0200 | [diff] [blame] | 2 | # Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved. |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
Gyorgy Szing | fd03e0a | 2023-07-27 20:04:24 +0200 | [diff] [blame] | 8 | include(${CMAKE_CURRENT_LIST_DIR}/Uuid.cmake) |
| 9 | |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 10 | #[===[.rst: |
| 11 | .. cmake:command:: export_sp |
| 12 | |
| 13 | .. code:: cmake |
| 14 | |
Imre Kis | 686bd27 | 2021-12-15 19:19:02 +0100 | [diff] [blame] | 15 | export_sp( |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 16 | SP_UUID_CANON <uuid_str_canon> |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 17 | SP_NAME <name> MK_IN <.mk path> |
Imre Kis | 686bd27 | 2021-12-15 19:19:02 +0100 | [diff] [blame] | 18 | DTS_IN <DTS path> |
| 19 | DTS_MEM_REGIONS <Memory region manifest path> |
| 20 | JSON_IN <JSON path> |
| 21 | ) |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 22 | |
| 23 | INPUTS: |
| 24 | |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 25 | ``SP_UUID_CANON`` |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 26 | The FF_A UUID of the SP as a canonical string. |
| 27 | |
| 28 | ``SP_BIN_UUID_CANON`` |
| 29 | The UUID of the SP binary a canonical string. When not set use the |
| 30 | SP_UUID_CANON as the SP_BIN_UUID_CANON. |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 31 | |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 32 | ``SP_NAME`` |
| 33 | The name of the SP. |
| 34 | |
| 35 | ``MK_IN`` |
| 36 | Optional, Makefile template for OP-TEE build |
| 37 | |
| 38 | ``DTS_IN`` |
| 39 | Manifest file template |
| 40 | |
Imre Kis | 686bd27 | 2021-12-15 19:19:02 +0100 | [diff] [blame] | 41 | `DTS_MEM_REGIONS` |
| 42 | Optional, Memory region manifest file |
| 43 | |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 44 | ``JSON_IN`` |
| 45 | Optional, SP layout JSON file template for TF-A |
| 46 | |
| 47 | #]===] |
| 48 | function (export_sp) |
| 49 | set(options) |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 50 | set(oneValueArgs SP_UUID_CANON SP_BIN_UUID_CANON SP_UUID_LE SP_NAME MK_IN DTS_IN DTS_MEM_REGIONS JSON_IN) |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 51 | set(multiValueArgs) |
| 52 | cmake_parse_arguments(EXPORT "${options}" "${oneValueArgs}" |
| 53 | "${multiValueArgs}" ${ARGN} ) |
| 54 | |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 55 | if(NOT DEFINED EXPORT_SP_UUID_CANON) |
| 56 | message(FATAL_ERROR "export_sp: mandatory parameter SP_UUID_CANON not defined!") |
| 57 | endif() |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 58 | if(NOT DEFINED EXPORT_SP_BIN_UUID_CANON) |
| 59 | # We use the same UUID for the binary and FF-A if the UUID of the SP binary is not set |
| 60 | set(EXPORT_SP_BIN_UUID_CANON ${EXPORT_SP_UUID_CANON}) |
| 61 | endif() |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 62 | if(NOT DEFINED EXPORT_SP_NAME) |
| 63 | message(FATAL_ERROR "export_sp: mandatory parameter SP_NAME not defined!") |
| 64 | endif() |
| 65 | if(NOT DEFINED EXPORT_DTS_IN) |
| 66 | message(FATAL_ERROR "export_sp: mandatory parameter DTS_IN not defined!") |
| 67 | endif() |
| 68 | |
| 69 | if (DEFINED EXPORT_MK_IN) |
| 70 | configure_file(${EXPORT_MK_IN} ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_NAME}.mk @ONLY NEWLINE_STYLE UNIX) |
| 71 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_NAME}.mk DESTINATION ${TS_ENV}/lib/make) |
| 72 | endif() |
| 73 | |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 74 | # In the SP manifest DT the UUID format is four uint32 numbers (little-endian) |
Gyorgy Szing | fd03e0a | 2023-07-27 20:04:24 +0200 | [diff] [blame] | 75 | # Create a litte endian 4 digit octests representation. |
| 76 | uuid_canon_to_le_words(UUID ${EXPORT_SP_UUID_CANON} RES _le_words) |
| 77 | list(JOIN _le_words " 0x" _uuid_le) |
| 78 | set(SP_UUID_LE " 0x${_uuid_le}" PARENT_SCOPE) |
| 79 | set(EXPORT_SP_UUID_DT " 0x${_uuid_le}") |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 80 | |
| 81 | # As the .dtsi is meant to be included in .dts file, it shouldn't contain a separate |
| 82 | # /dts-v1/ tag and its node should be unique, i.e. the SP name. |
| 83 | set(DTS_TAG "") |
| 84 | set(DTS_NODE "${EXPORT_SP_NAME}") |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 85 | configure_file(${EXPORT_DTS_IN} ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}_before_preprocessing.dtsi @ONLY NEWLINE_STYLE UNIX) |
Imre Kis | 7dfd497 | 2022-10-27 16:55:57 +0200 | [diff] [blame] | 86 | |
| 87 | compiler_preprocess_file( |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 88 | SRC ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}_before_preprocessing.dtsi |
| 89 | DST ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}.dtsi |
Imre Kis | 7dfd497 | 2022-10-27 16:55:57 +0200 | [diff] [blame] | 90 | TARGET ${EXPORT_SP_NAME} |
| 91 | ) |
| 92 | |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 93 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}.dtsi DESTINATION ${TS_ENV}/manifest) |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 94 | |
| 95 | # The .dts file is a standalone structure, thus it should have the /dts-v1/ tag and it |
| 96 | # starts with the root node. |
| 97 | set(DTS_TAG "/dts-v1/;") |
| 98 | set(DTS_NODE "/") |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 99 | configure_file(${EXPORT_DTS_IN} ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}_before_preprocessing.dts @ONLY NEWLINE_STYLE UNIX) |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 100 | |
Imre Kis | 7dfd497 | 2022-10-27 16:55:57 +0200 | [diff] [blame] | 101 | compiler_preprocess_file( |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 102 | SRC ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}_before_preprocessing.dts |
| 103 | DST ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}.dts |
Imre Kis | 7dfd497 | 2022-10-27 16:55:57 +0200 | [diff] [blame] | 104 | TARGET ${EXPORT_SP_NAME} |
| 105 | ) |
| 106 | |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 107 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}.dts DESTINATION ${TS_ENV}/manifest) |
| 108 | |
| 109 | if (DEFINED EXPORT_DTS_MEM_REGIONS) |
| 110 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_DTS_MEM_REGIONS} DESTINATION ${TS_ENV}/manifest) |
| 111 | endif() |
Imre Kis | 686bd27 | 2021-12-15 19:19:02 +0100 | [diff] [blame] | 112 | |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 113 | if (DEFINED EXPORT_JSON_IN) |
| 114 | configure_file(${EXPORT_JSON_IN} ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_NAME}.json @ONLY NEWLINE_STYLE UNIX) |
| 115 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_NAME}.json DESTINATION ${TS_ENV}/json) |
| 116 | endif() |
Imre Kis | 686bd27 | 2021-12-15 19:19:02 +0100 | [diff] [blame] | 117 | endfunction() |