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( |
Jelle Sels | 4960c41 | 2023-02-01 09:43:24 +0100 | [diff] [blame] | 16 | SP_FFA_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> |
Gabor Toth | 7e4babe | 2024-03-14 11:09:19 +0100 | [diff] [blame] | 18 | SP_BOOT_ORDER <number> |
Imre Kis | 686bd27 | 2021-12-15 19:19:02 +0100 | [diff] [blame] | 19 | DTS_IN <DTS path> |
| 20 | DTS_MEM_REGIONS <Memory region manifest path> |
| 21 | JSON_IN <JSON path> |
| 22 | ) |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 23 | |
| 24 | INPUTS: |
| 25 | |
Jelle Sels | 4960c41 | 2023-02-01 09:43:24 +0100 | [diff] [blame] | 26 | ``SP_FFA_UUID_CANON`` |
| 27 | The FF-A UUID of the SP as a canonical string. |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 28 | |
| 29 | ``SP_BIN_UUID_CANON`` |
| 30 | The UUID of the SP binary a canonical string. When not set use the |
Jelle Sels | 4960c41 | 2023-02-01 09:43:24 +0100 | [diff] [blame] | 31 | SP_FFA_UUID_CANON as the SP_BIN_UUID_CANON. |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 32 | |
Gabor Toth | 7e4babe | 2024-03-14 11:09:19 +0100 | [diff] [blame] | 33 | ``SP_BOOT_ORDER`` |
| 34 | Boot-order of the SP. 0 will be booted first. |
| 35 | |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 36 | ``SP_NAME`` |
| 37 | The name of the SP. |
| 38 | |
| 39 | ``MK_IN`` |
| 40 | Optional, Makefile template for OP-TEE build |
| 41 | |
| 42 | ``DTS_IN`` |
| 43 | Manifest file template |
| 44 | |
Imre Kis | 686bd27 | 2021-12-15 19:19:02 +0100 | [diff] [blame] | 45 | `DTS_MEM_REGIONS` |
| 46 | Optional, Memory region manifest file |
| 47 | |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 48 | ``JSON_IN`` |
| 49 | Optional, SP layout JSON file template for TF-A |
| 50 | |
| 51 | #]===] |
| 52 | function (export_sp) |
| 53 | set(options) |
Gabor Toth | 7e4babe | 2024-03-14 11:09:19 +0100 | [diff] [blame] | 54 | set(oneValueArgs SP_FFA_UUID_CANON SP_BIN_UUID_CANON SP_BOOT_ORDER SP_NAME MK_IN DTS_IN DTS_MEM_REGIONS JSON_IN) |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 55 | set(multiValueArgs) |
| 56 | cmake_parse_arguments(EXPORT "${options}" "${oneValueArgs}" |
| 57 | "${multiValueArgs}" ${ARGN} ) |
| 58 | |
Jelle Sels | 4960c41 | 2023-02-01 09:43:24 +0100 | [diff] [blame] | 59 | if(NOT DEFINED EXPORT_SP_FFA_UUID_CANON) |
| 60 | message(FATAL_ERROR "export_sp: mandatory parameter SP_FFA_UUID_CANON not defined!") |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 61 | endif() |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 62 | if(NOT DEFINED EXPORT_SP_BIN_UUID_CANON) |
| 63 | # We use the same UUID for the binary and FF-A if the UUID of the SP binary is not set |
Jelle Sels | 4960c41 | 2023-02-01 09:43:24 +0100 | [diff] [blame] | 64 | set(EXPORT_SP_BIN_UUID_CANON ${EXPORT_SP_FFA_UUID_CANON}) |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 65 | endif() |
Gabor Toth | 7e4babe | 2024-03-14 11:09:19 +0100 | [diff] [blame] | 66 | if(NOT DEFINED EXPORT_SP_BOOT_ORDER) |
| 67 | message(FATAL_ERROR "export_sp: mandatory parameter SP_BOOT_ORDER not defined!") |
| 68 | endif() |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 69 | if(NOT DEFINED EXPORT_SP_NAME) |
| 70 | message(FATAL_ERROR "export_sp: mandatory parameter SP_NAME not defined!") |
| 71 | endif() |
| 72 | if(NOT DEFINED EXPORT_DTS_IN) |
| 73 | message(FATAL_ERROR "export_sp: mandatory parameter DTS_IN not defined!") |
| 74 | endif() |
| 75 | |
| 76 | if (DEFINED EXPORT_MK_IN) |
| 77 | configure_file(${EXPORT_MK_IN} ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_NAME}.mk @ONLY NEWLINE_STYLE UNIX) |
| 78 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_NAME}.mk DESTINATION ${TS_ENV}/lib/make) |
| 79 | endif() |
| 80 | |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 81 | # 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] | 82 | # Create a litte endian 4 digit octests representation. |
Jelle Sels | 4960c41 | 2023-02-01 09:43:24 +0100 | [diff] [blame] | 83 | uuid_canon_to_le_words(UUID ${EXPORT_SP_FFA_UUID_CANON} RES _le_words) |
Gyorgy Szing | fd03e0a | 2023-07-27 20:04:24 +0200 | [diff] [blame] | 84 | list(JOIN _le_words " 0x" _uuid_le) |
| 85 | set(SP_UUID_LE " 0x${_uuid_le}" PARENT_SCOPE) |
| 86 | set(EXPORT_SP_UUID_DT " 0x${_uuid_le}") |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 87 | |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 88 | # The .dts file is a standalone structure, thus it should have the /dts-v1/ tag and it |
| 89 | # starts with the root node. |
| 90 | set(DTS_TAG "/dts-v1/;") |
| 91 | set(DTS_NODE "/") |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 92 | 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] | 93 | |
Imre Kis | 7dfd497 | 2022-10-27 16:55:57 +0200 | [diff] [blame] | 94 | compiler_preprocess_file( |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 95 | SRC ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}_before_preprocessing.dts |
| 96 | DST ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}.dts |
Imre Kis | 7dfd497 | 2022-10-27 16:55:57 +0200 | [diff] [blame] | 97 | TARGET ${EXPORT_SP_NAME} |
| 98 | ) |
| 99 | |
Jelle Sels | c85a0c2 | 2022-12-07 14:04:49 +0100 | [diff] [blame] | 100 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}.dts DESTINATION ${TS_ENV}/manifest) |
| 101 | |
| 102 | if (DEFINED EXPORT_DTS_MEM_REGIONS) |
| 103 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_DTS_MEM_REGIONS} DESTINATION ${TS_ENV}/manifest) |
| 104 | endif() |
Imre Kis | 686bd27 | 2021-12-15 19:19:02 +0100 | [diff] [blame] | 105 | |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 106 | if (DEFINED EXPORT_JSON_IN) |
| 107 | configure_file(${EXPORT_JSON_IN} ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_NAME}.json @ONLY NEWLINE_STYLE UNIX) |
| 108 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_NAME}.json DESTINATION ${TS_ENV}/json) |
| 109 | endif() |
Imre Kis | 686bd27 | 2021-12-15 19:19:02 +0100 | [diff] [blame] | 110 | endfunction() |