blob: d8c3e6884393733e3970fbad4b5191cb2a76595f [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
62#
Soby Mathewb4c6df42022-11-09 11:13:29 +000063# Introduce a pseudo-library purely for applying flags to RMM's libraries.
64# This is applied to any targets created after this point.
65#
66
67add_library(rmm-common INTERFACE)
68
69target_compile_definitions(rmm-common
70 INTERFACE "$<$<CONFIG:Debug>:DEBUG>")
71
72if(MAX_CPUS EQUAL 0x0)
73 message(FATAL_ERROR "MAX_CPUS is not initialized")
74endif()
75
76target_compile_definitions(rmm-common
Javier Almansa Sobrinoc4ad5b02022-07-05 19:05:14 +010077 INTERFACE "MAX_CPUS=${MAX_CPUS}U")
Soby Mathewb4c6df42022-11-09 11:13:29 +000078
Mate Toth-Palac0cfbb2023-06-19 16:29:52 +020079if(NOT(GRANULE_SHIFT EQUAL 12))
80 message(FATAL_ERROR "GRANULE_SHIFT is not initialized correctly")
Soby Mathewb4c6df42022-11-09 11:13:29 +000081endif()
82
83target_compile_definitions(rmm-common
Mate Toth-Palac0cfbb2023-06-19 16:29:52 +020084 INTERFACE "GRANULE_SHIFT=U(${GRANULE_SHIFT})")
Soby Mathewb4c6df42022-11-09 11:13:29 +000085
AlexeiFedorov7c5001a2022-12-14 13:22:33 +000086if (RMM_MAX_GRANULES EQUAL 0x0)
87 message (FATAL_ERROR "RMM_MAX_GRANULES not configured")
88endif()
89
90target_compile_definitions(rmm-common
91 INTERFACE "RMM_MAX_GRANULES=U(${RMM_MAX_GRANULES})")
92
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +020093target_compile_definitions(rmm-common
94 INTERFACE "RMM_NUM_PAGES_PER_STACK=UL(${RMM_NUM_PAGES_PER_STACK})")
95
Arunachalam Ganapathy188d9e62024-04-18 13:42:56 +010096if(RMM_FPU_USE_AT_REL2 AND RMM_ARCH STREQUAL aarch64)
Soby Mathewb4c6df42022-11-09 11:13:29 +000097 target_compile_definitions(rmm-common
98 INTERFACE "RMM_FPU_USE_AT_REL2=1")
99endif()
100
AlexeiFedorovea68b552023-10-03 11:11:47 +0100101target_compile_definitions(rmm-common
102 INTERFACE "RMM_CCA_TOKEN_BUFFER=U(${RMM_CCA_TOKEN_BUFFER})")
103
Soby Mathewb4c6df42022-11-09 11:13:29 +0000104#
105# Project name and version
106#
107target_compile_definitions(rmm-common
108 INTERFACE "NAME=\"${PROJECT_NAME}\"")
109
110target_compile_definitions(rmm-common
111 INTERFACE "VERSION=\"${PROJECT_VERSION}\"")
112
113#
114# Get git commit information
115#
116find_package(Git)
117if(GIT_FOUND)
118 execute_process(
119 COMMAND ${GIT_EXECUTABLE} describe --always --dirty --tags
120 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
121 OUTPUT_VARIABLE COMMIT_INFO
122 OUTPUT_STRIP_TRAILING_WHITESPACE
123 )
124endif()
125
126target_compile_definitions(rmm-common
127 INTERFACE "COMMIT_INFO=\"${COMMIT_INFO}\"")
128
129link_libraries(rmm-common)