1#
2# SPDX-License-Identifier: BSD-3-Clause
3# SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4#
5
6add_library(rmm-lib-realm)
7
8arm_config_option(
9    NAME VIRT_ADDR_SPACE_WIDTH
10    HELP "Size in bits of the virtual address space."
11    DEFAULT 0x0
12    TYPE STRING
13    ADVANCED)
14
15#
16# RMM_MAX_GRANULES. Maximum number of granules supported.
17#
18arm_config_option(
19    NAME RMM_MAX_GRANULES
20    HELP "Maximum number of granules supported"
21    DEFAULT 0x0
22    TYPE STRING)
23
24if(VIRT_ADDR_SPACE_WIDTH EQUAL 0x0)
25    message(FATAL_ERROR "VIRT_ADDR_SPACE_WIDTH is not initialized")
26endif()
27
28target_compile_definitions(rmm-lib-realm
29    PUBLIC "VIRT_ADDR_SPACE_SIZE=(1ULL << ULL(${VIRT_ADDR_SPACE_WIDTH}))")
30
31if (RMM_MAX_GRANULES EQUAL 0x0)
32    message (FATAL_ERROR "RMM_MAX_GRANULES not configured")
33endif()
34
35# Export RMM_MAX_GRANULES for use in `plat` component.
36target_compile_definitions(rmm-lib-realm
37    PUBLIC "RMM_MAX_GRANULES=U(${RMM_MAX_GRANULES})")
38
39target_link_libraries(rmm-lib-realm
40    PRIVATE rmm-lib-arch
41            rmm-lib-common
42            rmm-lib-debug
43            rmm-lib-gic
44            rmm-lib-xlat
45            rmm-lib-allocator
46            rmm-lib-attestation
47            rmm-platform)
48
49target_link_libraries(rmm-lib-realm
50    PUBLIC rmm-lib-measurement
51           rmm-lib-smc)
52
53target_include_directories(rmm-lib-realm
54    PUBLIC "include"
55    PRIVATE "src/include/${RMM_ARCH}")
56
57target_sources(rmm-lib-realm
58    PRIVATE "src/buffer.c"
59            "src/granule.c"
60            "src/s2tt.c"
61            "src/sve.c")
62
63if(NOT RMM_ARCH STREQUAL fake_host)
64    target_sources(rmm-lib-realm
65        PRIVATE "src/aarch64/sve_helpers.S")
66endif()
67