blob: d212c06a82028beacb817892876813cb5fb70005 [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
51 DEFAULT ON
52 DEPENDS (RMM_ARCH STREQUAL aarch64)
53 ELSE OFF)
54
55#
AlexeiFedorovea68b552023-10-03 11:11:47 +010056# The number of 4K pages allocated for attestation buffer.
57#
58arm_config_option(
59 NAME RMM_CCA_TOKEN_BUFFER
60 HELP "Number of pages to allocate in Aux granules for Realm CCA token"
61 TYPE STRING
62 DEFAULT 1)
63
64#
Soby Mathewb4c6df42022-11-09 11:13:29 +000065# Introduce a pseudo-library purely for applying flags to RMM's libraries.
66# This is applied to any targets created after this point.
67#
68
69add_library(rmm-common INTERFACE)
70
71target_compile_definitions(rmm-common
72 INTERFACE "$<$<CONFIG:Debug>:DEBUG>")
73
74if(MAX_CPUS EQUAL 0x0)
75 message(FATAL_ERROR "MAX_CPUS is not initialized")
76endif()
77
78target_compile_definitions(rmm-common
Javier Almansa Sobrinoc4ad5b02022-07-05 19:05:14 +010079 INTERFACE "MAX_CPUS=${MAX_CPUS}U")
Soby Mathewb4c6df42022-11-09 11:13:29 +000080
Mate Toth-Palac0cfbb2023-06-19 16:29:52 +020081if(NOT(GRANULE_SHIFT EQUAL 12))
82 message(FATAL_ERROR "GRANULE_SHIFT is not initialized correctly")
Soby Mathewb4c6df42022-11-09 11:13:29 +000083endif()
84
85target_compile_definitions(rmm-common
Mate Toth-Palac0cfbb2023-06-19 16:29:52 +020086 INTERFACE "GRANULE_SHIFT=U(${GRANULE_SHIFT})")
Soby Mathewb4c6df42022-11-09 11:13:29 +000087
AlexeiFedorov7c5001a2022-12-14 13:22:33 +000088if (RMM_MAX_GRANULES EQUAL 0x0)
89 message (FATAL_ERROR "RMM_MAX_GRANULES not configured")
90endif()
91
92target_compile_definitions(rmm-common
93 INTERFACE "RMM_MAX_GRANULES=U(${RMM_MAX_GRANULES})")
94
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +020095target_compile_definitions(rmm-common
96 INTERFACE "RMM_NUM_PAGES_PER_STACK=UL(${RMM_NUM_PAGES_PER_STACK})")
97
Soby Mathewb4c6df42022-11-09 11:13:29 +000098if(RMM_FPU_USE_AT_REL2)
99 target_compile_definitions(rmm-common
100 INTERFACE "RMM_FPU_USE_AT_REL2=1")
101endif()
102
AlexeiFedorovea68b552023-10-03 11:11:47 +0100103target_compile_definitions(rmm-common
104 INTERFACE "RMM_CCA_TOKEN_BUFFER=U(${RMM_CCA_TOKEN_BUFFER})")
105
Soby Mathewb4c6df42022-11-09 11:13:29 +0000106#
107# Project name and version
108#
109target_compile_definitions(rmm-common
110 INTERFACE "NAME=\"${PROJECT_NAME}\"")
111
112target_compile_definitions(rmm-common
113 INTERFACE "VERSION=\"${PROJECT_VERSION}\"")
114
115#
116# Get git commit information
117#
118find_package(Git)
119if(GIT_FOUND)
120 execute_process(
121 COMMAND ${GIT_EXECUTABLE} describe --always --dirty --tags
122 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
123 OUTPUT_VARIABLE COMMIT_INFO
124 OUTPUT_STRIP_TRAILING_WHITESPACE
125 )
126endif()
127
128target_compile_definitions(rmm-common
129 INTERFACE "COMMIT_INFO=\"${COMMIT_INFO}\"")
130
131link_libraries(rmm-common)