blob: 2d57c8c854b000341606e0eba0a752f459808bec [file] [log] [blame]
Soby Mathewb4c6df42022-11-09 11:13:29 +00001#
2# SPDX-License-Identifier: BSD-3-Clause
3# SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4#
5
6#
7# Common config options
8#
9arm_config_option(
10 NAME MAX_CPUS
11 HELP "Maximum number of CPUs supported by RMM"
12 TYPE STRING
13 DEFAULT 16)
14
15#
16# The RMM is mapped with 4K pages, and all RMM APIs use the same granularity.
17#
18arm_config_option(
Mate Toth-Palac0cfbb2023-06-19 16:29:52 +020019 NAME GRANULE_SHIFT
20 HELP "The shift value of granule size. i.e: GRANULE_SIZE == 1 << GRANULE_SHIFT"
Soby Mathewb4c6df42022-11-09 11:13:29 +000021 TYPE STRING
Mate Toth-Palac0cfbb2023-06-19 16:29:52 +020022 DEFAULT 12)
Soby Mathewb4c6df42022-11-09 11:13:29 +000023
AlexeiFedorov7c5001a2022-12-14 13:22:33 +000024#
25# RMM_MAX_GRANULES. Maximum number of granules supported.
26#
27arm_config_option(
28 NAME RMM_MAX_GRANULES
29 HELP "Maximum number of granules supported"
30 TYPE STRING
31 DEFAULT 0x0)
32
Soby Mathewb4c6df42022-11-09 11:13:29 +000033arm_config_option(
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +020034 NAME RMM_NUM_PAGES_PER_STACK
35 HELP "Number of pages to use per CPU stack"
36 TYPE STRING
37 DEFAULT 5
38 ADVANCED)
39
40arm_config_option(
Soby Mathewb4c6df42022-11-09 11:13:29 +000041 NAME RMM_DOCS
42 HELP "RMM Documentation build"
43 TYPE BOOL
44 DEFAULT OFF)
45
46# TODO: Move to lib/arch once MbedTLS compilation is moved to build phase.
47arm_config_option(
48 NAME RMM_FPU_USE_AT_REL2
49 HELP "Enable Advanced SIMD support in RMM"
50 TYPE BOOL
Soby Mathew9b2de242024-02-27 16:08:42 +000051 DEFAULT OFF)
Soby Mathewb4c6df42022-11-09 11:13:29 +000052
53#
AlexeiFedorovea68b552023-10-03 11:11:47 +010054# The number of 4K pages allocated for attestation buffer.
55#
56arm_config_option(
57 NAME RMM_CCA_TOKEN_BUFFER
58 HELP "Number of pages to allocate in Aux granules for Realm CCA token"
59 TYPE STRING
60 DEFAULT 1)
61
Arunachalam Ganapathy33e3bdc2024-04-10 20:55:40 +010062arm_config_option(
63 NAME RMM_CCA_DA
64 HELP "Enable Device Assignment support in RMM (experimental)"
65 TYPE BOOL
66 DEFAULT OFF)
67
AlexeiFedorovea68b552023-10-03 11:11:47 +010068#
Soby Mathewb4c6df42022-11-09 11:13:29 +000069# Introduce a pseudo-library purely for applying flags to RMM's libraries.
70# This is applied to any targets created after this point.
71#
72
73add_library(rmm-common INTERFACE)
74
75target_compile_definitions(rmm-common
76 INTERFACE "$<$<CONFIG:Debug>:DEBUG>")
77
78if(MAX_CPUS EQUAL 0x0)
79 message(FATAL_ERROR "MAX_CPUS is not initialized")
80endif()
81
82target_compile_definitions(rmm-common
Javier Almansa Sobrinoc4ad5b02022-07-05 19:05:14 +010083 INTERFACE "MAX_CPUS=${MAX_CPUS}U")
Soby Mathewb4c6df42022-11-09 11:13:29 +000084
Mate Toth-Palac0cfbb2023-06-19 16:29:52 +020085if(NOT(GRANULE_SHIFT EQUAL 12))
86 message(FATAL_ERROR "GRANULE_SHIFT is not initialized correctly")
Soby Mathewb4c6df42022-11-09 11:13:29 +000087endif()
88
89target_compile_definitions(rmm-common
Mate Toth-Palac0cfbb2023-06-19 16:29:52 +020090 INTERFACE "GRANULE_SHIFT=U(${GRANULE_SHIFT})")
Soby Mathewb4c6df42022-11-09 11:13:29 +000091
AlexeiFedorov7c5001a2022-12-14 13:22:33 +000092if (RMM_MAX_GRANULES EQUAL 0x0)
93 message (FATAL_ERROR "RMM_MAX_GRANULES not configured")
94endif()
95
96target_compile_definitions(rmm-common
97 INTERFACE "RMM_MAX_GRANULES=U(${RMM_MAX_GRANULES})")
98
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +020099target_compile_definitions(rmm-common
100 INTERFACE "RMM_NUM_PAGES_PER_STACK=UL(${RMM_NUM_PAGES_PER_STACK})")
101
Arunachalam Ganapathy188d9e62024-04-18 13:42:56 +0100102if(RMM_FPU_USE_AT_REL2 AND RMM_ARCH STREQUAL aarch64)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000103 target_compile_definitions(rmm-common
104 INTERFACE "RMM_FPU_USE_AT_REL2=1")
105endif()
106
AlexeiFedorovea68b552023-10-03 11:11:47 +0100107target_compile_definitions(rmm-common
108 INTERFACE "RMM_CCA_TOKEN_BUFFER=U(${RMM_CCA_TOKEN_BUFFER})")
109
Soby Mathewb4c6df42022-11-09 11:13:29 +0000110#
111# Project name and version
112#
113target_compile_definitions(rmm-common
114 INTERFACE "NAME=\"${PROJECT_NAME}\"")
115
116target_compile_definitions(rmm-common
117 INTERFACE "VERSION=\"${PROJECT_VERSION}\"")
118
119#
120# Get git commit information
121#
122find_package(Git)
123if(GIT_FOUND)
124 execute_process(
125 COMMAND ${GIT_EXECUTABLE} describe --always --dirty --tags
126 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
127 OUTPUT_VARIABLE COMMIT_INFO
128 OUTPUT_STRIP_TRAILING_WHITESPACE
129 )
130endif()
131
132target_compile_definitions(rmm-common
133 INTERFACE "COMMIT_INFO=\"${COMMIT_INFO}\"")
134
Arunachalam Ganapathy33e3bdc2024-04-10 20:55:40 +0100135if(RMM_CCA_DA)
136 message(WARNING "DA is an experimental feature")
137 target_compile_definitions(rmm-common
138 INTERFACE "RMM_CCA_DA=1")
139endif()
140
Soby Mathewb4c6df42022-11-09 11:13:29 +0000141link_libraries(rmm-common)