blob: bad02b215428cd562e3b91be9067e292a9369965 [file] [log] [blame]
Imre Kisa74aaf92021-12-14 17:13:06 +01001#-------------------------------------------------------------------------------
Imre Kis7dfd4972022-10-27 16:55:57 +02002# Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.
Imre Kisa74aaf92021-12-14 17:13:06 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8#[===[.rst:
9.. cmake:command:: export_sp
10
11 .. code:: cmake
12
Imre Kis686bd272021-12-15 19:19:02 +010013 export_sp(
Balint Dobszayc9daea92022-06-15 15:17:11 +020014 SP_UUID_CANON <uuid_str_canon>
15 SP_UUID_LE <uuid_le_bytes>
16 SP_NAME <name> MK_IN <.mk path>
Imre Kis686bd272021-12-15 19:19:02 +010017 DTS_IN <DTS path>
18 DTS_MEM_REGIONS <Memory region manifest path>
19 JSON_IN <JSON path>
20 )
Imre Kisa74aaf92021-12-14 17:13:06 +010021
22 INPUTS:
23
Balint Dobszayc9daea92022-06-15 15:17:11 +020024 ``SP_UUID_CANON``
Jelle Selsc85a0c22022-12-07 14:04:49 +010025 The FF_A UUID of the SP as a canonical string.
26
27 ``SP_BIN_UUID_CANON``
28 The UUID of the SP binary a canonical string. When not set use the
29 SP_UUID_CANON as the SP_BIN_UUID_CANON.
Balint Dobszayc9daea92022-06-15 15:17:11 +020030
31 ``SP_UUID_LE``
32 The UUID of the SP as four 32 bit little-endian unsigned integers.
Imre Kisa74aaf92021-12-14 17:13:06 +010033
34 ``SP_NAME``
35 The name of the SP.
36
37 ``MK_IN``
38 Optional, Makefile template for OP-TEE build
39
40 ``DTS_IN``
41 Manifest file template
42
Imre Kis686bd272021-12-15 19:19:02 +010043 `DTS_MEM_REGIONS`
44 Optional, Memory region manifest file
45
Imre Kisa74aaf92021-12-14 17:13:06 +010046 ``JSON_IN``
47 Optional, SP layout JSON file template for TF-A
48
49#]===]
50function (export_sp)
51 set(options)
Jelle Selsc85a0c22022-12-07 14:04:49 +010052 set(oneValueArgs SP_UUID_CANON SP_BIN_UUID_CANON SP_UUID_LE SP_NAME MK_IN DTS_IN DTS_MEM_REGIONS JSON_IN)
Imre Kisa74aaf92021-12-14 17:13:06 +010053 set(multiValueArgs)
54 cmake_parse_arguments(EXPORT "${options}" "${oneValueArgs}"
55 "${multiValueArgs}" ${ARGN} )
56
Balint Dobszayc9daea92022-06-15 15:17:11 +020057 if(NOT DEFINED EXPORT_SP_UUID_CANON)
58 message(FATAL_ERROR "export_sp: mandatory parameter SP_UUID_CANON not defined!")
59 endif()
Jelle Selsc85a0c22022-12-07 14:04:49 +010060 if(NOT DEFINED EXPORT_SP_BIN_UUID_CANON)
61 # We use the same UUID for the binary and FF-A if the UUID of the SP binary is not set
62 set(EXPORT_SP_BIN_UUID_CANON ${EXPORT_SP_UUID_CANON})
63 endif()
Balint Dobszayc9daea92022-06-15 15:17:11 +020064 if(NOT DEFINED EXPORT_SP_UUID_LE)
65 message(FATAL_ERROR "export_sp: mandatory parameter SP_UUID_LE not defined!")
Imre Kisa74aaf92021-12-14 17:13:06 +010066 endif()
67 if(NOT DEFINED EXPORT_SP_NAME)
68 message(FATAL_ERROR "export_sp: mandatory parameter SP_NAME not defined!")
69 endif()
70 if(NOT DEFINED EXPORT_DTS_IN)
71 message(FATAL_ERROR "export_sp: mandatory parameter DTS_IN not defined!")
72 endif()
73
74 if (DEFINED EXPORT_MK_IN)
75 configure_file(${EXPORT_MK_IN} ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_NAME}.mk @ONLY NEWLINE_STYLE UNIX)
76 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_NAME}.mk DESTINATION ${TS_ENV}/lib/make)
77 endif()
78
Balint Dobszayc9daea92022-06-15 15:17:11 +020079 # In the SP manifest DT the UUID format is four uint32 numbers (little-endian)
80 set(EXPORT_SP_UUID_DT "${EXPORT_SP_UUID_LE}")
Imre Kisa74aaf92021-12-14 17:13:06 +010081
82 # As the .dtsi is meant to be included in .dts file, it shouldn't contain a separate
83 # /dts-v1/ tag and its node should be unique, i.e. the SP name.
84 set(DTS_TAG "")
85 set(DTS_NODE "${EXPORT_SP_NAME}")
Jelle Selsc85a0c22022-12-07 14:04:49 +010086 configure_file(${EXPORT_DTS_IN} ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}_before_preprocessing.dtsi @ONLY NEWLINE_STYLE UNIX)
Imre Kis7dfd4972022-10-27 16:55:57 +020087
88 compiler_preprocess_file(
Jelle Selsc85a0c22022-12-07 14:04:49 +010089 SRC ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}_before_preprocessing.dtsi
90 DST ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}.dtsi
Imre Kis7dfd4972022-10-27 16:55:57 +020091 TARGET ${EXPORT_SP_NAME}
92 )
93
Jelle Selsc85a0c22022-12-07 14:04:49 +010094 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}.dtsi DESTINATION ${TS_ENV}/manifest)
Imre Kisa74aaf92021-12-14 17:13:06 +010095
96 # The .dts file is a standalone structure, thus it should have the /dts-v1/ tag and it
97 # starts with the root node.
98 set(DTS_TAG "/dts-v1/;")
99 set(DTS_NODE "/")
Jelle Selsc85a0c22022-12-07 14:04:49 +0100100 configure_file(${EXPORT_DTS_IN} ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}_before_preprocessing.dts @ONLY NEWLINE_STYLE UNIX)
Imre Kisa74aaf92021-12-14 17:13:06 +0100101
Imre Kis7dfd4972022-10-27 16:55:57 +0200102 compiler_preprocess_file(
Jelle Selsc85a0c22022-12-07 14:04:49 +0100103 SRC ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}_before_preprocessing.dts
104 DST ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}.dts
Imre Kis7dfd4972022-10-27 16:55:57 +0200105 TARGET ${EXPORT_SP_NAME}
106 )
107
Jelle Selsc85a0c22022-12-07 14:04:49 +0100108 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_BIN_UUID_CANON}.dts DESTINATION ${TS_ENV}/manifest)
109
110 if (DEFINED EXPORT_DTS_MEM_REGIONS)
111 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_DTS_MEM_REGIONS} DESTINATION ${TS_ENV}/manifest)
112 endif()
Imre Kis686bd272021-12-15 19:19:02 +0100113
Imre Kisa74aaf92021-12-14 17:13:06 +0100114 if (DEFINED EXPORT_JSON_IN)
115 configure_file(${EXPORT_JSON_IN} ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_NAME}.json @ONLY NEWLINE_STYLE UNIX)
116 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_SP_NAME}.json DESTINATION ${TS_ENV}/json)
117 endif()
Imre Kis686bd272021-12-15 19:19:02 +0100118endfunction()