#
# SPDX-License-Identifier: BSD-3-Clause
# SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
#

add_library(rmm-lib-xlat)

target_link_libraries(rmm-lib-xlat
    PRIVATE rmm-lib-common
            rmm-lib-libc
            rmm-lib-arch
            rmm-lib-debug)

target_include_directories(rmm-lib-xlat
    PUBLIC "include")

target_include_directories(rmm-lib-xlat
    PRIVATE "src")

target_sources(rmm-lib-xlat
    PRIVATE "src/xlat_tables_core.c"
            "src/xlat_tables_utils.c"
	    "src/xlat_tables_arch.c")

if(NOT RMM_ARCH STREQUAL fake_host)
    target_sources(rmm-lib-xlat
        PRIVATE "src/aarch64/enable_mmu.S")
endif()

arm_config_option(
    NAME XLAT_GRANULARITY_SIZE_SHIFT
    HELP "Size in bits of the translation granularity"
    TYPE STRING
    STRINGS "12" "14" "16"
    DEFAULT "12"
    ADVANCED)

if(NOT(XLAT_GRANULARITY_SIZE_SHIFT EQUAL "12"))
    message(FATAL_ERROR "Only 4K granularity is supported at the moment")
endif()

target_compile_definitions(rmm-lib-xlat
    PUBLIC "XLAT_GRANULARITY_SIZE_SHIFT=UL(${XLAT_GRANULARITY_SIZE_SHIFT})")
